001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.spi.options;
043:
044: import java.awt.Image;
045: import javax.swing.Icon;
046: import javax.swing.ImageIcon;
047: import org.openide.util.Utilities;
048:
049: /**
050: * Implementation of this class represents one category (like "Fonts & Colors"
051: * or "Editor") in Options Dialog. It should be registerred in layers:
052: *
053: * <pre style="background-color: rgb(255, 255, 153);">
054: * <folder name="OptionsDialog">
055: * <file name="FooOptionsPanel.instance">
056: * <attr name="instanceClass" stringvalue="org.foo.FooOptionsPanel"/>
057: * </file>
058: * </folder></pre>
059: *
060: * Use standard way how to sort items registered in layers:
061: *
062: * <pre style="background-color: rgb(255, 255, 153);">
063: * <attr name="GeneralPanel.instance/FooOptionsPanel.instance" boolvalue="true"/>
064: * </pre>
065: *
066: * @see AdvancedOption
067: * @see OptionsPanelController
068: *
069: * @author Jan Jancura
070: */
071: public abstract class OptionsCategory {
072:
073: /**
074: * Returns base name of 32x32 icon (gif, png) used in list on the left side of
075: * Options Dialog. See {@link AbstractNode#setIconBase} method for more info.
076: *
077: * @deprecated This method will not be a part of NB50! Use
078: * {@link #getIcon} instead.
079: * @return base name of 32x32 icon
080: */
081: public String getIconBase() {
082: return null;
083: }
084:
085: /**
086: * Returns 32x32 icon used in list on the left side of
087: * Options Dialog.
088: *
089: * @return 32x32 icon
090: */
091: public Icon getIcon() {
092: Image image = Utilities.loadImage(getIconBase() + ".png");
093: if (image != null)
094: return new ImageIcon(image);
095: image = Utilities.loadImage(getIconBase() + ".gif");
096: if (image == null)
097: return null;
098: return new ImageIcon(image);
099: }
100:
101: /**
102: * Returns name of category used in list on the left side of
103: * Options Dialog.
104: *
105: * @return name of category
106: */
107: public abstract String getCategoryName();
108:
109: /**
110: * This text will be used in title component on the top of Options Dialog
111: * when your panel will be selected.
112: *
113: * @return title of this panel
114: */
115: public abstract String getTitle();
116:
117: /**
118: * Returns new {@link OptionsPanelController} for this category. PanelController
119: * creates visual component to be used inside of the Options Dialog.
120: * You should not do any time-consuming operations inside
121: * the constructor, because it blocks initialization of OptionsDialog.
122: * Initialization should be implemented in update method.
123: *
124: * @return new instance of PanelController for this options category
125: */
126: public abstract OptionsPanelController create();
127:
128: }
|