[hg] main-silver: More flexible search and replace action

  • From: Milutin Kristofic < >
  • To:
  • Subject: [hg] main-silver: More flexible search and replace action
  • Date: Tue, 22 Jan 2013 08:38:12 -0800

changeset 31183fc1717b in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/31183fc1717b
description:
        More flexible search and replace action

diffstat:

 
editor.search/src/org/netbeans/modules/editor/search/actions/ReplaceAction.java
 |  9 +++++----
 
editor.search/src/org/netbeans/modules/editor/search/actions/SearchAction.java
  |  9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diffs (73 lines):

diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/actions/ReplaceAction.java
 
b/editor.search/src/org/netbeans/modules/editor/search/actions/ReplaceAction.java
--- 
a/editor.search/src/org/netbeans/modules/editor/search/actions/ReplaceAction.java
+++ 
b/editor.search/src/org/netbeans/modules/editor/search/actions/ReplaceAction.java
@@ -77,26 +77,27 @@
             if ((target instanceof JEditorPane) && ((JEditorPane) 
target).getEditorKit() instanceof SearchNbEditorKit) {
                 target = SearchBar.getInstance().getActualTextComponent();
             }
-            EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(target);
-            if (eui != null) {
                 JPanel jp = null;
                 Object clientProperty = 
target.getClientProperty(SearchNbEditorKit.PROP_SEARCH_CONTAINER);
                 if (clientProperty instanceof JPanel) {
                     jp = (JPanel) clientProperty;
                 } else {
+                EditorUI eui = 
org.netbeans.editor.Utilities.getEditorUI(target);
+                if (eui != null) {
                     JComponent comp = eui.hasExtComponent() ? 
eui.getExtComponent() : null;
                     if (comp != null) {
                         jp = SearchNbEditorKit.findComponent(comp, 
SearchNbEditorKit.SearchJPanel.class, 5);
                     }
                 }
+            }
                 if (jp != null && target.isEditable()) {
-                    SearchBar searchBar = 
SearchBar.getInstance(eui.getComponent());
+                SearchBar searchBar = SearchBar.getInstance(target);
                     jp.add(searchBar);
                     jp.add(ReplaceBar.getInstance(searchBar));
                     ReplaceBar.getInstance(searchBar).gainFocus();
                     SearchNbEditorKit.makeSearchAndReplaceBarPersistent();
                 }
+
             }
         }
     }
-}
diff --git 
a/editor.search/src/org/netbeans/modules/editor/search/actions/SearchAction.java
 
b/editor.search/src/org/netbeans/modules/editor/search/actions/SearchAction.java
--- 
a/editor.search/src/org/netbeans/modules/editor/search/actions/SearchAction.java
+++ 
b/editor.search/src/org/netbeans/modules/editor/search/actions/SearchAction.java
@@ -75,8 +75,6 @@
             if ((target instanceof JEditorPane) && ((JEditorPane) 
target).getEditorKit() instanceof SearchNbEditorKit) {
                 target = SearchBar.getInstance().getActualTextComponent();
             }
-            EditorUI eui = org.netbeans.editor.Utilities.getEditorUI(target);
-            if (eui != null) {
                 //need to find if it has extended editor first, otherwise 
getExtComponent() will create all sidebars
                 //and other parts of full editor if action is assigned to 
just editor pane and broke later action logic.
                 JPanel jp = null;
@@ -84,13 +82,16 @@
                 if (clientProperty instanceof JPanel) {
                     jp = (JPanel) clientProperty;
                 } else {
+                EditorUI eui = 
org.netbeans.editor.Utilities.getEditorUI(target);
+                if (eui != null) {
                     JComponent comp = eui.hasExtComponent() ? 
eui.getExtComponent() : null;
                     if (comp != null) {
                         jp = SearchNbEditorKit.findComponent(comp, 
SearchNbEditorKit.SearchJPanel.class, 5);
                     }
                 }
+            }
                 if (jp != null) {
-                    SearchBar searchBarInstance = 
SearchBar.getInstance(eui.getComponent());
+                SearchBar searchBarInstance = SearchBar.getInstance(target);
                     jp.add(searchBarInstance);
                     ReplaceBar replaceBarInstance = 
ReplaceBar.getInstance(searchBarInstance);
                     if (replaceBarInstance.isVisible()) {
@@ -100,6 +101,6 @@
                     SearchNbEditorKit.makeSearchAndReplaceBarPersistent();
                 }
             }
+
         }
     }
-    }

[hg] main-silver: More flexible search and replace action

Milutin Kristofic 01/22/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