diff -r c9a896e042ec core.ui/src/org/netbeans/core/ui/options/general/Bundle.properties --- a/core.ui/src/org/netbeans/core/ui/options/general/Bundle.properties Wed Jul 09 07:04:51 2008 +0200 +++ b/core.ui/src/org/netbeans/core/ui/options/general/Bundle.properties Thu Jul 10 16:35:14 2008 +0200 @@ -227,3 +227,6 @@ WebBrowsersOptionsPanel.AccessibleContext.accessibleDescription=Web Browsers GeneralOptionsPanel_rbUseSystemProxy_Direct=Direct connection. GeneralOptionsPanel_rbUseSystemProxy_Format={0}:{1} + +# Keywords for quick-search +KW_General=proxy, general diff -r c9a896e042ec core.ui/src/org/netbeans/core/ui/options/general/GeneralOptions.java --- a/core.ui/src/org/netbeans/core/ui/options/general/GeneralOptions.java Wed Jul 09 07:04:51 2008 +0200 +++ b/core.ui/src/org/netbeans/core/ui/options/general/GeneralOptions.java Thu Jul 10 16:35:14 2008 +0200 @@ -56,37 +56,37 @@ * @author Jan Jancura */ -public final class GeneralOptions extends OptionsCategory { +public final class GeneralOptions /*extends OptionsCategory*/ { - private static String loc (String key) { - return NbBundle.getMessage (GeneralOptionsPanel.class, key); - } - - - private static Icon icon; - - public Icon getIcon () { - if (icon == null) - icon = new ImageIcon ( - Utilities.loadImage - ("org/netbeans/modules/options/resources/generalOptions.png") - ); - return icon; - } - - public String getCategoryName () { - return loc ("CTL_General_Options"); - } - - public String getTitle () { - return loc ("CTL_General_Options_Title"); - } - - public String getDescription () { - return loc ("CTL_General_Options_Description"); - } - - public OptionsPanelController create () { - return new GeneralOptionsPanelController (); - } +// private static String loc (String key) { +// return NbBundle.getMessage (GeneralOptionsPanel.class, key); +// } +// +// +// private static Icon icon; +// +// public Icon getIcon () { +// if (icon == null) +// icon = new ImageIcon ( +// Utilities.loadImage +// ("org/netbeans/modules/options/resources/generalOptions.png") +// ); +// return icon; +// } +// +// public String getCategoryName () { +// return loc ("CTL_General_Options"); +// } +// +// public String getTitle () { +// return loc ("CTL_General_Options_Title"); +// } +// +// public String getDescription () { +// return loc ("CTL_General_Options_Description"); +// } +// +// public OptionsPanelController create () { +// return new GeneralOptionsPanelController (); +// } } diff -r c9a896e042ec core.ui/src/org/netbeans/core/ui/resources/layer.xml --- a/core.ui/src/org/netbeans/core/ui/resources/layer.xml Wed Jul 09 07:04:51 2008 +0200 +++ b/core.ui/src/org/netbeans/core/ui/resources/layer.xml Thu Jul 10 16:35:15 2008 +0200 @@ -40,7 +40,7 @@ Version 2 license, then the option applies only if the new code is made subject to such option by the copyright holder. --> - + @@ -51,7 +51,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -95,38 +95,38 @@ - + - + - - - + + + - + - + - + - - + + - - + + @@ -200,7 +200,7 @@ - + @@ -208,9 +208,9 @@ - + - + @@ -223,7 +223,7 @@ - + @@ -240,8 +240,8 @@ - - + + @@ -260,13 +260,13 @@ - + - + - - + - + - + - - - + + + - + @@ -336,7 +336,7 @@ - + @@ -344,9 +344,9 @@ - + - + @@ -359,24 +359,24 @@ - + - + - + - + @@ -385,29 +385,29 @@ --> - + - + - + - + - + - + - + - + @@ -416,14 +416,14 @@ - + - + - - + + @@ -482,12 +482,12 @@ - + - - + + @@ -558,7 +558,7 @@ - + @@ -614,12 +614,12 @@ - + - - + + @@ -682,17 +682,28 @@ - + - + - + + + + + + + + + + + + - + diff -r c9a896e042ec java.editor/src/org/netbeans/modules/java/editor/options/Bundle.properties --- a/java.editor/src/org/netbeans/modules/java/editor/options/Bundle.properties Wed Jul 09 07:04:51 2008 +0200 +++ b/java.editor/src/org/netbeans/modules/java/editor/options/Bundle.properties Thu Jul 10 16:35:15 2008 +0200 @@ -38,6 +38,8 @@ # made subject to such option by the copyright holder. OPTIONS_java=Java Editor + +KW_Mark=Mark Occurrences PROP_completionCaseSensitive=Case Sensitive Code Completion HINT_completionCaseSensitive=If True, the completion query search will be case sensitive diff -r c9a896e042ec java.editor/src/org/netbeans/modules/java/editor/options/MarkOccurencesOptionsPanelController.java --- a/java.editor/src/org/netbeans/modules/java/editor/options/MarkOccurencesOptionsPanelController.java Wed Jul 09 07:04:51 2008 +0200 +++ b/java.editor/src/org/netbeans/modules/java/editor/options/MarkOccurencesOptionsPanelController.java Thu Jul 10 16:35:15 2008 +0200 @@ -42,12 +42,18 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; import java.util.prefs.Preferences; import javax.swing.JComponent; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.HelpCtx; import org.openide.util.Lookup; -import org.openide.util.NbPreferences; +import org.openide.util.NbBundle; final class MarkOccurencesOptionsPanelController extends OptionsPanelController { @@ -104,5 +110,14 @@ } pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); } - + + @Override + public Map> getKeywordsByCategory() { + String keywords = NbBundle.getMessage(MarkOccurencesOptionsPanelController.class, "KW_Mark"); + HashMap result = new HashMap(); + result.put("JavaOptions/MarkOccurences", new HashSet(Collections.list(new StringTokenizer(keywords, ",")))); //NOI18N + return result; + } + } + diff -r c9a896e042ec java.hints/src/org/netbeans/modules/java/hints/options/Bundle.properties --- a/java.hints/src/org/netbeans/modules/java/hints/options/Bundle.properties Wed Jul 09 07:04:51 2008 +0200 +++ b/java.hints/src/org/netbeans/modules/java/hints/options/Bundle.properties Thu Jul 10 16:35:15 2008 +0200 @@ -14,3 +14,5 @@ HintsPanel.errorTree.AccessibleContext.accessibleDescription=Hints HintsPanel.AccessibleContext.accessibleName=Hints Options HintsPanel.AccessibleContext.accessibleDescription=Hints Options +KW_Hints=Hints,Fixes,Suggestions,Javadoc Hints,Warnings + diff -r c9a896e042ec java.hints/src/org/netbeans/modules/java/hints/options/HintsOptionsPanelController.java --- a/java.hints/src/org/netbeans/modules/java/hints/options/HintsOptionsPanelController.java Wed Jul 09 07:04:51 2008 +0200 +++ b/java.hints/src/org/netbeans/modules/java/hints/options/HintsOptionsPanelController.java Thu Jul 10 16:35:15 2008 +0200 @@ -42,10 +42,17 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; import javax.swing.JComponent; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.HelpCtx; import org.openide.util.Lookup; +import org.openide.util.NbBundle; final class HintsOptionsPanelController extends OptionsPanelController { @@ -103,4 +110,11 @@ pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); } + @Override + public Map> getKeywordsByCategory() { + String keywords = NbBundle.getMessage(HintsOptionsPanelController.class, "KW_Hints"); + HashMap result = new HashMap(); + result.put("JavaOptions/Hints", new HashSet(Collections.list(new StringTokenizer(keywords, ",")))); //NOI18N + return result; + } } diff -r c9a896e042ec java.source/src/org/netbeans/modules/java/source/tasklist/Bundle.properties --- a/java.source/src/org/netbeans/modules/java/source/tasklist/Bundle.properties Wed Jul 09 07:04:51 2008 +0200 +++ b/java.source/src/org/netbeans/modules/java/source/tasklist/Bundle.properties Thu Jul 10 16:35:15 2008 +0200 @@ -43,6 +43,8 @@ jCheckBox2.text=Enable &Dependencies in Java Tasklist jCheckBox1.text_1=Enable &Error Badges on Files +KW_TaskList=Error Badges,Tasklist + DN_Tasklist=Tasklist TP_Tasklist=Java Tasklist Settings enableLint.text=Enable Compiler &Warnings diff -r c9a896e042ec java.source/src/org/netbeans/modules/java/source/tasklist/TasklistOptions.java --- a/java.source/src/org/netbeans/modules/java/source/tasklist/TasklistOptions.java Wed Jul 09 07:04:51 2008 +0200 +++ b/java.source/src/org/netbeans/modules/java/source/tasklist/TasklistOptions.java Thu Jul 10 16:35:15 2008 +0200 @@ -42,6 +42,12 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; import javax.swing.JComponent; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; @@ -145,5 +151,12 @@ pcs.firePropertyChange(PROP_CHANGED, null, null); } + @Override + public Map> getKeywordsByCategory() { + String keywords = NbBundle.getMessage(TasklistOptions.class, "KW_TaskList"); + HashMap result = new HashMap(); + result.put("JavaOptions/Tasklist", new HashSet(Collections.list(new StringTokenizer(keywords, ",")))); //NOI18N + return result; + } } } diff -r c9a896e042ec java.source/src/org/netbeans/modules/java/ui/Bundle.properties --- a/java.source/src/org/netbeans/modules/java/ui/Bundle.properties Wed Jul 09 07:04:51 2008 +0200 +++ b/java.source/src/org/netbeans/modules/java/ui/Bundle.properties Thu Jul 10 16:35:15 2008 +0200 @@ -39,6 +39,8 @@ OptionsCategory_Name=Java Code OptionsCategory_Title=Java Code + +KW_Formatting=Formatting,Indentation,Spaces,Alignment,Blank Lines,Braces CTL_Formating_DisplayName=Formatting CTL_Formating_ToolTip=Java Code Formatting Options diff -r c9a896e042ec java.source/src/org/netbeans/modules/java/ui/FormatingOptionsPanelController.java --- a/java.source/src/org/netbeans/modules/java/ui/FormatingOptionsPanelController.java Wed Jul 09 07:04:51 2008 +0200 +++ b/java.source/src/org/netbeans/modules/java/ui/FormatingOptionsPanelController.java Thu Jul 10 16:35:15 2008 +0200 @@ -42,6 +42,12 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; import javax.swing.JComponent; @@ -49,6 +55,7 @@ import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.HelpCtx; import org.openide.util.Lookup; +import org.openide.util.NbBundle; final class FormatingOptionsPanelController extends OptionsPanelController { @@ -57,7 +64,15 @@ private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); private boolean changed; - + + @Override + public Map> getKeywordsByCategory() { + String keywords = NbBundle.getMessage(FormatingOptionsPanelController.class, "KW_Formatting"); + HashMap result = new HashMap(); + result.put("JavaOptions/Formatting", new HashSet(Collections.list(new StringTokenizer(keywords, ",")))); //NOI18N + return result; + } + public void update() { changed = false; panel.load(null); diff -r c9a896e042ec java.source/src/org/netbeans/modules/java/ui/JavaOptionsPanelController.java --- a/java.source/src/org/netbeans/modules/java/ui/JavaOptionsPanelController.java Wed Jul 09 07:04:51 2008 +0200 +++ b/java.source/src/org/netbeans/modules/java/ui/JavaOptionsPanelController.java Thu Jul 10 16:35:15 2008 +0200 @@ -49,6 +49,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import javax.swing.JComponent; import javax.swing.JTabbedPane; import org.netbeans.spi.options.AdvancedOption; @@ -76,7 +77,20 @@ public JavaOptionsPanelController() { readPanels(); } - + + private Map> keywords = null; + + @Override + public Map> getKeywordsByCategory() { + if (keywords==null) { + keywords = new HashMap>(); + for (OptionsPanelController controller:getControllers()) { + keywords.putAll(controller.getKeywordsByCategory()); + } + } + return keywords; + } + public void update() { for (OptionsPanelController c : getControllers()) { c.update(); diff -r c9a896e042ec options.api/apichanges.xml --- a/options.api/apichanges.xml Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/apichanges.xml Thu Jul 10 16:35:15 2008 +0200 @@ -72,6 +72,20 @@ + + + Support for searchable options + + + + + + Added new method OptionsPanelController.getKeywordsByCategory + + + + + API to open the options dialog with some subcategory pre-selected diff -r c9a896e042ec options.api/nbproject/project.xml --- a/options.api/nbproject/project.xml Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/nbproject/project.xml Thu Jul 10 16:35:15 2008 +0200 @@ -47,19 +47,11 @@ org.netbeans.modules.options.api - org.openide.filesystems + org.netbeans.spi.quicksearch - 6.2 - - - - org.openide.util - - - - 6.2 + 1.0 @@ -72,6 +64,22 @@ org.openide.dialogs + + + + 6.2 + + + + org.openide.filesystems + + + + 6.2 + + + + org.openide.util diff -r c9a896e042ec options.api/src/org/netbeans/modules/options/Bundle.properties --- a/options.api/src/org/netbeans/modules/options/Bundle.properties Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/Bundle.properties Thu Jul 10 16:35:15 2008 +0200 @@ -67,3 +67,5 @@ ACS_OKButton=OK ACS_ClassicButton= Invokes Advanced Options dialog ACS_OptionsPanel=Options Dialog + +QuickSearch/GoToOption=Options diff -r c9a896e042ec options.api/src/org/netbeans/modules/options/CategoryModel.java --- a/options.api/src/org/netbeans/modules/options/CategoryModel.java Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/CategoryModel.java Thu Jul 10 16:35:15 2008 +0200 @@ -69,13 +69,18 @@ */ public final class CategoryModel implements LookupListener { private static Reference INSTANCE = new WeakReference(new CategoryModel()); - private final RequestProcessor RP = new RequestProcessor(); + private final RequestProcessor RP = new RequestProcessor(); private static String currentCategoryID = null; - private String highlitedCategoryID = null; + private String highlitedCategoryID = null; private boolean categoriesValid = true; - private final Map id2Category = + private final Map id2Category = Collections.synchronizedMap(new LinkedHashMap()); private MasterLookup masterLookup; + + Set> getCategories() { + return id2Category.entrySet(); + } + private final RequestProcessor.Task masterLookupTask = RP.create(new Runnable() { public void run() { String[] categoryIDs = getCategoryIDs(); @@ -93,7 +98,7 @@ },true); private final RequestProcessor.Task categoryTask = RP.create(new Runnable() { public void run() { - Map all = loadOptionsCategories(); + Map all = loadOptionsCategories(); Map temp = new LinkedHashMap(); for (Iterator> it = all.entrySet().iterator(); it.hasNext();) { Map.Entry entry = it.next(); @@ -107,11 +112,11 @@ masterLookupTask.schedule(0); } },true); - + private CategoryModel() { categoryTask.schedule(0); } - + public static CategoryModel getInstance() { CategoryModel retval = INSTANCE.get(); if (retval == null) { @@ -120,39 +125,39 @@ } return retval; } - + boolean needsReinit() { synchronized(CategoryModel.class) { return !categoriesValid; - } + } } - + boolean isInitialized() { return categoryTask.isFinished(); } - + boolean isLookupInitialized() { return masterLookupTask.isFinished(); } - - + + void waitForInitialization() { categoryTask.waitFinished(); } - + public String getCurrentCategoryID() { return verifyCategoryID(currentCategoryID); } - + public void setCurrentCategoryID(String categoryID) { currentCategoryID = verifyCategoryID(categoryID); } - + String getHighlitedCategoryID() { return verifyCategoryID(highlitedCategoryID); } - + private String verifyCategoryID(String categoryID) { String retval = findCurrentCategoryID(categoryID) != -1 ? categoryID : null; if (retval == null) { @@ -163,22 +168,22 @@ } return retval; } - + private int findCurrentCategoryID(String categoryID) { return categoryID == null ? -1 : Arrays.asList(getCategoryIDs()).indexOf(categoryID); } - + public String[] getCategoryIDs() { categoryTask.waitFinished(); - Set keys = id2Category.keySet(); + Set keys = id2Category.keySet(); return keys.toArray(new String[keys.size()]); } - + Category getCurrent() { String categoryID = getCurrentCategoryID(); return (categoryID == null) ? null : getCategory(categoryID); } - + void setCurrent(Category item) { item.setCurrent(); } @@ -186,12 +191,12 @@ void setHighlited(Category item,boolean highlited) { item.setHighlited(highlited); } - + HelpCtx getHelpCtx() { final CategoryModel.Category category = getCurrent(); return (category == null) ? null : category.getHelpCtx(); } - + void update(PropertyChangeListener l, boolean force) { String[] categoryIDs = getCategoryIDs(); for (int i = 0; i < categoryIDs.length; i++) { @@ -199,7 +204,7 @@ item.update(l, force); } } - + void save() { String[] categoryIDs = getCategoryIDs(); for (int i = 0; i < categoryIDs.length; i++) { @@ -207,7 +212,7 @@ item.applyChanges(); } } - + void cancel() { String[] categoryIDs = getCategoryIDs(); for (int i = 0; i < categoryIDs.length; i++) { @@ -215,7 +220,7 @@ item.cancel(); } } - + boolean dataValid() { boolean retval = true; String[] categoryIDs = getCategoryIDs(); @@ -225,7 +230,7 @@ } return retval; } - + boolean isChanged() { boolean retval = false; String[] categoryIDs = getCategoryIDs(); @@ -235,8 +240,8 @@ } return retval; } - - + + Category getNextCategory() { int idx = findCurrentCategoryID(getCurrentCategoryID()); String[] categoryIDs = getCategoryIDs(); @@ -252,7 +257,7 @@ } return nextId != null ? getCategory(nextId) : null; } - + Category getPreviousCategory() { int idx = findCurrentCategoryID(getCurrentCategoryID()); String[] categoryIDs = getCategoryIDs(); @@ -268,20 +273,20 @@ } return previousId != null ? getCategory(previousId) : null; } - - + + Category getCategory(String categoryID) { categoryTask.waitFinished(); return id2Category.get(categoryID); } - + private MasterLookup getMasterLookup() { if (masterLookup == null) { masterLookup = new MasterLookup(); } return masterLookup; } - + private Map loadOptionsCategories() { Lookup lookup = Lookups.forPath("OptionsDialog"); // NOI18N Lookup.Result result = lookup.lookup(new Lookup.Template(OptionsCategory.class)); @@ -296,12 +301,12 @@ public void resultChanged(LookupEvent ev) { synchronized(CategoryModel.class) { - categoriesValid = false; + categoriesValid = false; OptionsDisplayerImpl.lookupListener.resultChanged(ev); INSTANCE = new WeakReference(new CategoryModel()); } } - + final class Category { private OptionsCategory category; private OptionsPanelController controller; @@ -310,20 +315,20 @@ private JComponent component; private Lookup lookup; private final String id; - + private Category(final String id, final OptionsCategory category) { this.category = category; this.id = id; } - + boolean isCurrent() { return getID().equals(getCurrentCategoryID()); } - + boolean isHighlited() { return getID().equals(getHighlitedCategoryID()); } - + private void setCurrent() { setCurrentCategoryID(getID()); } @@ -331,7 +336,7 @@ public void setCurrentSubcategory(String subpath) { OptionsPanelControllerAccessor.getDefault().setCurrentSubcategory(create(), subpath); } - + private void setHighlited(boolean highlited) { if (highlited) { highlitedCategoryID = getID(); @@ -339,7 +344,7 @@ highlitedCategoryID = currentCategoryID; } } - + public Icon getIcon() { return category.getIcon(); } @@ -349,22 +354,32 @@ public String getID() { return id; } - + public String getCategoryName() { return category.getCategoryName(); } - + public String getTitle() { return category.getTitle(); } - + private synchronized OptionsPanelController create() { if (controller == null) { controller = category.create(); } return controller; } - + + public Map> getKeywords() { + if(category != null) + return category.getKeywordsByCategory(); + + //XXX remove after all has been rewritten to declarative + //previous non-declarative version + return create().getKeywordsByCategory(); + + } + final void update(PropertyChangeListener l, boolean forceUpdate) { if ((!isUpdated && !forceUpdate) || (isUpdated && forceUpdate)) { isUpdated = true; @@ -375,21 +390,21 @@ } } } - + private void applyChanges() { if (isUpdated) { create().applyChanges(); } isUpdated = false; } - + private void cancel() { if (isUpdated) { create().cancel(); } isUpdated = false; } - + private boolean isValid() { boolean retval = true; if (isUpdated) { @@ -397,7 +412,7 @@ } return retval; } - + private boolean isChanged() { boolean retval = false; if (isUpdated) { @@ -405,19 +420,19 @@ } return retval; } - + public JComponent getComponent() { if (component == null) { component = create().getComponent(getMasterLookup()); } return component; } - + private HelpCtx getHelpCtx() { return create().getHelpCtx(); } - - + + private Lookup getLookup() { if (lookup == null) { lookup = create().getLookup(); @@ -425,7 +440,7 @@ return lookup; } } - + private class MasterLookup extends ProxyLookup { private void setLookups(List lookups) { setLookups(lookups.toArray(new Lookup[lookups.size()])); diff -r c9a896e042ec options.api/src/org/netbeans/modules/options/QuickSearchProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/options.api/src/org/netbeans/modules/options/QuickSearchProvider.java Thu Jul 10 16:35:15 2008 +0200 @@ -0,0 +1,83 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.options; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.netbeans.api.options.OptionsDisplayer; +import org.netbeans.spi.quicksearch.SearchProvider; +import org.netbeans.spi.quicksearch.SearchRequest; +import org.netbeans.spi.quicksearch.SearchResponse; + +/** + * + * @author Jan Becicka + */ +public class QuickSearchProvider implements SearchProvider { + + public void evaluate(SearchRequest request, SearchResponse response) { + for (Map.Entry entry : CategoryModel.getInstance().getCategories()) { + for (Map.Entry> kw : entry.getValue().getKeywords().entrySet()) { + for (String keyword : kw.getValue()) { + if (keyword.toLowerCase().indexOf(request.getText().toLowerCase()) > -1) { + if (!response.addResult(new OpenOption(kw.getKey()), keyword)) { + return; + } + } + } + } + } + } + + private class OpenOption implements Runnable { + + private String path; + + OpenOption(String path) { + this.path = path; + } + + public void run() { + OptionsDisplayer.getDefault().open(path); + } + + } +} \ No newline at end of file diff -r c9a896e042ec options.api/src/org/netbeans/modules/options/advanced/Advanced.java --- a/options.api/src/org/netbeans/modules/options/advanced/Advanced.java Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/advanced/Advanced.java Thu Jul 10 16:35:15 2008 +0200 @@ -59,39 +59,42 @@ public final class Advanced extends OptionsCategory { private OptionsPanelController controller; - + private static String loc (String key) { return NbBundle.getMessage (Advanced.class, key); } private static Icon icon; - + @Override public Icon getIcon () { if (icon == null) icon = new ImageIcon ( - Utilities.loadImage + Utilities.loadImage ("org/netbeans/modules/options/resources/advanced.png") ); return icon; } - + + @Override public String getCategoryName () { return loc ("CTL_Advanced_Options"); } + @Override public String getTitle () { return loc ("CTL_Advanced_Options_Title"); } - + public String getDescription () { return loc ("CTL_Advanced_Options_Description"); } + @Override public OptionsPanelController create () { if (controller == null) { controller = new AdvancedPanelController(OptionsDisplayer.ADVANCED); } return controller; - } + } } diff -r c9a896e042ec options.api/src/org/netbeans/modules/options/advanced/AdvancedPanel.java --- a/options.api/src/org/netbeans/modules/options/advanced/AdvancedPanel.java Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/advanced/AdvancedPanel.java Thu Jul 10 16:35:15 2008 +0200 @@ -86,6 +86,10 @@ AdvancedPanel(String subpath) { this.subpath = subpath; this.model = new Model(subpath, listener); + } + + public Model getModel() { + return model; } public void update () { diff -r c9a896e042ec options.api/src/org/netbeans/modules/options/advanced/AdvancedPanelController.java --- a/options.api/src/org/netbeans/modules/options/advanced/AdvancedPanelController.java Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/advanced/AdvancedPanelController.java Thu Jul 10 16:35:15 2008 +0200 @@ -42,7 +42,12 @@ package org.netbeans.modules.options.advanced; import java.beans.PropertyChangeListener; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import javax.swing.JComponent; +import org.netbeans.spi.options.AdvancedOption; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.HelpCtx; import org.openide.util.Lookup; @@ -58,8 +63,8 @@ private String subpath = null; /* Creates new AdvancedPanelController. - * @param subpath path to folder under OptionsDialog folder containing - * instances of AdvancedOption class. Path is composed from registration + * @param subpath path to folder under OptionsDialog folder containing + * instances of AdvancedOption class. Path is composed from registration * names divided by slash. */ public AdvancedPanelController(String subpath) { @@ -73,38 +78,38 @@ public void applyChanges () { getAdvancedPanel ().applyChanges (); } - + public void cancel () { getAdvancedPanel ().cancel (); } - + public boolean isValid () { return getAdvancedPanel ().dataValid (); } - + public boolean isChanged () { return getAdvancedPanel ().isChanged (); } - + @Override public Lookup getLookup () { return getAdvancedPanel ().getLookup (); } - + public JComponent getComponent (Lookup masterLookup) { getAdvancedPanel ().init (masterLookup); return getAdvancedPanel (); } - + @Override public void setCurrentSubcategory(String subpath) { getAdvancedPanel().setCurrentSubcategory(subpath); } - + public HelpCtx getHelpCtx () { return getAdvancedPanel ().getHelpCtx (); } - + public void addPropertyChangeListener (PropertyChangeListener l) { getAdvancedPanel().addModelPropertyChangeListener(l); } @@ -114,10 +119,29 @@ } private AdvancedPanel advancedPanel; - + private AdvancedPanel getAdvancedPanel () { if (advancedPanel == null) advancedPanel = new AdvancedPanel(subpath); return advancedPanel; } + + private Map> keywords = null; + + @Override + public Map> getKeywordsByCategory() { + if (keywords == null) { + keywords = new HashMap>(); + + for (Entry entry : getAdvancedPanel().getModel().getCategoryToOption().entrySet()) { + keywords.putAll(entry.getValue().getKeywordsByCategory()); + } + + //XXX remove; obsolete non-declarative version +// for (Entry entry : getAdvancedPanel().getModel().getCategoryToController().entrySet()) { +// keywords.putAll(entry.getValue().getKeywordsByCategory()); +// } + } + return keywords; + } } diff -r c9a896e042ec options.api/src/org/netbeans/modules/options/advanced/Model.java --- a/options.api/src/org/netbeans/modules/options/advanced/Model.java Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/advanced/Model.java Thu Jul 10 16:35:15 2008 +0200 @@ -50,6 +50,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import javax.swing.JComponent; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; @@ -133,15 +135,41 @@ public OptionsPanelController getController(String categoryID) { return categoryToController.get(getDisplayName(categoryID)); } - + + +// private boolean init = false; +// public Map getCategoryToController() { +// init(); +// if (!init) { +// for ( Entry entry: categoryToOption.entrySet()) { +// if (categoryToController.get(entry.getKey())==null) +// categoryToController.put (entry.getKey(), entry.getValue().create()); +// } +// init=true; +// } +// +// return categoryToController; +// } + + public Map getCategoryToOption() { + init(); + return categoryToOption; + } + public JComponent getPanel (String category) { init (); JComponent panel = categoryToPanel.get (category); if (panel != null) return panel; AdvancedOption option = categoryToOption.get (category); - OptionsPanelController controller = new DelegatingController(option.create ()); +// OptionsPanelController controller = new DelegatingController(option.create ()); + OptionsPanelController controller = categoryToController.get(category); + if (controller==null) { + controller = new DelegatingController(option.create ()); + categoryToController.put (category, controller); + } + controller.addPropertyChangeListener(propertyChangeListener); - categoryToController.put (category, controller); +// categoryToController.put (category, controller); panel = controller.getComponent (masterLookup); categoryToPanel.put (category, panel); Border b = panel.getBorder (); @@ -306,7 +334,12 @@ public void removePropertyChangeListener(PropertyChangeListener l) { delegate.removePropertyChangeListener(l); - } + } + + @Override + public Map> getKeywordsByCategory() { + return delegate.getKeywordsByCategory(); + } } } diff -r c9a896e042ec options.api/src/org/netbeans/modules/options/resources/mf-layer.xml --- a/options.api/src/org/netbeans/modules/options/resources/mf-layer.xml Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/modules/options/resources/mf-layer.xml Thu Jul 10 16:35:15 2008 +0200 @@ -69,4 +69,15 @@ + + + + + + + + + + + diff -r c9a896e042ec options.api/src/org/netbeans/spi/options/AdvancedOption.java --- a/options.api/src/org/netbeans/spi/options/AdvancedOption.java Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/spi/options/AdvancedOption.java Thu Jul 10 16:35:15 2008 +0200 @@ -41,6 +41,15 @@ package org.netbeans.spi.options; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; + /** * Implementation of this class represents one category (like "Ant" * or "Form Editor") in Miscellaneous Panel of Options Dialog. It should @@ -60,24 +69,60 @@ * @see OptionsCategory * @see OptionsPanelController * @author Jan Jancura + * @author Max Sauer */ -public abstract class AdvancedOption { - +public class AdvancedOption { + + //xml entry names + private static final String DISPLAYNAME = "displayName"; + private static final String TOOLTIP = "tooltip"; + private static final String KEYWORDS = "keywords"; + private static final String CONTROLLER_CLASSNAME = "controllerClassname"; + private static Object KEYWORDS_CATEGORY = "keywordsCategory"; + + private String displayName; + private String tooltip; + private String keywords; + private String controllerClassname; + private String keywordsCategory; + + private AdvancedOption(String controllerclassname, String displayName, String tooltip, String keywords, String keywordsCategory) { + this.controllerClassname = controllerclassname; + this.displayName = displayName; + this.tooltip = tooltip; + this.keywords = keywords; + this.keywordsCategory = keywordsCategory; + } + + public AdvancedOption() { + } + /** * Returns name of category used in Advanced Panel of * Options Dialog. * * @return name of category */ - public abstract String getDisplayName (); + public String getDisplayName () { + return displayName; + } /** * Returns tooltip to be used on category name. * * @return tooltip for this category */ - public abstract String getTooltip (); - + public String getTooltip () { + return tooltip; + } + + public Map> getKeywordsByCategory() { + HashMap> result = new HashMap>(); + if(keywordsCategory != null && keywords != null) + result.put(keywordsCategory, new HashSet(Collections.list(new StringTokenizer(keywords, ",")))); //NOI18N + return result; + } + /** * Returns {@link OptionsPanelController} for this category. PanelController * creates visual component to be used inside of Advanced Panel. @@ -85,6 +130,32 @@ * @return new instance of {@link OptionsPanelController} for this advanced options * category */ - public abstract OptionsPanelController create (); + public OptionsPanelController create() { + OptionsPanelController controller = null; + + try { + Class controllerClass = null; + controllerClass = Lookup.getDefault().lookup(ClassLoader.class).loadClass(controllerClassname); + controller = (OptionsPanelController) controllerClass.newInstance(); + } catch (ClassNotFoundException ex) { + Exceptions.printStackTrace(ex); + } catch (InstantiationException ex) { + Exceptions.printStackTrace(ex); + } catch (IllegalAccessException ex) { + Exceptions.printStackTrace(ex); + } + + return controller; + } + + static AdvancedOption createSubCategory(Map attrs) { + String displayName = attrs.get(DISPLAYNAME); + String tooltip = attrs.get(TOOLTIP); + String keywords = attrs.get(KEYWORDS); + String controllerClassname = attrs.get(CONTROLLER_CLASSNAME); + String keywordsCategory = attrs.get(KEYWORDS_CATEGORY); + + return new AdvancedOption(controllerClassname, displayName, tooltip, keywords, keywordsCategory); + } } diff -r c9a896e042ec options.api/src/org/netbeans/spi/options/OptionsCategory.java --- a/options.api/src/org/netbeans/spi/options/OptionsCategory.java Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/spi/options/OptionsCategory.java Thu Jul 10 16:35:15 2008 +0200 @@ -42,10 +42,20 @@ package org.netbeans.spi.options; import java.awt.Image; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; import javax.swing.Icon; import javax.swing.ImageIcon; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; import org.openide.util.Utilities; + +//TODO: update the comment /** * Implementation of this class represents one category (like "Fonts & Colors" * or "Editor") in Options Dialog. It should be registerred in layers: @@ -58,69 +68,154 @@ * </folder> * * Use standard way how to sort items registered in layers: - * + * *
  * <attr name="GeneralPanel.instance/FooOptionsPanel.instance" boolvalue="true"/>
  * 
* * @see AdvancedOption - * @see OptionsPanelController + * @see OptionsPanelController * * @author Jan Jancura + * @author Max Sauer */ -public abstract class OptionsCategory { - +public class OptionsCategory { + + //xml entry names + private static final String TITLE = "title"; + private static final String CATEGORY_NAME = "categoryName"; + private static final String ICON = "iconBase"; + private static final String CONTROLLER_CLASSNAME = "controllerClassname"; + private static final String DESCRIPTION = "description"; + private static final String KEYWORDS = "keywords"; + private static Object KEYWORDS_CATEGORY = "keywordsCategory"; + + //category fields + private String title; + private String categoryName; + private String iconBase; + private ImageIcon icon; + private String controllerClassname; + private String description; + private String keywords; + private String keywordsCategory; + + public OptionsCategory() { + + } + + private OptionsCategory(String title, String categoryName, String iconBase, String controllerClassname, String description, String keywords, String keywordsCategory) { + this.title = title; + this.categoryName = categoryName; + this.iconBase = iconBase; + this.controllerClassname = controllerClassname; + this.description = description; + this.keywords = keywords; + this.keywordsCategory = keywordsCategory; + } + /** - * Returns base name of 32x32 icon (gif, png) used in list on the left side of - * Options Dialog. See {@link AbstractNode#setIconBase} method for more info. - * - * @deprecated This method will not be a part of NB50! Use - * {@link #getIcon} instead. - * @return base name of 32x32 icon - */ - public String getIconBase () { - return null; - } - - /** - * Returns 32x32 icon used in list on the left side of + * Returns 32x32 icon used in list on the top of * Options Dialog. * * @return 32x32 icon */ - public Icon getIcon () { - Image image = Utilities.loadImage (getIconBase () + ".png"); - if (image != null) return new ImageIcon (image); - image = Utilities.loadImage (getIconBase () + ".gif"); - if (image == null) return null; - return new ImageIcon (image); + public Icon getIcon() { + if (icon == null) { + Image image = Utilities.loadImage(iconBase); + if (image != null) { + return new ImageIcon(image); + } + image = Utilities.loadImage(iconBase + ".png"); + if (image != null) { + return new ImageIcon(image); + } + image = Utilities.loadImage(iconBase + ".gif"); + if (image == null) { + return null; + } + icon = new ImageIcon(image); + } + return icon; } - + /** - * Returns name of category used in list on the left side of + * Returns name of category used in list on the top side of * Options Dialog. * * @return name of category */ - public abstract String getCategoryName (); - + public String getCategoryName () { + return categoryName; + } + /** * This text will be used in title component on the top of Options Dialog * when your panel will be selected. * * @return title of this panel */ - public abstract String getTitle (); - + public String getTitle () { + return title; + } + + public String getDescription() { + return description; + } + + public Map> getKeywordsByCategory() { + HashMap> result = new HashMap>(); + if(keywordsCategory != null && keywords != null) + result.put(keywordsCategory, new HashSet(Collections.list(new StringTokenizer(keywords, ",")))); //NOI18N + return result; + } + /** - * Returns new {@link OptionsPanelController} for this category. PanelController + * Returns new {@link OptionsPanelController} for this category. PanelController * creates visual component to be used inside of the Options Dialog. - * You should not do any time-consuming operations inside - * the constructor, because it blocks initialization of OptionsDialog. + * You should not do any time-consuming operations inside + * the constructor, because it blocks initialization of OptionsDialog. * Initialization should be implemented in update method. * * @return new instance of PanelController for this options category */ - public abstract OptionsPanelController create (); - + public OptionsPanelController create() { + OptionsPanelController controller = null; + + try { + Class controllerClass = null; + controllerClass = Lookup.getDefault().lookup(ClassLoader.class).loadClass(controllerClassname); + controller = (OptionsPanelController) controllerClass.newInstance(); + } catch (ClassNotFoundException ex) { + Exceptions.printStackTrace(ex); + } catch (InstantiationException ex) { + Exceptions.printStackTrace(ex); + } catch (IllegalAccessException ex) { + Exceptions.printStackTrace(ex); + } + + return controller; + + } + + /** + * Creates instance of OptionsCategory based on layer.xml + * attribute values + * + * @param attrs attributes loaded from layer.xml + * @return new OptionsCategory instance + */ + static OptionsCategory createCategory(Map attrs) { + String title = attrs.get(TITLE); + String categoryName = attrs.get(CATEGORY_NAME); + String iconBase = attrs.get(ICON); + String controllerClassName = attrs.get(CONTROLLER_CLASSNAME); + String description = attrs.get(DESCRIPTION); + String keywords = attrs.get(KEYWORDS); + String keywordsCategory = attrs.get(KEYWORDS_CATEGORY); + + return new OptionsCategory(title, categoryName, iconBase, controllerClassName, description, keywords, keywordsCategory); + } + + } diff -r c9a896e042ec options.api/src/org/netbeans/spi/options/OptionsPanelController.java --- a/options.api/src/org/netbeans/spi/options/OptionsPanelController.java Wed Jul 09 07:04:51 2008 +0200 +++ b/options.api/src/org/netbeans/spi/options/OptionsPanelController.java Thu Jul 10 16:35:15 2008 +0200 @@ -41,6 +41,9 @@ package org.netbeans.spi.options; import java.beans.PropertyChangeListener; +import java.util.Collections; +import java.util.Map; +import java.util.Set; import javax.swing.JComponent; import org.netbeans.modules.options.OptionsPanelControllerAccessor; import org.netbeans.modules.options.advanced.AdvancedPanelController; @@ -210,4 +213,12 @@ * @param l a listener to be removed */ public abstract void removePropertyChangeListener (PropertyChangeListener l); + + /** + * Set of keywords related to this panel + * @return Map) + */ + public Map> getKeywordsByCategory() { + return Collections.EMPTY_MAP; + } } diff -r c9a896e042ec tasklist.todo/src/org/netbeans/modules/tasklist/todo/layer.xml --- a/tasklist.todo/src/org/netbeans/modules/tasklist/todo/layer.xml Wed Jul 09 07:04:51 2008 +0200 +++ b/tasklist.todo/src/org/netbeans/modules/tasklist/todo/layer.xml Thu Jul 10 16:35:15 2008 +0200 @@ -30,7 +30,16 @@ + + + + + + + + diff -r c9a896e042ec tasklist.todo/src/org/netbeans/modules/tasklist/todo/settings/Bundle.properties --- a/tasklist.todo/src/org/netbeans/modules/tasklist/todo/settings/Bundle.properties Wed Jul 09 07:04:51 2008 +0200 +++ b/tasklist.todo/src/org/netbeans/modules/tasklist/todo/settings/Bundle.properties Thu Jul 10 16:35:15 2008 +0200 @@ -9,4 +9,6 @@ ToDoCustomizer.btnChange.text=&Edit LBL_Options=ToDo Tasks -HINT_Options=Options for ToDo tasks in Task List window. \ No newline at end of file +HINT_Options=Options for ToDo tasks in Task List window. + +KW_ToDo=ToDo,@todo,FIXME,PENDING diff -r c9a896e042ec tasklist.todo/src/org/netbeans/modules/tasklist/todo/settings/ToDoOptions.java --- a/tasklist.todo/src/org/netbeans/modules/tasklist/todo/settings/ToDoOptions.java Wed Jul 09 07:04:51 2008 +0200 +++ b/tasklist.todo/src/org/netbeans/modules/tasklist/todo/settings/ToDoOptions.java Thu Jul 10 16:35:15 2008 +0200 @@ -49,18 +49,18 @@ * * @author S. Aubrecht */ -public class ToDoOptions extends AdvancedOption { +public class ToDoOptions /*extends AdvancedOption*/ { - public String getDisplayName() { - return NbBundle.getMessage( ToDoOptions.class, "LBL_Options" ); //NOI18N - } - - public String getTooltip() { - return NbBundle.getMessage( ToDoOptions.class, "HINT_Options" ); //NOI18N - } - - public OptionsPanelController create() { - return new ToDoOptionsController(); - } +// public String getDisplayName() { +// return NbBundle.getMessage( ToDoOptions.class, "LBL_Options" ); //NOI18N +// } +// +// public String getTooltip() { +// return NbBundle.getMessage( ToDoOptions.class, "HINT_Options" ); //NOI18N +// } +// +// public OptionsPanelController create() { +// return new ToDoOptionsController(); +// } } diff -r c9a896e042ec tasklist.todo/src/org/netbeans/modules/tasklist/todo/settings/ToDoOptionsController.java --- a/tasklist.todo/src/org/netbeans/modules/tasklist/todo/settings/ToDoOptionsController.java Wed Jul 09 07:04:51 2008 +0200 +++ b/tasklist.todo/src/org/netbeans/modules/tasklist/todo/settings/ToDoOptionsController.java Thu Jul 10 16:35:15 2008 +0200 @@ -42,10 +42,17 @@ package org.netbeans.modules.tasklist.todo.settings; import java.beans.PropertyChangeListener; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; import javax.swing.JComponent; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.HelpCtx; import org.openide.util.Lookup; +import org.openide.util.NbBundle; /** * @@ -97,4 +104,13 @@ } return customizer; } + + @Override + public Map> getKeywordsByCategory() { + String keywords = NbBundle.getMessage(ToDoOptionsController.class, "KW_ToDo"); + HashMap result = new HashMap(); + result.put("Advanced/ToDo", new HashSet(Collections.list(new StringTokenizer(keywords, ",")))); //NOI18N + return result; + } + }