Author: linus Date: 2011-12-30 23:05:14-0800 New Revision: 19858 Modified: trunk/src/argouml-app/src/org/argouml/application/Main.java
Log: Fix for issue 6169, now allowing file paths with # in them. Simplified the handling of files as arguments (no longer converting from File to URL to File. Modified: trunk/src/argouml-app/src/org/argouml/application/Main.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/application/Main.java?view=diff&pathrev=19858&r1=19857&r2=19858 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/application/Main.java (original) +++ trunk/src/argouml-app/src/org/argouml/application/Main.java 2011-12-30 23:05:14-0800 @@ -48,7 +48,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; -import java.net.URL; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Enumeration; @@ -104,7 +103,6 @@ import org.argouml.util.JavaRuntimeUtility; import org.argouml.util.logging.AwtExceptionHandler; import org.argouml.util.logging.SimpleTimer; -import org.tigris.gef.util.Util; /** * This is the main class for two of the types @@ -205,14 +203,14 @@ projectName = getMostRecentProject(); } - URL urlToOpen = null; + File fileToOpen = null; if (projectName != null) { projectName = PersistenceManager.getInstance().fixExtension(projectName); - urlToOpen = projectUrl(projectName, urlToOpen); + fileToOpen = new File(projectName); } - openProject(st, splash, pb, urlToOpen); + openProject(st, splash, pb, fileToOpen); st.mark("perspectives"); if (splash != null) { @@ -387,10 +385,8 @@ String projectToBePrinted = PersistenceManager.getInstance().fixExtension( args[++i]); - URL urlToBePrinted = projectUrl(projectToBePrinted, - null); ProjectBrowser.getInstance().loadProject( - new File(urlToBePrinted.getFile()), true, null); + new File(projectToBePrinted), true, null); // now, let's print it PrintManager.getInstance().print(); // nothing else to do (?) @@ -479,7 +475,7 @@ private static void openProject(SimpleTimer st, SplashScreen splash, - ProjectBrowser pb, URL urlToOpen) { + ProjectBrowser pb, File fileToOpen) { if (splash != null) { splash.updateProgress(40); } @@ -489,7 +485,7 @@ Designer.clearCritiquing(); Project project = null; - if (urlToOpen != null) { + if (fileToOpen != null) { if (splash != null) { Object[] msgArgs = {projectName}; splash.showStatus( @@ -497,14 +493,9 @@ "statusmsg.bar.readingproject", msgArgs)); } - String filename = urlToOpen.getFile(); - File file = new File(filename); - System.err.println("The url of the file to open is " - + urlToOpen); - System.err.println("The filename is " + filename); - System.err.println("The file is " + file); - System.err.println("File.exists = " + file.exists()); - project = pb.loadProject2(file, true, null); + System.err.println("The file is " + fileToOpen); + System.err.println("File.exists = " + fileToOpen.exists()); + project = pb.loadProject2(fileToOpen, true, null); } else { if (splash != null) { splash.showStatus( @@ -558,31 +549,6 @@ } } - /** - * Calculates the {@link URL} for the given project name. - * If the file does not exist or cannot be converted the default - * {@link URL} is returned. - * - * @param theProjectName is the file name of the project - * @param urlToOpen is the default {@link URL} - * @return the new URL. - */ - private static URL projectUrl(final String theProjectName, URL urlToOpen) { - File projectFile = new File(theProjectName); - if (!projectFile.exists()) { - System.err.println("Project file '" + projectFile - + "' does not exist."); - /* this will cause an empty project to be created */ - } else { - try { - urlToOpen = Util.fileToURL(projectFile); - } catch (Exception e) { - LOG.error("Exception opening project in main()", e); - } - } - - return urlToOpen; - } /** * Prints the usage message. ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2903151 To unsubscribe from this discussion, e-mail: [[email protected]].
