001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: //
007: package com.sun.portal.ffj.options;
008:
009: //
010: import java.awt.Image;
011: import java.beans.*;
012:
013: import org.openide.TopManager;
014: import org.openide.ErrorManager;
015:
016: import org.openide.util.NbBundle;
017:
018: import com.sun.portal.ffj.util.PSConstants;
019:
020: //
021: public class PSSettingsBeanInfo extends SimpleBeanInfo implements
022: PSConstants {
023: //
024: //
025: //
026: public PropertyDescriptor[] getPropertyDescriptors() {
027: try {
028: //
029: PropertyDescriptor classPath = new PropertyDescriptor(
030: PSSettings.PROP_CLASSPATH, PSSettings.class);
031: classPath.setDisplayName(NbBundle.getMessage(
032: PSSettingsBeanInfo.class, "PROP_"
033: + PSSettings.PROP_CLASSPATH));
034: classPath.setShortDescription(NbBundle.getMessage(
035: PSSettingsBeanInfo.class, "HINT_"
036: + PSSettings.PROP_CLASSPATH));
037:
038: //
039: PropertyDescriptor docRoot = new PropertyDescriptor(
040: PSSettings.PROP_DOCROOT, PSSettings.class);
041: docRoot.setDisplayName(NbBundle.getMessage(
042: PSSettingsBeanInfo.class, "PROP_"
043: + PSSettings.PROP_DOCROOT));
044: docRoot.setShortDescription(NbBundle.getMessage(
045: PSSettingsBeanInfo.class, "HINT_"
046: + PSSettings.PROP_DOCROOT));
047:
048: //
049: PropertyDescriptor debugTrace = new PropertyDescriptor(
050: PSSettings.PROP_DEBUGTRACE, PSSettings.class);
051: debugTrace.setDisplayName(NbBundle.getMessage(
052: PSSettingsBeanInfo.class, "PROP_"
053: + PSSettings.PROP_DEBUGTRACE));
054: debugTrace.setShortDescription(NbBundle.getMessage(
055: PSSettingsBeanInfo.class, "HINT_"
056: + PSSettings.PROP_DEBUGTRACE));
057: debugTrace.setPropertyEditorClass(DebugTraceEd.class);
058:
059: //
060: PropertyDescriptor userName = new PropertyDescriptor(
061: PSSettings.PROP_USERNAME, PSSettings.class);
062: userName.setDisplayName(NbBundle.getMessage(
063: PSSettingsBeanInfo.class, "PROP_"
064: + PSSettings.PROP_USERNAME));
065: userName.setShortDescription(NbBundle.getMessage(
066: PSSettingsBeanInfo.class, "HINT_"
067: + PSSettings.PROP_USERNAME));
068:
069: //
070: PropertyDescriptor configDir = new PropertyDescriptor(
071: PSSettings.PROP_CONFIGDIR, PSSettings.class);
072: configDir.setDisplayName(NbBundle.getMessage(
073: PSSettingsBeanInfo.class, "PROP_"
074: + PSSettings.PROP_CONFIGDIR));
075: configDir.setShortDescription(NbBundle.getMessage(
076: PSSettingsBeanInfo.class, "HINT_"
077: + PSSettings.PROP_CONFIGDIR));
078:
079: return new PropertyDescriptor[] { classPath, docRoot,
080: debugTrace, userName, configDir };
081: } catch (IntrospectionException ie) {
082: TopManager.getDefault().getErrorManager().notify(
083: ErrorManager.USER, ie);
084: return null;
085: }
086: }
087:
088: //
089: //
090: //
091: public static class DebugTraceEd extends PropertyEditorSupport {
092: //
093: //
094: //
095: private static final String[] tags = {
096: NbBundle.getMessage(PSSettingsBeanInfo.class,
097: "LBL_DEBUG_OFF"),
098: NbBundle.getMessage(PSSettingsBeanInfo.class,
099: "LBL_DEBUG_WARNING"),
100: NbBundle.getMessage(PSSettingsBeanInfo.class,
101: "LBL_DEBUG_MESSAGE"),
102: NbBundle.getMessage(PSSettingsBeanInfo.class,
103: "LBL_DEBUG_ERROR") };
104:
105: //
106: //
107: //
108: public String[] getTags() {
109: return tags;
110: }
111:
112: //
113: public String getAsText() {
114: return tags[((Short) getValue()).shortValue()];
115: }
116:
117: //
118: public void setAsText(String text)
119: throws IllegalArgumentException {
120: //
121: if (tags[0].equals(text))
122: setValue(new Short(DEBUG_OFF));
123: else if (tags[1].equals(text))
124: setValue(new Short(DEBUG_WARNING));
125: else if (tags[2].equals(text))
126: setValue(new Short(DEBUG_MESSAGE));
127: else if (tags[3].equals(text))
128: setValue(new Short(DEBUG_ERROR));
129: else
130: throw new IllegalArgumentException();
131: }
132:
133: //
134: //
135: //
136: }
137:
138: //
139: //
140: //
141: }
|