You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2019/09/18 08:12:25 UTC

[cayenne] branch master updated: CAY-2616 Modeler: Wrong handling of path with spaces

This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new 73a101f  CAY-2616 Modeler: Wrong handling of path with spaces
73a101f is described below

commit 73a101fbf89fccd45c80c5480d039d10dcd1587d
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Wed Sep 18 10:54:59 2019 +0300

    CAY-2616 Modeler: Wrong handling of path with spaces
---
 .../cayenne/modeler/CayenneModelerController.java  | 26 +++++++++++++++-------
 1 file changed, 18 insertions(+), 8 deletions(-)

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 094a77e..5d5f304 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
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.modeler;
 
+import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.modeler.action.ExitAction;
 import org.apache.cayenne.modeler.action.OpenProjectAction;
 import org.apache.cayenne.modeler.dialog.validator.ValidatorDialog;
@@ -165,17 +166,14 @@ public class CayenneModelerController extends CayenneController {
     }
 
     public void projectModifiedAction() {
-        String title = (projectController.getProject().getConfigurationResource() == null)
-                ? "[New Project]"
-                : projectController.getProject().getConfigurationResource().getURL().getPath();
-        frame.setTitle("* - " + title);
+        frame.setTitle("* - " + getProjectLocationString());
     }
 
     public void projectSavedAction() {
         projectController.setDirty(false);
         projectController.updateProjectControllerPreferences();
         updateStatus("Project saved...");
-        frame.setTitle(projectController.getProject().getConfigurationResource().getURL().getPath());
+        frame.setTitle(getProjectLocationString());
     }
 
     /**
@@ -217,19 +215,19 @@ public class CayenneModelerController extends CayenneController {
         // do status update AFTER the project is actually opened...
         if (project.getConfigurationResource() == null) {
             updateStatus("New project created...");
-            frame.setTitle("[New Project]");
         } else {
             updateStatus("Project opened...");
             try {
-                File file = new File(project.getConfigurationResource().getURL().toURI());
-                frame.setTitle(file.toString());
                 // update preferences
+                File file = new File(project.getConfigurationResource().getURL().toURI());
                 getLastDirectory().setDirectory(file);
                 frame.fireRecentFileListChanged();
             } catch (URISyntaxException ignore) {
             }
         }
 
+        frame.setTitle(getProjectLocationString());
+
         PROJECT_STATE_UTIL.fireLastState(projectController);
 
         // for validation purposes combine load failures with post-load validation (not
@@ -314,4 +312,16 @@ public class CayenneModelerController extends CayenneController {
         return dbImportController;
     }
 
+    protected String getProjectLocationString() {
+        if(projectController.getProject().getConfigurationResource() == null) {
+            return "[New Project]";
+        }
+        try {
+            File projectFile = new File(projectController.getProject().getConfigurationResource().getURL().toURI());
+            return projectFile.toString();
+        } catch (URISyntaxException e) {
+            throw new CayenneRuntimeException("Invalid project source URL", e);
+        }
+    }
+
 }