CAY-1873 | Remove DataDomain cache configuration from the Modeler
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/03136ff1 Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/03136ff1 Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/03136ff1 Branch: refs/heads/master Commit: 03136ff1eb6dab04896d7e80dee4d5a56e369042 Parents: a4cba4e Author: Savva Kolbachev <s.kolbac...@gmail.com> Authored: Tue Jun 30 12:05:06 2015 +0300 Committer: Nikita Timofeev <stari...@gmail.com> Committed: Fri Mar 10 15:54:44 2017 +0300 ---------------------------------------------------------------------- .../datadomain/CacheSyncConfigController.java | 337 ------------------- .../dialog/datadomain/CacheSyncConfigView.java | 103 ------ .../CustomRemoteEventsConfigPanel.java | 58 ---- .../dialog/datadomain/JGroupsConfigPanel.java | 104 ------ .../dialog/datadomain/JMSConfigPanel.java | 58 ---- .../cayenne/modeler/editor/DataDomainView.java | 132 +------- 6 files changed, 11 insertions(+), 781 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cayenne/blob/03136ff1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CacheSyncConfigController.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CacheSyncConfigController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CacheSyncConfigController.java deleted file mode 100644 index bb43da9..0000000 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CacheSyncConfigController.java +++ /dev/null @@ -1,337 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.modeler.dialog.datadomain; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.HashMap; -import java.util.Map; - -import javax.swing.WindowConstants; - -import org.apache.cayenne.access.DataRowStore; -import org.apache.cayenne.configuration.DataChannelDescriptor; -import org.apache.cayenne.configuration.event.DomainEvent; -import org.apache.cayenne.event.JMSBridgeFactory; -import org.apache.cayenne.event.JavaGroupsBridgeFactory; -import org.apache.cayenne.modeler.ProjectController; -import org.apache.cayenne.modeler.util.CayenneController; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * A controller for CacheSyncConfigDialog and its subviews. This controller - * manages one main dialog view, and its subviews organized using CardLayout. - * - */ -public class CacheSyncConfigController extends CayenneController { - - private static Log logObj = LogFactory.getLog(CacheSyncConfigController.class); - - // using strings instead of the actioal factory classes, since we - // JMS and JavaGroups libraries may not be around, and Modeler - // may throw CNFE - private static final String JGROUPS_FACTORY_CLASS = "org.apache.cayenne.event.JavaGroupsBridgeFactory"; - private static final String JMS_FACTORY_CLASS = "org.apache.cayenne.event.JMSBridgeFactory"; - - public static final String SAVE_CONFIG_CONTROL = "Done"; - public static final String CANCEL_CONFIG_CONTROL = "Cancel"; - - public static final String JGROUPS_DEFAULT_CONTROL = "Standard Configuration"; - - public static final String JGROUPS_URL_CONTROL = "Use Configuration File"; - - public static final String JGROUPS_FACTORY_LABEL = "JavaGroups Multicast (Default)"; - public static final String JMS_FACTORY_LABEL = "JMS Transport"; - public static final String CUSTOM_FACTORY_LABEL = "Custom Transport"; - - protected Map existingCards; - protected Map properties; - protected boolean modified; - protected ProjectController eventController; - - protected CacheSyncConfigView view; - - public CacheSyncConfigController(ProjectController eventController) { - super(eventController); - this.eventController = eventController; - } - - /** - * Creates and shows a new modal dialog window. - */ - public void startup() { - DataChannelDescriptor domain = (DataChannelDescriptor)eventController.getProject().getRootNode(); - - String factory = (String) domain.getProperties().get( - DataRowStore.EVENT_BRIDGE_FACTORY_PROPERTY); - - view = new CacheSyncConfigView(); - initView(); - - properties = new HashMap(((DataChannelDescriptor)eventController.getProject() - .getRootNode()).getProperties()); - - // build cards, showing the one corresponding to DataDomain state - prepareChildren(factory); - - view.pack(); - view.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - view.setModal(true); - makeCloseableOnEscape(); - centerView(); - view.setVisible(true); - } - - public Component getView() { - return this.view; - } - - private void initView() { - view.getCancelButton().addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - view.dispose(); - } - }); - view.getSaveButton().addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - commitChanges(); - } - }); - view.getTypeSelector().addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - selectCard(); - } - }); - } - - protected void selectCard() { - view.showCard((String)view.getTypeSelector().getSelectedItem()); - } - - protected void jgroupsDefaultConfig() { - JGroupsConfigPanel view = (JGroupsConfigPanel) existingCards - .get(JGROUPS_FACTORY_LABEL); - if (view != null) { - view.showDefaultConfig(); - } - } - - protected void jgroupsURLConfig() { - JGroupsConfigPanel view = (JGroupsConfigPanel) existingCards - .get(JGROUPS_FACTORY_LABEL); - if (view != null) { - view.showCustomConfig(); - } - } - - /** - * Stores configuration changes in the data domain properties. - */ - protected void commitChanges() { - DataChannelDescriptor domain = (DataChannelDescriptor)eventController.getProject().getRootNode(); - logObj.warn("domain properties BEFORE: " + domain.getProperties()); - - Map<String, String> props = domain.getProperties(); - - String type = (String)view.getTypeSelector().getSelectedItem(); - if (JGROUPS_FACTORY_LABEL.equals(type)) { - JGroupsConfigPanel jgroupsPanel = (JGroupsConfigPanel) existingCards - .get(JGROUPS_FACTORY_LABEL); - props.put(DataRowStore.EVENT_BRIDGE_FACTORY_PROPERTY, JGROUPS_FACTORY_CLASS); - if (jgroupsPanel.useConfigFile.isSelected()) { - props.remove(JavaGroupsBridgeFactory.MCAST_ADDRESS_PROPERTY); - props.remove(JavaGroupsBridgeFactory.MCAST_PORT_PROPERTY); - if (!"".equals(jgroupsPanel.configURL.getText())) { - props.put(JavaGroupsBridgeFactory.JGROUPS_CONFIG_URL_PROPERTY, - jgroupsPanel.configURL.getText()); - } - else { - props.put(JavaGroupsBridgeFactory.JGROUPS_CONFIG_URL_PROPERTY, null); - } - } - else { - props.remove(JavaGroupsBridgeFactory.JGROUPS_CONFIG_URL_PROPERTY); - if (!"".equals(jgroupsPanel.multicastAddress.getText())) { - props.put(JavaGroupsBridgeFactory.MCAST_ADDRESS_PROPERTY, - jgroupsPanel.multicastAddress.getText()); - } - else { - props.put(JavaGroupsBridgeFactory.MCAST_ADDRESS_PROPERTY, null); - } - if (!"".equals(jgroupsPanel.multicastPort.getText())) { - props.put(JavaGroupsBridgeFactory.MCAST_PORT_PROPERTY, - jgroupsPanel.multicastPort.getText()); - } - else { - props.put(JavaGroupsBridgeFactory.MCAST_PORT_PROPERTY, null); - } - } - } - else if (JMS_FACTORY_LABEL.equals(type)) { - JMSConfigPanel jmsPanel = (JMSConfigPanel) existingCards - .get(JMS_FACTORY_LABEL); - props.put(DataRowStore.EVENT_BRIDGE_FACTORY_PROPERTY, JMS_FACTORY_CLASS); - if (!"".equals(jmsPanel.topicFactory.getText())) { - props.put(JMSBridgeFactory.TOPIC_CONNECTION_FACTORY_PROPERTY, - jmsPanel.topicFactory.getText()); - } - else { - props.put(JMSBridgeFactory.TOPIC_CONNECTION_FACTORY_PROPERTY, null); - } - } - else if (CUSTOM_FACTORY_LABEL.equals(type)) { - CustomRemoteEventsConfigPanel customPanel = (CustomRemoteEventsConfigPanel) existingCards - .get(CUSTOM_FACTORY_LABEL); - if (!"".equals(customPanel.factoryClass.getText())) { - props.put(DataRowStore.EVENT_BRIDGE_FACTORY_PROPERTY, customPanel.factoryClass.getText()); - } - else { - props.put(DataRowStore.EVENT_BRIDGE_FACTORY_PROPERTY, null); - } - } - - logObj.warn("domain properties: " + domain.getProperties()); - - eventController.fireDomainEvent(new DomainEvent(this, domain)); - - view.dispose(); - } - - protected void loadProperties(String factory) { - String configUrl = (String)properties.get(JavaGroupsBridgeFactory.JGROUPS_CONFIG_URL_PROPERTY); - String multicastAddress = (String)properties.get(JavaGroupsBridgeFactory.MCAST_ADDRESS_PROPERTY); - String multicastPort = (String)properties.get(JavaGroupsBridgeFactory.MCAST_PORT_PROPERTY); - String topicFactory = (String)properties.get(JMSBridgeFactory.TOPIC_CONNECTION_FACTORY_PROPERTY); - - JGroupsConfigPanel jgroupsPanel = (JGroupsConfigPanel) existingCards - .get(JGROUPS_FACTORY_LABEL); - - if (configUrl != null) { - jgroupsPanel.useConfigFile.setSelected(true); - jgroupsURLConfig(); - jgroupsPanel.configURL.setText(configUrl); - } - else { - jgroupsPanel.useDefaultConfig.setSelected(true); - jgroupsDefaultConfig(); - } - - if (multicastAddress != null) { - jgroupsPanel.multicastAddress.setText(multicastAddress); - } - else { - jgroupsPanel.multicastAddress.setText(JavaGroupsBridgeFactory.MCAST_ADDRESS_DEFAULT); - } - - if (multicastPort != null) { - jgroupsPanel.multicastPort.setText(multicastPort); - } - else { - jgroupsPanel.multicastPort.setText(JavaGroupsBridgeFactory.MCAST_PORT_DEFAULT); - } - - JMSConfigPanel jmsPanel = (JMSConfigPanel) existingCards - .get(JMS_FACTORY_LABEL); - - if (topicFactory != null) { - jmsPanel.topicFactory.setText(topicFactory); - } - else { - jmsPanel.topicFactory.setText(JMSBridgeFactory.TOPIC_CONNECTION_FACTORY_DEFAULT); - } - - CustomRemoteEventsConfigPanel customPanel = (CustomRemoteEventsConfigPanel) existingCards - .get(CUSTOM_FACTORY_LABEL); - String factoryClass = (String)properties.get(DataRowStore.EVENT_BRIDGE_FACTORY_PROPERTY); - if (factoryClass != null) { - customPanel.factoryClass.setText(factoryClass); - } - else { - customPanel.factoryClass.setText(DataRowStore.EVENT_BRIDGE_FACTORY_DEFAULT); - } - - if (JGROUPS_FACTORY_CLASS.equals(factory)) { - view.getTypeSelector().setSelectedItem(JGROUPS_FACTORY_LABEL); - } - else if (JMS_FACTORY_CLASS.equals(factory)) { - view.getTypeSelector().setSelectedItem(JMS_FACTORY_LABEL); - } - else { - view.getTypeSelector().setSelectedItem(CUSTOM_FACTORY_LABEL); - } - } - - protected void prepareChildren(String factory) { - existingCards = new HashMap(); - CacheSyncConfigView topView = (CacheSyncConfigView) getView(); - - // note that none of the panels need a controller - // if they issue controls, they will use this object taken from parent - - JGroupsConfigPanel jgroupsPanel = new JGroupsConfigPanel(); - existingCards.put(JGROUPS_FACTORY_LABEL, jgroupsPanel); - topView.addCard(jgroupsPanel, JGROUPS_FACTORY_LABEL); - - jgroupsPanel.getUseDefaultConfig().addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - jgroupsDefaultConfig(); - } - }); - jgroupsPanel.getUseConfigFile().addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - jgroupsURLConfig(); - } - }); - - JMSConfigPanel jmsPanel = new JMSConfigPanel(); - existingCards.put(JMS_FACTORY_LABEL, jmsPanel); - topView.addCard(jmsPanel, JMS_FACTORY_LABEL); - - CustomRemoteEventsConfigPanel customFactoryPanel = new CustomRemoteEventsConfigPanel(); - existingCards.put(CUSTOM_FACTORY_LABEL, customFactoryPanel); - topView.addCard(customFactoryPanel, CUSTOM_FACTORY_LABEL); - - if (factory == null) { - factory = DataRowStore.EVENT_BRIDGE_FACTORY_DEFAULT; - } - - if (JGROUPS_FACTORY_CLASS.equals(factory)) { - ((CacheSyncConfigView) getView()) - .showCard(JGROUPS_FACTORY_LABEL); - } - else if (JMS_FACTORY_CLASS.equals(factory)) { - ((CacheSyncConfigView) getView()) - .showCard(JMS_FACTORY_LABEL); - } - else { - ((CacheSyncConfigView) getView()) - .showCard(CUSTOM_FACTORY_LABEL); - } - - loadProperties(factory); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/03136ff1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CacheSyncConfigView.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CacheSyncConfigView.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CacheSyncConfigView.java deleted file mode 100644 index a9f0d51..0000000 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CacheSyncConfigView.java +++ /dev/null @@ -1,103 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.modeler.dialog.datadomain; - -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Component; -import java.awt.FlowLayout; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JPanel; - -import com.jgoodies.forms.builder.DefaultFormBuilder; -import com.jgoodies.forms.layout.FormLayout; - -/** - */ -public class CacheSyncConfigView extends JDialog { - public static final String EMPTY_CARD_KEY = "Empty"; - - protected JPanel configPanel; - protected JComboBox typeSelector; - protected JButton saveButton; - protected JButton cancelButton; - - public CacheSyncConfigView() { - initView(); - } - - protected void initView() { - this.setLayout(new BorderLayout()); - this.setTitle("Configure Remote Cache Synchronization"); - - typeSelector = new JComboBox(); - typeSelector.addItem("JavaGroups Multicast (Default)"); - typeSelector.addItem("JMS Transport"); - typeSelector.addItem("Custom Transport"); - - saveButton = new JButton(CacheSyncConfigController.SAVE_CONFIG_CONTROL); - cancelButton = - new JButton(CacheSyncConfigController.CANCEL_CONFIG_CONTROL); - - // buttons panel - JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - buttonPanel.add(saveButton); - buttonPanel.add(cancelButton); - - // type form - FormLayout layout = new FormLayout("right:150, 3dlu, left:200", ""); - DefaultFormBuilder builder = new DefaultFormBuilder(layout); - builder.setDefaultDialogBorder(); - builder.append("Notification Transport Type:", typeSelector); - - // config panel - configPanel = new JPanel(new CardLayout()); - addCard(new JPanel(), EMPTY_CARD_KEY); - - this.add(builder.getPanel(), BorderLayout.NORTH); - this.add(configPanel, BorderLayout.CENTER); - this.add(buttonPanel, BorderLayout.SOUTH); - - showCard(EMPTY_CARD_KEY); - } - - public void addCard(Component card, String key) { - configPanel.add(card, key); - } - - public void showCard(String key) { - ((CardLayout) configPanel.getLayout()).show(configPanel, key); - } - - public JButton getSaveButton() { - return this.saveButton; - } - - public JButton getCancelButton() { - return this.cancelButton; - } - - public JComboBox getTypeSelector() { - return this.typeSelector; - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/03136ff1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CustomRemoteEventsConfigPanel.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CustomRemoteEventsConfigPanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CustomRemoteEventsConfigPanel.java deleted file mode 100644 index 82bcc4c..0000000 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/CustomRemoteEventsConfigPanel.java +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.modeler.dialog.datadomain; - -import java.awt.BorderLayout; - -import javax.swing.JPanel; -import javax.swing.JTextField; - -import com.jgoodies.forms.builder.DefaultFormBuilder; -import com.jgoodies.forms.layout.FormLayout; - -/** - */ -public class CustomRemoteEventsConfigPanel extends JPanel { - - protected JTextField factoryClass; - - public CustomRemoteEventsConfigPanel() { - super(); - initView(); - } - - protected void initView() { - setLayout(new BorderLayout()); - - factoryClass = new JTextField(30); - - // type form - FormLayout layout = new FormLayout("right:150, 3dlu, left:200", ""); - DefaultFormBuilder builder = new DefaultFormBuilder(layout); - builder.setDefaultDialogBorder(); - builder.appendSeparator("Custom EventBridge Factory"); - - // "1" at the end would enforce spanning the text field to - // the full width - builder.append("Factory Class:", factoryClass, 1); - - add(builder.getPanel(), BorderLayout.NORTH); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/03136ff1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/JGroupsConfigPanel.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/JGroupsConfigPanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/JGroupsConfigPanel.java deleted file mode 100644 index 0d38ef6..0000000 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/JGroupsConfigPanel.java +++ /dev/null @@ -1,104 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.modeler.dialog.datadomain; - -import java.awt.BorderLayout; - -import javax.swing.ButtonGroup; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JTextField; - -import com.jgoodies.forms.builder.DefaultFormBuilder; -import com.jgoodies.forms.layout.FormLayout; - -public class JGroupsConfigPanel extends JPanel { - - protected JTextField multicastAddress; - protected JTextField multicastPort; - protected JTextField configURL; - protected JRadioButton useDefaultConfig; - protected JRadioButton useConfigFile; - - public JGroupsConfigPanel() { - initView(); - } - - protected void initView() { - setLayout(new BorderLayout()); - - useDefaultConfig = new JRadioButton(CacheSyncConfigController.JGROUPS_DEFAULT_CONTROL); - useDefaultConfig.setSelected(true); - useConfigFile = new JRadioButton(CacheSyncConfigController.JGROUPS_URL_CONTROL); - - ButtonGroup radioGroup = new ButtonGroup(); - radioGroup.add(useConfigFile); - radioGroup.add(useDefaultConfig); - - multicastAddress = new JTextField(20); - multicastPort = new JTextField(5); - configURL = new JTextField(20); - - // type form - FormLayout layout = new FormLayout("right:150, 3dlu, left:200", ""); - DefaultFormBuilder builder = new DefaultFormBuilder(layout); - builder.setDefaultDialogBorder(); - builder.appendSeparator("JavaGroups Settings"); - - builder.append(useDefaultConfig); - builder.nextLine(); - - // "1" at the end would enforce spanning the text field to - // the full width - builder.append("Multicast Address:", multicastAddress, 1); - builder.append("Multicast Port:", multicastPort); - - builder.nextLine(); - builder.append(useConfigFile); - builder.nextLine(); - builder.append("JGroups Config File:", configURL, 1); - - add(builder.getPanel(), BorderLayout.NORTH); - } - - public void showDefaultConfig() { - multicastAddress.setEditable(true); - multicastPort.setEditable(true); - configURL.setEditable(false); - } - - public void showCustomConfig() { - multicastAddress.setEditable(false); - multicastPort.setEditable(false); - configURL.setEditable(true); - } - - public JRadioButton getUseDefaultConfig() { - return this.useDefaultConfig; - } - - public void setUseDefaultConfig(JRadioButton button) { - this.useDefaultConfig = button; - } - - public JRadioButton getUseConfigFile() { - return this.useConfigFile; - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/03136ff1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/JMSConfigPanel.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/JMSConfigPanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/JMSConfigPanel.java deleted file mode 100644 index e896b53..0000000 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/JMSConfigPanel.java +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.modeler.dialog.datadomain; - -import java.awt.BorderLayout; - -import javax.swing.JPanel; -import javax.swing.JTextField; - -import com.jgoodies.forms.builder.DefaultFormBuilder; -import com.jgoodies.forms.layout.FormLayout; - -/** - */ -public class JMSConfigPanel extends JPanel { - - protected JTextField topicFactory; - - public JMSConfigPanel() { - super(); - initView(); - } - - protected void initView() { - setLayout(new BorderLayout()); - - topicFactory = new JTextField(30); - - // type form - FormLayout layout = new FormLayout("right:150, 3dlu, left:200", ""); - DefaultFormBuilder builder = new DefaultFormBuilder(layout); - builder.setDefaultDialogBorder(); - builder.appendSeparator("JMS Settings"); - - // "1" at the end would enforce spanning the text field to - // the full width - builder.append("Connection Factory Name:", topicFactory, 1); - - add(builder.getPanel(), BorderLayout.NORTH); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/03136ff1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java ---------------------------------------------------------------------- diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java index ebc5473..7f225c8 100644 --- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java @@ -19,24 +19,14 @@ package org.apache.cayenne.modeler.editor; -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Map; -import java.util.prefs.Preferences; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JPanel; -import javax.swing.JTextField; - +import com.jgoodies.forms.builder.PanelBuilder; +import com.jgoodies.forms.layout.CellConstraints; +import com.jgoodies.forms.layout.FormLayout; import org.apache.cayenne.access.DataDomain; -import org.apache.cayenne.access.DataRowStore; import org.apache.cayenne.configuration.DataChannelDescriptor; import org.apache.cayenne.configuration.event.DomainEvent; import org.apache.cayenne.modeler.Application; import org.apache.cayenne.modeler.ProjectController; -import org.apache.cayenne.modeler.dialog.datadomain.CacheSyncConfigController; import org.apache.cayenne.modeler.event.DomainDisplayEvent; import org.apache.cayenne.modeler.event.DomainDisplayListener; import org.apache.cayenne.modeler.util.TextAdapter; @@ -44,9 +34,14 @@ import org.apache.cayenne.pref.RenamedPreferences; import org.apache.cayenne.util.Util; import org.apache.cayenne.validation.ValidationException; -import com.jgoodies.forms.builder.PanelBuilder; -import com.jgoodies.forms.layout.CellConstraints; -import com.jgoodies.forms.layout.FormLayout; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JTextField; +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Map; +import java.util.prefs.Preferences; /** * Panel for editing DataDomain. @@ -56,11 +51,7 @@ public class DataDomainView extends JPanel implements DomainDisplayListener { protected ProjectController projectController; protected TextAdapter name; - protected TextAdapter cacheSize; protected JCheckBox objectValidation; - protected JCheckBox sharedCache; - protected JCheckBox remoteUpdates; - protected JButton configRemoteUpdates; public DataDomainView(ProjectController projectController) { this.projectController = projectController; @@ -82,18 +73,7 @@ public class DataDomainView extends JPanel implements DomainDisplayListener { } }; - this.cacheSize = new TextAdapter(new JTextField(10)) { - - protected void updateModel(String text) { - setCacheSize(text); - } - }; - this.objectValidation = new JCheckBox(); - this.sharedCache = new JCheckBox(); - this.remoteUpdates = new JCheckBox(); - this.configRemoteUpdates = new JButton("Configure..."); - configRemoteUpdates.setEnabled(false); // assemble CellConstraints cc = new CellConstraints(); @@ -111,18 +91,6 @@ public class DataDomainView extends JPanel implements DomainDisplayListener { builder.addLabel("Object Validation:", cc.xy(1, 5)); builder.add(objectValidation, cc.xy(3, 5)); - builder.addSeparator("Cache Configuration", cc.xywh(1, 7, 7, 1)); - - builder.addLabel("Size of Object Cache:", cc.xy(1, 9)); - builder.add(cacheSize.getComponent(), cc.xy(3, 9)); - - builder.addLabel("Use Shared Cache:", cc.xy(1, 11)); - builder.add(sharedCache, cc.xy(3, 11)); - - builder.addLabel("Remote Change Notifications:", cc.xy(1, 13)); - builder.add(remoteUpdates, cc.xy(3, 13)); - builder.add(configRemoteUpdates, cc.xy(7, 13)); - this.setLayout(new BorderLayout()); this.add(builder.getPanel(), BorderLayout.CENTER); } @@ -142,55 +110,6 @@ public class DataDomainView extends JPanel implements DomainDisplayListener { } }); - sharedCache.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - String value = sharedCache.isSelected() ? "true" : "false"; - setDomainProperty( - DataDomain.SHARED_CACHE_ENABLED_PROPERTY, - value, - Boolean.toString(DataDomain.SHARED_CACHE_ENABLED_DEFAULT)); - - // turning off shared cache should result in disabling remote events - - remoteUpdates.setEnabled(sharedCache.isSelected()); - - if (!sharedCache.isSelected()) { - // uncheck remote updates... - remoteUpdates.setSelected(false); - - setDomainProperty( - DataRowStore.REMOTE_NOTIFICATION_PROPERTY, - "false", - Boolean.toString(DataRowStore.REMOTE_NOTIFICATION_DEFAULT)); - } - - // depending on final remote updates status change button status - configRemoteUpdates.setEnabled(remoteUpdates.isSelected()); - } - }); - - remoteUpdates.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - String value = remoteUpdates.isSelected() ? "true" : "false"; - - // update config button state - configRemoteUpdates.setEnabled(remoteUpdates.isSelected()); - - setDomainProperty( - DataRowStore.REMOTE_NOTIFICATION_PROPERTY, - value, - Boolean.toString(DataRowStore.REMOTE_NOTIFICATION_DEFAULT)); - } - }); - - configRemoteUpdates.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - new CacheSyncConfigController(projectController).startup(); - } - }); } /** @@ -258,24 +177,9 @@ public class DataDomainView extends JPanel implements DomainDisplayListener { // extract values from the new domain object name.setText(domain.getName()); - cacheSize.setText(getDomainProperty( - DataRowStore.SNAPSHOT_CACHE_SIZE_PROPERTY, - Integer.toString(DataRowStore.SNAPSHOT_CACHE_SIZE_DEFAULT))); - objectValidation.setSelected(getDomainBooleanProperty( DataDomain.VALIDATING_OBJECTS_ON_COMMIT_PROPERTY, Boolean.toString(DataDomain.VALIDATING_OBJECTS_ON_COMMIT_DEFAULT))); - - sharedCache.setSelected(getDomainBooleanProperty( - DataDomain.SHARED_CACHE_ENABLED_PROPERTY, - Boolean.toString(DataDomain.SHARED_CACHE_ENABLED_DEFAULT))); - - remoteUpdates.setSelected(getDomainBooleanProperty( - DataRowStore.REMOTE_NOTIFICATION_PROPERTY, - Boolean.toString(DataRowStore.REMOTE_NOTIFICATION_DEFAULT))); - remoteUpdates.setEnabled(sharedCache.isSelected()); - configRemoteUpdates.setEnabled(remoteUpdates.isEnabled() - && remoteUpdates.isSelected()); } void setDomainName(String newName) { @@ -304,18 +208,4 @@ public class DataDomainView extends JPanel implements DomainDisplayListener { RenamedPreferences.copyPreferences(newName, prefs); projectController.fireDomainEvent(e); } - - void setCacheSize(String text) { - if (text.length() > 0) { - try { - Integer.parseInt(text); - } - catch (NumberFormatException ex) { - throw new ValidationException("Cache size must be an integer: " + text); - } - } - - setDomainProperty(DataRowStore.SNAPSHOT_CACHE_SIZE_PROPERTY, text, Integer - .toString(DataRowStore.SNAPSHOT_CACHE_SIZE_DEFAULT)); - } }