001: /*
002: *
003: * Copyright (c) 2005, SeeBeyond Technology Corporation,
004: * All Rights Reserved
005: *
006: * This program, and all the routines referenced herein,
007: * are the proprietary properties and trade secrets of
008: * SEEBEYOND TECHNOLOGY CORPORATION.
009: *
010: * Except as provided for by license agreement, this
011: * program shall not be duplicated, used, or disclosed
012: * without written consent signed by an officer of
013: * SEEBEYOND TECHNOLOGY CORPORATION.
014: *
015: */
016: package org.netbeans.modules.mashup.db.ui.model;
017:
018: import java.beans.BeanDescriptor;
019: import java.beans.EventSetDescriptor;
020: import java.beans.IntrospectionException;
021: import java.beans.MethodDescriptor;
022: import java.beans.PropertyDescriptor;
023: import java.beans.SimpleBeanInfo;
024: import java.util.ArrayList;
025: import java.util.List;
026:
027: import net.java.hulp.i18n.Logger;
028: import org.netbeans.modules.etl.logger.Localizer;
029: import org.netbeans.modules.etl.logger.LogUtil;
030:
031: /**
032: * Exposes getters for flatfile database properties. TODO Extend this class to expose
033: * setters for read-write property sheets (MutabledFlatfileDatabaseBeanInfo?)
034: *
035: * @author Jonathan Giron
036: * @version $Revision$
037: */
038: public class FlatfileDatabaseBeanInfo extends SimpleBeanInfo {
039:
040: private static BeanDescriptor beanDescriptor = null;
041: private static EventSetDescriptor[] eventSet = null;
042: private static MethodDescriptor[] methods = null;
043: private static PropertyDescriptor[] properties = null;
044: private static transient final Logger mLogger = LogUtil
045: .getLogger(FlatfileDatabaseBeanInfo.class.getName());
046: private static transient final Localizer mLoc = Localizer.get();
047: private static int defaultPropertyIndex = -1; // GEN-BEGIN:Idx
048: private static int defaultEventIndex = -1; // GEN-END:Idx
049:
050: /**
051: * Gets the bean's <code>BeanDescriptor</code>s.
052: *
053: * @return BeanDescriptor describing the editable properties of this bean. May return
054: * null if the information should be obtained by automatic analysis.
055: */
056: public BeanDescriptor getBeanDescriptor() {
057: if (beanDescriptor == null) {
058: beanDescriptor = new BeanDescriptor(FlatfileDatabase.class);
059: }
060:
061: return beanDescriptor;
062: }
063:
064: /**
065: * Gets the bean's <code>PropertyDescriptor</code>s.
066: *
067: * @return An array of PropertyDescriptors describing the editable properties
068: * supported by this bean. May return null if the information should be
069: * obtained by automatic analysis.
070: * <p>
071: * If a property is indexed, then its entry in the result array will belong to
072: * the IndexedPropertyDescriptor subclass of PropertyDescriptor. A client of
073: * getPropertyDescriptors can use "instanceof" to check if a given
074: * PropertyDescriptor is an IndexedPropertyDescriptor.
075: */
076: public PropertyDescriptor[] getPropertyDescriptors() {
077: if (properties == null) {
078: List myProps = new ArrayList();
079:
080: try {
081: PropertyDescriptor pd = new PropertyDescriptor("name",
082: FlatfileDatabase.class, "getName", null); // NOI18N
083: String nbBundle1 = mLoc
084: .t("PRSR001: Flat file definition name");
085: String label = Localizer.parse(nbBundle1); // NOI18N
086: pd.setDisplayName(label);
087: myProps.add(pd);
088: } catch (IntrospectionException e) {
089: }
090:
091: try {
092: PropertyDescriptor pd = new PropertyDescriptor(
093: "description", FlatfileDatabase.class,
094: "getDescription", null); // NOI18N
095: String nbBundle2 = mLoc.t("PRSR001: Description");
096: String label = Localizer.parse(nbBundle2); // NOI18N
097: pd.setDisplayName(label);
098: myProps.add(pd);
099: } catch (IntrospectionException e) {
100: }
101:
102: properties = (PropertyDescriptor[]) myProps
103: .toArray(new PropertyDescriptor[myProps.size()]);
104: }
105:
106: return properties;
107: }
108:
109: /**
110: * Gets the bean's <code>EventSetDescriptor</code>s.
111: *
112: * @return An array of EventSetDescriptors describing the kinds of events fired by
113: * this bean. May return null if the information should be obtained by
114: * automatic analysis.
115: */
116: public EventSetDescriptor[] getEventSetDescriptors() {
117: if (eventSet == null) {
118: eventSet = new EventSetDescriptor[0];
119: }
120: return eventSet;
121: }
122:
123: /**
124: * Gets the bean's <code>MethodDescriptor</code>s.
125: *
126: * @return An array of MethodDescriptors describing the methods implemented by this
127: * bean. May return null if the information should be obtained by automatic
128: * analysis.
129: */
130: public MethodDescriptor[] getMethodDescriptors() {
131: if (methods == null) {
132: methods = new MethodDescriptor[0];
133: }
134:
135: return methods;
136: }
137:
138: /**
139: * A bean may have a "default" property that is the property that will mostly commonly
140: * be initially chosen for update by human's who are customizing the bean.
141: *
142: * @return Index of default property in the PropertyDescriptor array returned by
143: * getPropertyDescriptors.
144: * <P>
145: * Returns -1 if there is no default property.
146: */
147: public int getDefaultPropertyIndex() {
148: return defaultPropertyIndex;
149: }
150:
151: /**
152: * A bean may have a "default" event that is the event that will mostly commonly be
153: * used by human's when using the bean.
154: *
155: * @return Index of default event in the EventSetDescriptor array returned by
156: * getEventSetDescriptors.
157: * <P>
158: * Returns -1 if there is no default event.
159: */
160: public int getDefaultEventIndex() {
161: return defaultEventIndex;
162: }
163: }
|