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-2007 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.modules.compapp.casaeditor.nodes;
043:
044: import java.awt.Color;
045: import java.awt.Font;
046: import java.awt.Image;
047: import org.netbeans.modules.compapp.casaeditor.Constants;
048: import org.netbeans.modules.compapp.casaeditor.graph.CasaCustomizer;
049: import org.netbeans.modules.compapp.casaeditor.graph.CasaFactory;
050: import org.netbeans.modules.compapp.casaeditor.properties.LookAndFeelProperty;
051: import org.netbeans.modules.compapp.casaeditor.properties.PropertyUtils;
052: import org.openide.nodes.PropertySupport;
053: import org.openide.nodes.Sheet;
054: import org.openide.util.NbBundle;
055: import org.openide.util.Utilities;
056:
057: /**
058: *
059: * @author jsandusky
060: */
061: public class LookAndFeelNode extends CasaNode {
062:
063: private static final Image ICON = Utilities
064: .loadImage("org/netbeans/modules/compapp/casaeditor/nodes/resources/LookAndFeelNode.png"); // NOI18N
065:
066: public LookAndFeelNode() {
067: super ();
068: }
069:
070: public String getName() {
071: return NbBundle.getMessage(LookAndFeelProperty.class,
072: "LBL_LookAndFeel"); // NOI18N
073: }
074:
075: protected void setupPropertySheet(Sheet sheet) {
076: Sheet.Set fontPropertySet = getPropertySet(sheet,
077: PropertyUtils.PropertiesGroups.FONT_SET);
078: Sheet.Set colorPropertySet = getPropertySet(sheet,
079: PropertyUtils.PropertiesGroups.COLOR_SET);
080: Sheet.Set genericPropertySet = getPropertySet(sheet,
081: PropertyUtils.PropertiesGroups.GENERIC_SET);
082:
083: sheet.put(genericPropertySet);
084: sheet.put(colorPropertySet);
085: sheet.put(fontPropertySet);
086:
087: for (String key : CasaFactory.getCasaCustomizer()
088: .getColorsMapReference().keySet()) {
089: colorPropertySet.put(new PropertySupport.ReadWrite<Color>(
090: key, // NO18N
091: Color.class, NbBundle.getMessage(getClass(), key),
092: Constants.EMPTY_STRING) {
093:
094: public Color getValue() {
095: return (Color) CasaFactory.getCasaCustomizer()
096: .getValue(getName());
097: }
098:
099: public void setValue(Color value) {
100: CasaFactory.getCasaCustomizer().setValue(getName(),
101: value);
102: }
103:
104: public void restoreDefaultValue() {
105: CasaCustomizer customizer = CasaFactory
106: .getCasaCustomizer();
107: String strValue = customizer.getDefaultColors()
108: .get(getName());
109: customizer.setValue(getName(), new Color(Integer
110: .parseInt(strValue)));
111: if (customizer.getDefaultGradients().containsKey(
112: getName())) {
113: strValue = customizer.getDefaultGradients()
114: .get(getName());
115: customizer.setValue(getName(), customizer
116: .getGradient(strValue));
117: }
118: }
119:
120: public boolean supportsDefaultValue() {
121: return true;
122: }
123: });
124: }
125:
126: for (String key : CasaFactory.getCasaCustomizer()
127: .getFontsMapReference().keySet()) {
128: fontPropertySet.put(new PropertySupport.ReadWrite<Font>(
129: key, // NO18N
130: Font.class, NbBundle.getMessage(getClass(), key),
131: Constants.EMPTY_STRING) {
132:
133: public Font getValue() {
134: return (Font) CasaFactory.getCasaCustomizer()
135: .getValue(getName());
136: }
137:
138: public void setValue(Font value) {
139: CasaFactory.getCasaCustomizer().setValue(getName(),
140: value);
141: }
142:
143: public void restoreDefaultValue() {
144: CasaCustomizer customizer = CasaFactory
145: .getCasaCustomizer();
146: String strValue = customizer.getDefaultFonts().get(
147: getName());
148: customizer.setValue(getName(), customizer
149: .getFont(strValue));
150: }
151:
152: public boolean supportsDefaultValue() {
153: return true;
154: }
155:
156: });
157: }
158: }
159:
160: public Image getIcon(int type) {
161: return ICON;
162: }
163:
164: public Image getOpenedIcon(int type) {
165: return ICON;
166: }
167:
168: }
|