cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1505113 [1/2] - in /cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: ./ action/ dialog/ dialog/db/ dialog/objentity/ dialog/validator/ editor/ graph/ undo/ util/
Date Sat, 20 Jul 2013 09:49:21 GMT
Author: aadamchik
Date: Sat Jul 20 09:49:20 2013
New Revision: 1505113

URL: http://svn.apache.org/r1505113
Log:
CAY-1852  Straighten thread model and synchronization in the Modeler

Modified:
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/FileClassLoadingService.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DuplicatedAttributesDialog.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/ValidatorDialog.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/BaseGraphBuilder.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/graph/DataDomainGraphTab.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoManager.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/TextCompoundEdit.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CircularArray.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/EntityTreeModel.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/FileWatchdog.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/JEditTextAreaUndoable.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/MultiColumnBrowser.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ValidatorTextAdapter.java

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/FileClassLoadingService.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/FileClassLoadingService.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/FileClassLoadingService.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/FileClassLoadingService.java Sat Jul 20 09:49:20 2013
@@ -43,10 +43,11 @@ public class FileClassLoadingService imp
     }
 
     /**
-     * Returns class for a given name, loading it if needed from configured locations.
+     * Returns class for a given name, loading it if needed from configured
+     * locations.
      */
     @SuppressWarnings("all")
-    public synchronized <T> Class<T> loadClass(Class<T> interfaceType, String className) throws ClassNotFoundException {
+    public <T> Class<T> loadClass(Class<T> interfaceType, String className) throws ClassNotFoundException {
         return (Class<T>) nonNullClassLoader().loadClass(className);
     }
 
@@ -60,11 +61,11 @@ public class FileClassLoadingService imp
     /**
      * Returns an unmodifiable list of configured CLASSPATH locations.
      */
-    public synchronized List<File> getPathFiles() {
+    public List<File> getPathFiles() {
         return Collections.unmodifiableList(pathFiles);
     }
 
-    public synchronized void setPathFiles(Collection<File> files) {
+    public void setPathFiles(Collection<File> files) {
 
         pathFiles.clear();
         classLoader = null;
@@ -87,8 +88,7 @@ public class FileClassLoadingService imp
         if (classLoader != null) {
             try {
                 classLoader.addURL(file.toURI().toURL());
-            }
-            catch (MalformedURLException ex) {
+            } catch (MalformedURLException ex) {
                 return;
             }
         }
@@ -96,7 +96,7 @@ public class FileClassLoadingService imp
         pathFiles.add(file);
     }
 
-    private synchronized FileClassLoader nonNullClassLoader() {
+    private FileClassLoader nonNullClassLoader() {
         // init class loader on demand
         if (classLoader == null) {
             classLoader = new FileClassLoader(getClass().getClassLoader(), pathFiles);
@@ -119,8 +119,7 @@ public class FileClassLoadingService imp
                 // I guess here we have to quetly ignore invalid URLs...
                 try {
                     addURL(file.toURI().toURL());
-                }
-                catch (MalformedURLException ex) {
+                } catch (MalformedURLException ex) {
                 }
             }
         }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java Sat Jul 20 09:49:20 2013
@@ -414,54 +414,51 @@ public class ProjectController extends C
 
     private void removeFromHistory(EventObject e) {
 
-        synchronized (controllerStateHistory) {
-            int count = controllerStateHistory.size();
-            List<Object> removeList = new ArrayList<Object>();
+        int count = controllerStateHistory.size();
+        List<Object> removeList = new ArrayList<Object>();
 
-            for (int i = 0; i < count; i++) {
-                ControllerState cs = (ControllerState) controllerStateHistory.get(i);
+        for (int i = 0; i < count; i++) {
+            ControllerState cs = (ControllerState) controllerStateHistory.get(i);
 
-                EventObject csEvent = cs.event;
+            EventObject csEvent = cs.event;
 
-                if (csEvent == null) {
-                    continue;
-                }
+            if (csEvent == null) {
+                continue;
+            }
 
-                if (e instanceof EntityEvent && csEvent instanceof EntityDisplayEvent) {
-                    if (((EntityEvent) e).getEntity() == ((EntityDisplayEvent) csEvent).getEntity()) {
-                        removeList.add(cs);
-                    }
-                } else if (e instanceof EmbeddableEvent && csEvent instanceof EmbeddableDisplayEvent) {
-                    if (((EmbeddableEvent) e).getEmbeddable() == ((EmbeddableDisplayEvent) csEvent).getEmbeddable()) {
-                        removeList.add(cs);
-                    }
-                } else if (e instanceof ProcedureEvent && csEvent instanceof ProcedureDisplayEvent) {
-                    if (((ProcedureEvent) e).getProcedure() == ((ProcedureDisplayEvent) csEvent).getProcedure()) {
-                        removeList.add(cs);
-                    }
-                } else if (e instanceof QueryEvent && csEvent instanceof QueryDisplayEvent) {
-                    if (((QueryEvent) e).getQuery() == ((QueryDisplayEvent) csEvent).getQuery()) {
-                        removeList.add(cs);
-                    }
-                } else if (e instanceof DataMapEvent && csEvent instanceof DataMapDisplayEvent) {
-                    if (((DataMapEvent) e).getDataMap() == ((DataMapDisplayEvent) csEvent).getDataMap()) {
-                        removeList.add(cs);
-                    }
-                } else if (e instanceof DataNodeEvent && csEvent instanceof DataNodeDisplayEvent) {
-                    if (((DataNodeEvent) e).getDataNode() == ((DataNodeDisplayEvent) csEvent).getDataNode()) {
-                        removeList.add(cs);
-                    }
-                } else if (e instanceof DomainEvent && csEvent instanceof DomainDisplayEvent) {
-                    if (((DomainEvent) e).getDomain() == ((DomainDisplayEvent) csEvent).getDomain()) {
-                        removeList.add(cs);
-                    }
+            if (e instanceof EntityEvent && csEvent instanceof EntityDisplayEvent) {
+                if (((EntityEvent) e).getEntity() == ((EntityDisplayEvent) csEvent).getEntity()) {
+                    removeList.add(cs);
+                }
+            } else if (e instanceof EmbeddableEvent && csEvent instanceof EmbeddableDisplayEvent) {
+                if (((EmbeddableEvent) e).getEmbeddable() == ((EmbeddableDisplayEvent) csEvent).getEmbeddable()) {
+                    removeList.add(cs);
+                }
+            } else if (e instanceof ProcedureEvent && csEvent instanceof ProcedureDisplayEvent) {
+                if (((ProcedureEvent) e).getProcedure() == ((ProcedureDisplayEvent) csEvent).getProcedure()) {
+                    removeList.add(cs);
+                }
+            } else if (e instanceof QueryEvent && csEvent instanceof QueryDisplayEvent) {
+                if (((QueryEvent) e).getQuery() == ((QueryDisplayEvent) csEvent).getQuery()) {
+                    removeList.add(cs);
+                }
+            } else if (e instanceof DataMapEvent && csEvent instanceof DataMapDisplayEvent) {
+                if (((DataMapEvent) e).getDataMap() == ((DataMapDisplayEvent) csEvent).getDataMap()) {
+                    removeList.add(cs);
+                }
+            } else if (e instanceof DataNodeEvent && csEvent instanceof DataNodeDisplayEvent) {
+                if (((DataNodeEvent) e).getDataNode() == ((DataNodeDisplayEvent) csEvent).getDataNode()) {
+                    removeList.add(cs);
+                }
+            } else if (e instanceof DomainEvent && csEvent instanceof DomainDisplayEvent) {
+                if (((DomainEvent) e).getDomain() == ((DomainDisplayEvent) csEvent).getDomain()) {
+                    removeList.add(cs);
                 }
             }
-            Iterator it = removeList.iterator();
-            while (it.hasNext()) {
-                controllerStateHistory.remove(it.next());
-            }
+        }
 
+        for (Object o : removeList) {
+            controllerStateHistory.remove(o);
         }
     }
 

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java Sat Jul 20 09:49:20 2013
@@ -64,15 +64,13 @@ public class SaveAsAction extends Cayenn
     }
 
     public KeyStroke getAcceleratorKey() {
-        return KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit
-                .getDefaultToolkit()
-                .getMenuShortcutKeyMask()
+        return KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
                 | ActionEvent.SHIFT_MASK);
     }
 
     /**
-     * Saves project and related files. Saving is done to temporary files, and only on
-     * successful save, master files are replaced with new versions.
+     * Saves project and related files. Saving is done to temporary files, and
+     * only on successful save, master files are replaced with new versions.
      */
     protected boolean saveAll() throws Exception {
         Project p = getCurrentProject();
@@ -88,13 +86,8 @@ public class SaveAsAction extends Cayenn
         }
 
         if (projectDir.exists() && !projectDir.canWrite()) {
-            JOptionPane.showMessageDialog(
-                    Application.getFrame(),
-                    "Can't save project - unable to write to file \""
-                            + projectDir.getPath()
-                            + "\"",
-                    "Can't Save Project",
-                    JOptionPane.OK_OPTION);
+            JOptionPane.showMessageDialog(Application.getFrame(), "Can't save project - unable to write to file \""
+                    + projectDir.getPath() + "\"", "Can't Save Project", JOptionPane.OK_OPTION);
             return false;
         }
 
@@ -104,8 +97,7 @@ public class SaveAsAction extends Cayenn
 
         URLResource res = new URLResource(url);
 
-        ProjectSaver saver = getApplication().getInjector().getInstance(
-                ProjectSaver.class);
+        ProjectSaver saver = getApplication().getInjector().getInstance(ProjectSaver.class);
 
         boolean isNewProject = p.getConfigurationResource() == null;
         Preferences tempOldPref = null;
@@ -115,41 +107,27 @@ public class SaveAsAction extends Cayenn
 
         saver.saveAs(p, res);
 
-        if (oldPath != null
-                && oldPath.length() != 0
+        if (oldPath != null && oldPath.length() != 0
                 && !oldPath.equals(p.getConfigurationResource().getURL().getPath())) {
 
-            String newName = p.getConfigurationResource().getURL().getPath().replace(
-                    ".xml",
-                    "");
+            String newName = p.getConfigurationResource().getURL().getPath().replace(".xml", "");
             String oldName = oldPath.replace(".xml", "");
 
             Preferences oldPref = getProjectController().getPreferenceForProject();
             String projPath = oldPref.absolutePath().replace(oldName, "");
-            Preferences newPref = getProjectController().getPreferenceForProject().node(
-                    projPath + newName);
-            RenamedPreferences.copyPreferences(newPref, getProjectController()
-                    .getPreferenceForProject(), false);
-        }
-        else if (isNewProject) {
+            Preferences newPref = getProjectController().getPreferenceForProject().node(projPath + newName);
+            RenamedPreferences.copyPreferences(newPref, getProjectController().getPreferenceForProject(), false);
+        } else if (isNewProject) {
             if (tempOldPref != null) {
 
                 String newProjectName = getApplication().getNewProjectTemporaryName();
 
                 if (tempOldPref.absolutePath().contains(newProjectName)) {
 
-                    String projPath = tempOldPref.absolutePath().replace(
-                            "/" + newProjectName,
-                            "");
-                    String newName = p
-                            .getConfigurationResource()
-                            .getURL()
-                            .getPath()
-                            .replace(".xml", "");
-
-                    Preferences newPref = getApplication()
-                            .getMainPreferenceForProject()
-                            .node(projPath + newName);
+                    String projPath = tempOldPref.absolutePath().replace("/" + newProjectName, "");
+                    String newName = p.getConfigurationResource().getURL().getPath().replace(".xml", "");
+
+                    Preferences newPref = getApplication().getMainPreferenceForProject().node(projPath + newName);
 
                     RenamedPreferences.copyPreferences(newPref, tempOldPref, false);
                     tempOldPref.removeNode();
@@ -159,8 +137,7 @@ public class SaveAsAction extends Cayenn
 
         RenamedPreferences.removeNewPreferences();
 
-        getApplication().getFrameController().addToLastProjListAction(
-                p.getConfigurationResource().getURL().getPath());
+        getApplication().getFrameController().addToLastProjListAction(p.getConfigurationResource().getURL().getPath());
 
         Application.getFrame().fireRecentFileListChanged();
 
@@ -173,25 +150,23 @@ public class SaveAsAction extends Cayenn
     }
 
     /**
-     * This method is synchronized to prevent problems on double-clicking "save".
+     * This method is synchronized to prevent problems on double-clicking
+     * "save".
      */
-    public synchronized void performAction(ActionEvent e) {
+    public void performAction(ActionEvent e) {
         performAction(ValidationDisplayHandler.WARNING);
     }
 
-    public synchronized void performAction(int warningLevel) {
+    public void performAction(int warningLevel) {
 
-        ProjectValidator projectValidator = getApplication().getInjector().getInstance(
-                ProjectValidator.class);
-        ValidationResult validationResult = projectValidator.validate(getCurrentProject()
-                .getRootNode());
+        ProjectValidator projectValidator = getApplication().getInjector().getInstance(ProjectValidator.class);
+        ValidationResult validationResult = projectValidator.validate(getCurrentProject().getRootNode());
 
         try {
             if (!saveAll()) {
                 return;
             }
-        }
-        catch (Exception ex) {
+        } catch (Exception ex) {
             throw new CayenneRuntimeException("Error on save", ex);
         }
 
@@ -199,14 +174,13 @@ public class SaveAsAction extends Cayenn
 
         // If there were errors or warnings at validation, display them
         if (validationResult.getFailures().size() > 0) {
-            ValidatorDialog.showDialog(Application.getFrame(), validationResult
-                    .getFailures());
+            ValidatorDialog.showDialog(Application.getFrame(), validationResult.getFailures());
         }
     }
 
     /**
-     * Returns <code>true</code> if path contains a Project object and the project is
-     * modified.
+     * Returns <code>true</code> if path contains a Project object and the
+     * project is modified.
      */
     public boolean enableForPath(ConfigurationNode object) {
         if (object == null) {

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java Sat Jul 20 09:49:20 2013
@@ -41,20 +41,19 @@ import org.apache.cayenne.modeler.util.M
 import org.apache.cayenne.util.LocalizedStringsHandler;
 import org.apache.cayenne.util.Util;
 
-/** 
+/**
  * Displays the Cayenne license and build information.
  */
-// Implementation note - the data displayed here is 
-// static and very simple, so there is no need to implement complex Scope MVC 
+// Implementation note - the data displayed here is
+// static and very simple, so there is no need to implement complex Scope MVC
 // triad, though it might be beneficial to use strings file
 public class AboutDialog extends JFrame implements FocusListener, KeyListener, MouseListener {
 
-    
     private JLabel license, info;
     private static String infoString;
     private static ImageIcon logoImage;
 
-    static synchronized ImageIcon getLogoImage() {
+    static ImageIcon getLogoImage() {
         if (logoImage == null) {
             logoImage = ModelerUtil.buildIcon("logo.jpg");
         }
@@ -64,7 +63,7 @@ public class AboutDialog extends JFrame 
     /**
      * Builds and returns CayenneModeler info string.
      */
-    static synchronized String getInfoString() {
+    static String getInfoString() {
         if (infoString == null) {
 
             double maxMemory = (double) Runtime.getRuntime().maxMemory() / 1024 / 1024;
@@ -78,14 +77,8 @@ public class AboutDialog extends JFrame 
             buffer.append("</font>");
 
             buffer.append("<font size='-2' face='Arial,Helvetica'>");
-            buffer.append("<br>JVM: "
-                    + System.getProperty("java.vm.name")
-                    + " "
-                    + System.getProperty("java.version"));
-            buffer.append(String.format(
-                    "<br>Memory: used %.2f MB, max %.2f MB",
-                    totalMemory - freeMemory,
-                    maxMemory));
+            buffer.append("<br>JVM: " + System.getProperty("java.vm.name") + " " + System.getProperty("java.version"));
+            buffer.append(String.format("<br>Memory: used %.2f MB, max %.2f MB", totalMemory - freeMemory, maxMemory));
 
             String version = LocalizedStringsHandler.getString("cayenne.version");
             if (version != null) {
@@ -117,7 +110,7 @@ public class AboutDialog extends JFrame 
         addFocusListener(this);
         addKeyListener(this);
         setLocationRelativeTo(null); // centre on screen
-        
+
         final JPanel panel = new JPanel();
         panel.setLayout(new GridBagLayout());
         panel.setBackground(Color.WHITE);
@@ -135,7 +128,7 @@ public class AboutDialog extends JFrame 
         gridBagConstraints_1.insets = new Insets(0, 12, 0, 0);
         panel.add(license, gridBagConstraints_1);
         license.setText("<html><font size='-1' face='Arial,Helvetica'>Available under the Apache license.</font></html>");
-        
+
         info = new JLabel();
         final GridBagConstraints gridBagConstraints_2 = new GridBagConstraints();
         gridBagConstraints_2.fill = GridBagConstraints.HORIZONTAL;
@@ -145,16 +138,16 @@ public class AboutDialog extends JFrame 
         gridBagConstraints_2.insets = new Insets(6, 12, 12, 12);
         panel.add(info, gridBagConstraints_2);
         info.setText(getInfoString());
-        
+
         this.pack();
         this.setLocationRelativeTo(null);
         this.setVisible(true);
     }
-    
+
     public void keyPressed(KeyEvent e) {
         dispose();
     }
-   
+
     public void focusLost(FocusEvent e) {
         dispose();
     }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java Sat Jul 20 09:49:20 2013
@@ -61,11 +61,10 @@ public class DbLoaderHelper {
 
     private static Log logObj = LogFactory.getLog(DbLoaderHelper.class);
 
-    // TODO: this is a temp hack... need to delegate to DbAdapter, or configurable in
+    // TODO: this is a temp hack... need to delegate to DbAdapter, or
+    // configurable in
     // preferences...
-    private static final Collection<String> EXCLUDED_TABLES = Arrays.asList(
-            "AUTO_PK_SUPPORT",
-            "auto_pk_support");
+    private static final Collection<String> EXCLUDED_TABLES = Arrays.asList("AUTO_PK_SUPPORT", "auto_pk_support");
 
     static DbLoaderMergeDialog mergeDialog;
 
@@ -92,7 +91,7 @@ public class DbLoaderHelper {
      */
     protected List<ObjEntity> addedObjEntities;
 
-    static synchronized DbLoaderMergeDialog getMergeDialogInstance() {
+    static DbLoaderMergeDialog getMergeDialogInstance() {
         if (mergeDialog == null) {
             mergeDialog = new DbLoaderMergeDialog(Application.getFrame());
         }
@@ -100,8 +99,7 @@ public class DbLoaderHelper {
         return mergeDialog;
     }
 
-    public DbLoaderHelper(ProjectController mediator, Connection connection,
-            DbAdapter adapter, String dbUserName) {
+    public DbLoaderHelper(ProjectController mediator, Connection connection, DbAdapter adapter, String dbUserName) {
         this.dbUserName = dbUserName;
         this.mediator = mediator;
         this.loader = new DbLoader(connection, adapter, new LoaderDelegate());
@@ -132,16 +130,15 @@ public class DbLoaderHelper {
     }
 
     /**
-     * Performs reverse engineering of the DB using internal DbLoader. This method should
-     * be invoked outside EventDispatchThread, or it will throw an exception.
+     * Performs reverse engineering of the DB using internal DbLoader. This
+     * method should be invoked outside EventDispatchThread, or it will throw an
+     * exception.
      */
     public void execute() {
         stoppingReverseEngineering = false;
 
         // load schemas...
-        LongRunningTask loadSchemasTask = new LoadSchemasTask(
-                Application.getFrame(),
-                "Loading Schemas");
+        LongRunningTask loadSchemasTask = new LoadSchemasTask(Application.getFrame(), "Loading Schemas");
 
         loadSchemasTask.startAndWait();
 
@@ -149,10 +146,7 @@ public class DbLoaderHelper {
             return;
         }
 
-        final DbLoaderOptionsDialog dialog = new DbLoaderOptionsDialog(
-                schemas,
-                dbUserName,
-                false);
+        final DbLoaderOptionsDialog dialog = new DbLoaderOptionsDialog(schemas, dbUserName, false);
 
         try {
             // since we are not inside EventDisptahcer Thread, must run it via
@@ -164,8 +158,7 @@ public class DbLoaderHelper {
                     dialog.dispose();
                 }
             });
-        }
-        catch (Throwable th) {
+        } catch (Throwable th) {
             processException(th, "Error Reengineering Database");
             return;
         }
@@ -184,9 +177,7 @@ public class DbLoaderHelper {
         this.loader.setNamingStrategy(dialog.getNamingStrategy());
 
         // load DataMap...
-        LongRunningTask loadDataMapTask = new LoadDataMapTask(
-                Application.getFrame(),
-                "Reengineering DB");
+        LongRunningTask loadDataMapTask = new LoadDataMapTask(Application.getFrame(), "Reengineering DB");
         loadDataMapTask.startAndWait();
     }
 
@@ -196,10 +187,7 @@ public class DbLoaderHelper {
         SwingUtilities.invokeLater(new Runnable() {
 
             public void run() {
-                JOptionPane.showMessageDialog(
-                        Application.getFrame(),
-                        th.getMessage(),
-                        message,
+                JOptionPane.showMessageDialog(Application.getFrame(), th.getMessage(), message,
                         JOptionPane.ERROR_MESSAGE);
             }
         });
@@ -211,8 +199,7 @@ public class DbLoaderHelper {
             if (loader.getConnection() != null) {
                 loader.getConnection().close();
             }
-        }
-        catch (SQLException e) {
+        } catch (SQLException e) {
             logObj.warn("Error closing connection.", e);
         }
     }
@@ -242,12 +229,12 @@ public class DbLoaderHelper {
 
             loadStatusNote = "Importing table '" + entity.getName() + "'...";
 
-            // TODO: hack to prevent PK tables from being visible... this should really be
+            // TODO: hack to prevent PK tables from being visible... this should
+            // really be
             // delegated to DbAdapter to decide...
             if (EXCLUDED_TABLES.contains(entity.getName()) && entity.getDataMap() != null) {
                 entity.getDataMap().removeDbEntity(entity.getName());
-            }
-            else if (existingMap) {
+            } else if (existingMap) {
                 mediator.fireDbEntityEvent(new EntityEvent(this, entity, MapEvent.ADD));
             }
         }
@@ -267,10 +254,7 @@ public class DbLoaderHelper {
             checkCanceled();
 
             if (existingMap) {
-                mediator.fireDbEntityEvent(new EntityEvent(
-                        Application.getFrame(),
-                        entity,
-                        MapEvent.REMOVE));
+                mediator.fireDbEntityEvent(new EntityEvent(Application.getFrame(), entity, MapEvent.REMOVE));
             }
         }
 
@@ -278,10 +262,7 @@ public class DbLoaderHelper {
             checkCanceled();
 
             if (existingMap) {
-                mediator.fireObjEntityEvent(new EntityEvent(
-                        Application.getFrame(),
-                        entity,
-                        MapEvent.REMOVE));
+                mediator.fireObjEntityEvent(new EntityEvent(Application.getFrame(), entity, MapEvent.REMOVE));
             }
         }
 
@@ -342,8 +323,7 @@ public class DbLoaderHelper {
 
             try {
                 schemas = loader.getSchemas();
-            }
-            catch (Throwable th) {
+            } catch (Throwable th) {
                 processException(th, "Error Loading Schemas");
             }
         }
@@ -365,9 +345,8 @@ public class DbLoaderHelper {
 
             if (!existingMap) {
                 dataMap = (DataMap) NamedObjectFactory.createObject(DataMap.class, null);
-                dataMap.setName(NamedObjectFactory.createName(
-                        DataMap.class,
-                        (DataChannelDescriptor) mediator.getProject().getRootNode()));
+                dataMap.setName(NamedObjectFactory.createName(DataMap.class, (DataChannelDescriptor) mediator
+                        .getProject().getRootNode()));
                 dataMap.setDefaultSchema(schemaName);
             }
 
@@ -387,8 +366,7 @@ public class DbLoaderHelper {
                 for (ObjEntity addedObjEntity : addedObjEntities) {
                     DeleteRuleUpdater.updateObjEntity(addedObjEntity);
                 }
-            }
-            catch (Throwable th) {
+            } catch (Throwable th) {
                 if (!isCanceled()) {
                     processException(th, "Error Reengineering Database");
                 }
@@ -397,13 +375,8 @@ public class DbLoaderHelper {
             if (loadProcedures) {
                 loadStatusNote = "Importing procedures...";
                 try {
-                    loader
-                            .loadProceduresFromDB(
-                                    schemaName,
-                                    procedureNamePattern,
-                                    dataMap);
-                }
-                catch (Throwable th) {
+                    loader.loadProceduresFromDB(schemaName, procedureNamePattern, dataMap);
+                } catch (Throwable th) {
                     if (!isCanceled()) {
                         processException(th, "Error Reengineering Database");
                     }
@@ -415,21 +388,15 @@ public class DbLoaderHelper {
             // fire up events
             loadStatusNote = "Updating view...";
             if (mediator.getCurrentDataMap() != null) {
-                mediator.fireDataMapEvent(new DataMapEvent(
-                        Application.getFrame(),
-                        dataMap,
-                        MapEvent.CHANGE));
-                mediator.fireDataMapDisplayEvent(new DataMapDisplayEvent(Application
-                        .getFrame(), dataMap, (DataChannelDescriptor) mediator
-                        .getProject()
-                        .getRootNode(), mediator.getCurrentDataNode()));
-            }
-            else {
-                DataChannelDescriptor currentDomain = (DataChannelDescriptor) mediator
-                        .getProject().getRootNode();
+                mediator.fireDataMapEvent(new DataMapEvent(Application.getFrame(), dataMap, MapEvent.CHANGE));
+                mediator.fireDataMapDisplayEvent(new DataMapDisplayEvent(Application.getFrame(), dataMap,
+                        (DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataNode()));
+            } else {
+                DataChannelDescriptor currentDomain = (DataChannelDescriptor) mediator.getProject().getRootNode();
                 Resource baseResource = currentDomain.getConfigurationSource();
 
-                // this will be new data map so need to set configuration source for it
+                // this will be new data map so need to set configuration source
+                // for it
                 if (baseResource != null) {
                     Resource dataMapResource = baseResource.getRelativeResource(dataMap.getName());
                     dataMap.setConfigurationSource(dataMapResource);

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java Sat Jul 20 09:49:20 2013
@@ -55,16 +55,15 @@ import org.apache.cayenne.util.DeleteRul
 import org.apache.cayenne.util.NamedObjectFactory;
 import org.apache.cayenne.util.Util;
 
-public class ObjRelationshipInfo extends CayenneController implements
-    TreeSelectionListener {
-    
+public class ObjRelationshipInfo extends CayenneController implements TreeSelectionListener {
+
     static final String COLLECTION_TYPE_MAP = "java.util.Map";
     static final String COLLECTION_TYPE_SET = "java.util.Set";
     static final String COLLECTION_TYPE_COLLECTION = "java.util.Collection";
     static final String DEFAULT_MAP_KEY = "ID (default)";
-    
+
     protected ObjRelationship relationship;
-    
+
     protected List<DbRelationship> dbRelationships;
 
     protected List<DbRelationship> savedDbRelationships;
@@ -78,7 +77,7 @@ public class ObjRelationshipInfo extends
     protected ObjRelationshipInfoView view;
     protected String currentPath;
     protected ProjectController mediator;
-    
+
     /**
      * Starts options dialog.
      */
@@ -90,15 +89,15 @@ public class ObjRelationshipInfo extends
         centerView();
         view.setVisible(true);
     }
-   
-    public ObjRelationshipInfo(ProjectController mediator,ObjRelationship relationship) {
+
+    public ObjRelationshipInfo(ProjectController mediator, ObjRelationship relationship) {
         super(mediator);
         this.view = new ObjRelationshipInfoView(mediator);
-        this.mediator=mediator;
+        this.mediator = mediator;
         ObjEntity target = getObjectTarget();
         getPathBrowser().addTreeSelectionListener(this);
         setObjectTarget(target);
-        view.sourceEntityLabel.setText(relationship.getSourceEntity().getName());    
+        view.sourceEntityLabel.setText(relationship.getSourceEntity().getName());
         this.relationship = relationship;
         this.relationshipName = relationship.getName();
         view.relationshipName.setText(relationshipName);
@@ -123,11 +122,11 @@ public class ObjRelationshipInfo extends
         targetCollections.add(ObjRelationship.DEFAULT_COLLECTION_TYPE);
         targetCollections.add(COLLECTION_TYPE_MAP);
         targetCollections.add(COLLECTION_TYPE_SET);
-        
-        for( String s : targetCollections) {
+
+        for (String s : targetCollections) {
             view.collectionTypeCombo.addItem(s);
         }
-       
+
         this.mapKeys = new ArrayList<String>();
         initMapKeys();
 
@@ -135,13 +134,13 @@ public class ObjRelationshipInfo extends
         dbRelationships = new ArrayList<DbRelationship>(relationship.getDbRelationships());
         selectPath();
         updateCollectionChoosers();
-       
+
         // add dummy last relationship if we are not connected
         connectEnds();
         initFromModel();
         initController();
     }
-    
+
     private void initController() {
         view.getCancelButton().addActionListener(new ActionListener() {
 
@@ -166,21 +165,21 @@ public class ObjRelationshipInfo extends
             public void actionPerformed(ActionEvent e) {
                 selectPath();
             }
-        });  
+        });
         view.getCollectionTypeCombo().addActionListener(new ActionListener() {
-            
+
             public void actionPerformed(ActionEvent e) {
                 setCollectionType();
             }
         });
         view.getMapKeysCombo().addActionListener(new ActionListener() {
-            
+
             public void actionPerformed(ActionEvent e) {
                 setMapKey();
             }
         });
     }
-    
+
     void initFromModel() {
 
         if (view.pathBrowser.getModel() == null) {
@@ -198,7 +197,8 @@ public class ObjRelationshipInfo extends
                     }
 
                     /**
-                     * We do not allow A->B->A chains, where relationships are to-one
+                     * We do not allow A->B->A chains, where relationships are
+                     * to-one
                      */
                     DbRelationship prev = (DbRelationship) node;
                     return !(!rel.isToMany() && prev.getReverseRelationship() == rel);
@@ -211,7 +211,7 @@ public class ObjRelationshipInfo extends
             setSelectionPath(getSavedDbRelationships());
         }
     }
-    
+
     /**
      * Selects path in browser
      */
@@ -223,30 +223,29 @@ public class ObjRelationshipInfo extends
 
         view.pathBrowser.setSelectionPath(new TreePath(path));
     }
-    
+
     public void setCollectionType() {
-        setTargetCollection((String)view.collectionTypeCombo.getSelectedItem());
-        
-        if (COLLECTION_TYPE_MAP.equals(targetCollection)){
+        setTargetCollection((String) view.collectionTypeCombo.getSelectedItem());
+
+        if (COLLECTION_TYPE_MAP.equals(targetCollection)) {
             view.mapKeysLabel.setEnabled(true);
             view.mapKeysCombo.setEnabled(true);
             setMapKey();
-        }
-        else {
+        } else {
             view.mapKeysLabel.setEnabled(false);
             view.mapKeysCombo.setEnabled(false);
         }
     }
-    
+
     public void setMapKey() {
-        setMapKey((String)view.mapKeysCombo.getSelectedItem());
+        setMapKey((String) view.mapKeysCombo.getSelectedItem());
     }
 
     @Override
     public Component getView() {
         return view;
     }
- 
+
     public void setSavedDbRelationships(List<DbRelationship> rels) {
         this.savedDbRelationships = rels;
 
@@ -260,9 +259,9 @@ public class ObjRelationshipInfo extends
         }
 
         currentPath = currPath;
-        view.currentPathLabel.setText(currPath);   
+        view.currentPathLabel.setText(currPath);
     }
-    
+
     public void selectPath() {
         setSavedDbRelationships(new ArrayList<DbRelationship>(dbRelationships));
     }
@@ -274,7 +273,7 @@ public class ObjRelationshipInfo extends
         setSelectionPath(getSavedDbRelationships());
         setDbRelationships(getSavedDbRelationships());
     }
-    
+
     /**
      * Updates 'collection type' and 'map keys' comboboxes
      */
@@ -287,15 +286,14 @@ public class ObjRelationshipInfo extends
         }
 
         boolean mapKeysEnabled = collectionTypeEnabled
-                && ObjRelationshipInfo.COLLECTION_TYPE_MAP
-                        .equals(view.collectionTypeCombo.getSelectedItem());
+                && ObjRelationshipInfo.COLLECTION_TYPE_MAP.equals(view.collectionTypeCombo.getSelectedItem());
         view.mapKeysCombo.setEnabled(mapKeysEnabled);
         view.mapKeysLabel.setEnabled(mapKeysEnabled);
         if (mapKeysEnabled) {
             view.mapKeysCombo.setSelectedItem(mapKey);
         }
     }
-    
+
     /**
      * Clears paths and selections in browser
      */
@@ -306,55 +304,47 @@ public class ObjRelationshipInfo extends
 
     protected void saveMapping() {
         if (!getDbRelationships().equals(getSavedDbRelationships())) {
-            if (JOptionPane.showConfirmDialog(
-                    (Component) getView(),
-                    "You have changed Db Relationship path. Do you want it to be saved?",
-                    "Save ObjRelationship",
+            if (JOptionPane.showConfirmDialog((Component) getView(),
+                    "You have changed Db Relationship path. Do you want it to be saved?", "Save ObjRelationship",
                     JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                 selectPath();
             }
         }
 
         if (savePath()) {
-            mediator.fireObjRelationshipEvent(new RelationshipEvent(Application
-                    .getFrame(), getRelationship(), getRelationship()
-                    .getSourceEntity()));
+            mediator.fireObjRelationshipEvent(new RelationshipEvent(Application.getFrame(), getRelationship(),
+                    getRelationship().getSourceEntity()));
         }
-        view.sourceEntityLabel.setText(relationship.getSourceEntity().getName()); 
+        view.sourceEntityLabel.setText(relationship.getSourceEntity().getName());
         view.dispose();
     }
-    
+
     /**
      * @return relationship path browser
      */
     public MultiColumnBrowser getPathBrowser() {
         return view.pathBrowser;
     }
-    
+
     /**
-     * Creates a new relationship connecting currently selected source entity with
-     * ObjRelationship target entity. User is allowed to edit the relationship, change its
-     * name, and create joins.
+     * Creates a new relationship connecting currently selected source entity
+     * with ObjRelationship target entity. User is allowed to edit the
+     * relationship, change its name, and create joins.
      */
     protected void createRelationship() {
-      
+
         DbRelationship dbRel = getLastRelationship();
         DbEntity source = dbRel != null ? (DbEntity) dbRel.getTargetEntity() : null;
 
-        DbRelationshipTarget targetModel = new DbRelationshipTarget(mediator,
-                getStartEntity(),
-                source);
+        DbRelationshipTarget targetModel = new DbRelationshipTarget(mediator, getStartEntity(), source);
         targetModel.startupAction();
 
         if (!targetModel.isSavePressed()) {
             return;
         }
 
-        DbRelationship dbRelationship = (DbRelationship) NamedObjectFactory
-                .createRelationship(
-                        targetModel.getSource(),
-                        targetModel.getTarget(),
-                        targetModel.isToMany());
+        DbRelationship dbRelationship = (DbRelationship) NamedObjectFactory.createRelationship(targetModel.getSource(),
+                targetModel.getTarget(), targetModel.isToMany());
 
         // note: NamedObjectFactory doesn't set source or target, just the name
         dbRelationship.setSourceEntity(targetModel.getSource());
@@ -362,20 +352,18 @@ public class ObjRelationshipInfo extends
         dbRelationship.setToMany(targetModel.isToMany());
         targetModel.getSource().addRelationship(dbRelationship);
 
-        // TODO: creating relationship outside of ResolveDbRelationshipDialog confuses it
+        // TODO: creating relationship outside of ResolveDbRelationshipDialog
+        // confuses it
         // to send incorrect event - CHANGE instead of ADD
-        ResolveDbRelationshipDialog dialog = new ResolveDbRelationshipDialog(
-                dbRelationship);
+        ResolveDbRelationshipDialog dialog = new ResolveDbRelationshipDialog(dbRelationship);
 
         dialog.setVisible(true);
         if (dialog.isCancelPressed()) {
             targetModel.getSource().removeRelationship(dbRelationship.getName());
-        }
-        else {
+        } else {
             MultiColumnBrowser pathBrowser = getPathBrowser();
-            Object[] oldPath = targetModel.isSource1Selected() ? new Object[] {
-                    getStartEntity()
-                } : pathBrowser.getSelectionPath().getPath();
+            Object[] oldPath = targetModel.isSource1Selected() ? new Object[] { getStartEntity() } : pathBrowser
+                    .getSelectionPath().getPath();
 
             /**
              * Update the view
@@ -383,9 +371,7 @@ public class ObjRelationshipInfo extends
             EntityTreeModel treeModel = (EntityTreeModel) pathBrowser.getModel();
             treeModel.invalidate();
 
-            pathBrowser.setSelectionPath(new TreePath(new Object[] {
-                getStartEntity()
-            }));
+            pathBrowser.setSelectionPath(new TreePath(new Object[] { getStartEntity() }));
             pathBrowser.repaint();
 
             Object[] path = new Object[oldPath.length + 1];
@@ -397,7 +383,7 @@ public class ObjRelationshipInfo extends
 
         dialog.dispose();
     }
-    
+
     /**
      * Sets list of DB Relationships current ObjRelationship is mapped to
      */
@@ -412,39 +398,39 @@ public class ObjRelationshipInfo extends
 
         Relationship rel = (Relationship) selectedPath.getLastPathComponent();
         DbEntity target = (DbEntity) rel.getTargetEntity();
-         /**
+        /**
          * Initialize root with one of mapped ObjEntities.
          */
         Collection<ObjEntity> objEntities = target.getDataMap().getMappedEntities(target);
 
-        List<DbRelationship> relPath = new Vector<DbRelationship>(selectedPath
-                .getPathCount() - 1);
+        List<DbRelationship> relPath = new Vector<DbRelationship>(selectedPath.getPathCount() - 1);
         for (int i = 1; i < selectedPath.getPathCount(); i++) {
             relPath.add((DbRelationship) selectedPath.getPathComponent(i));
         }
         setDbRelationships(relPath);
-        setObjectTarget(objEntities.size() == 0 ? null : objEntities
-                .iterator()
-                .next());
+        setObjectTarget(objEntities.size() == 0 ? null : objEntities.iterator().next());
 
         updateCollectionChoosers();
     }
+
     public void setObjectTarget(ObjEntity objectTarget) {
         if (this.objectTarget != objectTarget) {
-             this.objectTarget = objectTarget;
-             view.targetCombo.setSelectedItem(objectTarget);
+            this.objectTarget = objectTarget;
+            view.targetCombo.setSelectedItem(objectTarget);
 
             // init available map keys
             initMapKeys();
         }
     }
+
     private void initMapKeys() {
         this.mapKeys.clear();
 
         mapKeys.add(DEFAULT_MAP_KEY);
 
         /**
-         * Object target can be null when selected target DbEntity has no ObjEntities
+         * Object target can be null when selected target DbEntity has no
+         * ObjEntities
          */
         if (objectTarget == null) {
             return;
@@ -454,15 +440,15 @@ public class ObjRelationshipInfo extends
             mapKeys.add(attribute.getName());
         }
         view.mapKeysCombo.removeAllItems();
-        for(String s :mapKeys)
+        for (String s : mapKeys)
             view.mapKeysCombo.addItem(s);
-        
+
         if (mapKey != null && !mapKeys.contains(mapKey)) {
             mapKey = DEFAULT_MAP_KEY;
             view.mapKeysCombo.setSelectedItem(mapKey);
         }
     }
-    
+
     /**
      * Places in objectTargets list all ObjEntities for specified DbEntity
      */
@@ -477,8 +463,8 @@ public class ObjRelationshipInfo extends
             Collections.sort(objectTargets, Comparators.getNamedObjectComparator());
         }
         view.targetCombo.removeAllItems();
-        for( ObjEntity s : objectTargets) {
-           view.targetCombo.addItem(s.getName());
+        for (ObjEntity s : objectTargets) {
+            view.targetCombo.addItem(s.getName());
         }
     }
 
@@ -501,11 +487,11 @@ public class ObjRelationshipInfo extends
     }
 
     /**
-     * @return last relationship in the path, or <code>null</code> if path is empty
+     * @return last relationship in the path, or <code>null</code> if path is
+     *         empty
      */
     public DbRelationship getLastRelationship() {
-        return dbRelationships.size() == 0 ? null : dbRelationships.get(dbRelationships
-                .size() - 1);
+        return dbRelationships.size() == 0 ? null : dbRelationships.get(dbRelationships.size() - 1);
     }
 
     /**
@@ -514,13 +500,11 @@ public class ObjRelationshipInfo extends
     public void setDbRelationships(List<DbRelationship> rels) {
         this.dbRelationships = rels;
 
-        updateTargetCombo(rels.size() > 0 ? (DbEntity) rels
-                .get(rels.size() - 1)
-                .getTargetEntity() : null);
-        
+        updateTargetCombo(rels.size() > 0 ? (DbEntity) rels.get(rels.size() - 1).getTargetEntity() : null);
+
         updateCollectionChoosers();
     }
-    
+
     /**
      * Returns currently selected target of the ObjRelationship.
      */
@@ -547,7 +531,7 @@ public class ObjRelationshipInfo extends
     /**
      * Processes relationship path when path component at index was changed.
      */
-    public synchronized void relationshipChanged(int index) {
+    public void relationshipChanged(int index) {
         // strip everything starting from the index
         breakChain(index);
 
@@ -556,7 +540,8 @@ public class ObjRelationshipInfo extends
     }
 
     public boolean isToMany() {
-        // copied algorithm from ObjRelationship.calculateToMany(), only iterating through
+        // copied algorithm from ObjRelationship.calculateToMany(), only
+        // iterating through
         // the unsaved dbrels selection.
 
         for (DbRelationship relationship : dbRelationships) {
@@ -567,11 +552,11 @@ public class ObjRelationshipInfo extends
 
         return false;
     }
-    
+
     /**
      * Stores current state of the model in the internal ObjRelationship.
      */
-    public synchronized boolean savePath() {
+    public boolean savePath() {
         boolean hasChanges = false;
 
         boolean oldToMany = relationship.isToMany();
@@ -582,27 +567,21 @@ public class ObjRelationshipInfo extends
         }
 
         if (savedDbRelationships.size() > 0) {
-            DbEntity lastEntity = (DbEntity) savedDbRelationships.get(
-                    savedDbRelationships.size() - 1).getTargetEntity();
+            DbEntity lastEntity = (DbEntity) savedDbRelationships.get(savedDbRelationships.size() - 1)
+                    .getTargetEntity();
 
             if (objectTarget == null || objectTarget.getDbEntity() != lastEntity) {
                 /**
-                 * Entities in combobox and path browser do not match. In this case, we
-                 * rely on the browser and automatically select one of lastEntity's
-                 * ObjEntities
+                 * Entities in combobox and path browser do not match. In this
+                 * case, we rely on the browser and automatically select one of
+                 * lastEntity's ObjEntities
                  */
-                Collection<ObjEntity> objEntities = lastEntity
-                        .getDataMap()
-                        .getMappedEntities(lastEntity);
-                objectTarget = objEntities.size() == 0 ? null : objEntities
-                        .iterator()
-                        .next();
+                Collection<ObjEntity> objEntities = lastEntity.getDataMap().getMappedEntities(lastEntity);
+                objectTarget = objEntities.size() == 0 ? null : objEntities.iterator().next();
             }
         }
 
-        if (objectTarget == null
-                || !Util.nullSafeEquals(objectTarget.getName(), relationship
-                        .getTargetEntityName())) {
+        if (objectTarget == null || !Util.nullSafeEquals(objectTarget.getName(), relationship.getTargetEntityName())) {
             hasChanges = true;
 
             // note on events notification - this needs to be propagated
@@ -616,8 +595,7 @@ public class ObjRelationshipInfo extends
         if (oldPath.size() != savedDbRelationships.size()) {
             hasChanges = true;
             updatePath();
-        }
-        else {
+        } else {
             for (int i = 0; i < oldPath.size(); i++) {
                 DbRelationship next = savedDbRelationships.get(i);
 
@@ -629,8 +607,7 @@ public class ObjRelationshipInfo extends
             }
         }
 
-        String collectionType = ObjRelationship.DEFAULT_COLLECTION_TYPE
-                .equals(targetCollection)
+        String collectionType = ObjRelationship.DEFAULT_COLLECTION_TYPE.equals(targetCollection)
                 || !relationship.isToMany() ? null : targetCollection;
         if (!Util.nullSafeEquals(collectionType, relationship.getCollectionType())) {
             hasChanges = true;
@@ -638,16 +615,16 @@ public class ObjRelationshipInfo extends
         }
 
         // map key only makes sense for Map relationships
-        String mapKey = COLLECTION_TYPE_MAP.equals(collectionType)
-                && !DEFAULT_MAP_KEY.equals(this.mapKey) ? this.mapKey : null;
+        String mapKey = COLLECTION_TYPE_MAP.equals(collectionType) && !DEFAULT_MAP_KEY.equals(this.mapKey) ? this.mapKey
+                : null;
         if (!Util.nullSafeEquals(mapKey, relationship.getMapKey())) {
             hasChanges = true;
             relationship.setMapKey(mapKey);
         }
 
         /**
-         * As of CAY-436 here we check if to-many property has changed during the editing,
-         * and if so, delete rule must be reset to default value
+         * As of CAY-436 here we check if to-many property has changed during
+         * the editing, and if so, delete rule must be reset to default value
          */
         if (hasChanges && relationship.isToMany() != oldToMany) {
             DeleteRuleUpdater.updateObjRelationship(relationship);
@@ -676,6 +653,7 @@ public class ObjRelationshipInfo extends
             dbRelationships.remove(dbRelationships.size() - 1);
         }
     }
+
     // Connects last selected DbRelationship in the path to the
     // last DbEntity, creating a dummy relationship if needed.
     private void connectEnds() {
@@ -694,8 +672,7 @@ public class ObjRelationshipInfo extends
             Entity source = (last == null) ? getStartEntity() : last.getTargetEntity();
             if (source != null) {
 
-                Relationship anyConnector = source != null ? source
-                        .getAnyRelationship(target) : null;
+                Relationship anyConnector = source != null ? source.getAnyRelationship(target) : null;
 
                 if (anyConnector != null) {
                     dbRelationships.add((DbRelationship) anyConnector);
@@ -705,18 +682,17 @@ public class ObjRelationshipInfo extends
     }
 
     /**
-     * Checks if the entity can be edited with this inspector. NOTE: As of CAY-1077,
-     * relationship inspector can be opened even if no target entity was set.
+     * Checks if the entity can be edited with this inspector. NOTE: As of
+     * CAY-1077, relationship inspector can be opened even if no target entity
+     * was set.
      */
     private void validateCanMap() {
         if (relationship.getSourceEntity() == null) {
-            throw new CayenneRuntimeException(
-                    "Can't map relationship without source entity.");
+            throw new CayenneRuntimeException("Can't map relationship without source entity.");
         }
 
         if (getStartEntity() == null) {
-            throw new CayenneRuntimeException(
-                    "Can't map relationship without source DbEntity.");
+            throw new CayenneRuntimeException("Can't map relationship without source DbEntity.");
         }
     }
 
@@ -726,7 +702,8 @@ public class ObjRelationshipInfo extends
 
     public DbEntity getEndEntity() {
         /**
-         * Object target can be null when selected target DbEntity has no ObjEntities
+         * Object target can be null when selected target DbEntity has no
+         * ObjEntities
          */
         if (objectTarget == null) {
             return null;

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DuplicatedAttributesDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DuplicatedAttributesDialog.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DuplicatedAttributesDialog.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/DuplicatedAttributesDialog.java Sat Jul 20 09:49:20 2013
@@ -18,67 +18,61 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.dialog.validator;
 
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.table.TableColumn;
 
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.CayenneModelerFrame;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.util.CayenneDialog;
-import org.apache.cayenne.modeler.util.WidgetFactory;
-import org.apache.cayenne.modeler.util.ProjectUtil;
 import org.apache.cayenne.modeler.util.CayenneTableModel;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjEntity;
-
-
-import javax.swing.table.TableColumn;
-import javax.swing.JTable;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JScrollPane;
-import javax.swing.JPanel;
-import javax.swing.JDialog;
-import java.util.List;
-import java.util.LinkedList;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.awt.FlowLayout;
-import java.awt.BorderLayout;
-
+import org.apache.cayenne.modeler.util.ProjectUtil;
 
+import com.jgoodies.forms.builder.PanelBuilder;
 import com.jgoodies.forms.layout.CellConstraints;
 import com.jgoodies.forms.layout.FormLayout;
-import com.jgoodies.forms.builder.PanelBuilder;
 
 /**
  * Dialog for resolving name collision.
  * 
  */
 public class DuplicatedAttributesDialog extends CayenneDialog {
-    
+
     protected static DuplicatedAttributesDialog instance;
-    
+
     static final String DELETE_ACTION = "delete";
     static final String RENAME_ACTION = "rename";
-    
+
     public static final String CANCEL_RESULT = "cancel";
     public static final String PROCEEDED_RESULT = "proceeded";
-    
+
     static String result = CANCEL_RESULT;
-    
+
     protected List<DuplicatedAttributeInfo> duplicatedAttributes;
-    
+
     protected ObjEntity superEntity;
     protected ObjEntity entity;
-    
+
     protected JTable attributesTable;
     protected JButton cancelButton;
     protected JButton proceedButton;
 
-    public static synchronized void showDialog(
-            CayenneModelerFrame editor,
-            List<ObjAttribute> duplicatedAttributes,
-            ObjEntity superEntity,
-            ObjEntity entity) {
+    public static void showDialog(CayenneModelerFrame editor, List<ObjAttribute> duplicatedAttributes,
+            ObjEntity superEntity, ObjEntity entity) {
 
         if (instance == null) {
             instance = new DuplicatedAttributesDialog(editor);
@@ -96,7 +90,7 @@ public class DuplicatedAttributesDialog 
         super(editor, "Duplicated Attributes", true);
 
         result = CANCEL_RESULT;
-        
+
         initView();
         initController();
     }
@@ -109,22 +103,16 @@ public class DuplicatedAttributesDialog 
 
         // assemble
         CellConstraints cc = new CellConstraints();
-        PanelBuilder builder = new PanelBuilder(new FormLayout(
-                "fill:200dlu:grow",
-                "pref, 3dlu, top:40dlu:grow"));
+        PanelBuilder builder = new PanelBuilder(new FormLayout("fill:200dlu:grow", "pref, 3dlu, top:40dlu:grow"));
 
         builder.setDefaultDialogBorder();
 
-        builder
-                .addLabel(
-                        "Select actions for duplicated attributes:",
-                        cc.xy(1, 1));
+        builder.addLabel("Select actions for duplicated attributes:", cc.xy(1, 1));
         builder.add(new JScrollPane(attributesTable), cc.xy(1, 3));
 
         JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
         buttons.add(cancelButton);
         buttons.add(proceedButton);
-        
 
         getContentPane().setLayout(new BorderLayout());
         getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
@@ -162,7 +150,8 @@ public class DuplicatedAttributesDialog 
 
     private void updateTable() {
         TableColumn actionColumn = attributesTable.getColumnModel().getColumn(DuplicatedAttributeTableModel.ACTION);
-        JComboBox actionsCombo = Application.getWidgetFactory().createComboBox(new String[]{DELETE_ACTION, RENAME_ACTION}, false);
+        JComboBox actionsCombo = Application.getWidgetFactory().createComboBox(
+                new String[] { DELETE_ACTION, RENAME_ACTION }, false);
         actionColumn.setCellEditor(Application.getWidgetFactory().createCellEditor(actionsCombo));
     }
 
@@ -176,20 +165,21 @@ public class DuplicatedAttributesDialog 
             }
         }
     }
-    
+
     public void setDuplicatedAttributes(List<ObjAttribute> attributes) {
         if (duplicatedAttributes == null) {
             duplicatedAttributes = new LinkedList<DuplicatedAttributeInfo>();
         }
-        
+
         duplicatedAttributes.clear();
-        
+
         for (ObjAttribute attribute : attributes) {
-            DuplicatedAttributeInfo attributeInfo = new DuplicatedAttributeInfo(attribute.getName(), attribute.getType(),
-                    ((ObjAttribute) superEntity.getAttribute(attribute.getName())).getType(), DELETE_ACTION);
+            DuplicatedAttributeInfo attributeInfo = new DuplicatedAttributeInfo(attribute.getName(),
+                    attribute.getType(), ((ObjAttribute) superEntity.getAttribute(attribute.getName())).getType(),
+                    DELETE_ACTION);
             duplicatedAttributes.add(attributeInfo);
         }
-        
+
         attributesTable.setModel(new DuplicatedAttributeTableModel(getMediator(), this, duplicatedAttributes));
 
     }
@@ -203,7 +193,7 @@ public class DuplicatedAttributesDialog 
     }
 
     class DuplicatedAttributeTableModel extends CayenneTableModel {
-        
+
         static final int ATTRIBUTE_NAME = 0;
         static final int PARENT_TYPE = 1;
         static final int TYPE = 2;
@@ -218,17 +208,18 @@ public class DuplicatedAttributesDialog 
 
         public void setUpdatedValueAt(Object newValue, int row, int column) {
             DuplicatedAttributeInfo attributeInfo = duplicatedAttributes.get(row);
-            if(column == ATTRIBUTE_NAME) {
+            if (column == ATTRIBUTE_NAME) {
                 attributeInfo.setNewName(newValue.toString());
                 attributeInfo.setAction(RENAME_ACTION);
-                //TODO: add warn if new valuew equals the old one or name equals to another attribute name.
+                // TODO: add warn if new valuew equals the old one or name
+                // equals to another attribute name.
                 this.fireTableDataChanged();
             }
 
             if (column == ACTION) {
                 attributeInfo.setAction(newValue.toString());
             }
-            
+
         }
 
         public Class<?> getElementsClass() {
@@ -242,20 +233,18 @@ public class DuplicatedAttributesDialog 
         public Object getValueAt(int row, int col) {
             DuplicatedAttributeInfo attributeInfo = duplicatedAttributes.get(row);
             switch (col) {
-                case ATTRIBUTE_NAME:
-                    return attributeInfo.getNewName();
-                case PARENT_TYPE:
-                    return attributeInfo.getParentType();
-                case TYPE:
-                    return attributeInfo.getType();
-                case ACTION:
-                    return attributeInfo.getAction();
-                
+            case ATTRIBUTE_NAME:
+                return attributeInfo.getNewName();
+            case PARENT_TYPE:
+                return attributeInfo.getParentType();
+            case TYPE:
+                return attributeInfo.getType();
+            case ACTION:
+                return attributeInfo.getAction();
+
             }
             return "";
         }
-        
-        
 
         public boolean isCellEditable(int row, int column) {
             if (column == ACTION || column == ATTRIBUTE_NAME) {
@@ -266,20 +255,20 @@ public class DuplicatedAttributesDialog 
 
         public String getColumnName(int column) {
             switch (column) {
-                case ATTRIBUTE_NAME:
-                    return "Name";
-                case PARENT_TYPE:
-                    return "Type in super entity";
-                case TYPE :
-                    return "Type";
-                case ACTION:
-                    return "Action";
+            case ATTRIBUTE_NAME:
+                return "Name";
+            case PARENT_TYPE:
+                return "Type in super entity";
+            case TYPE:
+                return "Type";
+            case ACTION:
+                return "Action";
             }
             return " ";
         }
 
         public Class getColumnClass(int column) {
-          return String.class;
+            return String.class;
         }
 
         @Override
@@ -335,5 +324,5 @@ public class DuplicatedAttributesDialog 
             this.newName = newName;
         }
     }
-    
+
 }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/ValidatorDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/ValidatorDialog.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/ValidatorDialog.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/validator/ValidatorDialog.java Sat Jul 20 09:49:20 2013
@@ -67,9 +67,7 @@ public class ValidatorDialog extends Cay
     protected JButton refreshButton;
     protected List<ValidationFailure> validationObjects;
 
-    public static synchronized void showDialog(
-            CayenneModelerFrame frame,
-            List<ValidationFailure> list) {
+    public static void showDialog(CayenneModelerFrame frame, List<ValidationFailure> list) {
         if (instance == null) {
             instance = new ValidatorDialog(frame);
             instance.centerWindow();
@@ -79,15 +77,14 @@ public class ValidatorDialog extends Cay
         instance.setVisible(true);
     }
 
-    public static synchronized void showValidationSuccess(CayenneModelerFrame editor) {
+    public static void showValidationSuccess(CayenneModelerFrame editor) {
 
         if (instance != null) {
             instance.dispose();
             instance = null;
         }
 
-        JOptionPane
-                .showMessageDialog(Application.getFrame(), "Cayenne project is valid.");
+        JOptionPane.showMessageDialog(Application.getFrame(), "Cayenne project is valid.");
     }
 
     protected ValidatorDialog(CayenneModelerFrame editor) {
@@ -109,22 +106,15 @@ public class ValidatorDialog extends Cay
         problemsTable.setRowMargin(3);
         problemsTable.setCellSelectionEnabled(false);
         problemsTable.setRowSelectionAllowed(true);
-        problemsTable.setDefaultRenderer(
-                ValidationFailure.class,
-                new ValidationRenderer());
+        problemsTable.setDefaultRenderer(ValidationFailure.class, new ValidationRenderer());
 
         // assemble
         CellConstraints cc = new CellConstraints();
-        PanelBuilder builder = new PanelBuilder(new FormLayout(
-                "fill:200dlu:grow",
-                "pref, 3dlu, fill:40dlu:grow"));
+        PanelBuilder builder = new PanelBuilder(new FormLayout("fill:200dlu:grow", "pref, 3dlu, fill:40dlu:grow"));
 
         builder.setDefaultDialogBorder();
 
-        builder
-                .addLabel(
-                        "Click on any row below to go to the object that has a validation problem:",
-                        cc.xy(1, 1));
+        builder.addLabel("Click on any row below to go to the object that has a validation problem:", cc.xy(1, 1));
         builder.add(new JScrollPane(problemsTable), cc.xy(1, 3));
 
         JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
@@ -142,13 +132,12 @@ public class ValidatorDialog extends Cay
     private void initController() {
 
         setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
-        problemsTable.getSelectionModel().addListSelectionListener(
-                new ListSelectionListener() {
+        problemsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
 
-                    public void valueChanged(ListSelectionEvent e) {
-                        showFailedObject();
-                    }
-                });
+            public void valueChanged(ListSelectionEvent e) {
+                showFailedObject();
+            }
+        });
 
         closeButton.addActionListener(new ActionListener() {
 
@@ -161,8 +150,7 @@ public class ValidatorDialog extends Cay
         refreshButton.addActionListener(new ActionListener() {
 
             public void actionPerformed(ActionEvent e) {
-                Application.getInstance().getActionManager().getAction(
-                        ValidateAction.class).actionPerformed(e);
+                Application.getInstance().getActionManager().getAction(ValidateAction.class).actionPerformed(e);
             }
         });
 
@@ -186,12 +174,9 @@ public class ValidatorDialog extends Cay
 
     private void showFailedObject() {
         if (problemsTable.getSelectedRow() >= 0) {
-            ValidationFailure obj = (ValidationFailure) problemsTable
-                    .getModel()
-                    .getValueAt(problemsTable.getSelectedRow(), 0);
-            ValidationDisplayHandler.getErrorMsg(obj).displayField(
-                    getMediator(),
-                    super.getParentEditor());
+            ValidationFailure obj = (ValidationFailure) problemsTable.getModel().getValueAt(
+                    problemsTable.getSelectedRow(), 0);
+            ValidationDisplayHandler.getErrorMsg(obj).displayField(getMediator(), super.getParentEditor());
         }
     }
 
@@ -225,13 +210,8 @@ public class ValidatorDialog extends Cay
     // a renderer for the error message
     class ValidationRenderer extends DefaultTableCellRenderer {
 
-        public Component getTableCellRendererComponent(
-                JTable table,
-                Object value,
-                boolean isSelected,
-                boolean hasFocus,
-                int row,
-                int column) {
+        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
+                boolean hasFocus, int row, int column) {
 
             boolean error = false;
             if (value != null) {
@@ -240,13 +220,7 @@ public class ValidatorDialog extends Cay
             }
 
             setBackground(error ? ERROR_COLOR : WARNING_COLOR);
-            return super.getTableCellRendererComponent(
-                    table,
-                    value,
-                    isSelected,
-                    hasFocus,
-                    row,
-                    column);
+            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
         }
     }
 }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EjbqlQueryScriptsTab.java Sat Jul 20 09:49:20 2013
@@ -25,6 +25,7 @@ import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 
 import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.text.BadLocationException;
@@ -72,16 +73,12 @@ public class EjbqlQueryScriptsTab extend
 
             public void insertUpdate(DocumentEvent e) {
                 try {
-                    String text = scriptArea
-                            .getDocument()
-                            .getText(e.getOffset(), 1)
-                            .toString();
+                    String text = scriptArea.getDocument().getText(e.getOffset(), 1).toString();
                     if (text.equals(" ") || text.equals("\n") || text.equals("\t")) {
                         getQuery().setEjbqlStatement(scriptArea.getText());
                         validateEJBQL();
                     }
-                }
-                catch (BadLocationException e1) {
+                } catch (BadLocationException e1) {
                     e1.printStackTrace();
                 }
             }
@@ -111,25 +108,20 @@ public class EjbqlQueryScriptsTab extend
             boolean pasteOrCut;
 
             public void keyPressed(KeyEvent e) {
-                if (e.getKeyCode() == KeyEvent.VK_END
-                        || e.getKeyCode() == KeyEvent.VK_HOME
-                        || e.getKeyCode() == KeyEvent.VK_LEFT
-                        || e.getKeyCode() == KeyEvent.VK_RIGHT
-                        || e.getKeyCode() == KeyEvent.VK_UP
-                        || e.getKeyCode() == KeyEvent.VK_UNDO) {
+                if (e.getKeyCode() == KeyEvent.VK_END || e.getKeyCode() == KeyEvent.VK_HOME
+                        || e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_RIGHT
+                        || e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_UNDO) {
                     getQuery().setEjbqlStatement(scriptArea.getText());
                     validateEJBQL();
                 }
-                if ((e.getKeyCode() == KeyEvent.VK_V || e.getKeyCode() == KeyEvent.VK_X)
-                        && e.isControlDown()) {
+                if ((e.getKeyCode() == KeyEvent.VK_V || e.getKeyCode() == KeyEvent.VK_X) && e.isControlDown()) {
                     pasteOrCut = true;
                 }
             }
 
             public void keyReleased(KeyEvent e) {
 
-                if ((pasteOrCut && e.getKeyCode() == KeyEvent.VK_CONTROL)
-                        || e.getKeyCode() == KeyEvent.VK_DELETE) {
+                if ((pasteOrCut && e.getKeyCode() == KeyEvent.VK_CONTROL) || e.getKeyCode() == KeyEvent.VK_DELETE) {
                     scriptArea.removeHighlightText();
                     getQuery().setEjbqlStatement(scriptArea.getText());
                     validateEJBQL();
@@ -169,8 +161,7 @@ public class EjbqlQueryScriptsTab extend
         Document doc = e.getDocument();
         try {
             setEJBQL(doc.getText(0, doc.getLength()));
-        }
-        catch (BadLocationException e1) {
+        } catch (BadLocationException e1) {
             e1.printStackTrace();
         }
     }
@@ -213,23 +204,24 @@ public class EjbqlQueryScriptsTab extend
     }
 
     void validateEJBQL() {
-        PositionException positionException = ejbqlQueryValidator.validateEJBQL(
-                getQuery(),
-                new EntityResolver(((DataChannelDescriptor) mediator
-                        .getProject()
-                        .getRootNode()).getDataMaps()));
+        final PositionException positionException = ejbqlQueryValidator.validateEJBQL(getQuery(), new EntityResolver(
+                ((DataChannelDescriptor) mediator.getProject().getRootNode()).getDataMaps()));
         if (positionException != null) {
-            if (positionException.getBeginLine() != null
-                    || positionException.getBeginColumn() != null
-                    || positionException.getLength() != null) {
-                scriptArea.setHighlightText(
-                        positionException.getBeginLine(),
-                        positionException.getBeginColumn(),
-                        positionException.getLength(),
-                        positionException.getMessage());
-            }
-            else {
-                scriptArea.removeHighlightText();
+
+            if (!SwingUtilities.isEventDispatchThread()) {
+                SwingUtilities.invokeLater(new Runnable() {
+
+                    public void run() {
+                        if (positionException.getBeginLine() != null || positionException.getBeginColumn() != null
+                                || positionException.getLength() != null) {
+                            scriptArea.setHighlightText(positionException.getBeginLine(),
+                                    positionException.getBeginColumn(), positionException.getLength(),
+                                    positionException.getMessage());
+                        } else {
+                            scriptArea.removeHighlightText();
+                        }
+                    }
+                });
             }
         }
     }
@@ -252,8 +244,7 @@ public class EjbqlQueryScriptsTab extend
             running = true;
             while (running) {
                 int caretPosition = scriptArea.getCaretPosition();
-                if (previousCaretPosition != 0
-                        && previousCaretPosition == caretPosition
+                if (previousCaretPosition != 0 && previousCaretPosition == caretPosition
                         && validateCaretPosition != previousCaretPosition) {
                     validateEJBQL();
                     validateCaretPosition = caretPosition;
@@ -262,8 +253,7 @@ public class EjbqlQueryScriptsTab extend
                 synchronized (timer) {
                     try {
                         timer.wait(DELAY);
-                    }
-                    catch (InterruptedException e) {
+                    } catch (InterruptedException e) {
                     }
                 }
             }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java?rev=1505113&r1=1505112&r2=1505113&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureTab.java Sat Jul 20 09:49:20 2013
@@ -45,11 +45,11 @@ import com.jgoodies.forms.layout.CellCon
 import com.jgoodies.forms.layout.FormLayout;
 
 /**
- * A panel for editing stored procedure general settings, such as name, schema, etc.
+ * A panel for editing stored procedure general settings, such as name, schema,
+ * etc.
  * 
  */
-public class ProcedureTab extends JPanel implements ProcedureDisplayListener,
-        ExistingSelectionProcessor {
+public class ProcedureTab extends JPanel implements ProcedureDisplayListener, ExistingSelectionProcessor {
 
     protected ProjectController eventController;
     protected TextAdapter name;
@@ -87,8 +87,7 @@ public class ProcedureTab extends JPanel
         returnValueHelp.setFont(returnValueHelp.getFont().deriveFont(10));
 
         // assemble
-        FormLayout layout = new FormLayout(
-                "right:max(50dlu;pref), 3dlu, left:max(20dlu;pref), 3dlu, fill:150dlu",
+        FormLayout layout = new FormLayout("right:max(50dlu;pref), 3dlu, left:max(20dlu;pref), 3dlu, fill:150dlu",
                 "p, 3dlu, p, 3dlu, p, 3dlu, p");
 
         CellConstraints cc = new CellConstraints();
@@ -115,29 +114,24 @@ public class ProcedureTab extends JPanel
                 Procedure procedure = eventController.getCurrentProcedure();
                 if (procedure != null && !ignoreChange) {
                     procedure.setReturningValue(returnsValue.isSelected());
-                    eventController.fireProcedureEvent(new ProcedureEvent(
-                            ProcedureTab.this,
-                            procedure));
+                    eventController.fireProcedureEvent(new ProcedureEvent(ProcedureTab.this, procedure));
                 }
             }
         });
 
         eventController.addProcedureDisplayListener(this);
     }
-    
+
     public void processExistingSelection(EventObject e) {
-        ProcedureDisplayEvent pde = new ProcedureDisplayEvent(
-                this,
-                eventController.getCurrentProcedure(),
-                eventController.getCurrentDataMap(),
-                (DataChannelDescriptor)eventController.getProject().getRootNode());
+        ProcedureDisplayEvent pde = new ProcedureDisplayEvent(this, eventController.getCurrentProcedure(),
+                eventController.getCurrentDataMap(), (DataChannelDescriptor) eventController.getProject().getRootNode());
         eventController.fireProcedureDisplayEvent(pde);
     }
 
     /**
      * Invoked when currently selected Procedure object is changed.
      */
-    public synchronized void currentProcedureChanged(ProcedureDisplayEvent e) {
+    public void currentProcedureChanged(ProcedureDisplayEvent e) {
         Procedure procedure = e.getProcedure();
         if (procedure == null || !e.isProcedureChanged()) {
             return;
@@ -164,18 +158,14 @@ public class ProcedureTab extends JPanel
 
         if (newName == null) {
             throw new ValidationException("Procedure name is required.");
-        }
-        else if (procedure.getDataMap().getProcedure(newName) == null) {
+        } else if (procedure.getDataMap().getProcedure(newName) == null) {
             // completely new name, set new name for entity
             ProcedureEvent e = new ProcedureEvent(this, procedure, procedure.getName());
             ProjectUtil.setProcedureName(procedure.getDataMap(), procedure, newName);
             eventController.fireProcedureEvent(e);
-        }
-        else {
+        } else {
             // there is an entity with the same name
-            throw new ValidationException("There is another procedure with name '"
-                    + newName
-                    + "'.");
+            throw new ValidationException("There is another procedure with name '" + newName + "'.");
         }
     }
 



Mime
View raw message