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.modules.form;
043:
044: import java.awt.Image;
045: import java.beans.*;
046: import java.lang.reflect.Modifier;
047: import java.util.*;
048: import org.netbeans.modules.form.editors.ModifierEditor;
049: import org.openide.util.NbBundle;
050:
051: import org.openide.util.Utilities;
052:
053: /**
054: * A BeanInfo for FormLoaderSettings.
055: */
056:
057: public class FormLoaderSettingsBeanInfo extends SimpleBeanInfo {
058:
059: /** The icons for Settings */
060: private static String iconURL = "org/netbeans/modules/form/resources/formSettings.gif"; // NOI18N
061: private static String icon32URL = "org/netbeans/modules/form/resources/formSettings32.gif"; // NOI18N
062:
063: /** Descriptor of valid properties
064: * @return array of properties
065: */
066: @Override
067: public PropertyDescriptor[] getPropertyDescriptors() {
068: try {
069: PropertyDescriptor[] desc = new PropertyDescriptor[] {
070: new PropertyDescriptor(
071: FormLoaderSettings.PROP_USE_INDENT_ENGINE,
072: FormLoaderSettings.class,
073: "getUseIndentEngine", // NOI18N
074: "setUseIndentEngine"), // NOI18N
075: new PropertyDescriptor(
076: FormLoaderSettings.PROP_EVENT_VARIABLE_NAME,
077: FormLoaderSettings.class,
078: "getEventVariableName", // NOI18N
079: "setEventVariableName"), // NOI18N
080: new PropertyDescriptor(
081: FormLoaderSettings.PROP_LISTENER_GENERATION_STYLE,
082: FormLoaderSettings.class,
083: "getListenerGenerationStyle", // NOI18N
084: "setListenerGenerationStyle"), // NOI18N
085: new PropertyDescriptor(
086: FormLoaderSettings.PROP_LAYOUT_CODE_TARGET,
087: FormLoaderSettings.class,
088: "getLayoutCodeTarget", // NOI18N
089: "setLayoutCodeTarget"), // NOI18N
090: new PropertyDescriptor(
091: FormLoaderSettings.PROP_SELECTION_BORDER_SIZE,
092: FormLoaderSettings.class,
093: "getSelectionBorderSize", // NOI18N
094: "setSelectionBorderSize"), // NOI18N
095: new PropertyDescriptor(
096: FormLoaderSettings.PROP_SELECTION_BORDER_COLOR,
097: FormLoaderSettings.class,
098: "getSelectionBorderColor", // NOI18N
099: "setSelectionBorderColor"), // NOI18N
100: new PropertyDescriptor(
101: FormLoaderSettings.PROP_CONNECTION_BORDER_COLOR,
102: FormLoaderSettings.class,
103: "getConnectionBorderColor", // NOI18N
104: "setConnectionBorderColor"), // NOI18N
105: new PropertyDescriptor(
106: FormLoaderSettings.PROP_DRAG_BORDER_COLOR,
107: FormLoaderSettings.class,
108: "getDragBorderColor", // NOI18N
109: "setDragBorderColor"), // NOI18N
110: new PropertyDescriptor(
111: FormLoaderSettings.PROP_GUIDING_LINE_COLOR,
112: FormLoaderSettings.class,
113: "getGuidingLineColor", // NOI18N
114: "setGuidingLineColor"), // NOI18N
115: new PropertyDescriptor(
116: FormLoaderSettings.PROP_GRID_X,
117: FormLoaderSettings.class, "getGridX",
118: "setGridX"), // NOI18N
119: new PropertyDescriptor(
120: FormLoaderSettings.PROP_GRID_Y,
121: FormLoaderSettings.class, "getGridY",
122: "setGridY"), // NOI18N
123: new PropertyDescriptor(
124: FormLoaderSettings.PROP_APPLY_GRID_TO_POSITION,
125: FormLoaderSettings.class,
126: "getApplyGridToPosition", // NOI18N
127: "setApplyGridToPosition"), // NOI18N
128: new PropertyDescriptor(
129: FormLoaderSettings.PROP_APPLY_GRID_TO_SIZE,
130: FormLoaderSettings.class,
131: "getApplyGridToSize", // NOI18N
132: "setApplyGridToSize"), // NOI18N
133: new PropertyDescriptor(
134: FormLoaderSettings.PROP_VARIABLES_MODIFIER,
135: FormLoaderSettings.class,
136: "getVariablesModifier", // NOI18N
137: "setVariablesModifier"), // NOI18N
138: new PropertyDescriptor(
139: FormLoaderSettings.PROP_EDITOR_SEARCH_PATH,
140: FormLoaderSettings.class,
141: "getEditorSearchPath", // NOI18N
142: "setEditorSearchPath"), // NOI18N
143: new PropertyDescriptor(
144: FormLoaderSettings.PROP_PALETTE_IN_TOOLBAR,
145: FormLoaderSettings.class,
146: "isPaletteInToolBar", // NOI18N
147: "setPaletteInToolBar"), // NOI18N
148: // new PropertyDescriptor(FormLoaderSettings.PROP_CONTAINER_BEANS,
149: // FormLoaderSettings.class,
150: // "getContainerBeans", // NOI18N
151: // "setContainerBeans"), // NOI18N
152: new PropertyDescriptor(
153: FormLoaderSettings.PROP_FORMDESIGNER_BACKGROUND_COLOR,
154: FormLoaderSettings.class,
155: "getFormDesignerBackgroundColor", // NOI18N
156: "setFormDesignerBackgroundColor"), // NOI18N
157: new PropertyDescriptor(
158: FormLoaderSettings.PROP_FORMDESIGNER_BORDER_COLOR,
159: FormLoaderSettings.class,
160: "getFormDesignerBorderColor", // NOI18N
161: "setFormDesignerBorderColor"), // NOI18N
162: new PropertyDescriptor(
163: FormLoaderSettings.PROP_VARIABLES_LOCAL,
164: FormLoaderSettings.class,
165: "getVariablesLocal", // NOI18N
166: "setVariablesLocal"), // NOI18N
167: new PropertyDescriptor(
168: FormLoaderSettings.PROP_DISPLAY_WRITABLE_ONLY,
169: FormLoaderSettings.class,
170: "getDisplayWritableOnly", // NOI18N
171: "setDisplayWritableOnly"), // NOI18N
172: new PropertyDescriptor(
173: FormLoaderSettings.PROP_GENERATE_MNEMONICS,
174: FormLoaderSettings.class,
175: "getGenerateMnemonicsCode", // NOI18N
176: "setGenerateMnemonicsCode"), // NOI18N
177: new PropertyDescriptor(
178: FormLoaderSettings.PROP_FOLD_GENERATED_CODE,
179: FormLoaderSettings.class,
180: "getFoldGeneratedCode", // NOI18N
181: "setFoldGeneratedCode"), // NOI18N
182: new PropertyDescriptor(
183: FormLoaderSettings.PROP_ASSISTANT_SHOWN,
184: FormLoaderSettings.class,
185: "getAssistantShown", // NOI18N
186: "setAssistantShown"), // NOI18N
187: new PropertyDescriptor(
188: FormLoaderSettings.PROP_AUTO_RESOURCING,
189: FormLoaderSettings.class,
190: "getI18nAutoMode", // NOI18N
191: "setI18nAutoMode"), // NOI18N
192: new PropertyDescriptor(
193: FormLoaderSettings.PROP_AUTO_SET_COMPONENT_NAME,
194: FormLoaderSettings.class,
195: "getAutoSetComponentName", // NOI18N
196: "setAutoSetComponentName") // NOI18N
197: };
198:
199: ResourceBundle bundle = FormUtils.getBundle();
200: int i = -1;
201:
202: desc[++i].setDisplayName(bundle
203: .getString("PROP_USE_INDENT_ENGINE")); // NOI18N
204: desc[i].setShortDescription(bundle
205: .getString("HINT_USE_INDENT_ENGINE")); // NOI18N
206:
207: desc[++i].setDisplayName(bundle
208: .getString("PROP_EVENT_VARIABLE_NAME")); // NOI18N
209: desc[i].setShortDescription(bundle
210: .getString("HINT_EVENT_VARIABLE_NAME")); // NOI18N
211: desc[i].setExpert(true);
212:
213: desc[++i].setDisplayName(bundle
214: .getString("PROP_LISTENER_GENERATION_STYLE")); // NOI18N
215: desc[i].setShortDescription(bundle
216: .getString("HINT_LISTENER_GENERATION_STYLE")); // NOI18N
217: desc[i]
218: .setPropertyEditorClass(ListenerGenerationStyleEditor.class);
219: desc[i].setExpert(true);
220:
221: desc[++i].setDisplayName(bundle
222: .getString("PROP_LAYOUT_CODE_TARGET")); // NOI18N
223: desc[i].setShortDescription(bundle
224: .getString("HINT_LAYOUT_CODE_TARGET")); // NOI18N
225: desc[i]
226: .setPropertyEditorClass(LayoutCodeTargetEditor.class);
227: desc[i].setExpert(true);
228:
229: desc[++i].setDisplayName(bundle
230: .getString("PROP_SELECTION_BORDER_SIZE")); // NOI18N
231: desc[i].setShortDescription(bundle
232: .getString("HINT_SELECTION_BORDER_SIZE")); // NOI18N
233:
234: desc[++i].setDisplayName(bundle
235: .getString("PROP_SELECTION_BORDER_COLOR")); // NOI18N
236: desc[i].setShortDescription(bundle
237: .getString("HINT_SELECTION_BORDER_COLOR")); // NOI18N
238:
239: desc[++i].setDisplayName(bundle
240: .getString("PROP_CONNECTION_BORDER_COLOR")); // NOI18N
241: desc[i].setShortDescription(bundle
242: .getString("HINT_CONNECTION_BORDER_COLOR")); // NOI18N
243:
244: desc[++i].setDisplayName(bundle
245: .getString("PROP_DRAG_BORDER_COLOR")); // NOI18N
246: desc[i].setShortDescription(bundle
247: .getString("HINT_DRAG_BORDER_COLOR")); // NOI18N
248:
249: desc[++i].setDisplayName(bundle
250: .getString("PROP_GUIDING_LINE_COLOR")); // NOI18N
251: desc[i].setShortDescription(bundle
252: .getString("HINT_GUIDING_LINE_COLOR")); // NOI18N
253:
254: desc[++i].setDisplayName(bundle.getString("PROP_GRID_X")); // NOI18N
255: desc[i]
256: .setShortDescription(bundle
257: .getString("HINT_GRID_X")); // NOI18N
258: desc[i].setExpert(true);
259:
260: desc[++i].setDisplayName(bundle.getString("PROP_GRID_Y")); // NOI18N
261: desc[i]
262: .setShortDescription(bundle
263: .getString("HINT_GRID_Y")); // NOI18N
264: desc[i].setExpert(true);
265:
266: desc[++i].setDisplayName(bundle
267: .getString("PROP_APPLY_GRID_TO_POSITION")); // NOI18N
268: desc[i].setShortDescription(bundle
269: .getString("HINT_APPLY_GRID_TO_POSITION")); // NOI18N
270: desc[i].setExpert(true);
271:
272: desc[++i].setDisplayName(bundle
273: .getString("PROP_APPLY_GRID_TO_SIZE")); // NOI18N
274: desc[i].setShortDescription(bundle
275: .getString("HINT_APPLY_GRID_TO_SIZE")); // NOI18N
276: desc[i].setExpert(true);
277:
278: desc[++i].setDisplayName(bundle
279: .getString("PROP_VARIABLES_MODIFIER")); // NOI18N
280: desc[i].setShortDescription(bundle
281: .getString("HINT_VARIABLES_MODIFIER")); // NOI18N
282: desc[i]
283: .setPropertyEditorClass(FieldModifierPropertyEditor.class);
284: desc[i].setExpert(true);
285:
286: desc[++i].setDisplayName(bundle
287: .getString("PROP_EDITOR_SEARCH_PATH")); // NOI18N
288: desc[i].setShortDescription(bundle
289: .getString("HINT_EDITOR_SEARCH_PATH")); // NOI18N
290: desc[i].setExpert(true);
291:
292: desc[++i].setDisplayName(bundle
293: .getString("PROP_PALETTE_IN_TOOLBAR")); // NOI18N
294: desc[i].setShortDescription(bundle
295: .getString("HINT_PALETTE_IN_TOOLBAR")); // NOI18N
296:
297: desc[++i].setDisplayName(bundle
298: .getString("PROP_FORMDESIGNER_BACKGROUND_COLOR")); // NOI18N
299: desc[i].setShortDescription(bundle
300: .getString("HINT_FORMDESIGNER_BACKGROUND_COLOR")); // NOI18N
301:
302: desc[++i].setDisplayName(bundle
303: .getString("PROP_FORMDESIGNER_BORDER_COLOR")); // NOI18N
304: desc[i].setShortDescription(bundle
305: .getString("HINT_FORMDESIGNER_BORDER_COLOR")); // NOI18N
306:
307: desc[++i].setDisplayName(bundle
308: .getString("PROP_VARIABLES_LOCAL")); // NOI18N
309: desc[i].setShortDescription(bundle
310: .getString("HINT_VARIABLES_LOCAL")); // NOI18N
311: desc[i].setExpert(true);
312:
313: desc[++i].setHidden(true);
314:
315: desc[++i].setDisplayName(bundle
316: .getString("PROP_GENERATE_MNEMONICS")); // NOI18N
317: desc[i].setShortDescription(bundle
318: .getString("HINT_GENERATE_MNEMONICS")); // NOI18N
319: desc[i].setExpert(true);
320:
321: desc[++i].setDisplayName(bundle
322: .getString("PROP_FOLD_GENERATED_CODE")); // NOI18N
323: desc[i].setShortDescription(bundle
324: .getString("HINT_FOLD_GENERATED_CODE")); // NOI18N
325: desc[i].setExpert(true);
326:
327: desc[++i].setDisplayName(bundle
328: .getString("PROP_ASSISTANT_SHOWN")); // NOI18N
329: desc[i].setShortDescription(bundle
330: .getString("HINT_ASSISTANT_SHOWN")); // NOI18N
331: desc[i].setPreferred(true);
332:
333: desc[++i].setDisplayName(bundle
334: .getString("PROP_AUTO_RESOURCE")); // NOI18N
335: desc[i].setShortDescription(bundle
336: .getString("HINT_AUTO_RESOURCE_GLOBAL")); // NOI18N
337: desc[i].setPropertyEditorClass(ResourceModeEditor.class);
338: desc[i].setPreferred(true);
339:
340: desc[++i].setDisplayName(bundle
341: .getString("PROP_AUTO_SET_COMPONENT_NAME")); // NOI18N
342: desc[i].setShortDescription(bundle
343: .getString("HINT_AUTO_SET_COMPONENT_NAME")); // NOI18N
344: desc[i].setPropertyEditorClass(AutoNamingEditor.class);
345: desc[i].setPreferred(true);
346:
347: return desc;
348: } catch (IntrospectionException ex) {
349: throw new InternalError();
350: }
351: }
352:
353: /**
354: * Returns the FormLoaderSettings' icon.
355: *
356: * @param type icon type.
357: */
358: @Override
359: public Image getIcon(int type) {
360: return Utilities
361: .loadImage(type == java.beans.BeanInfo.ICON_COLOR_16x16
362: || type == java.beans.BeanInfo.ICON_MONO_16x16 ? iconURL
363: : icon32URL);
364: }
365:
366: @Override
367: public BeanDescriptor getBeanDescriptor() {
368: BeanDescriptor retval = new BeanDescriptor(
369: FormLoaderSettings.class, null);
370: retval.setDisplayName(NbBundle.getMessage(
371: FormLoaderSettings.class, "CTL_FormSettings")); // NOI18N
372: return retval;
373: }
374:
375: // --------
376:
377: /** Property editor for variables modifiers.
378: */
379: final public static class FieldModifierPropertyEditor extends
380: ModifierEditor {
381: static final long serialVersionUID = 7628317154007139777L;
382:
383: /** Construct new editor with mask for fields. */
384: public FieldModifierPropertyEditor() {
385: super (Modifier.PUBLIC | Modifier.PROTECTED
386: | Modifier.PRIVATE | Modifier.STATIC
387: | Modifier.FINAL | Modifier.TRANSIENT
388: | Modifier.VOLATILE);
389: }
390: }
391:
392: public final static class ListenerGenerationStyleEditor extends
393: org.netbeans.modules.form.editors.EnumEditor {
394: public ListenerGenerationStyleEditor() {
395: super (
396: new Object[] {
397: FormUtils
398: .getBundleString("CTL_LISTENER_ANONYMOUS_CLASSES"), // NOI18N
399: new Integer(
400: JavaCodeGenerator.ANONYMOUS_INNERCLASSES),
401: "", // NOI18N
402: FormUtils
403: .getBundleString("CTL_LISTENER_CEDL_INNERCLASS"), // NOI18N
404: new Integer(
405: JavaCodeGenerator.CEDL_INNERCLASS),
406: "", // NOI18N
407: FormUtils
408: .getBundleString("CTL_LISTENER_CEDL_MAINCLASS"), // NOI18N
409: new Integer(
410: JavaCodeGenerator.CEDL_MAINCLASS),
411: "" // NOI18N
412: });
413: }
414: }
415:
416: public final static class LayoutCodeTargetEditor extends
417: org.netbeans.modules.form.editors.EnumEditor {
418: public LayoutCodeTargetEditor() {
419: this (false);
420: }
421:
422: public LayoutCodeTargetEditor(boolean specific) {
423: super (
424: specific ? new Object[] {
425: FormUtils
426: .getBundleString("CTL_LAYOUT_CODE_JDK6"), // NOI18N
427: new Integer(
428: JavaCodeGenerator.LAYOUT_CODE_JDK6),
429: "", // NOI18N
430: FormUtils
431: .getBundleString("CTL_LAYOUT_CODE_LIBRARY"), // NOI18N
432: new Integer(
433: JavaCodeGenerator.LAYOUT_CODE_LIBRARY),
434: "" // NOI18N
435: }
436: : new Object[] {
437: FormUtils
438: .getBundleString("CTL_LAYOUT_CODE_AUTO"), // NOI18N
439: new Integer(
440: JavaCodeGenerator.LAYOUT_CODE_AUTO),
441: "", // NOI18N
442: FormUtils
443: .getBundleString("CTL_LAYOUT_CODE_JDK6"), // NOI18N
444: new Integer(
445: JavaCodeGenerator.LAYOUT_CODE_JDK6),
446: "", // NOI18N
447: FormUtils
448: .getBundleString("CTL_LAYOUT_CODE_LIBRARY"), // NOI18N
449: new Integer(
450: JavaCodeGenerator.LAYOUT_CODE_LIBRARY),
451: "" // NOI18N
452: });
453: }
454: }
455:
456: public final static class ResourceModeEditor extends
457: org.netbeans.modules.form.editors.EnumEditor {
458: public ResourceModeEditor() {
459: super (
460: new Object[] {
461: FormUtils
462: .getBundleString("CTL_AUTO_RESOURCE_DEFAULT"), // NOI18N
463: new Integer(
464: FormLoaderSettings.AUTO_RESOURCE_DEFAULT),
465: "", // NOI18N
466: FormUtils
467: .getBundleString("CTL_AUTO_RESOURCE_ON"), // NOI18N
468: new Integer(
469: FormLoaderSettings.AUTO_RESOURCE_ON),
470: "", // NOI18N
471: FormUtils
472: .getBundleString("CTL_AUTO_RESOURCE_OFF"), // NOI18N
473: new Integer(
474: FormLoaderSettings.AUTO_RESOURCE_OFF),
475: "" // NOI18N
476: });
477: }
478: }
479:
480: public final static class AutoNamingEditor extends
481: org.netbeans.modules.form.editors.EnumEditor {
482: public AutoNamingEditor() {
483: super (
484: new Object[] {
485: FormUtils
486: .getBundleString("CTL_AUTO_NAMING_DEFAULT"), // NOI18N
487: new Integer(
488: FormLoaderSettings.AUTO_NAMING_DEFAULT),
489: "", // NOI18N
490: FormUtils
491: .getBundleString("CTL_AUTO_NAMING_ON"), // NOI18N
492: new Integer(
493: FormLoaderSettings.AUTO_NAMING_ON),
494: "", // NOI18N
495: FormUtils
496: .getBundleString("CTL_AUTO_NAMING_OFF"), // NOI18N
497: new Integer(
498: FormLoaderSettings.AUTO_NAMING_OFF),
499: "" // NOI18N
500: });
501: }
502: }
503: }
|