cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject svn commit: r1141934 - in /cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: dialog/datamap/ editor/
Date Fri, 01 Jul 2011 13:37:44 GMT
Author: dkazimirchyk
Date: Fri Jul  1 13:37:43 2011
New Revision: 1141934

URL: http://svn.apache.org/viewvc?rev=1141934&view=rev
Log:
CAY-1461 CayenneModeler: remove ScopeMVC dependencies

removed scopemvc dependencies from DefaultsPreferences dialogs

Added:
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesView.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateView.java
Removed:
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesDialog.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateDialog.java
Modified:
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesController.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateController.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/PackageUpdateController.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SchemaUpdateController.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SuperclassUpdateController.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesController.java?rev=1141934&r1=1141933&r2=1141934&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesController.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesController.java
Fri Jul  1 13:37:43 2011
@@ -21,31 +21,31 @@ package org.apache.cayenne.modeler.dialo
 
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.ProjectController;
-import org.scopemvc.controller.basic.BasicController;
-import org.scopemvc.core.Control;
-import org.scopemvc.core.ControlException;
+import org.apache.cayenne.modeler.util.CayenneController;
 
 /**
  * An abstract controller for the DataMap defaults updates.
  * 
  */
-public abstract class DefaultsPreferencesController extends BasicController {
-
-    public static final String CANCEL_CONTROL = "cayenne.modeler.datamap.defaultprefs.cancel.button";
-    public static final String UPDATE_CONTROL = "cayenne.modeler.datamap.defaultprefs.update.button";
-
+public abstract class DefaultsPreferencesController extends CayenneController {
+    
     protected DataMap dataMap;
     protected ProjectController mediator;
+    
+    protected boolean allEntities;
 
     public DefaultsPreferencesController(ProjectController mediator, DataMap dataMap) {
-        setModel(new DefaultsPreferencesModel(true));
+        super(mediator);
+        this.allEntities = true;
         this.dataMap = dataMap;
         this.mediator = mediator;
     }
 
-    protected void doHandleControl(Control control) throws ControlException {
-        if (control.matchesID(CANCEL_CONTROL)) {
-            shutdown();
-        }
+    public boolean isAllEntities() {
+        return ((DefaultsPreferencesView)getView()).getUpdateAll().isSelected();
+    }
+
+    public boolean isUninitializedEntities() {
+        return !isAllEntities();
     }
 }

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesView.java?rev=1141934&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesView.java
(added)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/DefaultsPreferencesView.java
Fri Jul  1 13:37:43 2011
@@ -0,0 +1,95 @@
+/*****************************************************************
+ *   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.datamap;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+
+import com.jgoodies.forms.builder.PanelBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.layout.FormLayout;
+
+/**
+ */
+public class DefaultsPreferencesView extends JDialog {
+    
+    protected JRadioButton updateAll;
+    protected JRadioButton updateEmpty;
+    protected JButton updateButton;
+    protected JButton cancelButton;
+    protected JPanel buttonPanel;
+
+    public DefaultsPreferencesView(String allControl, String uninitializedControl) {
+        initView(allControl, uninitializedControl);
+    }
+
+    protected void initView(String allControl, String uninitializedControl) {
+        updateAll = new JRadioButton(allControl);
+        updateAll.setSelected(true);
+
+        updateEmpty = new JRadioButton(uninitializedControl);
+
+        ButtonGroup buttonGroup = new ButtonGroup();
+        buttonGroup.add(updateAll);
+        buttonGroup.add(updateEmpty);
+
+        updateButton = new JButton("Update");
+        cancelButton = new JButton("Cancel");
+
+        // assemble
+        JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+        buttonPanel.add(updateButton);
+        buttonPanel.add(cancelButton);
+
+        CellConstraints cc = new CellConstraints();
+        FormLayout layout = new FormLayout("left:max(180dlu;pref)", "p, 3dlu, p, 3dlu");
+        PanelBuilder builder = new PanelBuilder(layout);
+        builder.setDefaultDialogBorder();
+
+        builder.add(updateAll, cc.xy(1, 1));
+        builder.add(updateEmpty, cc.xy(1, 3));
+
+        setLayout(new BorderLayout());
+        add(builder.getPanel(), BorderLayout.CENTER);
+        add(buttonPanel, BorderLayout.SOUTH);
+    }
+
+    public JRadioButton getUpdateAll() {
+        return updateAll;
+    }
+
+    public JRadioButton getUpdateEmpty() {
+        return updateEmpty;
+    }
+
+    public JButton getUpdateButton() {
+        return updateButton;
+    }
+
+    public JButton getCancelButton() {
+        return cancelButton;
+    }
+}

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateController.java?rev=1141934&r1=1141933&r2=1141934&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateController.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateController.java
Fri Jul  1 13:37:43 2011
@@ -20,7 +20,6 @@
 package org.apache.cayenne.modeler.dialog.datamap;
 
 import java.awt.Component;
-import java.util.Iterator;
 
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.ObjAttribute;
@@ -35,7 +34,7 @@ import org.apache.cayenne.swing.BindingB
 
 public class LockingUpdateController extends CayenneController {
 
-    protected LockingUpdateDialog view;
+    protected LockingUpdateView view;
     protected DataMap dataMap;
 
     public LockingUpdateController(ProjectController parent, DataMap dataMap) {
@@ -45,7 +44,7 @@ public class LockingUpdateController ext
 
     public void startup() {
 
-        view = new LockingUpdateDialog();
+        view = new LockingUpdateView();
 
         boolean on = dataMap.getDefaultLockType() == ObjEntity.LOCK_TYPE_OPTIMISTIC;
         view.setTitle(on ? "Enable Optimistic Locking" : "Disable Optimistic Locking");

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateView.java?rev=1141934&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateView.java
(added)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/LockingUpdateView.java
Fri Jul  1 13:37:43 2011
@@ -0,0 +1,100 @@
+/*****************************************************************
+ *   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.datamap;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.FlowLayout;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+
+import com.jgoodies.forms.builder.PanelBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.layout.FormLayout;
+
+public class LockingUpdateView extends JDialog {
+
+    protected JCheckBox entities;
+    protected JCheckBox attributes;
+    protected JCheckBox relationships;
+
+    protected JButton cancelButton;
+    protected JButton updateButton;
+
+    public LockingUpdateView() {
+
+        this.entities = new JCheckBox("Update all Entities");
+        this.attributes = new JCheckBox("Update all Attributes");
+        this.relationships = new JCheckBox("Update all Relationships");
+
+        this.cancelButton = new JButton("Cancel");
+        this.updateButton = new JButton("Update");
+
+        // check all by default until we start storing this in preferences.
+        entities.setSelected(true);
+        attributes.setSelected(true);
+        relationships.setSelected(true);
+
+        // do layout...
+
+        CellConstraints cc = new CellConstraints();
+        FormLayout layout = new FormLayout(
+                "left:max(180dlu;pref)",
+                "p, 3dlu, p, 3dlu, p, 3dlu");
+        PanelBuilder builder = new PanelBuilder(layout);
+        builder.setDefaultDialogBorder();
+
+        builder.add(entities, cc.xy(1, 1));
+        builder.add(attributes, cc.xy(1, 3));
+        builder.add(relationships, cc.xy(1, 5));
+
+        JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+        buttonPanel.add(updateButton);
+        buttonPanel.add(cancelButton);
+
+        Container contentPane = getContentPane();
+        contentPane.setLayout(new BorderLayout());
+        contentPane.add(builder.getPanel(), BorderLayout.CENTER);
+        contentPane.add(buttonPanel, BorderLayout.SOUTH);
+    }
+
+    public JButton getCancelButton() {
+        return cancelButton;
+    }
+
+    public JButton getUpdateButton() {
+        return updateButton;
+    }
+
+    public JCheckBox getAttributes() {
+        return attributes;
+    }
+
+    public JCheckBox getEntities() {
+        return entities;
+    }
+
+    public JCheckBox getRelationships() {
+        return relationships;
+    }
+}

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/PackageUpdateController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/PackageUpdateController.java?rev=1141934&r1=1141933&r2=1141934&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/PackageUpdateController.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/PackageUpdateController.java
Fri Jul  1 13:37:43 2011
@@ -19,10 +19,15 @@
 
 package org.apache.cayenne.modeler.dialog.datamap;
 
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.regex.Pattern;
 
+import javax.swing.WindowConstants;
+
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.EmbeddedAttribute;
@@ -33,18 +38,18 @@ import org.apache.cayenne.map.event.Embe
 import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.util.Util;
-import org.scopemvc.core.Control;
-import org.scopemvc.core.ControlException;
-import org.scopemvc.view.swing.SPanel;
 
 /**
  */
 public class PackageUpdateController extends DefaultsPreferencesController {
 
-    public static final String ALL_CONTROL = "cayenne.modeler.datamap.defaultprefs.package.radio";
-    public static final String UNINIT_CONTROL = "cayenne.modeler.datamap.defaultprefs.packagenull.radio";
+    public static final String ALL_CONTROL = 
+            "Set/update package for all ObjEntities and Embeddables (create default class
names if missing)";
+    public static final String UNINIT_CONTROL = "Do not override class names with packages";
 
     protected boolean clientUpdate;
+    
+    protected DefaultsPreferencesView view;
 
     public PackageUpdateController(ProjectController mediator, DataMap dataMap,
             boolean clientUpdate) {
@@ -55,24 +60,40 @@ public class PackageUpdateController ext
     /**
      * Creates and runs the package update dialog.
      */
-    public void startup() {
-        SPanel view = new DefaultsPreferencesDialog(ALL_CONTROL, UNINIT_CONTROL);
+    public void startupAction() {
+        view = new DefaultsPreferencesView(ALL_CONTROL, UNINIT_CONTROL);
         view.setTitle("Update ObjEntities and Embeddables Java Package");
-        setView(view);
-        super.startup();
-    }
-
-    protected void doHandleControl(Control control) throws ControlException {
-        if (control.matchesID(UPDATE_CONTROL)) {
-            updatePackage();
-        }
-        else {
-            super.doHandleControl(control);
-        }
+        initController();
+        
+        view.pack();
+        view.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+        view.setModal(true);
+        makeCloseableOnEscape();
+        centerView();
+        view.setVisible(true);
+    }
+    
+    public Component getView() {
+        return this.view;
+    }
+    
+    private void initController() {
+        view.getCancelButton().addActionListener(new ActionListener() {
+            
+            public void actionPerformed(ActionEvent arg0) {
+                view.dispose();
+            }
+        });
+        view.getUpdateButton().addActionListener(new ActionListener() {
+            
+            public void actionPerformed(ActionEvent arg0) {
+                updatePackage();
+            }
+        });
     }
 
     protected void updatePackage() {
-        boolean doAll = ((DefaultsPreferencesModel) getModel()).isAllEntities();
+        boolean doAll = isAllEntities();
         String defaultPackage = getDefaultPackage();
         if (Util.isEmptyString(defaultPackage)) {
             defaultPackage = "";
@@ -120,7 +141,7 @@ public class PackageUpdateController ext
             }
         }
 
-        shutdown();
+        view.dispose();
     }
 
     protected String extractClassName(String name) {

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SchemaUpdateController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SchemaUpdateController.java?rev=1141934&r1=1141933&r2=1141934&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SchemaUpdateController.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SchemaUpdateController.java
Fri Jul  1 13:37:43 2011
@@ -19,7 +19,11 @@
 
 package org.apache.cayenne.modeler.dialog.datamap;
 
-import java.util.Iterator;
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.WindowConstants;
 
 import org.apache.cayenne.configuration.event.ProcedureEvent;
 import org.apache.cayenne.map.DataMap;
@@ -28,9 +32,6 @@ import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.util.Util;
-import org.scopemvc.core.Control;
-import org.scopemvc.core.ControlException;
-import org.scopemvc.view.swing.SPanel;
 
 /**
  * A controller for batch DbEntities schema update.
@@ -38,8 +39,10 @@ import org.scopemvc.view.swing.SPanel;
  */
 public class SchemaUpdateController extends DefaultsPreferencesController {
 
-    public static final String ALL_CONTROL = "cayenne.modeler.datamap.defaultprefs.schema.radio";
-    public static final String UNINIT_CONTROL = "cayenne.modeler.datamap.defaultprefs.schemanull.radio";
+    public static final String ALL_CONTROL = "Set/update schema for all DbEntities";
+    public static final String UNINIT_CONTROL = "Do not override existing non-empty schema";
+    
+    protected DefaultsPreferencesView view;
 
     public SchemaUpdateController(ProjectController mediator, DataMap dataMap) {
         super(mediator, dataMap);
@@ -48,24 +51,41 @@ public class SchemaUpdateController exte
     /**
      * Creates and runs the schema update dialog.
      */
-    public void startup() {
-        SPanel view = new DefaultsPreferencesDialog(ALL_CONTROL, UNINIT_CONTROL);
+    public void startupAction() {
+        view = new DefaultsPreferencesView(ALL_CONTROL, UNINIT_CONTROL);
         view.setTitle("Update DbEntities Schema");
-        setView(view);
-        super.startup();
+        initController();
+        
+        view.pack();
+        view.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+        view.setModal(true);
+        makeCloseableOnEscape();
+        centerView();
+        view.setVisible(true);
     }
-
-    protected void doHandleControl(Control control) throws ControlException {
-        if (control.matchesID(UPDATE_CONTROL)) {
-            updateSchema();
-        }
-        else {
-            super.doHandleControl(control);
-        }
+    
+    public Component getView() {
+        return this.view;
+    }
+    
+    private void initController() {
+        view.getUpdateButton().addActionListener(new ActionListener() {
+            
+            public void actionPerformed(ActionEvent arg0) {
+                updateSchema();
+            }
+        });
+        
+        view.getCancelButton().addActionListener(new ActionListener() {
+            
+            public void actionPerformed(ActionEvent arg0) {
+                view.dispose();
+            }
+        });
     }
 
     protected void updateSchema() {
-        boolean doAll = ((DefaultsPreferencesModel) getModel()).isAllEntities();
+        boolean doAll = isAllEntities();
         String defaultSchema = dataMap.getDefaultSchema();
 
         // set schema for DbEntities
@@ -93,6 +113,6 @@ public class SchemaUpdateController exte
                 }
             }
         }
-        shutdown();
+        view.dispose();
     }
 }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SuperclassUpdateController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SuperclassUpdateController.java?rev=1141934&r1=1141933&r2=1141934&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SuperclassUpdateController.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datamap/SuperclassUpdateController.java
Fri Jul  1 13:37:43 2011
@@ -19,25 +19,28 @@
 
 package org.apache.cayenne.modeler.dialog.datamap;
 
-import java.util.Iterator;
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.WindowConstants;
 
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.util.Util;
-import org.scopemvc.core.Control;
-import org.scopemvc.core.ControlException;
-import org.scopemvc.view.swing.SPanel;
 
 /**
  */
 public class SuperclassUpdateController extends DefaultsPreferencesController {
 
-    public static final String ALL_CONTROL = "cayenne.modeler.datamap.defaultprefs.superclass.radio";
-    public static final String UNINIT_CONTROL = "cayenne.modeler.datamap.defaultprefs.superclassnull.radio";
+    public static final String ALL_CONTROL = "Set/update superclass for all ObjEntities";
+    public static final String UNINIT_CONTROL = "Do not override existing non-empty superclasses";
 
     protected boolean clientUpdate;
+    
+    protected DefaultsPreferencesView view;
 
     public SuperclassUpdateController(ProjectController mediator, DataMap dataMap, boolean
clientUpdate) {
         super(mediator, dataMap);
@@ -47,24 +50,41 @@ public class SuperclassUpdateController 
     /**
      * Creates and runs superclass update dialog.
      */
-    public void startup() {
-        SPanel view = new DefaultsPreferencesDialog(ALL_CONTROL, UNINIT_CONTROL);
+    public void startupAction() {
+        view = new DefaultsPreferencesView(ALL_CONTROL, UNINIT_CONTROL);
         view.setTitle("Update DataObjects Superclass");
-        setView(view);
-        super.startup();
-    }
-
-    protected void doHandleControl(Control control) throws ControlException {
-        if (control.matchesID(UPDATE_CONTROL)) {
-            updateSuperclass();
-        }
-        else {
-            super.doHandleControl(control);
-        }
+        initController();
+        
+        view.pack();
+        view.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+        view.setModal(true);
+        makeCloseableOnEscape();
+        centerView();
+        view.setVisible(true);
+    }
+    
+    public Component getView() {
+        return this.view;
+    }
+    
+    private void initController() {
+        view.getUpdateButton().addActionListener(new ActionListener() {
+            
+            public void actionPerformed(ActionEvent e) {
+                updateSuperclass();
+            }
+        });
+        
+        view.getCancelButton().addActionListener(new ActionListener() {
+            
+            public void actionPerformed(ActionEvent arg0) {
+                view.dispose();
+            }
+        });
     }
 
     protected void updateSuperclass() {
-        boolean doAll = ((DefaultsPreferencesModel) getModel()).isAllEntities();
+        boolean doAll = isAllEntities();
         String defaultSuperclass = getSuperclass();
 
         for (ObjEntity entity : dataMap.getObjEntities()) {
@@ -79,7 +99,7 @@ public class SuperclassUpdateController 
             }
         }
 
-        shutdown();
+        view.dispose();
     }
 
     protected String getSuperclass() {

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java?rev=1141934&r1=1141933&r2=1141934&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
Fri Jul  1 13:37:43 2011
@@ -575,7 +575,7 @@ public class DataMapView extends JPanel 
         }
 
         if (dataMap.getDbEntities().size() > 0 || dataMap.getProcedures().size() >
0) {
-            new SchemaUpdateController(eventController, dataMap).startup();
+            new SchemaUpdateController(eventController, dataMap).startupAction();
         }
     }
 
@@ -587,7 +587,7 @@ public class DataMapView extends JPanel 
         }
 
         if (dataMap.getObjEntities().size() > 0) {
-            new SuperclassUpdateController(eventController, dataMap, false).startup();
+            new SuperclassUpdateController(eventController, dataMap, false).startupAction();
         }
     }
 
@@ -599,7 +599,7 @@ public class DataMapView extends JPanel 
         }
 
         if (dataMap.getObjEntities().size() > 0 || dataMap.getEmbeddables().size() >
0) {
-            new PackageUpdateController(eventController, dataMap, false).startup();
+            new PackageUpdateController(eventController, dataMap, false).startupAction();
         }
     }
 
@@ -611,7 +611,7 @@ public class DataMapView extends JPanel 
         }
 
         if (dataMap.getObjEntities().size() > 0) {
-            new PackageUpdateController(eventController, dataMap, true).startup();
+            new PackageUpdateController(eventController, dataMap, true).startupAction();
         }
     }
 
@@ -623,7 +623,7 @@ public class DataMapView extends JPanel 
         }
 
         if (dataMap.getObjEntities().size() > 0) {
-            new SuperclassUpdateController(eventController, dataMap, true).startup();
+            new SuperclassUpdateController(eventController, dataMap, true).startupAction();
         }
     }
 



Mime
View raw message