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 column table properties. TODO Extend this class to expose
033: * setters for read-write property sheets (MutabledFlatfileColumnBeanInfo?)
034: *
035: * @author Jonathan Giron
036: * @version $Revision$
037: */
038: public class FlatfileColumnBeanInfo extends SimpleBeanInfo {
039:
040: private static BeanDescriptor beanDescriptor = null;
041:
042: private static PropertyDescriptor[] properties = null;
043:
044: private static EventSetDescriptor[] eventSets = null;
045:
046: private static MethodDescriptor[] methods = null;
047:
048: private static transient final Logger mLogger = LogUtil
049: .getLogger(FlatfileColumnBeanInfo.class.getName());
050:
051: private static transient final Localizer mLoc = Localizer.get();
052:
053: /**
054: * Gets the bean's <code>BeanDescriptor</code>s.
055: *
056: * @return BeanDescriptor describing the editable properties of this bean. May return
057: * null if the information should be obtained by automatic analysis.
058: */
059: public BeanDescriptor getBeanDescriptor() {
060: if (beanDescriptor == null) {
061: beanDescriptor = new BeanDescriptor(FlatfileColumn.class);
062: }
063:
064: return beanDescriptor;
065: }
066:
067: /**
068: * Gets the bean's <code>PropertyDescriptor</code>s.
069: *
070: * @return An array of PropertyDescriptors describing the editable properties
071: * supported by this bean. May return null if the information should be
072: * obtained by automatic analysis.
073: * <p>
074: * If a property is indexed, then its entry in the result array will belong to
075: * the IndexedPropertyDescriptor subclass of PropertyDescriptor. A client of
076: * getPropertyDescriptors can use "instanceof" to check if a given
077: * PropertyDescriptor is an IndexedPropertyDescriptor.
078: */
079: public PropertyDescriptor[] getPropertyDescriptors() {
080: if (properties == null) {
081: List myProps = new ArrayList();
082: String nbBundle1 = mLoc.t("PRSR001: Column name");
083: try {
084: PropertyDescriptor pd = new PropertyDescriptor("name",
085: FlatfileColumn.class, "getName", null); // NOI18N
086: String label = Localizer.parse(nbBundle1); // NOI18N
087: pd.setDisplayName(label);
088: myProps.add(pd);
089: } catch (IntrospectionException e) {
090: }
091:
092: String nbBundle2 = mLoc.t("PRSR001: Ordinal position");
093: try {
094: PropertyDescriptor pd = new PropertyDescriptor(
095: "ordinalPosition", FlatfileColumn.class,
096: "getOrdinalPosition", null); // NOI18N
097: String label = Localizer.parse(nbBundle2);// NOI18N
098: pd.setDisplayName(label);
099: myProps.add(pd);
100: } catch (IntrospectionException e) {
101: }
102:
103: String nbBundle3 = mLoc.t("PRSR001: Precision / length");
104: try {
105: PropertyDescriptor pd = new PropertyDescriptor(
106: "precision", FlatfileColumn.class,
107: "getPrecision", null); // NOI18N
108: String label = Localizer.parse(nbBundle3); // NOI18N
109: pd.setDisplayName(label);
110: myProps.add(pd);
111: } catch (IntrospectionException e) {
112: }
113:
114: String nbBundle4 = mLoc.t("PRSR001: Scale");
115: try {
116: PropertyDescriptor pd = new PropertyDescriptor("scale",
117: FlatfileColumn.class, "getScale", null); // NOI18N
118: String label = Localizer.parse(nbBundle4); // NOI18N
119: pd.setDisplayName(label);
120: myProps.add(pd);
121: } catch (IntrospectionException e) {
122: }
123:
124: String nbBundle5 = mLoc.t("PRSR001: Data type");
125: try {
126: PropertyDescriptor pd = new PropertyDescriptor(
127: "sqlType", FlatfileColumn.class,
128: "getJdbcTypeString", null); // NOI18N
129: String label = Localizer.parse(nbBundle5); // NOI18N
130: pd.setDisplayName(label);
131: myProps.add(pd);
132: } catch (IntrospectionException e) {
133: }
134: String nbBundle6 = mLoc.t("PRSR001: Nullable");
135: try {
136: PropertyDescriptor pd = new PropertyDescriptor(
137: "nullable", FlatfileColumn.class, "isNullable",
138: null); // NOI18N
139: String label = Localizer.parse(nbBundle6); // NOI18N
140: pd.setDisplayName(label);
141: myProps.add(pd);
142: } catch (IntrospectionException e) {
143: }
144:
145: String nbBundle7 = mLoc.t("PRSR001: Indexed");
146: try {
147: PropertyDescriptor pd = new PropertyDescriptor(
148: "indexed", FlatfileColumn.class, "isIndexed",
149: null); // NOI18N
150: String label = Localizer.parse(nbBundle7); // NOI18N
151: pd.setDisplayName(label);
152: myProps.add(pd);
153: } catch (IntrospectionException e) {
154: }
155:
156: String nbBundle8 = mLoc.t("PRSR001: Primary key");
157: try {
158: PropertyDescriptor pd = new PropertyDescriptor(
159: "primaryKey", FlatfileColumn.class,
160: "isPrimaryKey", null); // NOI18N
161: String label = Localizer.parse(nbBundle8); // NOI18N
162: pd.setDisplayName(label);
163: myProps.add(pd);
164: } catch (IntrospectionException e) {
165: }
166:
167: String nbBundle9 = mLoc.t("PRSR001: Foreign key");
168: try {
169: PropertyDescriptor pd = new PropertyDescriptor(
170: "foreignKey", FlatfileColumn.class,
171: "isForeignKey", null); // NOI18N
172: String label = Localizer.parse(nbBundle9); // NOI18N
173: pd.setDisplayName(label);
174: myProps.add(pd);
175: } catch (IntrospectionException e) {
176: }
177: String nbBundle10 = mLoc.t("PRSR001: Default Value");
178: try {
179: PropertyDescriptor pd = new PropertyDescriptor(
180: "defaultValue", FlatfileColumn.class,
181: "getDefaultValue", null); // NOI18N
182: String label = Localizer.parse(nbBundle10); // NOI18N
183: pd.setDisplayName(label);
184: myProps.add(pd);
185: } catch (IntrospectionException e) {
186: }
187:
188: properties = (PropertyDescriptor[]) myProps
189: .toArray(new PropertyDescriptor[myProps.size()]);
190: }
191:
192: return properties;
193: }
194:
195: /**
196: * Gets the bean's <code>EventSetDescriptor</code>s.
197: *
198: * @return An array of EventSetDescriptors describing the kinds of events fired by
199: * this bean. May return null if the information should be obtained by
200: * automatic analysis.
201: */
202: public EventSetDescriptor[] getEventSetDescriptors() {
203: if (eventSets == null) {
204: eventSets = new EventSetDescriptor[0];
205: }
206:
207: return eventSets;
208: }
209:
210: /**
211: * Gets the bean's <code>MethodDescriptor</code>s.
212: *
213: * @return An array of MethodDescriptors describing the methods implemented by this
214: * bean. May return null if the information should be obtained by automatic
215: * analysis.
216: */
217: public MethodDescriptor[] getMethodDescriptors() {
218: if (methods == null) {
219: methods = new MethodDescriptor[0];
220: }
221:
222: return methods;
223: }
224: }
|