This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 171284
Collapse All | Expand All

(-)a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsAdvancedOption.java (-64 lines)
Lines 1-64 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.core.ui.options.filetypes;
42
43
import org.netbeans.spi.options.AdvancedOption;
44
import org.netbeans.spi.options.OptionsPanelController;
45
import org.openide.util.NbBundle;
46
47
/** Represents File Associations options panel in miscellaneous category.
48
 * 
49
 * @author Jiri Skrivanek
50
 */
51
public final class FileAssociationsAdvancedOption extends AdvancedOption {
52
53
    public String getDisplayName() {
54
        return NbBundle.getMessage(FileAssociationsAdvancedOption.class, "AdvancedOption.displayName");  //NOI18N
55
    }
56
57
    public String getTooltip() {
58
        return NbBundle.getMessage(FileAssociationsAdvancedOption.class, "AdvancedOption.tooltip");  //NOI18N
59
    }
60
61
    public OptionsPanelController create() {
62
        return new FileAssociationsOptionsPanelController();
63
    }
64
}
(-)a/core.ui/src/org/netbeans/core/ui/options/filetypes/FileAssociationsOptionsPanelController.java (-1 / +5 lines)
Lines 51-57 Link Here
51
 * 
51
 * 
52
 * @author Jiri Skrivanek
52
 * @author Jiri Skrivanek
53
 */
53
 */
54
final class FileAssociationsOptionsPanelController extends OptionsPanelController {
54
@OptionsPanelController.AdvancedRegistration(
55
    displayName="#AdvancedOption.displayName"
56
//    toolTip="#AdvancedOption.tooltip"
57
)
58
public final class FileAssociationsOptionsPanelController extends OptionsPanelController {
55
59
56
    private FileAssociationsPanel panel;
60
    private FileAssociationsPanel panel;
57
    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
61
    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
(-)a/core.ui/src/org/netbeans/core/ui/options/general/GeneralOptionsPanelController.java (+9 lines)
Lines 53-58 Link Here
53
 *
53
 *
54
 * @author Jan Jancura
54
 * @author Jan Jancura
55
 */
55
 */
56
@OptionsPanelController.TopLevelRegistration(
57
    categoryName="#CTL_General_Options",
58
    iconBase="org/netbeans/modules/options/resources/generalOptions.png",
59
    keywords="#KW_General",
60
    keywordsCategory="General",
61
//    title="#CTL_General_Options_Title",
62
//    description="#CTL_General_Options_Description",
63
    position=100
64
)
56
public final class GeneralOptionsPanelController extends OptionsPanelController {
65
public final class GeneralOptionsPanelController extends OptionsPanelController {
57
66
58
67
(-)a/core.ui/src/org/netbeans/core/ui/resources/layer.xml (-19 lines)
Lines 796-820 Link Here
796
796
797
    </folder>
797
    </folder>
798
798
799
    <folder name="OptionsDialog">
800
        <folder name="Advanced">
801
            <file name="org-netbeans-core-ui-options-filetypes-FileAssociationsAdvancedOption.instance"/>
802
        </folder>
803
        <file name="General.instance">
804
            <attr name="instanceCreate" methodvalue="org.netbeans.spi.options.OptionsCategory.createCategory"/>
805
806
            <attr name="title" bundlevalue="org.netbeans.core.ui.options.general.Bundle#CTL_General_Options_Title"/>
807
            <attr name="categoryName" bundlevalue="org.netbeans.core.ui.options.general.Bundle#CTL_General_Options"/>
808
            <attr name="iconBase" stringvalue="org/netbeans/modules/options/resources/generalOptions.png"/>
809
            <attr name="controller" newvalue="org.netbeans.core.ui.options.general.GeneralOptionsPanelController"/>
810
            <attr name="keywords" bundlevalue="org.netbeans.core.ui.options.general.Bundle#KW_General"/>
811
            <attr name="keywordsCategory" stringvalue="General"/>
812
            <attr name="description" bundlevalue="org.netbeans.core.ui.options.general.Bundle#CTL_General_Options_Description"/>
813
814
            <attr name="position" intvalue="100"/>
815
        </file>
816
    </folder>
817
818
    <folder name="OptionsExport">
799
    <folder name="OptionsExport">
819
        <folder name="General">
800
        <folder name="General">
820
            <attr name="displayName" bundlevalue="org.netbeans.core.ui.options.general.Bundle#General.Options.Export.Category.displayName"/>
801
            <attr name="displayName" bundlevalue="org.netbeans.core.ui.options.general.Bundle#General.Options.Export.Category.displayName"/>
(-)a/options.api/nbproject/project.properties (+1 lines)
Lines 41-43 Link Here
41
javac.source=1.5
41
javac.source=1.5
42
javadoc.arch=${basedir}/arch.xml
42
javadoc.arch=${basedir}/arch.xml
43
javadoc.apichanges=${basedir}/apichanges.xml
43
javadoc.apichanges=${basedir}/apichanges.xml
44
cp.extra=${nb_all}/apisupport.harness/external/openjdk-javac-6-b12.jar
(-)a/options.api/src/org/netbeans/modules/options/OptionsPanelControllerProcessor.java (+109 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.options;
41
42
import java.util.Set;
43
import javax.annotation.processing.Processor;
44
import javax.annotation.processing.RoundEnvironment;
45
import javax.annotation.processing.SupportedAnnotationTypes;
46
import javax.annotation.processing.SupportedSourceVersion;
47
import javax.lang.model.SourceVersion;
48
import javax.lang.model.element.Element;
49
import javax.lang.model.element.TypeElement;
50
import org.netbeans.spi.options.AdvancedOption;
51
import org.netbeans.spi.options.OptionsCategory;
52
import org.netbeans.spi.options.OptionsPanelController;
53
import org.netbeans.spi.options.OptionsPanelController.AdvancedRegistration;
54
import org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration;
55
import org.openide.filesystems.annotations.LayerBuilder.File;
56
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
57
import org.openide.filesystems.annotations.LayerGenerationException;
58
import org.openide.util.lookup.ServiceProvider;
59
60
@ServiceProvider(service=Processor.class)
61
@SupportedSourceVersion(SourceVersion.RELEASE_6)
62
@SupportedAnnotationTypes({
63
    "org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration",
64
    "org.netbeans.spi.options.OptionsPanelController.AdvancedRegistration"
65
})
66
public class OptionsPanelControllerProcessor extends LayerGeneratingProcessor {
67
68
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
69
        if (roundEnv.processingOver()) {
70
            return false;
71
        }
72
        for (Element e : roundEnv.getElementsAnnotatedWith(TopLevelRegistration.class)) {
73
            TopLevelRegistration r = e.getAnnotation(TopLevelRegistration.class);
74
            File file = layer(e).instanceFile("OptionsDialog", null, null).
75
                    methodvalue("instanceCreate", OptionsCategory.class.getName(), "createCategory").
76
                    instanceAttribute("controller", OptionsPanelController.class).
77
                    bundlevalue("categoryName", r.categoryName()).
78
                    // XXX verify that the icon exists
79
                    stringvalue("iconBase", r.iconBase()).
80
                    position(r.position());
81
            keywords(e, r.keywords(), r.keywordsCategory(), file);
82
            file.write();
83
        }
84
        for (Element e : roundEnv.getElementsAnnotatedWith(AdvancedRegistration.class)) {
85
            AdvancedRegistration r = e.getAnnotation(AdvancedRegistration.class);
86
            File file = layer(e).instanceFile("OptionsDialog/Advanced", null, null).
87
                    methodvalue("instanceCreate", AdvancedOption.class.getName(), "createSubCategory").
88
                    instanceAttribute("controller", OptionsPanelController.class).
89
                    bundlevalue("displayName", r.displayName());
90
            keywords(e, r.keywords(), r.keywordsCategory(), file);
91
            file.write();
92
        }
93
        return true;
94
    }
95
96
    private void keywords(Element e, String keywords, String keywordsCategory, File file) throws LayerGenerationException {
97
        if (keywords.length() > 0) {
98
            if (keywordsCategory.length() == 0) {
99
                throw new LayerGenerationException("Must specify both keywords and keywordsCategory", e);
100
            }
101
            file.bundlevalue("keywords", keywords).bundlevalue("keywordsCategory", keywordsCategory);
102
        } else {
103
            if (keywordsCategory.length() > 0) {
104
                throw new LayerGenerationException("Must specify both keywords and keywordsCategory", e);
105
            }
106
        }
107
    }
108
109
}
(-)a/options.api/src/org/netbeans/spi/options/AdvancedOption.java (-3 / +3 lines)
Lines 47-55 Link Here
47
47
48
/**
48
/**
49
 * This class represents one category (like "Ant"
49
 * This class represents one category (like "Ant"
50
 * or "Form Editor") in Miscellaneous Panel of Options Dialog. Its instances should
50
 * or "Form Editor") in Miscellaneous Panel of Options Dialog.
51
 * be registered in layers and created by <code>createSubCategory</code> factory
51
 * <p>Normally panels are registered using {@link OptionsPanelController.AdvancedRegistration}.
52
 * method as follows:
52
 * They may also be registered in a layer manually as follows:
53
 *
53
 *
54
 * <pre style="background-color: rgb(255, 255, 153);">
54
 * <pre style="background-color: rgb(255, 255, 153);">
55
 * &lt;folder name="OptionsDialog"&gt;
55
 * &lt;folder name="OptionsDialog"&gt;
(-)a/options.api/src/org/netbeans/spi/options/OptionsCategory.java (-3 / +3 lines)
Lines 52-60 Link Here
52
52
53
/**
53
/**
54
 * This class represents one category (like "Fonts & Colors"
54
 * This class represents one category (like "Fonts & Colors"
55
 * or "Editor") in Options Dialog. Its instances should
55
 * or "Editor") in Options Dialog.
56
 * be registered in layers and created by <code>createCategory</code> factory
56
 * <p>Normally panels are registered using {@link OptionsPanelController.TopLevelRegistration}.
57
 * method as follows:
57
 * They may also be registered in a layer manually as follows:
58
 *
58
 *
59
 *   <pre style="background-color: rgb(255, 255, 153);">
59
 *   <pre style="background-color: rgb(255, 255, 153);">
60
 *   &lt;folder name="OptionsDialog"&gt;
60
 *   &lt;folder name="OptionsDialog"&gt;
(-)a/options.api/src/org/netbeans/spi/options/OptionsPanelController.java (+49 lines)
Lines 41-46 Link Here
41
package org.netbeans.spi.options;
41
package org.netbeans.spi.options;
42
42
43
import java.beans.PropertyChangeListener;
43
import java.beans.PropertyChangeListener;
44
import java.lang.annotation.ElementType;
45
import java.lang.annotation.Retention;
46
import java.lang.annotation.RetentionPolicy;
47
import java.lang.annotation.Target;
44
import javax.swing.JComponent;
48
import javax.swing.JComponent;
45
import org.netbeans.modules.options.OptionsPanelControllerAccessor;
49
import org.netbeans.modules.options.OptionsPanelControllerAccessor;
46
import org.netbeans.modules.options.advanced.AdvancedPanelController;
50
import org.netbeans.modules.options.advanced.AdvancedPanelController;
Lines 210-213 Link Here
210
     * @param l a listener to be removed
214
     * @param l a listener to be removed
211
     */
215
     */
212
    public abstract void removePropertyChangeListener (PropertyChangeListener l);
216
    public abstract void removePropertyChangeListener (PropertyChangeListener l);
217
218
    /**
219
     * Registers a panel at the top level of the Options dialog.
220
     * Should be placed on a {@link OptionsPanelController} instance.
221
     * @see OptionsCategory
222
     * @since XXX
223
     */
224
    @Target({ElementType.TYPE, ElementType.METHOD})
225
    @Retention(RetentionPolicy.SOURCE)
226
    public @interface TopLevelRegistration {
227
        /** Label shown on the button. You may use {@code #key} syntax. */
228
        String categoryName();
229
        /** Path to icon for the button. */
230
        String iconBase();
231
        /**
232
         * Optional keywords (separated by commas) for use with Quick Search (must also specify {@link #keywordCategory}).
233
         * You may use {@code #key} syntax.
234
         */
235
        String keywords() default "";
236
        /** Keyword category for use with Quick Search (must also specify {@link #keywords}). */
237
        String keywordsCategory() default "";
238
        /** Position relative to other top-level panels. */
239
        int position() default Integer.MAX_VALUE;
240
    }
241
242
    /**
243
     * Registers a panel in the Advanced section of the Options dialog.
244
     * Should be placed on a {@link OptionsPanelController} instance.
245
     * @see AdvancedOption
246
     * @since XXX
247
     */
248
    @Target({ElementType.TYPE, ElementType.METHOD})
249
    @Retention(RetentionPolicy.SOURCE)
250
    public @interface AdvancedRegistration {
251
        /** Label shown on the tab. You may use {@code #key} syntax. */
252
        String displayName();
253
        /**
254
         * Optional keywords (separated by commas) for use with Quick Search (must also specify {@link #keywordCategory}).
255
         * You may use {@code #key} syntax.
256
         */
257
        String keywords() default "";
258
        /** Keyword category for use with Quick Search (must also specify {@link #keywords}). */
259
        String keywordsCategory() default "";
260
    }
261
213
}
262
}

Return to bug 171284