cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: CAY-2199 Modeler on Windows: The same project is displayed twice in "Recent Projects"
Date Mon, 06 Feb 2017 07:27:28 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master e3704c287 -> 15308e5dd


CAY-2199 Modeler on Windows: The same project is displayed twice in "Recent Projects"


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

Branch: refs/heads/master
Commit: 15308e5dd273244facfd7bf8337bdd83493862ed
Parents: e3704c2
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Mon Feb 6 10:27:20 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Mon Feb 6 10:27:20 2017 +0300

----------------------------------------------------------------------
 .../modeler/CayenneModelerController.java       | 75 +++++++------------
 .../cayenne/modeler/ModelerPreferences.java     | 11 +--
 .../modeler/action/OpenProjectAction.java       | 78 +++++++-------------
 .../cayenne/modeler/action/SaveAction.java      | 58 +++++++--------
 .../cayenne/modeler/action/SaveAsAction.java    | 23 +++---
 .../org/apache/cayenne/pref/Preference.java     |  6 +-
 6 files changed, 93 insertions(+), 158 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/15308e5d/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
index bda0504..ae90f12 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
@@ -59,7 +59,7 @@ public class CayenneModelerController extends CayenneController {
 
     private static final ProjectStateUtil PROJECT_STATE_UTIL = new ProjectStateUtil();
 
-    protected ProjectController projectController;
+    private ProjectController projectController;
 
     protected CayenneModelerFrame frame;
 	private EditorView editorView;
@@ -70,15 +70,11 @@ public class CayenneModelerController extends CayenneController {
         super(application);
 
         this.frame = new CayenneModelerFrame(application.getActionManager());
-
-        application
-                .getInjector()
-                .getInstance(PlatformInitializer.class)
-                .setupMenus(frame);
-
+        application.getInjector().getInstance(PlatformInitializer.class).setupMenus(frame);
         this.projectController = new ProjectController(this);
     }
 
+    @Override
     public Component getView() {
         return frame;
     }
@@ -92,9 +88,7 @@ public class CayenneModelerController extends CayenneController {
 
         FSPath path = (FSPath) application
                 .getCayenneProjectPreferences()
-                .getProjectDetailObject(
-                        FSPath.class,
-                        getViewPreferences().node("lastEOMDir"));
+                .getProjectDetailObject(FSPath.class, getViewPreferences().node("lastEOMDir"));
 
         if (path.getPath() == null) {
             path.setPath(getLastDirectory().getPath());
@@ -107,7 +101,7 @@ public class CayenneModelerController extends CayenneController {
         frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
 
         frame.addWindowListener(new WindowAdapter() {
-
+            @Override
             public void windowClosing(WindowEvent e) {
                 PROJECT_STATE_UTIL.saveLastState(projectController);
                 getApplication().getActionManager().getAction(ExitAction.class).exit();
@@ -123,12 +117,11 @@ public class CayenneModelerController extends CayenneController {
                     PROJECT_STATE_UTIL.saveLastState(projectController);
                 }
             };
-
             Runtime.getRuntime().addShutdownHook(new Thread(runner, "Window Prefs Hook"));
         }
 
         new DropTarget(frame, new DropTargetAdapter() {
-
+            @Override
             public void drop(DropTargetDropEvent dtde) {
                 dtde.acceptDrop(dtde.getDropAction());
                 Transferable transferable = dtde.getTransferable();
@@ -154,16 +147,10 @@ public class CayenneModelerController extends CayenneController {
 
         File transferFile = fileList.get(0);
             if (transferFile.isFile()) {
-
                 FileFilter filter = FileFilters.getApplicationFilter();
-
                 if (filter.accept(transferFile)) {
-                    ActionEvent e = new ActionEvent(
-                            transferFile,
-                            ActionEvent.ACTION_PERFORMED,
-                            "OpenProject");
-                    Application.getInstance().getActionManager().getAction(
-                            OpenProjectAction.class).actionPerformed(e);
+                    ActionEvent e = new ActionEvent(transferFile, ActionEvent.ACTION_PERFORMED,
"OpenProject");
+                    Application.getInstance().getActionManager().getAction(OpenProjectAction.class).actionPerformed(e);
                     return true;
                 }
             }
@@ -180,12 +167,7 @@ public class CayenneModelerController extends CayenneController {
     public void projectModifiedAction() {
         String title = (projectController.getProject().getConfigurationResource() == null)
                 ? "[New]"
-                : projectController
-                        .getProject()
-                        .getConfigurationResource()
-                        .getURL()
-                        .getPath();
-
+                : projectController.getProject().getConfigurationResource().getURL().getPath();
         frame.setTitle("* - " + ModelerConstants.TITLE + " - " + title);
     }
 
@@ -195,11 +177,7 @@ public class CayenneModelerController extends CayenneController {
         updateStatus("Project saved...");
         frame.setTitle(ModelerConstants.TITLE
                 + " - "
-                + projectController
-                        .getProject()
-                        .getConfigurationResource()
-                        .getURL()
-                        .getPath());
+                + projectController.getProject().getConfigurationResource().getURL().getPath());
     }
 
     /**
@@ -242,8 +220,7 @@ public class CayenneModelerController extends CayenneController {
         if (project.getConfigurationResource() == null) {
             updateStatus("New project created...");
             frame.setTitle(ModelerConstants.TITLE + "- [New]");
-        }
-        else {
+        } else {
             updateStatus("Project opened...");
             frame.setTitle(ModelerConstants.TITLE
                     + " - "
@@ -252,8 +229,7 @@ public class CayenneModelerController extends CayenneController {
 
         // update preferences
         if (project.getConfigurationResource() != null) {
-            getLastDirectory().setDirectory(
-                    new File(project.getConfigurationResource().getURL().getPath()));
+            getLastDirectory().setDirectory(new File(project.getConfigurationResource().getURL().getPath()));
             frame.fireRecentFileListChanged();
         }
 
@@ -262,9 +238,7 @@ public class CayenneModelerController extends CayenneController {
         // for validation purposes combine load failures with post-load validation (not
         // sure if that'll cause duplicate messages?).
         List<ValidationFailure> allFailures = new ArrayList<>();
-        Collection<ValidationFailure> loadFailures = project
-                .getConfigurationTree()
-                .getLoadFailures();
+        Collection<ValidationFailure> loadFailures = project.getConfigurationTree().getLoadFailures();
 
         if (!loadFailures.isEmpty()) {
             // mark project as unsaved
@@ -273,10 +247,8 @@ public class CayenneModelerController extends CayenneController {
             allFailures.addAll(loadFailures);
         }
 
-        ProjectValidator projectValidator = getApplication().getInjector().getInstance(
-                ProjectValidator.class);
-        ValidationResult validationResult = projectValidator.validate(project
-                .getRootNode());
+        ProjectValidator projectValidator = getApplication().getInjector().getInstance(ProjectValidator.class);
+        ValidationResult validationResult = projectValidator.validate(project.getRootNode());
         allFailures.addAll(validationResult.getFailures());
 
         if (!allFailures.isEmpty()) {
@@ -289,8 +261,9 @@ public class CayenneModelerController extends CayenneController {
     }
 
 	/** Adds path to the list of last opened projects in preferences. */
-    public void addToLastProjListAction(String path) {
+    public void addToLastProjListAction(File file) {
 
+        String path = file.getAbsolutePath();
         Preferences frefLastProjFiles = ModelerPreferences.getLastProjFilesPref();
         List<String> arr = ModelerPreferences.getLastProjFiles();
         // Add proj path to the preferences
@@ -339,11 +312,11 @@ public class CayenneModelerController extends CayenneController {
             this.message = message;
         }
 
+        @Override
         public void run() {
             try {
                 sleep(seconds * 1000);
-            }
-            catch (InterruptedException e) {
+            } catch (InterruptedException e) {
                 // ignore exception
             }
 
@@ -353,11 +326,14 @@ public class CayenneModelerController extends CayenneController {
         }
     }
 
-    public void changePathInLastProjListAction(String oldPath, String newPath) {
+    public void changePathInLastProjListAction(File oldFile, File newFile) {
         Preferences frefLastProjFiles = ModelerPreferences.getLastProjFilesPref();
         List<String> arr = ModelerPreferences.getLastProjFiles();
         // Add proj path to the preferences
         // Prevent duplicate entries.
+        String oldPath = oldFile.getAbsolutePath();
+        String newPath = newFile.getAbsolutePath();
+
         if (arr.contains(oldPath)) {
             arr.remove(oldPath);
         }
@@ -373,12 +349,11 @@ public class CayenneModelerController extends CayenneController {
 
         try {
             frefLastProjFiles.clear();
-        }
-        catch (BackingStoreException e) {
+        } catch (BackingStoreException e) {
             // ignore exception
         }
-        int size = arr.size();
 
+        int size = arr.size();
         for (int i = 0; i < size; i++) {
             frefLastProjFiles.put(String.valueOf(i), arr.get(i));
         }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/15308e5d/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.java
index 0111ea9..1535d85 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ModelerPreferences.java
@@ -66,8 +66,7 @@ public class ModelerPreferences implements PreferenceChangeListener {
      */
     public static Preferences getPreferences() {
         if (cayennePrefs == null) {
-            Preference decoratedPref = new UpgradeCayennePreference(
-                    new CayennePreference());
+            Preference decoratedPref = new UpgradeCayennePreference(new CayennePreference());
             cayennePrefs = decoratedPref.getCayennePreference();
             cayennePrefs.addPreferenceChangeListener(new ModelerPreferences());
         }
@@ -88,17 +87,15 @@ public class ModelerPreferences implements PreferenceChangeListener {
         String[] keys = null;
         try {
             keys = filesPrefs.keys();
-        }
-        
-        catch (BackingStoreException e) {
+        } catch (BackingStoreException e) {
             logObj.warn("Error reading preferences file.", e);
         }
+
         if (keys != null) {
             int len = keys.length;
-            
             ArrayList<Integer> keysInteger = new ArrayList<>();
             for (int i = 0; i < len; i++) {
-                keysInteger.add(new Integer(i));
+                keysInteger.add(i);
             }
             Collections.sort(keysInteger);
             

http://git-wip-us.apache.org/repos/asf/cayenne/blob/15308e5d/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java
index 61d8927..3ce93bc 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java
@@ -47,7 +47,7 @@ public class OpenProjectAction extends ProjectAction {
 
     private static Log logObj = LogFactory.getLog(OpenProjectAction.class);
 
-    protected ProjectOpener fileChooser;
+    private ProjectOpener fileChooser;
 
     public static String getActionName() {
         return "Open Project";
@@ -58,16 +58,17 @@ public class OpenProjectAction extends ProjectAction {
         this.fileChooser = new ProjectOpener();
     }
 
+    @Override
     public String getIconName() {
         return "icon-open.gif";
     }
 
+    @Override
     public KeyStroke getAcceleratorKey() {
-        return KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit
-                .getDefaultToolkit()
-                .getMenuShortcutKeyMask());
+        return KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
     }
 
+    @Override
     public void performAction(ActionEvent e) {
 
         // Save and close (if needed) currently open project.
@@ -79,8 +80,7 @@ public class OpenProjectAction extends ProjectAction {
         if (e.getSource() instanceof FileMenuItem) {
             FileMenuItem menu = (FileMenuItem) e.getSource();
             f = menu.getFile();
-        }
-        else if (e.getSource() instanceof File) {
+        } else if (e.getSource() instanceof File) {
             f = (File) e.getSource();
         }
 
@@ -88,8 +88,7 @@ public class OpenProjectAction extends ProjectAction {
             try {
                 // Get the project file name (always cayenne.xml)
                 f = fileChooser.openProjectFile(Application.getFrame());
-            }
-            catch (Exception ex) {
+            } catch (Exception ex) {
                 logObj.warn("Error loading project file.", ex);
             }
         }
@@ -112,24 +111,19 @@ public class OpenProjectAction extends ProjectAction {
             if (!file.exists()) {
                 JOptionPane.showMessageDialog(
                         Application.getFrame(),
-                        "Can't open project - file \""
-                                + file.getPath()
-                                + "\" does not exist",
+                        "Can't open project - file \"" + file.getPath() + "\" does not exist",
                         "Can't Open Project",
                         JOptionPane.OK_OPTION);
                 return;
             }
 
-            CayenneModelerController controller = Application
-                    .getInstance()
-                    .getFrameController();
-            controller.addToLastProjListAction(file.getAbsolutePath());
+            CayenneModelerController controller = Application.getInstance().getFrameController();
+            controller.addToLastProjListAction(file);
 
-            URL url = file.toURL();
+            URL url = file.toURI().toURL();
             Resource rootSource = new URLResource(url);
 
-            ProjectUpgrader upgrader = getApplication().getInjector().getInstance(
-                    ProjectUpgrader.class);
+            ProjectUpgrader upgrader = getApplication().getInjector().getInstance(ProjectUpgrader.class);
             UpgradeHandler handler = upgrader.getUpgradeHandler(rootSource);
             UpgradeMetaData md = handler.getUpgradeMetaData();
 
@@ -141,8 +135,7 @@ public class OpenProjectAction extends ProjectAction {
                                 "Can't Open Project",
                                 JOptionPane.OK_OPTION);
                 closeProject(false);
-            }
-            else if (UpgradeType.INTERMEDIATE_UPGRADE_NEEDED == md.getUpgradeType()) {
+            } else if (UpgradeType.INTERMEDIATE_UPGRADE_NEEDED == md.getUpgradeType()) {
                 JOptionPane
                         .showMessageDialog(Application.getFrame(),
                         // TODO: andrus 05/02/2010 - this message shows intermediate
@@ -156,9 +149,8 @@ public class OpenProjectAction extends ProjectAction {
                                 "Can't Upgrade Project",
                                 JOptionPane.OK_OPTION);
                 closeProject(false);
-            }
-            else if (UpgradeType.UPGRADE_NEEDED == md.getUpgradeType()) {
-                if (processUpgrades(md)) {
+            } else if (UpgradeType.UPGRADE_NEEDED == md.getUpgradeType()) {
+                if (processUpgrades()) {
                     // perform upgrade
                     logObj.info("Will upgrade project " + url.getPath());
                     Resource upgraded = handler.performUpgrade();
@@ -168,55 +160,37 @@ public class OpenProjectAction extends ProjectAction {
                         getProjectController().getFileChangeTracker().pauseWatching();
                         getProjectController().getFileChangeTracker().reconfigure();
 
-                        // if project file name changed
-                        // need upgrade all
-                        if (!file.getAbsolutePath().equals(
-                                project.getConfigurationResource().getURL().getPath())) {
-                            controller.changePathInLastProjListAction(file
-                                    .getAbsolutePath(), project
-                                    .getConfigurationResource()
-                                    .getURL()
-                                    .getPath());
+                        // need to update project file name if it has changed
+                        if (!file.getAbsolutePath().equals(project.getConfigurationResource().getURL().getPath()))
{
+                            File projectFile = new File(project.getConfigurationResource().getURL().toURI());
+                            controller.changePathInLastProjListAction(file, projectFile);
                         }
-                    }
-                    else {
+                    } else {
                         closeProject(false);
                     }
                 }
-            }
-            else {
+            } else {
                 openProjectResourse(rootSource, controller);
             }
-        }
-        catch (Exception ex) {
+        } catch (Exception ex) {
             logObj.warn("Error loading project file.", ex);
             ErrorDebugDialog.guiWarning(ex, "Error loading project");
         }
     }
 
-    private Project openProjectResourse(
-            Resource resource,
-            CayenneModelerController controller) {
-        Project project = getApplication()
-                .getInjector()
-                .getInstance(ProjectLoader.class)
-                .loadProject(resource);
-
+    private Project openProjectResourse(Resource resource, CayenneModelerController controller)
{
+        Project project = getApplication().getInjector().getInstance(ProjectLoader.class).loadProject(resource);
         controller.projectOpenedAction(project);
-
         return project;
     }
 
-    protected boolean processUpgrades(UpgradeMetaData md) {
+    private boolean processUpgrades() {
         // need an upgrade
         int returnCode = JOptionPane.showConfirmDialog(
                 Application.getFrame(),
                 "Project needs an upgrade to a newer version. Upgrade?",
                 "Upgrade Needed",
                 JOptionPane.YES_NO_OPTION);
-        if (returnCode == JOptionPane.NO_OPTION) {
-            return false;
-        }
-        return true;
+        return returnCode != JOptionPane.NO_OPTION;
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/15308e5d/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAction.java
index 077997a..0d2ae3e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAction.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.modeler.action;
 
 import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
+import java.io.File;
 
 import javax.swing.KeyStroke;
 
@@ -42,12 +43,12 @@ public class SaveAction extends SaveAsAction {
         super(getActionName(), application);
     }
 
+    @Override
     public KeyStroke getAcceleratorKey() {
-        return KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit
-                .getDefaultToolkit()
-                .getMenuShortcutKeyMask());
+        return KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
     }
 
+    @Override
     public String getIconName() {
         return "icon-save.gif";
     }
@@ -55,46 +56,37 @@ public class SaveAction extends SaveAsAction {
     @Override
     protected boolean saveAll() throws Exception {
         Project p = getCurrentProject();
-
         if (p == null || p.getConfigurationResource() == null) {
             return super.saveAll();
         }
-        else {
 
-            String oldPath = p.getConfigurationResource().getURL().getPath();
+        String oldPath = p.getConfigurationResource().getURL().getPath();
+        File oldProjectFile = new File(p.getConfigurationResource().getURL().toURI());
 
-            getProjectController().getFileChangeTracker().pauseWatching();
+        getProjectController().getFileChangeTracker().pauseWatching();
+        ProjectSaver saver = getApplication().getInjector().getInstance(ProjectSaver.class);
+        saver.save(p);
 
-            ProjectSaver saver = getApplication().getInjector().getInstance(
-                    ProjectSaver.class);
-            saver.save(p);
+        RenamedPreferences.removeOldPreferences();
 
-            RenamedPreferences.removeOldPreferences();
+        // if change DataChanelDescriptor name - as result change name of xml file
+        // we will need change preferences path
+        String[] path = oldPath.split("/");
+        String[] newPath = p.getConfigurationResource().getURL().getPath().split("/");
 
-            // if change DataChanelDescriptor name - as result change name of xml file
-            // we will need change preferences path
-            String[] path = oldPath.split("/");
-            String[] newPath = p.getConfigurationResource().getURL().getPath().split("/");
-
-            if (!path[path.length - 1].equals(newPath[newPath.length - 1])) {
-                String newName = newPath[newPath.length - 1].replace(".xml", "");
-                RenamedPreferences.copyPreferences(
-                        newName,
-                        getProjectController().getPreferenceForProject());
-                RenamedPreferences.removeOldPreferences();
-            }
-
-            getApplication().getFrameController().changePathInLastProjListAction(
-                    oldPath,
-                    p.getConfigurationResource().getURL().getPath());
-            Application.getFrame().fireRecentFileListChanged();
-
-            /**
-             * Reset the watcher now
-             */
-            getProjectController().getFileChangeTracker().reconfigure();
+        if (!path[path.length - 1].equals(newPath[newPath.length - 1])) {
+            String newName = newPath[newPath.length - 1].replace(".xml", "");
+            RenamedPreferences.copyPreferences(newName, getProjectController().getPreferenceForProject());
+            RenamedPreferences.removeOldPreferences();
         }
 
+        File newProjectFile = new File(p.getConfigurationResource().getURL().toURI());
+        getApplication().getFrameController().changePathInLastProjListAction(oldProjectFile,
newProjectFile);
+        Application.getFrame().fireRecentFileListChanged();
+
+        // Reset the watcher now
+        getProjectController().getFileChangeTracker().reconfigure();
+
         return true;
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/15308e5d/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java
index c01c5a3..e7968a2 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/SaveAsAction.java
@@ -23,7 +23,6 @@ import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import java.io.File;
-import java.net.URL;
 import java.util.prefs.Preferences;
 
 import javax.swing.JOptionPane;
@@ -32,7 +31,6 @@ import javax.swing.KeyStroke;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.configuration.ConfigurationNode;
 import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.dialog.validator.ValidationDisplayHandler;
 import org.apache.cayenne.modeler.dialog.validator.ValidatorDialog;
 import org.apache.cayenne.modeler.event.ProjectOnSaveEvent;
 import org.apache.cayenne.modeler.util.CayenneAction;
@@ -49,7 +47,7 @@ import org.apache.cayenne.validation.ValidationResult;
  */
 public class SaveAsAction extends CayenneAction {
 
-    protected ProjectOpener fileChooser;
+    private ProjectOpener fileChooser;
 
     public static String getActionName() {
         return "Save As...";
@@ -64,6 +62,7 @@ public class SaveAsAction extends CayenneAction {
         this.fileChooser = new ProjectOpener();
     }
 
+    @Override
     public KeyStroke getAcceleratorKey() {
         return KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
                 | ActionEvent.SHIFT_MASK);
@@ -94,9 +93,7 @@ public class SaveAsAction extends CayenneAction {
 
         getProjectController().getFileChangeTracker().pauseWatching();
 
-        URL url = projectDir.toURL();
-
-        URLResource res = new URLResource(url);
+        URLResource res = new URLResource(projectDir.toURI().toURL());
 
         ProjectSaver saver = getApplication().getInjector().getInstance(ProjectSaver.class);
 
@@ -138,13 +135,11 @@ public class SaveAsAction extends CayenneAction {
 
         RenamedPreferences.removeNewPreferences();
 
-        getApplication().getFrameController().addToLastProjListAction(p.getConfigurationResource().getURL().getPath());
-
+        File file = new File(p.getConfigurationResource().getURL().toURI());
+        getApplication().getFrameController().addToLastProjListAction(file);
         Application.getFrame().fireRecentFileListChanged();
 
-        /**
-         * Reset the watcher now
-         */
+        // Reset the watcher now
         getProjectController().getFileChangeTracker().reconfigure();
 
         return true;
@@ -154,11 +149,12 @@ public class SaveAsAction extends CayenneAction {
      * This method is synchronized to prevent problems on double-clicking
      * "save".
      */
+    @Override
     public void performAction(ActionEvent e) {
-        performAction(ValidationDisplayHandler.WARNING);
+        performAction();
     }
 
-    public void performAction(int warningLevel) {
+    public void performAction() {
 
         ProjectValidator projectValidator = getApplication().getInjector().getInstance(ProjectValidator.class);
         ValidationResult validationResult = projectValidator.validate(getCurrentProject().getRootNode());
@@ -185,6 +181,7 @@ public class SaveAsAction extends CayenneAction {
      * Returns <code>true</code> if path contains a Project object and the
      * project is modified.
      */
+    @Override
     public boolean enableForPath(ConfigurationNode object) {
         if (object == null) {
             return false;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/15308e5d/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/pref/Preference.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/pref/Preference.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/pref/Preference.java
index d346f89..68e48da 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/pref/Preference.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/pref/Preference.java
@@ -25,17 +25,17 @@ public interface Preference {
     /**
      * Key for preferences.
      */
-    public static final String CAYENNE_PREFERENCES_PATH = "org/apache/cayenne";
+    String CAYENNE_PREFERENCES_PATH = "org/apache/cayenne";
 
     /**
      * Preferences node name for the editor
      */
-    public static final String EDITOR = "editor";
+    String EDITOR = "editor";
 
     /**
      * Preferences node name for list of the last 12 opened project files.
      */
-    public static final String LAST_PROJ_FILES = "lastSeveralProjectFiles";
+    String LAST_PROJ_FILES = "lastSeveralProjectFiles";
 
     Preferences getRootPreference();
 


Mime
View raw message