cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/3] cayenne git commit: CAY-2312 Undo does not work for checkboxes
Date Fri, 30 Jun 2017 15:13:35 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 055cb4130 -> f7ef3e409


CAY-2312 Undo does not work for checkboxes


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/33e9b4b9
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/33e9b4b9
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/33e9b4b9

Branch: refs/heads/master
Commit: 33e9b4b927ad6f62a2dd8230612427799b0302c6
Parents: 64ef2a5
Author: Anton Dreka <drekoas@gmail.com>
Authored: Fri Jun 23 10:24:03 2017 +0300
Committer: Anton Dreka <drekoas@gmail.com>
Committed: Fri Jun 23 10:24:03 2017 +0300

----------------------------------------------------------------------
 .../action/CreateProcedureParameterAction.java  |  23 ++--
 .../cayenne/modeler/editor/DataDomainView.java  |  21 ++--
 .../cayenne/modeler/editor/DataMapView.java     |  24 ++--
 .../cayenne/modeler/editor/ObjEntityTab.java    |  46 ++++---
 .../editor/ObjectQueryPropertiesPanel.java      |  12 +-
 .../cayenne/modeler/editor/ProcedureTab.java    |   3 +-
 .../modeler/editor/RawQueryPropertiesPanel.java |  10 +-
 .../modeler/editor/SelectQueryMainTab.java      |  10 +-
 .../CreateProcedureParameterUndoableEdit.java   |  74 +++++++++++
 .../modeler/undo/JCheckBoxUndoListener.java     |  36 ++++++
 .../modeler/undo/JUndoableCheckBoxEdit.java     | 124 +++++++++++++++++++
 .../swing/components/JCayenneCheckBox.java      |  35 ++++++
 12 files changed, 363 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java
index 01287d3..caad9be 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java
@@ -30,6 +30,7 @@ import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent;
 import org.apache.cayenne.modeler.util.CayenneAction;
+import org.apache.cayenne.modeler.undo.CreateProcedureParameterUndoableEdit;
 
 import java.awt.event.ActionEvent;
 
@@ -67,18 +68,26 @@ public class CreateProcedureParameterAction extends CayenneAction {
      */
     @Override
     public void performAction(ActionEvent e) {
+        ProjectController mediator = getProjectController();
+
         if (getProjectController().getCurrentProcedure() != null) {
-            createProcedureParameter();
+            Procedure procedure = getProjectController().getCurrentProcedure();
+            ProcedureParameter parameter = new ProcedureParameter();
+            parameter.setName(NameBuilder.builder(parameter, procedure).name());
+
+            createProcedureParameter(procedure, parameter);
+
+            application.getUndoManager().addEdit(
+                    new CreateProcedureParameterUndoableEdit(
+                            (DataChannelDescriptor) mediator.getProject().getRootNode(),
mediator.getCurrentDataMap(),
+                            procedure, parameter
+                    )
+            );
         }
     }
 
-    public void createProcedureParameter() {
-        Procedure procedure = getProjectController().getCurrentProcedure();
-
-        ProcedureParameter parameter = new ProcedureParameter();
-        parameter.setName(NameBuilder.builder(parameter, procedure).name());
+    public void createProcedureParameter(Procedure procedure, ProcedureParameter parameter)
{
         procedure.addCallParameter(parameter);
-
         ProjectController mediator = getProjectController();
         fireProcedureParameterEvent(this, mediator, procedure, parameter);
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/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 a0efc04..f216b5a 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
@@ -26,6 +26,7 @@ import org.apache.cayenne.access.DataDomain;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.event.DomainEvent;
 import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.swing.components.JCayenneCheckBox;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.DomainDisplayEvent;
 import org.apache.cayenne.modeler.event.DomainDisplayListener;
@@ -38,8 +39,8 @@ 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.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.util.Map;
 import java.util.prefs.Preferences;
 
@@ -74,8 +75,8 @@ public class DataDomainView extends JPanel implements DomainDisplayListener
{
             }
         };
 
-        this.objectValidation = new JCheckBox();
-        this.sharedCache = new JCheckBox();
+        this.objectValidation = new JCayenneCheckBox();
+        this.sharedCache = new JCayenneCheckBox();
 
         // assemble
         CellConstraints cc = new CellConstraints();
@@ -103,10 +104,11 @@ public class DataDomainView extends JPanel implements DomainDisplayListener
{
     protected void initController() {
         projectController.addDomainDisplayListener(this);
 
-        // add action listener to checkboxes
-        objectValidation.addActionListener(new ActionListener() {
+        // add item listener to checkboxes
+        objectValidation.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 String value = objectValidation.isSelected() ? "true" : "false";
                 setDomainProperty(
                         DataDomain.VALIDATING_OBJECTS_ON_COMMIT_PROPERTY,
@@ -115,9 +117,10 @@ public class DataDomainView extends JPanel implements DomainDisplayListener
{
             }
         });
 
-        sharedCache.addActionListener(new ActionListener() {
+        sharedCache.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 String value = sharedCache.isSelected() ? "true" : "false";
                 setDomainProperty(
                         DataDomain.SHARED_CACHE_ENABLED_PROPERTY,

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
index 40521f7..cb12d63 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
@@ -27,6 +27,7 @@ import org.apache.cayenne.configuration.event.DataMapEvent;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.swing.components.JCayenneCheckBox;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.action.LinkDataMapAction;
 import org.apache.cayenne.modeler.dialog.datamap.CatalogUpdateController;
@@ -54,6 +55,8 @@ import javax.swing.JTextField;
 import java.awt.BorderLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.util.Arrays;
 
 /**
@@ -125,7 +128,7 @@ public class DataMapView extends JPanel {
             }
         };
 
-        quoteSQLIdentifiers = new JCheckBox();
+        quoteSQLIdentifiers = new JCayenneCheckBox();
 
         updateDefaultPackage = new JButton("Update...");
         defaultPackage = new TextAdapter(new JTextField()) {
@@ -144,9 +147,9 @@ public class DataMapView extends JPanel {
         };
 
         updateDefaultLockType = new JButton("Update...");
-        defaultLockType = new JCheckBox();
+        defaultLockType = new JCayenneCheckBox();
 
-        clientSupport = new JCheckBox();
+        clientSupport = new JCayenneCheckBox();
         updateDefaultClientPackage = new JButton("Update...");
         defaultClientPackage = new TextAdapter(new JTextField()) {
 
@@ -222,25 +225,28 @@ public class DataMapView extends JPanel {
             }
         });
 
-        quoteSQLIdentifiers.addActionListener(new ActionListener() {
+        quoteSQLIdentifiers.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 setQuoteSQLIdentifiers(quoteSQLIdentifiers.isSelected());
             }
         });
 
-        defaultLockType.addActionListener(new ActionListener() {
+        defaultLockType.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 setDefaultLockType(defaultLockType.isSelected()
                         ? ObjEntity.LOCK_TYPE_OPTIMISTIC
                         : ObjEntity.LOCK_TYPE_NONE);
             }
         });
 
-        clientSupport.addActionListener(new ActionListener() {
+        clientSupport.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 setClientSupport(clientSupport.isSelected());
             }
         });

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTab.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTab.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTab.java
index e720bd8..9c31e33 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTab.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTab.java
@@ -24,6 +24,8 @@ import java.awt.Color;
 import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.util.Arrays;
 import java.util.EventObject;
 import java.util.LinkedList;
@@ -50,6 +52,7 @@ import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.swing.components.JCayenneCheckBox;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.action.ActionManager;
 import org.apache.cayenne.modeler.action.CreateAttributeAction;
@@ -181,10 +184,11 @@ public class ObjEntityTab extends JPanel implements ObjEntityDisplayListener,
         AutoCompletion.enable(dbEntityCombo);
         AutoCompletion.enable(superEntityCombo);
 
-        readOnly = new JCheckBox();
-        optimisticLocking = new JCheckBox();
-        excludeSuperclassListeners = new JCheckBox();
-        excludeDefaultListeners = new JCheckBox();
+        readOnly = new JCayenneCheckBox();
+
+        optimisticLocking = new JCayenneCheckBox();
+        excludeSuperclassListeners = new JCayenneCheckBox();
+        excludeDefaultListeners = new JCayenneCheckBox();
 
         // borderless clickable button used as a label
         tableLabel = new JButton("Table/View:");
@@ -195,8 +199,8 @@ public class ObjEntityTab extends JPanel implements ObjEntityDisplayListener,
         tableLabel.setBorder(null);
 
 
-        isAbstract = new JCheckBox();
-        serverOnly = new JCheckBox();
+        isAbstract = new JCayenneCheckBox();
+        serverOnly = new JCayenneCheckBox();
         clientClassName = new TextAdapter(new JTextField()) {
 
             @Override
@@ -357,9 +361,10 @@ public class ObjEntityTab extends JPanel implements ObjEntityDisplayListener,
 
  
 
-        readOnly.addActionListener(new ActionListener() {
+        readOnly.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 ObjEntity entity = mediator.getCurrentObjEntity();
                 if (entity != null) {
                     entity.setReadOnly(readOnly.isSelected());
@@ -368,9 +373,10 @@ public class ObjEntityTab extends JPanel implements ObjEntityDisplayListener,
             }
         });
 
-        optimisticLocking.addActionListener(new ActionListener() {
+        optimisticLocking.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 ObjEntity entity = mediator.getCurrentObjEntity();
                 if (entity != null) {
                     entity.setDeclaredLockType(optimisticLocking.isSelected()
@@ -381,9 +387,10 @@ public class ObjEntityTab extends JPanel implements ObjEntityDisplayListener,
             }
         });
 
-        excludeSuperclassListeners.addActionListener(new ActionListener() {
+        excludeSuperclassListeners.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 ObjEntity entity = mediator.getCurrentObjEntity();
                 if (entity != null) {
                     entity.setExcludingSuperclassListeners(excludeSuperclassListeners
@@ -393,9 +400,10 @@ public class ObjEntityTab extends JPanel implements ObjEntityDisplayListener,
             }
         });
 
-        excludeDefaultListeners.addActionListener(new ActionListener() {
+        excludeDefaultListeners.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 ObjEntity entity = mediator.getCurrentObjEntity();
                 if (entity != null) {
                     entity.setExcludingDefaultListeners(excludeDefaultListeners
@@ -405,9 +413,10 @@ public class ObjEntityTab extends JPanel implements ObjEntityDisplayListener,
             }
         });
 
-        serverOnly.addActionListener(new ActionListener() {
+        serverOnly.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 ObjEntity entity = mediator.getCurrentObjEntity();
                 if (entity != null) {
                     entity.setServerOnly(serverOnly.isSelected());
@@ -417,9 +426,10 @@ public class ObjEntityTab extends JPanel implements ObjEntityDisplayListener,
             }
         });
 
-        isAbstract.addActionListener(new ActionListener() {
+        isAbstract.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent e) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 ObjEntity entity = mediator.getCurrentObjEntity();
                 if (entity != null) {
                     entity.setAbstract(isAbstract.isSelected());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
index eca066c..53524b6 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
@@ -20,11 +20,12 @@
 package org.apache.cayenne.modeler.editor;
 
 import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 
 import javax.swing.JCheckBox;
 
+import org.apache.cayenne.swing.components.JCayenneCheckBox;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.map.QueryDescriptor;
 import org.apache.cayenne.query.QueryMetadata;
@@ -49,7 +50,7 @@ public class ObjectQueryPropertiesPanel extends SelectPropertiesPanel {
         super.initView();
         // create widgets
 
-        dataRows = new JCheckBox();
+        dataRows = new JCayenneCheckBox();
 
         // assemble
         CellConstraints cc = new CellConstraints();
@@ -79,9 +80,10 @@ public class ObjectQueryPropertiesPanel extends SelectPropertiesPanel {
     protected void initController() {
         super.initController();
 
-        dataRows.addActionListener(new ActionListener() {
+        dataRows.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent event) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 Boolean b = dataRows.isSelected() ? Boolean.TRUE : Boolean.FALSE;
                 setQueryProperty(QueryMetadata.FETCHING_DATA_ROWS_PROPERTY, String.valueOf(b));
             }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
index 6d1d0a9..a9fa92e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
@@ -32,6 +32,7 @@ import javax.swing.JTextField;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.event.ProcedureEvent;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.swing.components.JCayenneCheckBox;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.ProcedureDisplayEvent;
 import org.apache.cayenne.modeler.event.ProcedureDisplayListener;
@@ -91,7 +92,7 @@ public class ProcedureTab extends JPanel implements ProcedureDisplayListener,
Ex
         JLabel returnValueHelp = new JLabel("(first parameter will be used as return value)");
         returnValueHelp.setFont(returnValueHelp.getFont().deriveFont(10));
 
-        this.returnsValue = new JCheckBox();
+        this.returnsValue = new JCayenneCheckBox();
         this.returnsValue.setToolTipText(returnValueHelp.getText());
 
         FormLayout layout = new FormLayout("right:pref, 3dlu, fill:200dlu", "");

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
index 8244aba..4e42f35 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
@@ -22,6 +22,8 @@ package org.apache.cayenne.modeler.editor;
 import java.awt.BorderLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -33,6 +35,7 @@ import javax.swing.JComboBox;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.swing.components.JCayenneCheckBox;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.util.CellRenderers;
 import org.apache.cayenne.modeler.util.Comparators;
@@ -59,9 +62,10 @@ public abstract class RawQueryPropertiesPanel extends SelectPropertiesPanel
{
 
     protected void initController() {
         super.initController();
-        dataObjects.addActionListener(new ActionListener() {
+        dataObjects.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent event) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 setFetchingDataObjects(dataObjects.isSelected());
             }
         });
@@ -106,7 +110,7 @@ public abstract class RawQueryPropertiesPanel extends SelectPropertiesPanel
{
 
         // create widgets
 
-        dataObjects = new JCheckBox();
+        dataObjects = new JCayenneCheckBox();
 
         entities = Application.getWidgetFactory().createUndoableComboBox();
         entities.setRenderer(CellRenderers.listRendererWithIcons());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java
index 0b8255d..a8a0d63 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java
@@ -24,6 +24,8 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.FocusEvent;
 import java.awt.event.FocusListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.util.Arrays;
 import java.util.Iterator;
 
@@ -43,6 +45,7 @@ import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.QueryDescriptor;
 import org.apache.cayenne.map.SelectQueryDescriptor;
 import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.swing.components.JCayenneCheckBox;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.util.CellRenderers;
 import org.apache.cayenne.modeler.util.Comparators;
@@ -108,7 +111,7 @@ public class SelectQueryMainTab extends JPanel {
             }
         };
 
-        distinct = new JCheckBox();
+        distinct = new JCayenneCheckBox();
 
         properties = new ObjectQueryPropertiesPanel(mediator);
 
@@ -142,9 +145,10 @@ public class SelectQueryMainTab extends JPanel {
         queryRoot.addFocusListener(rootHandler);
         queryRoot.getEditor().getEditorComponent().addFocusListener(rootHandler);
 
-        distinct.addActionListener(new ActionListener() {
+        distinct.addItemListener(new ItemListener() {
 
-            public void actionPerformed(ActionEvent event) {
+            @Override
+            public void itemStateChanged(ItemEvent e) {
                 QueryDescriptor query = getQuery();
                 if (query != null) {
                     query.setProperty(SelectQuery.DISTINCT_PROPERTY, Boolean.toString(distinct.isSelected()));

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureParameterUndoableEdit.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureParameterUndoableEdit.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureParameterUndoableEdit.java
new file mode 100644
index 0000000..4837046
--- /dev/null
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureParameterUndoableEdit.java
@@ -0,0 +1,74 @@
+/*****************************************************************
+ *   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.undo;
+
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.map.ProcedureParameter;
+import org.apache.cayenne.modeler.action.CreateProcedureParameterAction;
+import org.apache.cayenne.modeler.action.RemoveProcedureParameterAction;
+import org.apache.cayenne.modeler.event.ProcedureDisplayEvent;
+
+import javax.swing.undo.CannotRedoException;
+import javax.swing.undo.CannotUndoException;
+
+public class CreateProcedureParameterUndoableEdit extends CayenneUndoableEdit {
+
+    private DataChannelDescriptor domain;
+    private DataMap dataMap;
+    private Procedure procedure;
+    private ProcedureParameter parameter;
+
+    public CreateProcedureParameterUndoableEdit(
+            DataChannelDescriptor dataDomain, DataMap dataMap, Procedure procedure, ProcedureParameter
parameter) {
+
+        this.domain = dataDomain;
+        this.dataMap = dataMap;
+        this.procedure = procedure;
+        this.parameter = parameter;
+    }
+
+    @Override
+    public void undo() throws CannotUndoException {
+        RemoveProcedureParameterAction action = actionManager.getAction(RemoveProcedureParameterAction.class);
+
+        if (procedure != null) {
+            action.removeProcedureParameters(procedure, new ProcedureParameter[] {
+                    parameter
+            });
+
+            controller.fireProcedureDisplayEvent(new ProcedureDisplayEvent(this, procedure,
dataMap, domain));
+        }
+    }
+
+    @Override
+    public void redo() throws CannotRedoException {
+        CreateProcedureParameterAction action = actionManager.getAction(CreateProcedureParameterAction.class);
+        if (procedure != null) {
+            action.createProcedureParameter(procedure, parameter);
+        }
+    }
+
+    @Override
+    public String getPresentationName() {
+        return "Create Procedure Parameter";
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JCheckBoxUndoListener.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JCheckBoxUndoListener.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JCheckBoxUndoListener.java
new file mode 100644
index 0000000..e64f3c1
--- /dev/null
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JCheckBoxUndoListener.java
@@ -0,0 +1,36 @@
+/*****************************************************************
+ *   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.undo;
+
+import org.apache.cayenne.modeler.Application;
+
+import javax.swing.*;
+import javax.swing.undo.UndoableEdit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class JCheckBoxUndoListener implements ActionListener{
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        UndoableEdit edit = new JUndoableCheckBoxEdit((JCheckBox) e.getSource(), this);
+        Application.getInstance().getUndoManager().addEdit(edit);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JUndoableCheckBoxEdit.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JUndoableCheckBoxEdit.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JUndoableCheckBoxEdit.java
new file mode 100644
index 0000000..951a02c
--- /dev/null
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JUndoableCheckBoxEdit.java
@@ -0,0 +1,124 @@
+/*****************************************************************
+ *   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.undo;
+
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.CayenneModelerFrame;
+import org.apache.cayenne.modeler.editor.EditorView;
+import org.apache.cayenne.query.SQLTemplate;
+
+import javax.swing.*;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+import javax.swing.undo.AbstractUndoableEdit;
+import javax.swing.undo.CannotRedoException;
+import javax.swing.undo.CannotUndoException;
+import java.awt.event.ActionListener;
+
+public class JUndoableCheckBoxEdit extends AbstractUndoableEdit {
+
+    private JCheckBox checkBox;
+    private ActionListener actionListener;
+    private JTabbedPane tabbedPane;
+    private TreePath treePath;
+    private Object targetObject;
+    private EditorView editorView;
+
+    private int selectedTabIndex;
+
+    private boolean isSelected;
+
+
+    JUndoableCheckBoxEdit(JCheckBox checkBox, ActionListener actionListener) {
+
+        this.checkBox = checkBox;
+        this.actionListener = actionListener;
+        this.isSelected = checkBox.isSelected();
+
+        editorView = ((CayenneModelerFrame) Application.getInstance().getFrameController().getView()).getView();
+
+        treePath = editorView.getProjectTreeView().getSelectionPath();
+
+        if (treePath != null) {
+            DefaultMutableTreeNode newPath = (DefaultMutableTreeNode) treePath.getLastPathComponent();
+            targetObject = newPath.getUserObject();
+        }
+
+        if (targetObject instanceof DataChannelDescriptor) {
+            tabbedPane = editorView.getDataDomainView();
+        }
+
+        if (targetObject instanceof DataMap) {
+            tabbedPane = editorView.getDataMapView();
+        }
+
+        if (targetObject instanceof ObjEntity) {
+            tabbedPane = editorView.getObjDetailView();
+        }
+
+        if (targetObject instanceof SQLTemplate) {
+            tabbedPane = editorView.getSqlTemplateView();
+        }
+
+        if (tabbedPane != null) {
+            selectedTabIndex = tabbedPane.getSelectedIndex();
+        }
+    }
+
+    private void restoreSelections() {
+
+        editorView.getProjectTreeView().getSelectionModel().setSelectionPath(treePath);
+
+        if (tabbedPane != null) {
+            tabbedPane.setSelectedIndex(selectedTabIndex);
+        }
+    }
+
+    public String getPresentationName() {
+        return "CheckBox Change";
+    }
+
+    public void redo() throws CannotRedoException {
+        super.redo();
+
+        restoreSelections();
+        checkBox.removeActionListener(actionListener);
+        try {
+            checkBox.setSelected(isSelected);
+        } finally {
+            checkBox.addActionListener(actionListener);
+        }
+    }
+
+    public void undo() throws CannotUndoException {
+        super.undo();
+
+        restoreSelections();
+        checkBox.removeActionListener(actionListener);
+        try {
+            checkBox.setSelected(!isSelected);
+        } finally {
+            checkBox.addActionListener(actionListener);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/33e9b4b9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/swing/components/JCayenneCheckBox.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/swing/components/JCayenneCheckBox.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/swing/components/JCayenneCheckBox.java
new file mode 100644
index 0000000..de7f4b5
--- /dev/null
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/swing/components/JCayenneCheckBox.java
@@ -0,0 +1,35 @@
+/*****************************************************************
+ *   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.swing.components;
+
+import org.apache.cayenne.modeler.undo.JCheckBoxUndoListener;
+
+import javax.swing.*;
+import java.awt.event.ActionListener;
+
+public class JCayenneCheckBox extends JCheckBox {
+
+    private ActionListener actionListener;
+
+    public JCayenneCheckBox() {
+        this.actionListener = new JCheckBoxUndoListener();
+        this.addActionListener(this.actionListener);
+    }
+}
\ No newline at end of file


Mime
View raw message