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: * Abstract BeanInfo implementation to expose read-only access to selected table
033: * properties.
034: *
035: * @author Jonathan Giron
036: * @author Ahimanikya Satapathy
037: * @version $Revision$
038: */
039: public abstract class FlatfileTableBeanInfo extends SimpleBeanInfo {
040:
041: private static PropertyDescriptor[] properties = null;
042: private static EventSetDescriptor[] eventSets = null;
043: private static MethodDescriptor[] methods = null;
044: private static transient final Logger mLogger = LogUtil
045: .getLogger(FlatfileTableBeanInfo.class.getName());
046: private static transient final Localizer mLoc = Localizer.get();
047:
048: /**
049: * Gets the bean's <code>BeanDescriptor</code>s.
050: *
051: * @return BeanDescriptor describing the editable properties of this bean. May return
052: * null if the information should be obtained by automatic analysis.
053: */
054: public abstract BeanDescriptor getBeanDescriptor();
055:
056: /**
057: * Gets the bean's <code>PropertyDescriptor</code>s.
058: *
059: * @return An array of PropertyDescriptors describing the editable properties
060: * supported by this bean. May return null if the information should be
061: * obtained by automatic analysis.
062: * <p>
063: * If a property is indexed, then its entry in the result array will belong to
064: * the IndexedPropertyDescriptor subclass of PropertyDescriptor. A client of
065: * getPropertyDescriptors can use "instanceof" to check if a given
066: * PropertyDescriptor is an IndexedPropertyDescriptor.
067: */
068: public PropertyDescriptor[] getPropertyDescriptors() {
069: if (properties == null) {
070: List myProps = new ArrayList();
071:
072: try {
073: PropertyDescriptor pd = new PropertyDescriptor(
074: "tableName", FlatfileTable.class,
075: "getTableName", null); // NOI18N
076: String nbBundle1 = mLoc.t("PRSR001: Table name");
077: String label = Localizer.parse(nbBundle1); // NOI18N
078: pd.setDisplayName(label);
079: myProps.add(pd);
080: } catch (IntrospectionException e) {
081: }
082:
083: try {
084: PropertyDescriptor pd = new PropertyDescriptor(
085: "fileType", FlatfileTable.class, "getFileType",
086: null); // NOI18N
087: String nbBundle2 = mLoc.t("PRSR001: File type");
088: String label = Localizer.parse(nbBundle2); // NOI18N
089: pd.setDisplayName(label);
090: myProps.add(pd);
091: } catch (IntrospectionException e) {
092: }
093:
094: try {
095: PropertyDescriptor pd = new PropertyDescriptor(
096: "description", FlatfileTable.class,
097: "getDescription", null); // NOI18N
098: String nbBundle3 = mLoc.t("PRSR001: Description");
099: String label = Localizer.parse(nbBundle3); // NOI18N
100: pd.setDisplayName(label);
101: myProps.add(pd);
102: } catch (IntrospectionException ignore) {
103: }
104:
105: try {
106: PropertyDescriptor pd = new PropertyDescriptor(
107: "fileName", FlatfileTable.class, "getFileName",
108: null); // NOI18N
109: String nbBundle4 = mLoc.t("PRSR001: File name");
110: String label = Localizer.parse(nbBundle4);// NOI18N
111: pd.setDisplayName(label);
112: myProps.add(pd);
113: } catch (IntrospectionException e) {
114: }
115:
116: try {
117: PropertyDescriptor pd = new PropertyDescriptor(
118: "encodingScheme", FlatfileTable.class,
119: "getEncodingScheme", null); // NOI18N
120: String nbBundle5 = mLoc.t("PRSR001: Encoding scheme");
121: String label = Localizer.parse(nbBundle5); // NOI18N
122: pd.setDisplayName(label);
123: myProps.add(pd);
124: } catch (IntrospectionException ignore) {
125: }
126:
127: try {
128: PropertyDescriptor pd = new PropertyDescriptor(
129: "rowsToSkip", FlatfileTable.class,
130: "getRowsToSkip", null); // NOI18N
131: String nbBundle6 = mLoc
132: .t("PRSR001: Initial rows to skip");
133: String label = Localizer.parse(nbBundle6); // NOI18N
134: pd.setDisplayName(label);
135: myProps.add(pd);
136: } catch (IntrospectionException ignore) {
137: }
138:
139: try {
140: PropertyDescriptor pd = new PropertyDescriptor(
141: "maxFaults", FlatfileTable.class,
142: "getMaxFaults", null); // NOI18N
143: String nbBundle7 = mLoc
144: .t("PRSR001: Maximum # faults to tolerate");
145: String label = Localizer.parse(nbBundle7); // NOI18N
146: pd.setDisplayName(label);
147: myProps.add(pd);
148: } catch (IntrospectionException ignore) {
149: }
150:
151: try {
152: PropertyDescriptor pd = new PropertyDescriptor(
153: "isFirstLineHeader", FlatfileTable.class,
154: "isFirstLineHeader", null); // NOI18N
155: String nbBundle8 = mLoc
156: .t("PRSR001: First line is header");
157: String label = Localizer.parse(nbBundle8); // NOI18N
158: pd.setDisplayName(label);
159: myProps.add(pd);
160: } catch (IntrospectionException ignore) {
161: }
162:
163: try {
164: PropertyDescriptor pd = new PropertyDescriptor(
165: "recordDelimiter", FlatfileTable.class,
166: "getRecordDelimiter", null); // NOI18N
167: String nbBundle9 = mLoc.t("PRSR001: Record delimiter");
168: String label = Localizer.parse(nbBundle9); // NOI18N
169: pd.setDisplayName(label);
170: myProps.add(pd);
171: } catch (IntrospectionException ignore) {
172: }
173:
174: try {
175: PropertyDescriptor pd = new PropertyDescriptor(
176: "trimWhiteSpace", FlatfileTable.class,
177: "enableWhiteSpaceTrimming", null); // NOI18N
178: String nbBundle10 = mLoc
179: .t("PRSR001: Trim white space for columns");
180: String label = Localizer.parse(nbBundle10); // NOI18N
181: pd.setDisplayName(label);
182: myProps.add(pd);
183: } catch (IntrospectionException ignore) {
184: }
185:
186: properties = (PropertyDescriptor[]) myProps
187: .toArray(new PropertyDescriptor[myProps.size()]);
188: }
189:
190: return properties;
191: }
192:
193: /**
194: * Gets the bean's <code>EventSetDescriptor</code>s.
195: *
196: * @return An array of EventSetDescriptors describing the kinds of events fired by
197: * this bean. May return null if the information should be obtained by
198: * automatic analysis.
199: */
200: public EventSetDescriptor[] getEventSetDescriptors() {
201: if (eventSets == null) {
202: eventSets = new EventSetDescriptor[0];
203: }
204:
205: return eventSets;
206: }
207:
208: /**
209: * Gets the bean's <code>MethodDescriptor</code>s.
210: *
211: * @return An array of MethodDescriptors describing the methods implemented by this
212: * bean. May return null if the information should be obtained by automatic
213: * analysis.
214: */
215: public MethodDescriptor[] getMethodDescriptors() {
216: if (methods == null) {
217: methods = new MethodDescriptor[0];
218: }
219:
220: return methods;
221: }
222: }
|