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;
+ }
+
}