cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r405098 - in /incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action: NewProjectAction.java OpenProjectAction.java ProjectAction.java
Date Mon, 08 May 2006 17:32:31 GMT
Author: aadamchik
Date: Mon May  8 10:32:29 2006
New Revision: 405098

URL: http://svn.apache.org/viewcvs?rev=405098&view=rev
Log:
a minor bug that has been in CayenneModeler since the old days - current project should not
be closed until the new project selection is confirmed

Modified:
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/NewProjectAction.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/ProjectAction.java

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/NewProjectAction.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/NewProjectAction.java?rev=405098&r1=405097&r2=405098&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/NewProjectAction.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/NewProjectAction.java
Mon May  8 10:32:29 2006
@@ -96,7 +96,7 @@
                 .getInstance()
                 .getFrameController();
         // Save and close (if needed) currently open project.
-        if (getCurrentProject() != null && !closeProject()) {
+        if (getCurrentProject() != null && !closeProject(true)) {
             return;
         }
 

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java?rev=405098&r1=405097&r2=405098&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/OpenProjectAction.java
Mon May  8 10:32:29 2006
@@ -98,14 +98,18 @@
     }
 
     public KeyStroke getAcceleratorKey() {
-        return KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+        return KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit
+                .getDefaultToolkit()
+                .getMenuShortcutKeyMask());
     }
 
     public void performAction(ActionEvent e) {
+
         // Save and close (if needed) currently open project.
-        if (getProjectController() != null && !closeProject()) {
+        if (getProjectController() != null && !checkSaveOnClose()) {
             return;
         }
+
         File f = null;
         if (e.getSource() instanceof RecentFileMenuItem) {
             RecentFileMenuItem menu = (RecentFileMenuItem) e.getSource();
@@ -113,26 +117,22 @@
         }
 
         if (f == null) {
-            openProject();
-        }
-        else {
-            openProject(f);
+            try {
+                // Get the project file name (always cayenne.xml)
+                f = fileChooser.openProjectFile(Application.getFrame());
+            }
+            catch (Exception ex) {
+                logObj.warn("Error loading project file.", ex);
+            }
         }
-    }
 
-    /**
-     * Opens cayenne.xml file using file chooser dialog.
-     */
-    public void openProject() {
-        try {
-            // Get the project file name (always cayenne.xml)
-            File file = fileChooser.openProjectFile(Application.getFrame());
-            if (file != null) {
-                openProject(file);
+        if (f != null) {
+            // by now if the project is unsaved, this has been a user choice...
+            if (getProjectController() != null && !closeProject(false)) {
+                return;
             }
-        }
-        catch (Exception e) {
-            logObj.warn("Error loading project file.", e);
+
+            openProject(f);
         }
     }
 
@@ -149,7 +149,7 @@
 
             // if upgrade was canceled
             if (project.isUpgradeNeeded() && !processUpgrades(project)) {
-                closeProject();
+                closeProject(false);
             }
             else {
                 getApplication().getFrameController().projectOpenedAction(project);

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/ProjectAction.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/ProjectAction.java?rev=405098&r1=405097&r2=405098&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/ProjectAction.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/action/ProjectAction.java
Mon May  8 10:32:29 2006
@@ -93,7 +93,7 @@
      * Closes current project.
      */
     public void performAction(ActionEvent e) {
-        closeProject();
+        closeProject(true);
     }
 
     /**
@@ -109,13 +109,13 @@
     }
 
     /** Returns true if successfully closed project, false otherwise. */
-    public boolean closeProject() {
+    public boolean closeProject(boolean checkUnsaved) {
         // check if there is a project...
         if (getProjectController() == null || getProjectController().getProject() == null)
{
             return true;
         }
 
-        if (!checkSaveOnClose()) {
+        if (checkUnsaved && !checkSaveOnClose()) {
             return false;
         }
 



Mime
View raw message