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.IntrospectionException;
020: import java.beans.PropertyDescriptor;
021: import java.util.ArrayList;
022: import java.util.Arrays;
023: import java.util.List;
024:
025: import net.java.hulp.i18n.Logger;
026: import org.netbeans.modules.etl.logger.Localizer;
027: import org.netbeans.modules.etl.logger.LogUtil;
028:
029: /**
030: * Concrete class to expose delimited-specific flatfile table properties. TODO Extend this
031: * class to expose setters for read-write property sheets
032: * (MutableDelimitedFlatfileBeanInfo?)
033: *
034: * @author Jonathan Giron
035: * @author Ahimanikya Satapathy
036: * @version $Revision$
037: */
038: public class DelimitedFlatfileBeanInfo extends FlatfileTableBeanInfo {
039:
040: private static BeanDescriptor beanDescriptor = null;
041: private static transient final Logger mLogger = LogUtil
042: .getLogger(DelimitedFlatfileBeanInfo.class.getName());
043: private static transient final Localizer mLoc = Localizer.get();
044: private static PropertyDescriptor[] properties = null;
045:
046: /**
047: * Gets the bean's <code>BeanDescriptor</code>s.
048: *
049: * @return BeanDescriptor describing the editable properties of this bean. May return
050: * null if the information should be obtained by automatic analysis.
051: */
052: public BeanDescriptor getBeanDescriptor() {
053: if (beanDescriptor == null) {
054: beanDescriptor = new BeanDescriptor(DelimitedFlatfile.class);
055: }
056:
057: return beanDescriptor;
058: }
059:
060: /**
061: * Gets the bean's <code>PropertyDescriptor</code>s.
062: *
063: * @return An array of PropertyDescriptors describing the editable properties
064: * supported by this bean. May return null if the information should be
065: * obtained by automatic analysis.
066: * <p>
067: * If a property is indexed, then its entry in the result array will belong to
068: * the IndexedPropertyDescriptor subclass of PropertyDescriptor. A client of
069: * getPropertyDescriptors can use "instanceof" to check if a given
070: * PropertyDescriptor is an IndexedPropertyDescriptor.
071: */
072: public PropertyDescriptor[] getPropertyDescriptors() {
073: if (properties == null) {
074: List myProps = new ArrayList(Arrays.asList(super
075: .getPropertyDescriptors()));
076: String nbBundle1 = mLoc.t("PRSR001: Field delimiter");
077: try {
078: PropertyDescriptor pd = new PropertyDescriptor(
079: "fieldDelimiter", DelimitedFlatfile.class,
080: "getFieldDelimiter", null); // NOI18N
081: String label = Localizer.parse(nbBundle1); // NOI18N
082: pd.setDisplayName(label);
083: myProps.add(pd);
084: } catch (IntrospectionException ignore) {
085: }
086: String nbBundle2 = mLoc.t("PRSR001: Text qualifier");
087: try {
088: PropertyDescriptor pd = new PropertyDescriptor(
089: "fieldQualifier", DelimitedFlatfile.class,
090: "getTextQualifier", null); // NOI18N
091: String label = Localizer.parse(nbBundle2); // NOI18N
092: pd.setDisplayName(label);
093: myProps.add(pd);
094: } catch (IntrospectionException ignore) {
095: }
096:
097: properties = (PropertyDescriptor[]) myProps
098: .toArray(new PropertyDescriptor[myProps.size()]);
099: }
100:
101: return properties;
102: }
103: }
|