We check the annotation pattern for correctness (we try to render it in memory). BLD200410111800
authormentlicher@netbeans.org
Mon, 11 Oct 2004 15:57:53 +0000
changeset 5321485339ea46cb
parent 5320 66493b763e5c
child 5322 0d089ed95734
We check the annotation pattern for correctness (we try to render it in memory).
Also, special HTML characters are replaced with appropriate entity reference.
This is a fix of issue #48603.
vcscore/src/org/netbeans/modules/vcscore/Bundle.properties
vcscore/src/org/netbeans/modules/vcscore/VcsFileSystem.java
     1.1 --- a/vcscore/src/org/netbeans/modules/vcscore/Bundle.properties	Mon Oct 11 14:01:20 2004 +0000
     1.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/Bundle.properties	Mon Oct 11 15:57:53 2004 +0000
     1.3 @@ -74,7 +74,7 @@
     1.4  
     1.5  LBL_VCS_Output=Versioning
     1.6  
     1.7 -EXC_InvalidRegularExpressionForIgnoredFiles=Please enter a valid regular expression. {0}
     1.8 +EXC_InvalidAnnotationPatern=Not valid HTML annotation pattern: {0}
     1.9  
    1.10  #--------------------------------------------------------------------
    1.11  # VcsVersioningSystem
     2.1 --- a/vcscore/src/org/netbeans/modules/vcscore/VcsFileSystem.java	Mon Oct 11 14:01:20 2004 +0000
     2.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/VcsFileSystem.java	Mon Oct 11 15:57:53 2004 +0000
     2.3 @@ -2129,11 +2129,79 @@
     2.4          return annotationPattern;
     2.5      }
     2.6  
     2.7 -    public void setAnnotationPattern(String annotationPattern) {
     2.8 +    public void setAnnotationPattern(final String annotationPattern) throws IllegalArgumentException {
     2.9 +        if (!isValidAnnotationPattern(annotationPattern)) {
    2.10 +            throw (IllegalArgumentException) ErrorManager.getDefault().annotate(
    2.11 +                new IllegalArgumentException("Not valid HTML annotation pattern '"+annotationPattern+"' !"),
    2.12 +                NbBundle.getMessage(VcsFileSystem.class, "EXC_InvalidAnnotationPatern", annotationPattern));
    2.13 +        }
    2.14          String old = this.annotationPattern;
    2.15          this.annotationPattern = annotationPattern;
    2.16          firePropertyChange(PROP_ANNOTATION_PATTERN, old, this.annotationPattern);
    2.17      }
    2.18 +    
    2.19 +    private static boolean isValidAnnotationPattern(String pattern) {
    2.20 +        final String[] testStatus = { "" };
    2.21 +        FileStatusProvider testProvider = new FileStatusProvider() {
    2.22 +            public Set getPossibleFileStatusInfos() {
    2.23 +                return java.util.Collections.EMPTY_SET;
    2.24 +            }
    2.25 +            public String getNotInSynchStatus() { return "NSynch"; } // NOI18N
    2.26 +            public String getFileStatus(String fullName) {
    2.27 +                return testStatus[0];
    2.28 +            }
    2.29 +            public FileStatusInfo getFileStatusInfo(String fullName) { return null; }
    2.30 +            public String getFileLocker(String fullName) {
    2.31 +                return testStatus[0];
    2.32 +            }
    2.33 +            public String getFileRevision(String fullName) {
    2.34 +                return testStatus[0];
    2.35 +            }
    2.36 +            public String getFileSticky(String fullName) {
    2.37 +                return testStatus[0];
    2.38 +            }
    2.39 +            public String getFileAttribute(String fullName) {
    2.40 +                return testStatus[0];
    2.41 +            }
    2.42 +            public String getFileSize(String fullName) {
    2.43 +                return testStatus[0];
    2.44 +            }
    2.45 +            public String getFileDate(String fullName) {
    2.46 +                return testStatus[0];
    2.47 +            }
    2.48 +            public String getFileTime(String fullName) {
    2.49 +                return testStatus[0];
    2.50 +            }
    2.51 +            public void setFileStatus(String path, String status) {}
    2.52 +            public void setFileModified(String path) {}
    2.53 +            public String getLocalFileStatus() { return "Local"; } // NOI18N
    2.54 +            public void refreshDir(String path) {}
    2.55 +            public void refreshDirRecursive(String path) {}
    2.56 +        };
    2.57 +        String annot = RefreshCommandSupport.getHtmlStatusAnnotation("name", "full/name", pattern, testProvider, new Hashtable()); // NOI18N
    2.58 +        java.awt.image.BufferedImage bimage =
    2.59 +            new java.awt.image.BufferedImage(100, 100, java.awt.image.BufferedImage.TYPE_3BYTE_BGR);
    2.60 +        try {
    2.61 +            org.openide.awt.HtmlRenderer.renderHTML(annot, bimage.getGraphics(), 0, 0,
    2.62 +                0, 0, bimage.getGraphics().getFont(), bimage.getGraphics().getColor(), 0, true);
    2.63 +        } catch (Exception ex) {
    2.64 +            //ex.printStackTrace();
    2.65 +            //System.out.println("INVALID HTML");
    2.66 +            return false;
    2.67 +        }
    2.68 +        testStatus[0] = "test"; // NOI18N
    2.69 +        annot = RefreshCommandSupport.getHtmlStatusAnnotation("name", "full/name", pattern, testProvider, new Hashtable()); // NOI18N
    2.70 +        try {
    2.71 +            org.openide.awt.HtmlRenderer.renderHTML(annot, bimage.getGraphics(), 0, 0,
    2.72 +                0, 0, bimage.getGraphics().getFont(), bimage.getGraphics().getColor(), 0, true);
    2.73 +        } catch (Exception ex) {
    2.74 +            //ex.printStackTrace();
    2.75 +            //System.out.println("INVALID HTML");
    2.76 +            return false;
    2.77 +        }
    2.78 +        //System.out.println("VALID HTML");
    2.79 +        return true;
    2.80 +    }
    2.81  
    2.82      public int[] getMultiFileAnnotationTypes() {
    2.83          return multiFilesAnnotationTypes;