You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by de...@apache.org on 2006/01/09 14:15:07 UTC

svn commit: r367289 - /xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java

Author: deweese
Date: Mon Jan  9 05:14:56 2006
New Revision: 367289

URL: http://svn.apache.org/viewcvs?rev=367289&view=rev
Log:
Fixed duplicated fragment identifier bug

Modified:
    xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java

Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java?rev=367289&r1=367288&r2=367289&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java Mon Jan  9 05:14:56 2006
@@ -789,52 +789,51 @@
                     t = st.substring(i + 1);
                     st = st.substring(0, i);
                 }
-                if (!st.equals("")) {
-                    try{
-                        File f = new File(st);
-                        if (f.exists()) {
-                            if (f.isDirectory()) {
-                                st = null;
-                            } else {
-                                try {
-                                    st = f.getCanonicalPath();
-                                    if (st.startsWith("/")) {
-                                        st = "file:" + st;
-                                    } else {
-                                        st = "file:/" + st;
-                                    }
-                                } catch (IOException ex) {
+
+                if (st.equals("")) 
+                    return;
+
+                try{
+                    File f = new File(st);
+                    if (f.exists()) {
+                        if (f.isDirectory()) {
+                            return;
+                        } else {
+                            try {
+                                st = f.getCanonicalPath();
+                                if (st.startsWith("/")) {
+                                    st = "file:" + st;
+                                } else {
+                                    st = "file:/" + st;
                                 }
+                            } catch (IOException ex) {
                             }
                         }
-                    }catch(SecurityException se){
-                        // Could not patch the file URI for security
-                        // reasons (e.g., when run as an unsigned
-                        // JavaWebStart jar): file access is not
-                        // allowed. Loading will fail, but there is
-                        // nothing more to do at this point.
                     }
+                }catch(SecurityException se){
+                    // Could not patch the file URI for security
+                    // reasons (e.g., when run as an unsigned
+                    // JavaWebStart jar): file access is not
+                    // allowed. Loading will fail, but there is
+                    // nothing more to do at this point.
+                }
 
-                    if (st != null) {
-                        String fi = svgCanvas.getFragmentIdentifier();
-                        if (svgDocument != null) {
-                            ParsedURL docPURL 
-                                = new ParsedURL(svgDocument.getURL());
-                            ParsedURL purl = new ParsedURL(docPURL, st);
-                            fi = (fi == null) ? "" : fi;
-                            if (docPURL.equals(purl) && t.equals(fi)) {
-                                return;
-                            }
-                        }
-                        if (t.length() != 0) {
-                            st = st.substring(0, st.length()-(fi.length()+1));
-                            st += "#" + t;
-                        }
-                        locationBar.setText(st);
-                        locationBar.addToHistory(st);
-                        showSVGDocument(st);
+                String fi = svgCanvas.getFragmentIdentifier();
+                if (svgDocument != null) {
+                    ParsedURL docPURL 
+                        = new ParsedURL(svgDocument.getURL());
+                    ParsedURL purl = new ParsedURL(docPURL, st);
+                    fi = (fi == null) ? "" : fi;
+                    if (docPURL.equals(purl) && t.equals(fi)) {
+                        return;
                     }
                 }
+                if (t.length() != 0) {
+                    st += "#" + t;
+                }
+                locationBar.setText(st);
+                locationBar.addToHistory(st);
+                showSVGDocument(st);
             }
         });
 
@@ -2044,11 +2043,6 @@
         stopAction.update(false);
         svgCanvas.setCursor(DEFAULT_CURSOR);
         String s = svgDocumentURL;
-        String t = svgCanvas.getFragmentIdentifier();
-        if (t != null) {
-            s += "#" + t;
-        }
-
         locationBar.setText(s);
         if (title == null) {
             title = getTitle();