--- a/openide.explorer/apichanges.xml Tue Mar 06 10:49:56 2012 +0100
+++ a/openide.explorer/apichanges.xml Wed Mar 07 14:40:19 2012 +0100
@@ -50,6 +50,20 @@
Explorer API
+
+
+ QuickSearch attached to OutlineView
+
+
+
+
+
+ Added OutlineView.getQuickSearch()
+ method to get and control quick search functionality on OutlineView.
+
+
+
+
API method for creating a PropertyEnv instance
--- a/openide.explorer/manifest.mf Tue Mar 06 10:49:56 2012 +0100
+++ a/openide.explorer/manifest.mf Wed Mar 07 14:40:19 2012 +0100
@@ -2,5 +2,5 @@
OpenIDE-Module: org.openide.explorer
OpenIDE-Module-Localizing-Bundle: org/openide/explorer/Bundle.properties
AutoUpdate-Essential-Module: true
-OpenIDE-Module-Specification-Version: 6.42
+OpenIDE-Module-Specification-Version: 6.43
--- a/openide.explorer/nbproject/project.xml Tue Mar 06 10:49:56 2012 +0100
+++ a/openide.explorer/nbproject/project.xml Wed Mar 07 14:40:19 2012 +0100
@@ -70,7 +70,7 @@
- 6.2
+ 7.43
--- a/openide.explorer/src/org/openide/explorer/view/OutlineView.java Tue Mar 06 10:49:56 2012 +0100
+++ a/openide.explorer/src/org/openide/explorer/view/OutlineView.java Wed Mar 07 14:40:19 2012 +0100
@@ -88,6 +88,7 @@
import javax.swing.BorderFactory;
import javax.swing.InputMap;
import javax.swing.JComponent;
+import javax.swing.JMenu;
import javax.swing.JPopupMenu;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
@@ -132,6 +133,7 @@
import org.netbeans.swing.outline.TreePathSupport;
import org.openide.awt.Mnemonics;
import org.openide.awt.MouseUtils;
+import org.openide.awt.QuickSearch;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.explorer.propertysheet.PropertyPanel;
@@ -233,9 +235,8 @@
rowModel = new PropertiesRowModel();
model = createOutlineModel(treeModel, rowModel, nodesColumnLabel);
outline = new OutlineViewOutline(model, rowModel);
- quickSearch = QuickSearch.attach(this, searchConstraints);
- TableQuickSearchSupport tqss = new TableQuickSearchSupport(outline, outline, outline.qss);
- quickSearch.addQuickSearchListener(tqss);
+ TableQuickSearchSupport tqss = outline.createDefaultTableQuickSearchSupport();
+ attachQuickSearch(tqss, false, tqss.createSearchPopupMenu());
outline.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
@@ -250,7 +251,6 @@
quickSearch.processKeyEvent(e);
}
});
- quickSearch.setPopupMenu(tqss.createSearchPopupMenu());
rowModel.setOutline(outline);
outline.setRenderDataProvider(new NodeRenderDataProvider(outline));
SheetCell tableCell = new SheetCell.OutlineSheetCell(outline);
@@ -316,6 +316,13 @@
initializeTreeScrollSupport();
}
+
+ private void attachQuickSearch(QuickSearch.Callback callback, boolean asynchronous, JMenu popup) {
+ if (quickSearch != null) {
+ quickSearch.detach();
+ }
+ quickSearch = QuickSearch.attach(this, searchConstraints, callback, asynchronous, popup);
+ }
@Override
public void add(Component comp, Object constraints) {
@@ -683,22 +690,33 @@
/**
* Test whether the quick search feature is enabled or not.
* Default is enabled (true).
- * @since
- * @return true
if quick search feature is enabled, false
otherwise.
+ * @since 6.43
+ * @return true if quick search feature is enabled, false otherwise.
*/
- /*public*/ boolean isQuickSearchAllowed() {
+ public boolean isQuickSearchAllowed() {
return quickSearch.isEnabled();
}
/**
* Set whether the quick search feature is enabled or not.
- * @since
+ * @since 6.43
* @param allowedQuickSearch true
if quick search shall be enabled
*/
- /*public*/ void setQuickSearchAllowed(boolean allowedQuickSearch) {
+ public void setQuickSearchAllowed(boolean allowedQuickSearch) {
quickSearch.setEnabled(allowedQuickSearch);
}
+ /**
+ * Set a quick search filter.
+ * @param quickSearchTableFilter The quick search filter
+ * @param asynchronous
+ * @since 6.43
+ */
+ public void setQuickSearchTableFilter(QuickSearchTableFilter quickSearchTableFilter, boolean asynchronous) {
+ TableQuickSearchSupport tqss = outline.createTableQuickSearchSupport(quickSearchTableFilter);
+ attachQuickSearch(tqss, asynchronous, tqss.createSearchPopupMenu());
+ }
+
/** Initializes the component and lookup explorer manager.
*/
@Override
@@ -1327,7 +1345,7 @@
* Extension of the ETable that allows adding a special comparator
* for sorting the rows.
*/
- static class OutlineViewOutline extends Outline implements TableQuickSearchSupport.StringValuedTable {
+ static class OutlineViewOutline extends Outline {
private final PropertiesRowModel rowModel;
private static final String COLUMNS_SELECTOR_HINT = "ColumnsSelectorHint"; // NOI18N
private static final String COPY_ACTION_DELEGATE = "Outline Copy Action Delegate "; // NOI18N
@@ -1406,34 +1424,46 @@
}
return null;
}
+
+ private TableQuickSearchSupport createDefaultTableQuickSearchSupport() {
+ return new TableQuickSearchSupport(this, new DefaultQuickSearchTableFilter(), qss);
+ }
- @Override
- public String getStringValueAt(int row, int col) {
- Object value = transformValue(getValueAt(row, col));
- String str;
- if (value instanceof Property) {
- Property p = (Property) value;
- Object v = null;
- try {
- v = p.getValue();
- } catch (IllegalAccessException ex) {
- } catch (InvocationTargetException ex) {
- }
- if (v instanceof String) {
- str = (String) v;
+ private TableQuickSearchSupport createTableQuickSearchSupport(QuickSearchTableFilter quickSearchTableFilter) {
+ return new TableQuickSearchSupport(this, quickSearchTableFilter, qss);
+ }
+
+ private final class DefaultQuickSearchTableFilter implements QuickSearchTableFilter {
+
+ @Override
+ public String getStringValueAt(int row, int col) {
+ Object value = transformValue(getValueAt(row, col));
+ String str;
+ if (value instanceof Property) {
+ Property p = (Property) value;
+ Object v = null;
+ try {
+ v = p.getValue();
+ } catch (IllegalAccessException ex) {
+ } catch (InvocationTargetException ex) {
+ }
+ if (v instanceof String) {
+ str = (String) v;
+ } else {
+ str = null;
+ }
+ } else if (value instanceof VisualizerNode) {
+ str = ((VisualizerNode) value).getDisplayName();
+ } else if (value instanceof Node) {
+ str = ((Node) value).getDisplayName();
+ } else if (value instanceof String) {
+ str = (String) value;
} else {
str = null;
}
- } else if (value instanceof VisualizerNode) {
- str = ((VisualizerNode) value).getDisplayName();
- } else if (value instanceof Node) {
- str = ((Node) value).getDisplayName();
- } else if (value instanceof String) {
- str = (String) value;
- } else {
- str = null;
+ return str;
}
- return str;
+
}
private class CopyToClipboardAction implements Action {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ 6bce66b50582 Wed Mar 07 14:40:19 2012 +0100
@@ -0,0 +1,52 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.openide.explorer.view;
+
+/**
+ *
+ * @author Martin Entlicher
+ */
+public interface QuickSearchTableFilter {
+
+ String getStringValueAt(int row, int col);
+
+}
--- a/openide.explorer/src/org/openide/explorer/view/TableQuickSearchSupport.java Tue Mar 06 10:49:56 2012 +0100
+++ a/openide.explorer/src/org/openide/explorer/view/TableQuickSearchSupport.java Wed Mar 07 14:40:19 2012 +0100
@@ -61,7 +61,7 @@
import javax.swing.event.ChangeListener;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
-import javax.swing.text.Position;
+import org.openide.awt.QuickSearch;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;
@@ -70,7 +70,7 @@
*
* @author Martin Entlicher
*/
-class TableQuickSearchSupport implements QuickSearch.QuickSearchListener {
+class TableQuickSearchSupport implements QuickSearch.Callback {
private int quickSearchInitialRow = -1; // The search was initiated here
private int quickSearchInitialColumn = -1; // The search was initiated here
@@ -79,15 +79,20 @@
private String lastSearchText;
private JTable table;
- private StringValuedTable svTable;
+ //private StringValuedTable svTable;
+ private QuickSearchTableFilter quickSearchTableFilter;
private QuickSearchSettings qss;
- TableQuickSearchSupport(JTable table, StringValuedTable svTable, QuickSearchSettings qss) {
+ TableQuickSearchSupport(JTable table, QuickSearchTableFilter quickSearchTableFilter, QuickSearchSettings qss) {
this.table = table;
- this.svTable = svTable;
+ this.quickSearchTableFilter = quickSearchTableFilter;
this.qss = qss;
}
+ public void setQuickSearchTableFilter(QuickSearchTableFilter quickSearchTableFilter, boolean asynchronous) {
+ this.quickSearchTableFilter = quickSearchTableFilter;
+ }
+
@Override
public void quickSearchUpdate(String searchText) {
lastSearchText = searchText;
@@ -103,12 +108,12 @@
}
quickSearchLastRow = quickSearchInitialRow;
quickSearchLastColumn = quickSearchInitialColumn;
- doSearch(searchText, Position.Bias.Forward);
+ doSearch(searchText, true);
}
@Override
- public void showNextSelection(Position.Bias bias) {
- if (bias == Position.Bias.Forward) {
+ public void showNextSelection(boolean forward) {
+ if (forward) {
if (++quickSearchLastColumn >= table.getColumnCount()) {
quickSearchLastColumn = 0;
if (++quickSearchLastRow >= table.getRowCount()) {
@@ -116,7 +121,7 @@
}
}
}
- doSearch(lastSearchText, bias);
+ doSearch(lastSearchText, forward);
}
@Override
@@ -134,7 +139,7 @@
String maxPrefix = null;
for (int row = row1; row < row2; row++) {
for (int col = col1; col < col2; col++) {
- String str = svTable.getStringValueAt(row, col);
+ String str = quickSearchTableFilter.getStringValueAt(row, col);
String strUp;
if (qss.isMatchCase()) {
strUp = str;
@@ -145,7 +150,7 @@
if (maxPrefix == null) {
maxPrefix = str;
} else {
- maxPrefix = QuickSearch.findMaxCommonSubstring(maxPrefix, str, !qss.isMatchCase());
+ maxPrefix = QuickSearch.findMaxPrefix(maxPrefix, str, !qss.isMatchCase());
}
}
}
@@ -170,26 +175,26 @@
quickSearchInitialColumn = -1;
}
- private void doSearch(String searchText, Position.Bias bias) {
+ private void doSearch(String searchText, boolean forward) {
if (!qss.isMatchCase()) {
searchText = searchText.toUpperCase();
}
int n = table.getRowCount();
- boolean backward = bias == Position.Bias.Backward;
+ //boolean backward = bias == Position.Bias.Backward;
int row1 = quickSearchLastRow;
int row2 = quickSearchLastRow + n;
boolean lineStartSearch = true;
Set columnsIgnoredToSearch = qss.getColumnsIgnoredToSearch();
do {
int col1 = quickSearchLastColumn;
- int col2 = (backward) ? 0 : table.getColumnCount();
- for (int row = (backward) ? (row2 - 1) : row1; (backward) ? row >= row1 : row < row2; row = (backward) ? --row : ++row) {
- for (int col = col1; (backward) ? col >= col2 : col < col2; col = (backward) ? --col : ++col) {
+ int col2 = (forward) ? table.getColumnCount() : 0;
+ for (int row = (forward) ? row1 : (row2 - 1); (forward) ? row < row2 : row >= row1; row = (forward) ? ++row : --row) {
+ for (int col = col1; (forward) ? col < col2 : col >= col2; col = (forward) ? ++col : --col) {
String cName = table.getColumnName(col);
if (columnsIgnoredToSearch.contains(cName)) {
continue;
}
- String str = svTable.getStringValueAt(row % n, col);
+ String str = quickSearchTableFilter.getStringValueAt(row % n, col);
if (str == null) {
continue;
}
@@ -208,7 +213,7 @@
}
}
}
- col1 = (backward) ? table.getColumnCount() - 1 : 0;
+ col1 = (forward) ? 0 : table.getColumnCount() - 1;
}
lineStartSearch = !lineStartSearch;
} while (!lineStartSearch);
@@ -234,7 +239,7 @@
return TableQuickSearchSupport.getSearchPopupMenu(qss, table.getColumnModel(), new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- doSearch(lastSearchText, Position.Bias.Forward);
+ doSearch(lastSearchText, true);
}
});
}
--- a/openide.explorer/src/org/openide/explorer/view/TreeTable.java Tue Mar 06 10:49:56 2012 +0100
+++ a/openide.explorer/src/org/openide/explorer/view/TreeTable.java Wed Mar 07 14:40:19 2012 +0100
@@ -87,7 +87,7 @@
*
* @author Jan Rojcek
*/
-class TreeTable extends JTable implements Runnable, TableQuickSearchSupport.StringValuedTable {
+class TreeTable extends JTable implements Runnable {
/** Action key for up/down focus action */
private static final String ACTION_FOCUS_NEXT = "focusNext"; //NOI18N
private static Color unfocusedSelBg = null;
@@ -337,31 +337,41 @@
QuickSearchSettings getQuickSearchSettings() {
return qss;
}
+
+ private QuickSearchTableFilter qstf = new DefaultQuickSearchTableFilter();
+
+ QuickSearchTableFilter getQuickSearchTableFilter() {
+ return qstf;
+ }
- @Override
- public String getStringValueAt(int row, int col) {
- Object value = getValueAt(row, col);
- String str;
- if (value instanceof Property) {
- Property p = (Property) value;
- Object v = null;
- try {
- v = p.getValue();
- } catch (IllegalAccessException ex) {
- } catch (InvocationTargetException ex) {
- }
- if (v instanceof String) {
- str = (String) v;
+ private final class DefaultQuickSearchTableFilter implements QuickSearchTableFilter {
+
+ @Override
+ public String getStringValueAt(int row, int col) {
+ Object value = getValueAt(row, col);
+ String str;
+ if (value instanceof Property) {
+ Property p = (Property) value;
+ Object v = null;
+ try {
+ v = p.getValue();
+ } catch (IllegalAccessException ex) {
+ } catch (InvocationTargetException ex) {
+ }
+ if (v instanceof String) {
+ str = (String) v;
+ } else {
+ str = null;
+ }
+ } else if (value instanceof VisualizerNode) {
+ str = ((VisualizerNode) value).getDisplayName();
+ //str = Visualizer.findNode(value).getDisplayName();
} else {
str = null;
}
- } else if (value instanceof VisualizerNode) {
- str = ((VisualizerNode) value).getDisplayName();
- //str = Visualizer.findNode(value).getDisplayName();
- } else {
- str = null;
+ return str;
}
- return str;
+
}
private class GuardedActions implements Mutex.Action