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: package org.netbeans.modules.visualweb.designer.jsf;
042:
043: import java.awt.Image;
044: import java.beans.BeanDescriptor;
045: import java.beans.IntrospectionException;
046: import java.beans.PropertyDescriptor;
047: import java.beans.SimpleBeanInfo;
048: import java.util.logging.Level;
049: import java.util.logging.Logger;
050: import org.openide.util.NbBundle;
051: import org.openide.util.Utilities;
052:
053: /** A BeanInfo for designer settings.
054: *
055: * @author Po-Ting Wu
056: * @author Peter Zavadsky (added BeanDescriptor).
057: */
058: public class JsfDesignerPreferencesBeanInfo extends SimpleBeanInfo {
059:
060: @Override
061: public BeanDescriptor getBeanDescriptor() {
062: BeanDescriptor beanDescriptor = new BeanDescriptor(
063: JsfDesignerPreferences.class);
064: beanDescriptor.setDisplayName(NbBundle.getBundle(
065: JsfDesignerPreferences.class).getString(
066: "CTL_DesignerSettings"));
067: beanDescriptor.setValue("helpID",
068: "projrave_ui_elements_options_visual_editor"); // NOI18N
069: return beanDescriptor;
070: }
071:
072: /** Provides an explicit property info. */
073: @Override
074: public PropertyDescriptor[] getPropertyDescriptors() {
075: try {
076: PropertyDescriptor[] desc = new PropertyDescriptor[] {
077: new PropertyDescriptor(
078: JsfDesignerPreferences.PROP_GRID_SHOW,
079: JsfDesignerPreferences.class,
080: "getGridShow", "setGridShow"),
081: new java.beans.PropertyDescriptor(
082: JsfDesignerPreferences.PROP_GRID_SNAP,
083: JsfDesignerPreferences.class,
084: "getGridSnap", "setGridSnap"),
085: new java.beans.PropertyDescriptor(
086: JsfDesignerPreferences.PROP_GRID_WIDTH,
087: JsfDesignerPreferences.class,
088: "getGridWidth", "setGridWidth"),
089: new java.beans.PropertyDescriptor(
090: JsfDesignerPreferences.PROP_GRID_HEIGHT,
091: JsfDesignerPreferences.class,
092: "getGridHeight", "setGridHeight"),
093: new java.beans.PropertyDescriptor(
094: JsfDesignerPreferences.PROP_PAGE_SIZE,
095: JsfDesignerPreferences.class,
096: "getPageSize", "setPageSize"),
097: new java.beans.PropertyDescriptor(
098: JsfDesignerPreferences.PROP_SHOW_DECORATIONS,
099: JsfDesignerPreferences.class,
100: "isShowDecorations", "setShowDecorations"),
101: new java.beans.PropertyDescriptor(
102: JsfDesignerPreferences.PROP_DEFAULT_FONT_SIZE,
103: JsfDesignerPreferences.class,
104: "getDefaultFontSize", "setDefaultFontSize") // NOI18N
105: };
106:
107: desc[0].setDisplayName(NbBundle.getMessage(
108: JsfDesignerPreferences.class, "PROP_GRID_SHOW"));
109: desc[0].setShortDescription(NbBundle.getMessage(
110: JsfDesignerPreferences.class, "HINT_GRID_SHOW"));
111:
112: desc[1].setDisplayName(NbBundle.getMessage(
113: JsfDesignerPreferences.class, "PROP_GRID_SNAP"));
114: desc[1].setShortDescription(NbBundle.getMessage(
115: JsfDesignerPreferences.class, "HINT_GRID_SNAP"));
116:
117: desc[2].setDisplayName(NbBundle.getMessage(
118: JsfDesignerPreferences.class, "PROP_GRID_WIDTH"));
119: desc[2].setShortDescription(NbBundle.getMessage(
120: JsfDesignerPreferences.class, "HINT_GRID_WIDTH"));
121:
122: desc[3].setDisplayName(NbBundle.getMessage(
123: JsfDesignerPreferences.class, "PROP_GRID_HEIGHT"));
124: desc[3].setShortDescription(NbBundle.getMessage(
125: JsfDesignerPreferences.class, "HINT_GRID_HEIGHT"));
126:
127: desc[4].setDisplayName(NbBundle.getMessage(
128: JsfDesignerPreferences.class, "PROP_PAGE_SIZE"));
129: desc[4].setShortDescription(NbBundle.getMessage(
130: JsfDesignerPreferences.class, "HINT_PAGE_SIZE"));
131: desc[4].setPropertyEditorClass(ResolutionEditor.class);
132:
133: desc[5].setDisplayName(NbBundle.getMessage(
134: JsfDesignerPreferences.class,
135: "PROP_SHOW_DECORATIONS"));
136: desc[5].setShortDescription(NbBundle.getMessage(
137: JsfDesignerPreferences.class,
138: "HINT_SHOW_DECORATIONS"));
139: // #6470521 Do not show this to user, toolbar button is enough.
140: desc[5].setHidden(true);
141:
142: desc[6].setDisplayName(NbBundle.getMessage(
143: JsfDesignerPreferences.class,
144: "PROP_DEFAULT_FONT_SIZE"));
145: desc[6].setShortDescription(NbBundle.getMessage(
146: JsfDesignerPreferences.class,
147: "HINT_DEFAULT_FONT_SIZE"));
148:
149: return desc;
150: } catch (IntrospectionException ex) {
151: log(ex);
152:
153: return null;
154: }
155: }
156:
157: /** Returns the designer icon */
158: @Override
159: public Image getIcon(int type) {
160: return Utilities
161: .loadImage("org/netbeans/modules/visualweb/designer/jsf/resources/preferences.gif"); // NOI18N
162: }
163:
164: private static void log(Exception exception) {
165: Logger logger = Logger
166: .getLogger(JsfDesignerPreferencesBeanInfo.class
167: .getName());
168: logger.log(Level.INFO, null, exception);
169: }
170: }
|