--- a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsAdvancedOption.java +++ a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsAdvancedOption.java @@ -1,64 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ -package org.netbeans.core.ui.options.filetypes; - -import org.netbeans.spi.options.AdvancedOption; -import org.netbeans.spi.options.OptionsPanelController; -import org.openide.util.NbBundle; - -/** Represents File Associations options panel in miscellaneous category. - * - * @author Jiri Skrivanek - */ -public final class FileAssociationsAdvancedOption extends AdvancedOption { - - public String getDisplayName() { - return NbBundle.getMessage(FileAssociationsAdvancedOption.class, "AdvancedOption.displayName"); //NOI18N - } - - public String getTooltip() { - return NbBundle.getMessage(FileAssociationsAdvancedOption.class, "AdvancedOption.tooltip"); //NOI18N - } - - public OptionsPanelController create() { - return new FileAssociationsOptionsPanelController(); - } -} --- a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsOptionsPanelController.java +++ a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsOptionsPanelController.java @@ -51,7 +51,11 @@ * * @author Jiri Skrivanek */ -final class FileAssociationsOptionsPanelController extends OptionsPanelController { +@OptionsPanelController.AdvancedRegistration( + displayName="#AdvancedOption.displayName" +// toolTip="#AdvancedOption.tooltip" +) +public final class FileAssociationsOptionsPanelController extends OptionsPanelController { private FileAssociationsPanel panel; private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); --- a/core.ui/src/org/netbeans/core/ui/options/general/GeneralOptionsPanelController.java +++ a/core.ui/src/org/netbeans/core/ui/options/general/GeneralOptionsPanelController.java @@ -53,6 +53,15 @@ * * @author Jan Jancura */ +@OptionsPanelController.TopLevelRegistration( + categoryName="#CTL_General_Options", + iconBase="org/netbeans/modules/options/resources/generalOptions.png", + keywords="#KW_General", + keywordsCategory="General", +// title="#CTL_General_Options_Title", +// description="#CTL_General_Options_Description", + position=100 +) public final class GeneralOptionsPanelController extends OptionsPanelController { --- a/core.ui/src/org/netbeans/core/ui/resources/layer.xml +++ a/core.ui/src/org/netbeans/core/ui/resources/layer.xml @@ -796,25 +796,6 @@ - - - - - - - - - - - - - - - - - - - --- a/options.api/nbproject/project.properties +++ a/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 --- a/options.api/src/org/netbeans/modules/options/OptionsPanelControllerProcessor.java +++ a/options.api/src/org/netbeans/modules/options/OptionsPanelControllerProcessor.java @@ -0,0 +1,109 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 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 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.options; + +import java.util.Set; +import javax.annotation.processing.Processor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import org.netbeans.spi.options.AdvancedOption; +import org.netbeans.spi.options.OptionsCategory; +import org.netbeans.spi.options.OptionsPanelController; +import org.netbeans.spi.options.OptionsPanelController.AdvancedRegistration; +import org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration; +import org.openide.filesystems.annotations.LayerBuilder.File; +import org.openide.filesystems.annotations.LayerGeneratingProcessor; +import org.openide.filesystems.annotations.LayerGenerationException; +import org.openide.util.lookup.ServiceProvider; + +@ServiceProvider(service=Processor.class) +@SupportedSourceVersion(SourceVersion.RELEASE_6) +@SupportedAnnotationTypes({ + "org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration", + "org.netbeans.spi.options.OptionsPanelController.AdvancedRegistration" +}) +public class OptionsPanelControllerProcessor extends LayerGeneratingProcessor { + + protected boolean handleProcess(Set annotations, RoundEnvironment roundEnv) throws LayerGenerationException { + if (roundEnv.processingOver()) { + return false; + } + for (Element e : roundEnv.getElementsAnnotatedWith(TopLevelRegistration.class)) { + TopLevelRegistration r = e.getAnnotation(TopLevelRegistration.class); + File file = layer(e).instanceFile("OptionsDialog", null, null). + methodvalue("instanceCreate", OptionsCategory.class.getName(), "createCategory"). + instanceAttribute("controller", OptionsPanelController.class). + bundlevalue("categoryName", r.categoryName()). + // XXX verify that the icon exists + stringvalue("iconBase", r.iconBase()). + position(r.position()); + keywords(e, r.keywords(), r.keywordsCategory(), file); + file.write(); + } + for (Element e : roundEnv.getElementsAnnotatedWith(AdvancedRegistration.class)) { + AdvancedRegistration r = e.getAnnotation(AdvancedRegistration.class); + File file = layer(e).instanceFile("OptionsDialog/Advanced", null, null). + methodvalue("instanceCreate", AdvancedOption.class.getName(), "createSubCategory"). + instanceAttribute("controller", OptionsPanelController.class). + bundlevalue("displayName", r.displayName()); + keywords(e, r.keywords(), r.keywordsCategory(), file); + file.write(); + } + return true; + } + + private void keywords(Element e, String keywords, String keywordsCategory, File file) throws LayerGenerationException { + if (keywords.length() > 0) { + if (keywordsCategory.length() == 0) { + throw new LayerGenerationException("Must specify both keywords and keywordsCategory", e); + } + file.bundlevalue("keywords", keywords).bundlevalue("keywordsCategory", keywordsCategory); + } else { + if (keywordsCategory.length() > 0) { + throw new LayerGenerationException("Must specify both keywords and keywordsCategory", e); + } + } + } + +} --- a/options.api/src/org/netbeans/spi/options/AdvancedOption.java +++ a/options.api/src/org/netbeans/spi/options/AdvancedOption.java @@ -47,9 +47,9 @@ /** * This class represents one category (like "Ant" - * or "Form Editor") in Miscellaneous Panel of Options Dialog. Its instances should - * be registered in layers and created by createSubCategory factory - * method as follows: + * or "Form Editor") in Miscellaneous Panel of Options Dialog. + *

Normally panels are registered using {@link OptionsPanelController.AdvancedRegistration}. + * They may also be registered in a layer manually as follows: * *

  * <folder name="OptionsDialog">
--- a/options.api/src/org/netbeans/spi/options/OptionsCategory.java	
+++ a/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 by createCategory 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">
--- a/options.api/src/org/netbeans/spi/options/OptionsPanelController.java	
+++ a/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;
@@ -210,4 +214,49 @@ 
      * @param l a listener to be removed
      */
     public abstract void removePropertyChangeListener (PropertyChangeListener l);
+
+    /**
+     * Registers a 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 {
+        /** 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 panel in the Advanced section of 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 AdvancedRegistration {
+        /** 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 "";
+    }
+
 }