[hg] main-silver: editor.search warnings Resolved

  • From: Milutin Kristofic < >
  • To:
  • Subject: [hg] main-silver: editor.search warnings Resolved
  • Date: Fri, 26 Apr 2013 11:11:15 -0700

changeset d3251fa0982a in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/d3251fa0982a
description:
        editor.search warnings Resolved

diffstat:

 editor.search/src/org/netbeans/modules/editor/search/DocumentFinder.java     
                 |  66 ++++++---
 editor.search/src/org/netbeans/modules/editor/search/EditorFindSupport.java  
                 |  27 +--
 editor.search/src/org/netbeans/modules/editor/search/ReplaceBar.java         
                 |  10 +-
 editor.search/src/org/netbeans/modules/editor/search/SearchBar.java          
                 |  12 +-
 editor.search/src/org/netbeans/modules/editor/search/SearchButton.java       
                 |   2 -
 editor.search/src/org/netbeans/modules/editor/search/SearchComboBox.java     
                 |   4 +-
 
editor.search/src/org/netbeans/modules/editor/search/SearchComboBoxEditor.java
                |   3 +-
 editor.search/src/org/netbeans/modules/editor/search/SearchNbEditorKit.java  
                 |   4 +-
 
editor.search/src/org/netbeans/modules/editor/search/SearchPropertiesSupport.java
             |   6 +-
 
editor.search/src/org/netbeans/modules/editor/search/TextSearchHighlighting.java
              |   2 +-
 
editor.search/src/org/netbeans/modules/editor/search/actions/FindSelectionAction.java
         |   7 +-
 
editor.search/src/org/netbeans/modules/editor/search/actions/ToggleHighlightSearchAction.java
 |   7 +-
 12 files changed, 88 insertions(+), 62 deletions(-)

diffs (731 lines):

diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/DocumentFinder.java 
b/editor.search/src/org/netbeans/modules/editor/search/DocumentFinder.java
--- a/editor.search/src/org/netbeans/modules/editor/search/DocumentFinder.java
+++ b/editor.search/src/org/netbeans/modules/editor/search/DocumentFinder.java
@@ -76,7 +76,7 @@
     }
 
 
-    private static DocFinder getFinder(Document doc, Map searchProps, 
boolean oppositeDir, boolean blocksFinder){
+    private static DocFinder getFinder(Document doc, Map<String, Object>  
searchProps, boolean oppositeDir, boolean blocksFinder){
         String text = (String)searchProps.get(EditorFindSupport.FIND_WHAT);
         if (text == null || text.length() == 0) {
             if (blocksFinder) {
@@ -187,7 +187,7 @@
     }
     
 
-    private static FindReplaceResult findReplaceImpl(String replaceText, 
Document doc, int startOffset, int endOffset, Map props,
+    private static FindReplaceResult findReplaceImpl(String replaceText, 
Document doc, int startOffset, int endOffset, Map<String, Object>  props,
                              boolean oppositeDir) throws 
BadLocationException{
         int ret[] = new int[2];
         if (endOffset == -1){
@@ -293,7 +293,7 @@
      *   that nothing was found.
      * @param props find properties
      */
-    public static int[] find(Document doc, int startOffset, int endOffset, 
Map props,
+    public static int[] find(Document doc, int startOffset, int endOffset, 
Map<String, Object>  props,
                              boolean oppositeDir) throws 
BadLocationException{
         FindReplaceResult result = findReplaceImpl(null, doc, startOffset, 
endOffset, props, oppositeDir);
         if (result == null){
@@ -304,7 +304,7 @@
     }
 
     public static int[] findBlocks(Document doc, int startOffset, int 
endOffset, 
-                    Map props, int blocks[]) throws BadLocationException{
+                    Map<String, Object> props, int blocks[]) throws 
BadLocationException{
         BlocksFinder finder =(BlocksFinder) getFinder(doc, props, false, 
true);
         if (finder == null){
             return blocks;
@@ -327,7 +327,7 @@
      *  regexp backreferences.
      *  @return FindReplaceResult, that contains positions of found string 
and substituted replace expression
      */
-    public static FindReplaceResult findReplaceResult(String replaceString, 
Document doc, int startOffset, int endOffset, Map props,
+    public static FindReplaceResult findReplaceResult(String replaceString, 
Document doc, int startOffset, int endOffset, Map<String, Object> props,
                              boolean oppositeDir) throws 
BadLocationException{
         FindReplaceResult findReplaceImpl = findReplaceImpl(replaceString, 
doc, startOffset, endOffset, props, oppositeDir);
         return preserveCaseImpl(findReplaceImpl, replaceString, doc, props);
@@ -336,21 +336,21 @@
     private static void notifyRegexpException(Exception ex) throws 
MissingResourceException {
         String additionalHint = ""; //NOI18N
         if (ex instanceof IllegalArgumentException) {
-            additionalHint = "\n" + 
NbBundle.getBundle(DocumentFinder.class).getString("pattern-error-missing-escape-hint");
 //NOI18N
+            additionalHint = "\n" + 
NbBundle.getMessage(DocumentFinder.class, 
"pattern-error-missing-escape-hint"); //NOI18N
         }
         NotifyDescriptor msg = new 
NotifyDescriptor.Message(NbBundle.getMessage(DocumentFinder.class, 
"pattern-error-dialog-content") + "\n" +
                 ex.getLocalizedMessage() + additionalHint, 
NotifyDescriptor.ERROR_MESSAGE);
         
-        
msg.setTitle(NbBundle.getBundle(DocumentFinder.class).getString("pattern-error-dialog-title"));
 //NOI18N
+        msg.setTitle(NbBundle.getMessage(DocumentFinder.class, 
"pattern-error-dialog-title")); //NOI18N
         DialogDisplayer.getDefault().notify(msg);
     }
     
-     private static boolean getBoolFromEditorFindSupport(Map searchProps, 
String editorFindSupportConstant) {
+     private static boolean getBoolFromEditorFindSupport(Map<String, Object> 
searchProps, String editorFindSupportConstant) {
         Boolean b = (Boolean) searchProps.get(editorFindSupportConstant);
         return (b != null && b.booleanValue());
      }
 
-    private static boolean getMatchCaseFromEditorFindSupport(Map 
searchProps, String text) {
+    private static boolean getMatchCaseFromEditorFindSupport(Map<String, 
Object> searchProps, String text) {
         boolean matchCase = getBoolFromEditorFindSupport(searchProps, 
EditorFindSupport.FIND_MATCH_CASE);
         boolean smartCase = getBoolFromEditorFindSupport(searchProps, 
EditorFindSupport.FIND_SMART_CASE);
         if (smartCase && !matchCase) {
@@ -364,7 +364,7 @@
         return matchCase;
     }
     
-    private static FindReplaceResult preserveCaseImpl(FindReplaceResult 
findReplaceResult, String replaceString, Document doc, Map searchProps) 
throws BadLocationException {
+    private static FindReplaceResult preserveCaseImpl(FindReplaceResult 
findReplaceResult, String replaceString, Document doc, Map<String, Object> 
searchProps) throws BadLocationException {
         if (replaceString == null || findReplaceResult == null || 
findReplaceResult.getFoundPositions()[0] == -1) {
             return findReplaceResult;
         }
@@ -376,7 +376,7 @@
             assert(findReplaceResult.getFoundPositions()[0] <= 
findReplaceResult.getFoundPositions()[1]);
             int length = findReplaceResult.getFoundPositions()[1] - 
findReplaceResult.getFoundPositions()[0];
             String findStr = 
doc.getText(findReplaceResult.getFoundPositions()[0], length);
-            String replStr = replaceString.toString();
+            String replStr = replaceString;
             if (findStr.equals(findStr.toUpperCase())) {
                 replStr = replStr.toUpperCase();
             } else if (findStr.equals(findStr.toLowerCase())) {
@@ -398,22 +398,22 @@
     
 
     private static String convertStringForMatcher(String text) {
-        String res = null;
+        StringBuilder sb = null;
         if (text != null){
             String[] sGroups = text.split("\\\\\\\\", text.length()); 
//NOI18N
-            res = "";                         //NOI18N
+            sb = new StringBuilder();//NOI18N
             for(int i=0;i<sGroups.length;i++){
                 String tmp = sGroups[i];
                 tmp = tmp.replace("\\" + "r", "\r"); //NOI18N
                 tmp = tmp.replace("\\" + "n", "\n"); //NOI18N
                 tmp = tmp.replace("\\" + "t", "\t"); //NOI18N
-                res += tmp;
+                sb.append(tmp);
                 if (i != sGroups.length - 1){
-                    res += "\\\\";                   //NOI18N
+                    sb.append("\\\\");                   //NOI18N
                 }
             }
         }
-        return res;
+        return sb != null ? sb.toString() : null;
     }
 
     private interface DocFinder{
@@ -428,6 +428,7 @@
     private static final class FalseBlocksFinder extends 
AbstractBlocksFinder {
         public static final FalseBlocksFinder INSTANCE = new 
FalseBlocksFinder();
 
+        @Override
         public int find(int initOffset, CharSequence data) {
             return -1;
         }
@@ -439,10 +440,12 @@
     private static class FalseFinder extends AbstractFinder implements 
StringFinder {
         public static final FalseFinder INSTANCE = new FalseFinder();
 
+        @Override
         public int find(int initOffset, CharSequence data) {
             return -1;
         }
 
+        @Override
         public int getFoundLength() {
             return 0;
         }
@@ -453,7 +456,7 @@
     private static abstract class AbstractBlocksFinder extends AbstractFinder
         implements BlocksFinder {
 
-        private static int[] EMPTY_INT_ARRAY = new int[0];
+        private static final int[] EMPTY_INT_ARRAY = new int[0];
 
         private int[] blocks = EMPTY_INT_ARRAY;
 
@@ -468,6 +471,7 @@
             closed = false;
         }
 
+        @Override
         public final int[] getBlocks() {
             if (!closed) { // not closed yet
                 closeBlocks();
@@ -476,6 +480,7 @@
             return blocks;
         }
 
+        @Override
         public final void setBlocks(int[] blocks) {
             this.blocks = blocks;
             blocksInd = 0;
@@ -504,7 +509,7 @@
             StringBuffer buf = new StringBuffer();
             int ind = 0;
             while (blocks[ind] != -1) {
-                buf.append((ind/2 + 1) + ": [" + blocks[ind] + ", " + 
blocks[ind + 1] + "]\n"); // NOI18N
+                buf.append(ind/2 + 1).append(": 
[").append(blocks[ind]).append(", ").append(blocks[ind + 1]).append("]\n"); 
// NOI18N
                 ind+= 2;
             }
             return buf.toString();
@@ -542,11 +547,13 @@
         protected boolean found;
 
         /** Was the string found? */
+        @Override
         public final boolean isFound() {
             return found;
         }
 
         /** Reset the finder */
+        @Override
         public void reset() {
             found = false;
         }
@@ -608,6 +615,7 @@
             stringInd = 0;
         }
 
+        @Override
         public int find(int initOffset, CharSequence data) {
             int offset = 0;
             int limitPos = data.length();
@@ -701,6 +709,7 @@
             stringInd = 0;
         }
 
+        @Override
         public int find(int initOffset, CharSequence data) {
             int offset = 0;
             int endPos = data.length();
@@ -761,6 +770,7 @@
             lastCharWordPart = DocUtils.isIdentifierPart(doc, chars[endInd]);
         }
 
+        @Override
         public int getFoundLength() {
             return chars.length;
         }
@@ -773,6 +783,7 @@
             stringInd = endInd;
         }
 
+        @Override
         protected int scan(char ch, boolean lastChar) {
             if (!matchCase) {
                 ch = Character.toLowerCase(ch);
@@ -835,6 +846,7 @@
     /** Generic forward finder that simplifies the search process. */
     private static abstract class GenericFwdFinder extends AbstractFinder {
 
+        @Override
         public final int find(int initOffset, CharSequence chars) {
             int offset = initOffset;//0;
             int limitPos = chars.length();
@@ -868,6 +880,7 @@
     /** Generic backward finder that simplifies the search process. */
     private static abstract class GenericBwdFinder extends AbstractFinder {
 
+        @Override
         public final int find(int initOffset, CharSequence chars) {
             int offset = initOffset-1;
             int limitPos = 0;
@@ -926,6 +939,7 @@
             firstCharWordPart = DocUtils.isIdentifierPart(doc, chars[0]);
         }
         
+        @Override
         public int getFoundLength() {
             return chars.length;
         }
@@ -938,6 +952,7 @@
             stringInd = 0;
         }
 
+        @Override
         protected int scan(char ch, boolean lastChar) {
             if (!matchCase) {
                 ch = Character.toLowerCase(ch);
@@ -1017,6 +1032,7 @@
             endInd = chars.length - 1;
         }
         
+        @Override
         public int getFoundLength() {
             return chars.length;
         }
@@ -1027,6 +1043,7 @@
             stringInd = endInd;
         }
 
+        @Override
         protected int scan(char ch, boolean lastChar) {
             if (!matchCase) {
                 ch = Character.toLowerCase(ch);
@@ -1068,6 +1085,7 @@
             chars = (matchCase ? s : s.toLowerCase()).toCharArray();
         }
 
+        @Override
         public int getFoundLength() {
             return chars.length;
         }
@@ -1078,6 +1096,7 @@
             stringInd = 0;
         }
 
+        @Override
         protected int scan(char ch, boolean lastChar) {
             if (!matchCase) {
                 ch = Character.toLowerCase(ch);
@@ -1119,6 +1138,7 @@
         public RegExpBwdFinder() {
         }
 
+        @Override
         public Matcher getMatcher(){
             return matcher;
         }
@@ -1128,6 +1148,7 @@
             this.pattern = pattern;            
         }
         
+        @Override
         public int getFoundLength() {
             return length;
         }
@@ -1154,6 +1175,7 @@
             return ret;
         }
         
+        @Override
         public int find(int initOffset, CharSequence chars) {
             char ch;
             
@@ -1189,6 +1211,7 @@
         public RegExpFwdFinder() {
         }
 
+        @Override
         public Matcher getMatcher(){
             return matcher;
         }
@@ -1198,6 +1221,7 @@
             this.pattern = pattern;
         }
         
+        @Override
         public int getFoundLength() {
             return length;
         }
@@ -1208,6 +1232,7 @@
             length = 0;
         }
 
+        @Override
         public int find(int initOffset, CharSequence chars) {
             matcher = pattern.matcher(chars);
             if (matcher.find(initOffset)){
@@ -1257,6 +1282,7 @@
             stringInd = 0;
         }
 
+        @Override
         public int find(int initOffset, CharSequence data) {
             Matcher matcher = pattern.matcher(data);
             int ret = 0;
@@ -1302,8 +1328,8 @@
     }
 
     public static class FindReplaceResult{
-        private int[] positions;
-        private String replacedString;
+        private final int[] positions;
+        private final String replacedString;
         
         public FindReplaceResult(int[] positions, String replacedString){
             this.positions = positions;
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/EditorFindSupport.java 
b/editor.search/src/org/netbeans/modules/editor/search/EditorFindSupport.java
--- 
a/editor.search/src/org/netbeans/modules/editor/search/EditorFindSupport.java
+++ 
b/editor.search/src/org/netbeans/modules/editor/search/EditorFindSupport.java
@@ -161,7 +161,7 @@
         new WeakHashMap<>();
     
     /** Support for firing change events */
-    private PropertyChangeSupport changeSupport = new 
PropertyChangeSupport(this);
+    private final PropertyChangeSupport changeSupport = new 
PropertyChangeSupport(this);
     
     private SPW lastSelected;
     private List<SPW> historyList = new ArrayList<>();
@@ -171,7 +171,7 @@
     }
 
     /** Get shared instance of find support */
-    public static EditorFindSupport getInstance() {
+    public synchronized static EditorFindSupport getInstance() {
         if (findSupport == null) {
             findSupport = new EditorFindSupport();
         }
@@ -224,7 +224,7 @@
      */
     public int[] getBlocks(int[] blocks, Document doc,
                     int startOffset, int endOffset) throws 
BadLocationException {
-        Map props = getValidFindProperties(null);
+        Map<String, Object> props = getValidFindProperties(null);
         
         boolean blockSearch = 
Boolean.TRUE.equals(props.get(FIND_BLOCK_SEARCH));
         Position blockSearchStartPos = (Position) 
props.get(FIND_BLOCK_SEARCH_START);
@@ -389,7 +389,7 @@
         }
     }
     
-    private boolean isBackSearch(Map props, boolean oppositeDir) {
+    private boolean isBackSearch(Map<String, Object> props, boolean 
oppositeDir) {
         Boolean b = (Boolean)props.get(FIND_BACKWARD_SEARCH);
         boolean back = (b != null && b.booleanValue());
         if (oppositeDir) {
@@ -833,16 +833,13 @@
 
                 // Display message about replacement
                 if (totalCnt == 0){
-                    String exp = "'' "; //NOI18N
-                    if (findWhat != null) { // nothing to search for
-                        exp = "'" + findWhat + "' "; // NOI18N
-                    }
+                    String exp = "'" + findWhat + "' "; //NOI18N
                     ComponentUtils.setStatusText(c, exp + 
NbBundle.getMessage(
                                 EditorFindSupport.class, NOT_FOUND_LOCALE), 
IMPORTANCE_FIND_OR_REPLACE);
                 }else{
                     MessageFormat fmt = new MessageFormat(
                                             
NbBundle.getMessage(EditorFindSupport.class, ITEMS_REPLACED_LOCALE));
-                    String msg = fmt.format(new Object[] { new 
Integer(replacedCnt), new Integer(totalCnt) });
+                    String msg = fmt.format(new Object[] { 
Integer.valueOf(replacedCnt), Integer.valueOf(totalCnt) });
                     ComponentUtils.setStatusText(c, msg, 
IMPORTANCE_FIND_OR_REPLACE);
                 }
 
@@ -976,10 +973,10 @@
     }
     
     public final static class SPW{
-        private String searchExpression;
-        private boolean wholeWords;
-        private boolean matchCase;
-        private boolean regExp;
+        private final String searchExpression;
+        private final boolean wholeWords;
+        private final boolean matchCase;
+        private final boolean regExp;
         
         public SPW(String searchExpression, boolean wholeWords,
             boolean matchCase, boolean regExp){
@@ -1046,8 +1043,8 @@
 
     public final static class RP {
 
-        private String replaceExpression;
-        private boolean preserveCase;
+        private final String replaceExpression;
+        private final boolean preserveCase;
 
         public RP(String replaceExpression, boolean preserveCase) {
             this.replaceExpression = replaceExpression;
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/ReplaceBar.java 
b/editor.search/src/org/netbeans/modules/editor/search/ReplaceBar.java
--- a/editor.search/src/org/netbeans/modules/editor/search/ReplaceBar.java
+++ b/editor.search/src/org/netbeans/modules/editor/search/ReplaceBar.java
@@ -62,7 +62,7 @@
     private static ReplaceBar replacebarInstance = null;
     private static final Logger LOG = 
Logger.getLogger(ReplaceBar.class.getName());
     private SearchBar searchBar;
-    private final JComboBox replaceComboBox;
+    private final JComboBox<String> replaceComboBox;
     private final JTextComponent replaceTextField;
     private final JButton replaceButton;
     private final JButton replaceAllButton;
@@ -93,7 +93,7 @@
 
         // padding at the end of the toolbar
         add(Box.createHorizontalStrut(8)); //spacer in the beginnning of the 
toolbar
-        SearchComboBox scb = new SearchComboBox();
+        SearchComboBox<String> scb = new SearchComboBox<>();
         replaceComboBox = scb;
         replaceComboBox.addPopupMenuListener(new ReplacePopupMenuListener());
         replaceTextField = scb.getEditorPane();
@@ -261,12 +261,12 @@
         EditorFindSupport.getInstance().addToReplaceHistory(new 
EditorFindSupport.RP(incrementalSearchText, 
preserveCaseCheckBox.isSelected()));
         // Add the text to the top of the list
         for (int i = replaceComboBox.getItemCount() - 1; i >= 0; i--) {
-            String item = (String) replaceComboBox.getItemAt(i);
+            String item = replaceComboBox.getItemAt(i);
             if (item.equals(incrementalSearchText)) {
                 replaceComboBox.removeItemAt(i);
             }
         }
-        ((MutableComboBoxModel) 
replaceComboBox.getModel()).insertElementAt(incrementalSearchText, 0);
+        ((MutableComboBoxModel<String>) 
replaceComboBox.getModel()).insertElementAt(incrementalSearchText, 0);
         replaceComboBox.setSelectedIndex(0);
     }
 
@@ -325,7 +325,7 @@
             SearchComboBoxEditor.changeToOneLineEditorPane((JEditorPane) 
replaceTextField);
             addEnterKeystrokeReplaceTo(replaceTextField);
             String lastReplace = replaceTextField.getText();
-            MutableComboBoxModel comboBoxModelIncSearch = 
((MutableComboBoxModel) replaceComboBox.getModel());
+            MutableComboBoxModel<String> comboBoxModelIncSearch = 
((MutableComboBoxModel<String>) replaceComboBox.getModel());
             for (int i = comboBoxModelIncSearch.getSize() - 1; i >= 0; i--) {
                 comboBoxModelIncSearch.removeElementAt(i);
             }
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/SearchBar.java 
b/editor.search/src/org/netbeans/modules/editor/search/SearchBar.java
--- a/editor.search/src/org/netbeans/modules/editor/search/SearchBar.java
+++ b/editor.search/src/org/netbeans/modules/editor/search/SearchBar.java
@@ -102,7 +102,7 @@
     private KeyListener keyListenerForComponent;
     private PropertyChangeListener propertyChangeListenerForComponent;
     private final JLabel findLabel;
-    private final JComboBox incSearchComboBox;
+    private final JComboBox<String> incSearchComboBox;
     private final JTextComponent incSearchTextField;
     private final DocumentListener incSearchTextFieldListener;
     private boolean hadFocusOnIncSearchTextField = false;
@@ -151,7 +151,7 @@
 
         add(Box.createHorizontalStrut(8)); //spacer in the beginnning of the 
toolbar
 
-        SearchComboBox scb = new SearchComboBox();
+        SearchComboBox<String> scb = new SearchComboBox<>();
         incSearchComboBox = scb;
         incSearchComboBox.setFocusable(false);
         incSearchComboBox.addPopupMenuListener(new 
SearchPopupMenuListener());
@@ -410,12 +410,12 @@
         
incSearchTextField.getDocument().removeDocumentListener(incSearchTextFieldListener);
         // Add the text to the top of the list
         for (int i = incSearchComboBox.getItemCount() - 1; i >= 0; i--) {
-            String item = (String) incSearchComboBox.getItemAt(i);
+            String item = incSearchComboBox.getItemAt(i);
             if (item.equals(incrementalSearchText)) {
                 incSearchComboBox.removeItemAt(i);
             }
         }
-        ((MutableComboBoxModel) 
incSearchComboBox.getModel()).insertElementAt(incrementalSearchText, 0);
+        ((MutableComboBoxModel<String>) 
incSearchComboBox.getModel()).insertElementAt(incrementalSearchText, 0);
         incSearchComboBox.setSelectedIndex(0);
         
incSearchTextField.getDocument().addDocumentListener(incSearchTextFieldListener);
     }
@@ -748,7 +748,7 @@
         SearchComboBoxEditor.changeToOneLineEditorPane((JEditorPane) 
incSearchTextField);
         addEnterKeystrokeFindNextTo(incSearchTextField);
 
-        MutableComboBoxModel comboBoxModelIncSearch = 
((MutableComboBoxModel) incSearchComboBox.getModel());
+        MutableComboBoxModel<String> comboBoxModelIncSearch = 
((MutableComboBoxModel<String>) incSearchComboBox.getModel());
         for (int i = comboBoxModelIncSearch.getSize() - 1; i >= 0; i--) {
             comboBoxModelIncSearch.removeElementAt(i);
         }
@@ -1107,7 +1107,7 @@
         this.popupMenuWasCanceled = popupMenuWasCanceled;
     }
 
-    public JComboBox getIncSearchComboBox() {
+    public JComboBox<String> getIncSearchComboBox() {
         return incSearchComboBox;
     }
 
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/SearchButton.java 
b/editor.search/src/org/netbeans/modules/editor/search/SearchButton.java
--- a/editor.search/src/org/netbeans/modules/editor/search/SearchButton.java
+++ b/editor.search/src/org/netbeans/modules/editor/search/SearchButton.java
@@ -85,9 +85,7 @@
     private static void processButton(AbstractButton button) {
         removeButtonContentAreaAndBorder(button);
         button.setMargin(BUTTON_INSETS);
-        if (button instanceof AbstractButton) {
             button.addMouseListener(sharedMouseListener);
-        }
         button.setFocusable(false);
     }
 
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/SearchComboBox.java 
b/editor.search/src/org/netbeans/modules/editor/search/SearchComboBox.java
--- a/editor.search/src/org/netbeans/modules/editor/search/SearchComboBox.java
+++ b/editor.search/src/org/netbeans/modules/editor/search/SearchComboBox.java
@@ -45,11 +45,11 @@
 import javax.swing.JComboBox;
 import javax.swing.JEditorPane;
 
-public class SearchComboBox extends JComboBox {
+public class SearchComboBox<E> extends JComboBox<E> {
 
     private static final int DEFAULT_INCREMANTAL_SEARCH_COMBO_WIDTH = 200;
     private static final int MAX_INCREMANTAL_SEARCH_COMBO_WIDTH = 350;
-    private SearchComboBoxEditor searchComboBoxEditor = new 
SearchComboBoxEditor();
+    private final SearchComboBoxEditor searchComboBoxEditor = new 
SearchComboBoxEditor();
 
     public SearchComboBox() {
         setEditable(true);
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/SearchComboBoxEditor.java
 
b/editor.search/src/org/netbeans/modules/editor/search/SearchComboBoxEditor.java
--- 
a/editor.search/src/org/netbeans/modules/editor/search/SearchComboBoxEditor.java
+++ 
b/editor.search/src/org/netbeans/modules/editor/search/SearchComboBoxEditor.java
@@ -68,7 +68,7 @@
     private final JScrollPane scrollPane;
     private final JEditorPane editorPane;
     private Object oldValue;
-    private static final JTextField referenceTextField = (JTextField) new 
JComboBox().getEditor().getEditorComponent();
+    private static final JTextField referenceTextField = (JTextField) new 
JComboBox<String>().getEditor().getEditorComponent();
     private static final Logger LOG = 
Logger.getLogger(SearchComboBoxEditor.class.getName());
 
     public SearchComboBoxEditor() {
@@ -324,6 +324,7 @@
         }
     }
 
+    @SuppressWarnings({"rawtypes", "unchecked"})
     @Override
     public Object getItem() {
         Object newValue = editorPane.getText();
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/SearchNbEditorKit.java 
b/editor.search/src/org/netbeans/modules/editor/search/SearchNbEditorKit.java
--- 
a/editor.search/src/org/netbeans/modules/editor/search/SearchNbEditorKit.java
+++ 
b/editor.search/src/org/netbeans/modules/editor/search/SearchNbEditorKit.java
@@ -56,8 +56,7 @@
 import org.netbeans.api.editor.mimelookup.MimeRegistration;
 import org.netbeans.editor.BaseKit;
 import org.netbeans.editor.EditorUI;
-import org.netbeans.editor.SideBarFactory;
-import org.netbeans.editor.ext.ExtKit;
+import org.netbeans.spi.editor.SideBarFactory;
 import org.netbeans.modules.editor.NbEditorKit;
 
 @MimeRegistration(mimeType = SearchNbEditorKit.SEARCHBAR_MIMETYPE, service = 
EditorKit.class)
@@ -68,6 +67,7 @@
     public static final String SEARCHBAR_MIMETYPE = "text/x-editor-search"; 
// NOI18N
     public static final String PROP_SEARCH_CONTAINER = 
"diff.search.container"; // NOI18N
 
+    @SuppressWarnings("unchecked")
     public static <T> T findComponent(Container container, Class<T> 
componentClass, int depth) {
         if (depth > 0) {
             for (Component c : container.getComponents()) {
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/SearchPropertiesSupport.java
 
b/editor.search/src/org/netbeans/modules/editor/search/SearchPropertiesSupport.java
--- 
a/editor.search/src/org/netbeans/modules/editor/search/SearchPropertiesSupport.java
+++ 
b/editor.search/src/org/netbeans/modules/editor/search/SearchPropertiesSupport.java
@@ -61,7 +61,7 @@
     private SearchPropertiesSupport() {
     }
 
-    private static SearchPropertiesSupport getInstance() {
+    private synchronized static SearchPropertiesSupport getInstance() {
         if (instance == null) {
             instance = new SearchPropertiesSupport();
         }
@@ -72,14 +72,14 @@
         return prefs;
     }
 
-    public static SearchProperties getSearchProperties() {
+    public synchronized static SearchProperties getSearchProperties() {
         if (searchProps == null) {
             searchProps = createDefaultSearchProperties();
         }
         return searchProps;
     }
 
-    public static SearchProperties getReplaceProperties() {
+    public synchronized static SearchProperties getReplaceProperties() {
         if (replaceProps == null) {
             replaceProps = createDefaultReplaceProperties();
         }
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/TextSearchHighlighting.java
 
b/editor.search/src/org/netbeans/modules/editor/search/TextSearchHighlighting.java
--- 
a/editor.search/src/org/netbeans/modules/editor/search/TextSearchHighlighting.java
+++ 
b/editor.search/src/org/netbeans/modules/editor/search/TextSearchHighlighting.java
@@ -218,7 +218,7 @@
     @MimeRegistration(mimeType = "", service = HighlightsLayerFactory.class)
     public static final class FactoryImpl implements HighlightsLayerFactory {
 
-        public final class SearchBlockHighlighting extends BlockHighlighting 
{
+        public final static class SearchBlockHighlighting extends 
BlockHighlighting {
             public SearchBlockHighlighting(String layerId, JTextComponent 
component) {
                 super(layerId,component);
                 EditorFindSupport.getInstance().hookLayer(this, component);
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/actions/FindSelectionAction.java
 
b/editor.search/src/org/netbeans/modules/editor/search/actions/FindSelectionAction.java
--- 
a/editor.search/src/org/netbeans/modules/editor/search/actions/FindSelectionAction.java
+++ 
b/editor.search/src/org/netbeans/modules/editor/search/actions/FindSelectionAction.java
@@ -73,16 +73,17 @@
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     public void actionPerformed(ActionEvent evt, JTextComponent target) {
         if (target != null) {
             EditorFindSupport findSupport = EditorFindSupport.getInstance();
             Caret caret = target.getCaret();
             int dotPos = caret.getDot();
-            HashMap props = new 
HashMap(findSupport.createDefaultFindProperties());
+            HashMap<String, Object> props = new 
HashMap<>(findSupport.createDefaultFindProperties());
             String searchWord = null;
             boolean revert = false;
             Boolean originalValue = null;
-            Map revertMap = (Map) props.get(EditorFindSupport.REVERT_MAP);
+            Map<String, Object> revertMap = (Map<String, Object>) 
props.get(EditorFindSupport.REVERT_MAP);
             Boolean revertValue = revertMap != null ? (Boolean) 
revertMap.get(EditorFindSupport.FIND_WHOLE_WORDS) : null;
             if (Utilities.isSelectionShowing(caret)) {
                 // valid selection
@@ -114,7 +115,7 @@
                 }
                 props.put(EditorFindSupport.FIND_WHAT, searchWord);
                 if (revert) {
-                    revertMap = new HashMap();
+                    revertMap = new HashMap<>();
                     revertMap.put(EditorFindSupport.FIND_WHOLE_WORDS, 
originalValue != null ? originalValue : Boolean.FALSE);
                     props.put(EditorFindSupport.REVERT_MAP, revertMap);
                 }
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/actions/ToggleHighlightSearchAction.java
 
b/editor.search/src/org/netbeans/modules/editor/search/actions/ToggleHighlightSearchAction.java
--- 
a/editor.search/src/org/netbeans/modules/editor/search/actions/ToggleHighlightSearchAction.java
+++ 
b/editor.search/src/org/netbeans/modules/editor/search/actions/ToggleHighlightSearchAction.java
@@ -53,7 +53,6 @@
 import org.netbeans.api.editor.EditorActionRegistration;
 import org.netbeans.editor.BaseKit;
 import org.netbeans.modules.editor.search.EditorFindSupport;
-import org.netbeans.modules.editor.search.SearchNbEditorKit;
 import org.netbeans.spi.editor.AbstractEditorAction;
 import org.openide.util.WeakListeners;
 import org.openide.util.actions.Presenter;
@@ -62,7 +61,7 @@
 
 //    @EditorActionRegistration(name = BaseKit.toggleHighlightSearchAction,
 @EditorActionRegistration(name = BaseKit.toggleHighlightSearchAction, 
iconResource = 
"org/netbeans/modules/editor/search/resources/toggle_highlight.png") // NOI18N
-public class ToggleHighlightSearchAction extends AbstractEditorAction 
implements Presenter.Toolbar {
+public class ToggleHighlightSearchAction extends AbstractEditorAction {
     static final long serialVersionUID = 4603809175771743200L;
 
 
@@ -74,6 +73,7 @@
         b.setAction(this);
     }
 
+    @Override
     public void actionPerformed(ActionEvent evt, JTextComponent target) {
         if (target != null) {
             Boolean cur = (Boolean) 
EditorFindSupport.getInstance().getFindProperty(EditorFindSupport.FIND_HIGHLIGHT_SEARCH);
@@ -86,6 +86,7 @@
         }
     }
 
+    @Override
     public Component getToolbarPresenter() {
         JToggleButton b = new MyGaGaButton();
         b.setModel(new HighlightButtonModel());
@@ -102,6 +103,7 @@
             propertyChange(null);
         }
 
+        @Override
         public void propertyChange(PropertyChangeEvent evt) {
             if (evt == null || evt.getPropertyName() == null || 
evt.getPropertyName().equals(EditorFindSupport.FIND_HIGHLIGHT_SEARCH)) {
                 Boolean value = (Boolean) 
EditorFindSupport.getInstance().getFindProperty(EditorFindSupport.FIND_HIGHLIGHT_SEARCH);
@@ -129,6 +131,7 @@
             stateChanged(null);
         }
 
+        @Override
         public void stateChanged(ChangeEvent evt) {
             boolean selected = isSelected();
             super.setContentAreaFilled(selected);

[hg] main-silver: editor.search warnings Resolved

Milutin Kristofic 04/26/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 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close