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 fixedwidth-specific flatfile table properties. TODO Extend
031: * this class to expose setters for read-write property sheets
032: * (MutableFixedWidthFlatfileBeanInfo?)
033: *
034: * @author Jonathan Giron
035: * @version $Revision$
036: */
037: public class FixedWidthFlatfileBeanInfo extends FlatfileTableBeanInfo {
038:
039: private static BeanDescriptor beanDescriptor = null;
040: private static transient final Logger mLogger = LogUtil
041: .getLogger(FixedWidthFlatfileBeanInfo.class.getName());
042: private static transient final Localizer mLoc = Localizer.get();
043: private static PropertyDescriptor[] properties = null;
044:
045: /**
046: * Gets the bean's <code>BeanDescriptor</code>s.
047: *
048: * @return BeanDescriptor describing the editable properties of this bean. May return
049: * null if the information should be obtained by automatic analysis.
050: */
051: public BeanDescriptor getBeanDescriptor() {
052: if (beanDescriptor == null) {
053: beanDescriptor = new BeanDescriptor(
054: FixedWidthFlatfile.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: Record length");
077: try {
078: // This is a derived property and should not be writable
079: PropertyDescriptor pd = new PropertyDescriptor(
080: "recordLength", FixedWidthFlatfile.class,
081: "getRecordLength", null); // NOI18N
082: String label = Localizer.parse(nbBundle1); // NOI18N
083: pd.setDisplayName(label);
084: myProps.add(pd);
085: } catch (IntrospectionException ignore) {
086: }
087:
088: String nbBundle2 = mLoc.t("PRSR001: Header bytes to skip");
089: try {
090: PropertyDescriptor pd = new PropertyDescriptor(
091: "headerBytesOffset", FixedWidthFlatfile.class,
092: "getHeaderBytesOffset", null); // NOI18N
093: String label = Localizer.parse(nbBundle2); // NOI18N
094: pd.setDisplayName(label);
095: myProps.add(pd);
096: } catch (IntrospectionException ignore) {
097: }
098:
099: properties = (PropertyDescriptor[]) myProps
100: .toArray(new PropertyDescriptor[myProps.size()]);
101: }
102:
103: return properties;
104: }
105: }
|