KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > spi > options > OptionsCategory


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.spi.options;
21
22 import java.awt.Image JavaDoc;
23 import javax.swing.Icon JavaDoc;
24 import javax.swing.ImageIcon JavaDoc;
25 import org.openide.util.Utilities;
26
27 /**
28  * Implementation of this class represents one category (like "Fonts & Colors"
29  * or "Editor") in Options Dialog. It should be registerred in layers:
30  *
31  * <pre style="background-color: rgb(255, 255, 153);">
32  * &lt;folder name="OptionsDialog"&gt;
33  * &lt;file name="FooOptionsPanel.instance"&gt;
34  * &lt;attr name="instanceClass" stringvalue="org.foo.FooOptionsPanel"/&gt;
35  * &lt;/file&gt;
36  * &lt;/folder&gt;</pre>
37  *
38  * Use standard way how to sort items registered in layers:
39  *
40  * <pre style="background-color: rgb(255, 255, 153);">
41  * &lt;attr name="GeneralPanel.instance/FooOptionsPanel.instance" boolvalue="true"/&gt;
42  * </pre>
43  *
44  * @see AdvancedOption
45  * @see OptionsPanelController
46  *
47  * @author Jan Jancura
48  */

49 public abstract class OptionsCategory {
50     
51     /**
52      * Returns base name of 32x32 icon (gif, png) used in list on the left side of
53      * Options Dialog. See {@link AbstractNode#setIconBase} method for more info.
54      *
55      * @deprecated This method will not be a part of NB50! Use
56      * {@link #getIcon} instead.
57      * @return base name of 32x32 icon
58      */

59     public String JavaDoc getIconBase () {
60         return null;
61     }
62     
63     /**
64      * Returns 32x32 icon used in list on the left side of
65      * Options Dialog.
66      *
67      * @return 32x32 icon
68      */

69     public Icon JavaDoc getIcon () {
70         Image JavaDoc image = Utilities.loadImage (getIconBase () + ".png");
71         if (image != null) return new ImageIcon JavaDoc (image);
72         image = Utilities.loadImage (getIconBase () + ".gif");
73         if (image == null) return null;
74         return new ImageIcon JavaDoc (image);
75     }
76     
77     /**
78      * Returns name of category used in list on the left side of
79      * Options Dialog.
80      *
81      * @return name of category
82      */

83     public abstract String JavaDoc getCategoryName ();
84     
85     /**
86      * This text will be used in title component on the top of Options Dialog
87      * when your panel will be selected.
88      *
89      * @return title of this panel
90      */

91     public abstract String JavaDoc getTitle ();
92     
93     /**
94      * Returns new {@link OptionsPanelController} for this category. PanelController
95      * creates visual component to be used inside of the Options Dialog.
96      * You should not do any time-consuming operations inside
97      * the constructor, because it blocks initialization of OptionsDialog.
98      * Initialization should be implemented in update method.
99      *
100      * @return new instance of PanelController for this options category
101      */

102     public abstract OptionsPanelController create ();
103     
104 }
105
Popular Tags