While you can pick a specific instance file name, if possible you should pass null for {@code name} + * as using the generated name will help avoid accidental name collisions between annotations. + * @param path path to folder of instance file, e.g. {@code "Menu/File"} + * @param name instance file basename, e.g. {@code "my-menu-Item"}, or null to pick a name according to the element + * @return an instance file (call {@link File#write} to finalize) + * @throws IllegalArgumentException if the builder is not associated with exactly one + * {@linkplain TypeElement class} or {@linkplain ExecutableElement method} + * @throws LayerGenerationException if the associated element would not be loadable as an instance + * @since XXX + */ + public File instanceFile(String path, String name) throws IllegalArgumentException, LayerGenerationException { + String[] clazzOrMethod = instantiableClassOrMethod(null); + String clazz = clazzOrMethod[0]; + String method = clazzOrMethod[1]; + String basename; + if (name == null) { + basename = clazz.replace('.', '-'); + if (method != null) { + basename += "-" + method; + } + } else { + basename = name; + } + return file(path + "/" + basename + ".instance"); + } + private String[] instantiableClassOrMethod(Class type) throws IllegalArgumentException, LayerGenerationException { if (originatingElement == null) { throw new IllegalArgumentException("Only applicable to builders with exactly one associated element"); diff --git a/options.api/nbproject/project.properties b/options.api/nbproject/project.properties --- a/options.api/nbproject/project.properties +++ b/options.api/nbproject/project.properties @@ -41,3 +41,4 @@ javac.source=1.5 javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml +cp.extra=${nb_all}/apisupport.harness/external/openjdk-javac-6-b12.jar diff --git a/options.api/src/org/netbeans/api/options/OptionsDisplayer.java b/options.api/src/org/netbeans/api/options/OptionsDisplayer.java --- a/options.api/src/org/netbeans/api/options/OptionsDisplayer.java +++ b/options.api/src/org/netbeans/api/options/OptionsDisplayer.java @@ -45,7 +45,10 @@ import java.util.logging.Logger; import org.netbeans.modules.options.CategoryModel; import org.netbeans.modules.options.OptionsDisplayerImpl; +import org.netbeans.spi.options.OptionsPanelController.SubRegistration; +import org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration; import org.openide.util.Mutex; + /** * Permits Options Dialog to open the options dialog with some category pre-selected. * @since 1.5 @@ -80,26 +83,11 @@ } /** - * Open the options dialog with some category and subcategory pre-selected - * according to given path. - * @param path path of category and subcategories to be selected. Path is - * composed from registration names divided by slash. E.g. "MyCategory" or - * "MyCategory/Subcategory2" for the following registration: - *
- * <folder name="OptionsDialog"> - * <file name="MyCategory.instance"> - * <attr name="instanceClass" stringvalue="org.foo.MyCategory"/> - * <attr name="position" intvalue="900"/> - * </file> - * <folder name="MyCategory"> - * <file name="SubCategory1.instance"> - * <attr name="instanceClass" stringvalue="org.foo.Subcategory1"/> - * </file> - * <file name="SubCategory2.instance"> - * <attr name="instanceClass" stringvalue="org.foo.Subcategory2"/> - * </file> - * </file> - * </folder>+ * Open the options dialog with some panel preselected. + * To open a top-level panel, pass its {@link TopLevelRegistration#id}. + * To open a subpanel, pass its {@link SubRegistration#location} followed by {@code /} + * followed by its {@link SubRegistration#id}. + * @param path slash-separated path of category and perhaps subcategories to be selected * @return true if optins dialog was sucesfully opened with required category. * If this method is called when options dialog is already opened then this method * will return immediately false without affecting currently selected category diff --git a/options.api/src/org/netbeans/modules/options/AdvancedOptionImpl.java b/options.api/src/org/netbeans/modules/options/AdvancedOptionImpl.java --- a/options.api/src/org/netbeans/modules/options/AdvancedOptionImpl.java +++ b/options.api/src/org/netbeans/modules/options/AdvancedOptionImpl.java @@ -62,6 +62,7 @@ private Callable
createSubCategory
factory
- * method as follows:
+ * or "Form Editor") in Miscellaneous Panel of Options Dialog.
+ * Normally panels are registered using {@link OptionsPanelController.SubRegistration}. + * They may also be registered in a layer manually as follows: * *
* <folder name="OptionsDialog"> @@ -96,6 +96,12 @@ private static final String KEYWORDS_CATEGORY = "keywordsCategory"; /** + * @deprecated Use {@link OptionsPanelController.SubRegistration} instead. + */ + @Deprecated + protected AdvancedOption() {} + + /** * Returns name of category used in Advanced Panel of * Options Dialog. * diff --git a/options.api/src/org/netbeans/spi/options/OptionsCategory.java b/options.api/src/org/netbeans/spi/options/OptionsCategory.java --- a/options.api/src/org/netbeans/spi/options/OptionsCategory.java +++ b/options.api/src/org/netbeans/spi/options/OptionsCategory.java @@ -52,9 +52,9 @@ /** * This class represents one category (like "Fonts & Colors" - * or "Editor") in Options Dialog. Its instances should - * be registered in layers and created bycreateCategory
factory - * method as follows: + * or "Editor") in Options Dialog. + *Normally panels are registered using {@link OptionsPanelController.TopLevelRegistration}. + * They may also be registered in a layer manually as follows: * *
* <folder name="OptionsDialog"> diff --git a/options.api/src/org/netbeans/spi/options/OptionsPanelController.java b/options.api/src/org/netbeans/spi/options/OptionsPanelController.java --- a/options.api/src/org/netbeans/spi/options/OptionsPanelController.java +++ b/options.api/src/org/netbeans/spi/options/OptionsPanelController.java @@ -41,6 +41,10 @@ package org.netbeans.spi.options; import java.beans.PropertyChangeListener; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import javax.swing.JComponent; import org.netbeans.modules.options.OptionsPanelControllerAccessor; import org.netbeans.modules.options.advanced.AdvancedPanelController; @@ -102,7 +106,9 @@ * </folder>* @return OptionsPanelController a controller wrapping all AdvancedOption instances found in the folder * @since 1.8 + * @deprecated Use {@link OptionsCategory}{@code .createCategory} with {@code advancedOptionsFolder} instead. */ + @Deprecated public static final OptionsPanelController createAdvanced(String subpath) { return new AdvancedPanelController(subpath); } @@ -210,4 +216,67 @@ * @param l a listener to be removed */ public abstract void removePropertyChangeListener (PropertyChangeListener l); + + /** + * Registers a simple panel at the top level of the Options dialog. + * Should be placed on a {@link OptionsPanelController} instance. + * @see OptionsCategory + * @since XXX + */ + @Target({ElementType.TYPE, ElementType.METHOD}) + @Retention(RetentionPolicy.SOURCE) + public @interface TopLevelRegistration { + /** + * Optional path that can be used in {@link OptionsDisplayer#open(String)}. + */ + String id() default ""; + /** Label shown on the button. You may use {@code #key} syntax. */ + String categoryName(); + /** Path to icon for the button. */ + String iconBase(); + /** + * Optional keywords (separated by commas) for use with Quick Search (must also specify {@link #keywordCategory}). + * You may use {@code #key} syntax. + */ + String keywords() default ""; + /** Keyword category for use with Quick Search (must also specify {@link #keywords}). */ + String keywordsCategory() default ""; + /** Position relative to other top-level panels. */ + int position() default Integer.MAX_VALUE; + } + + /** + * Registers a subpanel inside a top-level container panel in the Options dialog. + * Should be placed on a {@link OptionsPanelController} instance. + * @see AdvancedOption + * @since XXX + */ + @Target({ElementType.TYPE, ElementType.METHOD}) + @Retention(RetentionPolicy.SOURCE) + public @interface SubRegistration { + /** + * Optional path that can be used (with {@link #location}) in {@link OptionsDisplayer#open(String)}. + */ + String id() default ""; + /** + * Location of this panel inside some top-level panel. + * If unspecified, placed in the Miscellaneous panel. + */ + String location() default "Advanced"; + /** Label shown on the tab. You may use {@code #key} syntax. */ + String displayName(); + /** + * Optional keywords (separated by commas) for use with Quick Search (must also specify {@link #keywordCategory}). + * You may use {@code #key} syntax. + */ + String keywords() default ""; + /** Keyword category for use with Quick Search (must also specify {@link #keywords}). */ + String keywordsCategory() default ""; + /** + * Position relative to sibling subpanels. + * Accepted only for non-default {@link #location} (Miscellaneous panel is sorted alphabetically). + */ + int position() default Integer.MAX_VALUE; + } + } diff --git a/options.api/test/unit/src/org/netbeans/api/options/MyAdvancedCategory.java b/options.api/test/unit/src/org/netbeans/api/options/MyAdvancedCategory.java --- a/options.api/test/unit/src/org/netbeans/api/options/MyAdvancedCategory.java +++ b/options.api/test/unit/src/org/netbeans/api/options/MyAdvancedCategory.java @@ -39,11 +39,9 @@ package org.netbeans.api.options; import javax.swing.Icon; -import javax.swing.ImageIcon; import org.netbeans.spi.options.OptionsCategory; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.ImageUtilities; -import org.openide.util.Utilities; public final class MyAdvancedCategory extends OptionsCategory { @@ -62,6 +60,7 @@ return "My Advanced Category"; } + @SuppressWarnings("deprecation") public OptionsPanelController create() { if(controller == null) { controller = OptionsPanelController.createAdvanced("MyAdvancedCategory"); diff --git a/options.api/test/unit/src/org/netbeans/api/options/Subcategory1.java b/options.api/test/unit/src/org/netbeans/api/options/Subcategory1.java --- a/options.api/test/unit/src/org/netbeans/api/options/Subcategory1.java +++ b/options.api/test/unit/src/org/netbeans/api/options/Subcategory1.java @@ -52,6 +52,9 @@ public class Subcategory1 extends AdvancedOption { public static final String DISPLAY_NAME = "Subcategory1 display name"; + + @SuppressWarnings("deprecation") + public Subcategory1() {} @Override public String getDisplayName() { diff --git a/options.api/test/unit/src/org/netbeans/api/options/Subcategory2.java b/options.api/test/unit/src/org/netbeans/api/options/Subcategory2.java --- a/options.api/test/unit/src/org/netbeans/api/options/Subcategory2.java +++ b/options.api/test/unit/src/org/netbeans/api/options/Subcategory2.java @@ -54,6 +54,9 @@ public static final String DISPLAY_NAME = "Subcategory2 display name"; public static String currentSubpath; + @SuppressWarnings("deprecation") + public Subcategory2() {} + @Override public String getDisplayName() { return DISPLAY_NAME; diff --git a/php.project/src/org/netbeans/modules/php/project/resources/layer.xml b/php.project/src/org/netbeans/modules/php/project/resources/layer.xml --- a/php.project/src/org/netbeans/modules/php/project/resources/layer.xml +++ b/php.project/src/org/netbeans/modules/php/project/resources/layer.xml @@ -179,13 +179,6 @@- - - - - - -