[hg] main-silver: #223431 - Make uses of StringEscapeHtml

  • From: Milutin Kristofic < >
  • To: ,
  • Subject: [hg] main-silver: #223431 - Make uses of StringEscapeHtml
  • Date: Thu, 07 Feb 2013 13:14:05 -0800

changeset 7ea5256d1014 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/7ea5256d1014
description:
        #223431 - Make uses of StringEscapeHtml

diffstat:

 
editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationView.java
 |  37 ++++++---
 1 files changed, 24 insertions(+), 13 deletions(-)

diffs (167 lines):

diff --git 
a/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationView.java
 
b/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationView.java
--- 
a/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationView.java
+++ 
b/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationView.java
@@ -84,7 +84,7 @@
 import org.netbeans.editor.BaseDocument;
 import org.netbeans.editor.BaseTextUI;
 import org.netbeans.editor.Utilities;
-import org.netbeans.lib.editor.util.swing.DocumentUtilities;
+import org.netbeans.lib.editor.util.StringEscapeUtils;
 import org.netbeans.modules.editor.errorstripe.caret.CaretMark;
 import org.netbeans.modules.editor.errorstripe.privatespi.Mark;
 import org.netbeans.spi.editor.errorstripe.UpToDateStatus;
@@ -128,7 +128,7 @@
     private final Insets scrollBar;
     private final AnnotationViewData data;
     
-    private static Icon busyIcon;
+    private static final Icon busyIcon;
     
     static {
         busyIcon = new 
ImageIcon(AnnotationView.class.getResource("resources/hodiny.gif"));
@@ -322,6 +322,7 @@
     }
 
     
+    @Override
     public void paintComponent(Graphics g) {
         if (isWriteLocked(doc)) {
             // Try a little bit later ;-)
@@ -465,12 +466,14 @@
             return result;
         }
         
+        @Override
         public void run() {
             final boolean clearMarksCache = readAndDestroyClearMarksCache();
             final boolean clearModelToViewCache= 
readAndDestroyClearModelToViewCache();
             
             //Fix for #54193:
             SwingUtilities.invokeLater(new Runnable() {
+                @Override
                 public void run() {
                     synchronized (AnnotationView.this) {
                         if (clearMarksCache) {
@@ -734,42 +737,52 @@
         return a;
     }
     
+    @Override
     public Dimension getMaximumSize() {
         return new Dimension(THICKNESS, Integer.MAX_VALUE);
     }
 
+    @Override
     public Dimension getMinimumSize() {
         return new Dimension(THICKNESS, Integer.MIN_VALUE);
     }
 
+    @Override
     public Dimension getPreferredSize() {
         return new Dimension(THICKNESS, Integer.MIN_VALUE);
     }
 
+    @Override
     public void mouseReleased(MouseEvent e) {
         //NOTHING:
         resetCursor();
     }
 
+    @Override
     public void mousePressed(MouseEvent e) {
         resetCursor();
     }
 
+    @Override
     public void mouseMoved(MouseEvent e) {
         checkCursor(e);
     }
 
+    @Override
     public void mouseExited(MouseEvent e) {
         resetCursor();
     }
 
+    @Override
     public void mouseEntered(MouseEvent e) {
         checkCursor(e);
     }
 
+    @Override
     public void mouseDragged(MouseEvent e) {
     }
 
+    @Override
     public void mouseClicked(MouseEvent e) {
         resetCursor();
         
@@ -795,6 +808,7 @@
         setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
     }
 
+    @Override
     public String getToolTipText(MouseEvent event) {
         if (ERR.isLoggable(ErrorManager.INFORMATIONAL)) {
             ERR.log(ErrorManager.INFORMATIONAL, "getToolTipText: event=" + 
event); // NOI18N
@@ -832,7 +846,7 @@
                     if (description.startsWith(HTML_PREFIX_LOWERCASE) || 
description.startsWith(HTML_PREFIX_UPPERCASE)) {
                         return description;
                     } else {
-                        return "<html><body>" + translate(description); // 
NOI18N
+                        return "<html><body>" + 
StringEscapeUtils.escapeHtml(description); // NOI18N
                     }
                 }
             }
@@ -843,35 +857,30 @@
     
     private static final String HTML_PREFIX_LOWERCASE = "<html"; //NOI18N
     private static final String HTML_PREFIX_UPPERCASE = "<HTML"; //NOI18N
-    private static String[] c = new String[] {"&", "<", ">", "\n", "\""}; // 
NOI18N
-    private static String[] tags = new String[] {"&amp;", "&lt;", "&gt;", 
"<br>", "&quot;"}; // NOI18N
     
-    private String translate(String input) {
-        for (int cntr = 0; cntr < c.length; cntr++) {
-            input = input.replaceAll(c[cntr], tags[cntr]);
-        }
-        
-        return input;
-    }
-
+    @Override
     public void foldHierarchyChanged(FoldHierarchyEvent evt) {
         //fix for #63402: clear the modelToViewCache after folds changed:
         //#64498: do not take monitor on this here:
         fullRepaint(false, true);
     }
 
+    @Override
     public void removeUpdate(DocumentEvent e) {
         documentChange();
     }
     
+    @Override
     public void insertUpdate(DocumentEvent e) {
         documentChange();
     }
     
+    @Override
     public void changedUpdate(DocumentEvent e) {
         //ignored...
     }
 
+    @Override
     public void propertyChange(PropertyChangeEvent evt) {
         if (evt.getSource() == this.pane && 
"document".equals(evt.getPropertyName())) {
             updateForNewDocument();
@@ -881,9 +890,11 @@
         fullRepaint();
     }
     
+    @Override
     public AccessibleContext getAccessibleContext() {
         if (accessibleContext == null) {
             accessibleContext = new AccessibleJComponent() {
+                @Override
                 public AccessibleRole getAccessibleRole() {
                     return AccessibleRole.PANEL;
                 }

[hg] main-silver: #223431 - Make uses of StringEscapeHtml

Milutin Kristofic 02/07/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close