0001: //** Copyright Statement ***************************************************
0002: //The Salmon Open Framework for Internet Applications (SOFIA)
0003: // Copyright (C) 1999 - 2002, Salmon LLC
0004: //
0005: // This program is free software; you can redistribute it and/or
0006: // modify it under the terms of the GNU General Public License version 2
0007: // as published by the Free Software Foundation;
0008: //
0009: // This program is distributed in the hope that it will be useful,
0010: // but WITHOUT ANY WARRANTY; without even the implied warranty of
0011: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0012: // GNU General Public License for more details.
0013: //
0014: // You should have received a copy of the GNU General Public License
0015: // along with this program; if not, write to the Free Software
0016: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
0017: //
0018: // For more information please visit http://www.salmonllc.com
0019: //** End Copyright Statement ***************************************************
0020: package com.salmonllc.ideTools;
0021:
0022: /////////////////////////
0023: //$Archive: /SOFIA/SourceCode/com/salmonllc/ideTools/ListFormDialog.java $
0024: //$Author: Dan $
0025: //$Revision: 11 $
0026: //$Modtime: 6/11/03 4:40p $
0027: /////////////////////////
0028: import com.salmonllc.sql.DataDictionary;
0029: import com.salmonllc.sql.DataStore;
0030: import com.salmonllc.sql.ColumnDefinition;
0031: import com.salmonllc.properties.Props;
0032: import com.salmonllc.util.Util;
0033: import com.salmonllc.xml.*;
0034: import javax.swing.*;
0035: import javax.swing.event.ListSelectionListener;
0036: import javax.swing.event.ListSelectionEvent;
0037: import javax.swing.event.CaretListener;
0038: import javax.swing.event.CaretEvent;
0039: import javax.swing.border.EmptyBorder;
0040: import java.awt.*;
0041: import java.awt.event.*;
0042: import java.util.Vector;
0043: import java.io.*;
0044:
0045: public class ListFormDialog extends JDialog implements ActionListener,
0046: ListSelectionListener, CaretListener, KeyListener {
0047:
0048: JButton _export;
0049: JButton _import;
0050: JButton _cancel;
0051: JPanel _main;
0052: JTextField _xmlName;
0053: JComboBox _tables, _bucketType, _colCompType;
0054: JList _colList, _colsInListForm;
0055: JTextField _colBucket, _colFormat, _colCaption, _colCompName,
0056: _colHref;
0057: JButton _addCol, _delCol, _updateCol, _fileButton, _up, _down,
0058: _clear;
0059: JCheckBox _updateable, _searchDisplay, _listDisplay,
0060: _detailDisplay, _mandatory, _readonly, _locked,
0061: _precedence, _exactmatch, _leadingwildcard, _casesensitive,
0062: _nullable, _primarykey;
0063: DataDictionary _dd;
0064: Frame _owner;
0065: boolean _clickedCancel = true;
0066: DataStore _ds = new DataStore();
0067:
0068: public class DataType {
0069: public int type;
0070:
0071: public DataType(int type) {
0072: this .type = type;
0073: }
0074:
0075: public DataType(String sType) {
0076: this .type = XMLTransporter.mapDataType(sType);
0077: }
0078:
0079: public String toString() {
0080: if (type == DataStore.DATATYPE_BYTEARRAY)
0081: return "binary";
0082: else if (type == DataStore.DATATYPE_DATE)
0083: return "date";
0084: else if (type == DataStore.DATATYPE_DATETIME)
0085: return "datetime";
0086: else if (type == DataStore.DATATYPE_DOUBLE)
0087: return "double";
0088: else if (type == DataStore.DATATYPE_FLOAT)
0089: return "float";
0090: else if (type == DataStore.DATATYPE_INT)
0091: return "int";
0092: else if (type == DataStore.DATATYPE_LONG)
0093: return "long";
0094: else if (type == DataStore.DATATYPE_SHORT)
0095: return "short";
0096: else if (type == DataStore.DATATYPE_STRING)
0097: return "string";
0098: else if (type == DataStore.DATATYPE_TIME)
0099: return "time";
0100: else
0101: return "unknown";
0102: }
0103:
0104: public int getType() {
0105: return type;
0106: }
0107: }
0108:
0109: public class ColumnDef {
0110: public ColumnDefinition def;
0111: public String bucket;
0112: public DataType bucketType;
0113: public String caption, compname, comptype, format,
0114: hrefexpression;
0115: public boolean detaildisplay, listdisplay, searchdisplay,
0116: locked, mandatory, readonly, casesensitive, exactmatch,
0117: leadingwildcard, precedence, nullable, primarykey,
0118: updateable;
0119: private int DISPLAY_SHORT = 0;
0120: private int DISPLAY_LONG = 1;
0121: private int DISPLAY_FULL = 2;
0122: private int _display = DISPLAY_SHORT;
0123:
0124: public ColumnDef(ColumnDefinition def, boolean displayShort) {
0125: this .def = def;
0126: _display = displayShort ? DISPLAY_SHORT : DISPLAY_FULL;
0127: }
0128:
0129: public String getColumnName() {
0130: if (def == null)
0131: return bucket;
0132: else
0133: return def.getColumnName();
0134: }
0135:
0136: public String getTableName() {
0137: if (def == null)
0138: return "";
0139: else
0140: return def.getTableName();
0141: }
0142:
0143: public String getColumnType() {
0144: if (def == null)
0145: return bucketType.toString();
0146: else
0147: return (new DataType(def.getDSDataType())).toString();
0148: }
0149:
0150: public boolean isBucket() {
0151: if (def == null)
0152: return true;
0153: return false;
0154: }
0155:
0156: public String toString() {
0157: if (_display == DISPLAY_SHORT) {
0158: if (def == null)
0159: return bucket;
0160: else
0161: return def.getColumnName();
0162: } else if (_display == DISPLAY_LONG) {
0163: if (def == null)
0164: return bucket;
0165: else
0166: return def.getTableName() + "."
0167: + def.getColumnName();
0168: } else if (_display == DISPLAY_FULL) {
0169: String tab;
0170: String nme;
0171: if (def == null) {
0172: tab = "";
0173: nme = bucket;
0174: } else {
0175: tab = def.getTableName() == null ? "" : def
0176: .getTableName();
0177: nme = tab == "" ? def.getColumnName() : tab + "."
0178: + def.getColumnName();
0179: }
0180: String cap = (caption == null || caption.length() == 0) ? ""
0181: : " | caption:" + caption;
0182: String cname = (compname == null || compname.length() == 0) ? ""
0183: : " | component name:" + compname;
0184: String ctype = (comptype == null || comptype.length() == 0) ? ""
0185: : " | component type:" + comptype;
0186: String fmt = (format == null || format.length() == 0) ? ""
0187: : " | format:" + format;
0188: String href = (hrefexpression == null || hrefexpression
0189: .length() == 0) ? "" : " | Href:"
0190: + hrefexpression;
0191: String ddisp = detaildisplay ? " | detail display:yes"
0192: : " | detail display:no";
0193: String ldisp = listdisplay ? " | list display:yes"
0194: : " | list display:no";
0195: String sdisp = searchdisplay ? " | search display:yes"
0196: : " | search display:no";
0197: String lock = locked ? " | locked:yes" : " | locked:no";
0198: String mand = mandatory ? " | mandatory:yes"
0199: : " | mandatory:no";
0200: String ronly = readonly ? " | read only:yes"
0201: : " | read only:no";
0202: String csens = casesensitive ? " | case sensitive:yes"
0203: : " | case sensitive:no";
0204: String ematch = exactmatch ? " | exact match:yes"
0205: : " | exact match:no";
0206: String lcard = leadingwildcard ? " | leading wildcard:yes"
0207: : " | leading wildcard:no";
0208: String pre = precedence ? " | precedence:yes"
0209: : " | precedence:no";
0210: String nul = nullable ? " | nullable:yes"
0211: : " | nullable:no";
0212: String pkey = primarykey ? " | primary key:yes"
0213: : " | primary key:no";
0214: String upd = updateable ? " | update:yes"
0215: : " | update:no";
0216: return nme + cap + cname + ctype + fmt + href + ddisp
0217: + ldisp + sdisp + lock + mand + ronly + csens
0218: + ematch + lcard + pre + nul + pkey + upd;
0219: }
0220: return "";
0221:
0222: }
0223:
0224: public void setFormat(String format) {
0225: this .format = format;
0226: }
0227:
0228: public void setComptype(String comptype) {
0229: this .comptype = comptype;
0230: }
0231:
0232: public void setCompname(String compname) {
0233: this .compname = compname;
0234: }
0235:
0236: public void setCaption(String caption) {
0237: this .caption = caption;
0238: }
0239:
0240: public void setHrefexpression(String hrefexpression) {
0241: this .hrefexpression = hrefexpression;
0242: }
0243:
0244: public void setDetaildisplay(boolean detaildisplay) {
0245: this .detaildisplay = detaildisplay;
0246: }
0247:
0248: public void setListdisplay(boolean listdisplay) {
0249: this .listdisplay = listdisplay;
0250: }
0251:
0252: public void setSearchdisplay(boolean searchdisplay) {
0253: this .searchdisplay = searchdisplay;
0254: }
0255:
0256: public void setLocked(boolean locked) {
0257: this .locked = locked;
0258: }
0259:
0260: public void setMandatory(boolean mandatory) {
0261: this .mandatory = mandatory;
0262: }
0263:
0264: public void setReadonly(boolean readonly) {
0265: this .readonly = readonly;
0266: }
0267:
0268: public void setCasesensitive(boolean casesensitive) {
0269: this .casesensitive = casesensitive;
0270: }
0271:
0272: public void setExactmatch(boolean exactmatch) {
0273: this .exactmatch = exactmatch;
0274: }
0275:
0276: public void setLeadingwildcard(boolean leadingwildcard) {
0277: this .leadingwildcard = leadingwildcard;
0278: }
0279:
0280: public void setPrecedence(boolean precedence) {
0281: this .precedence = precedence;
0282: }
0283:
0284: public void setNullable(boolean nullable) {
0285: this .nullable = nullable;
0286: }
0287:
0288: public void setPrimarykey(boolean primarykey) {
0289: this .primarykey = primarykey;
0290: }
0291:
0292: public void setUpdateable(boolean updateable) {
0293: this .updateable = updateable;
0294: }
0295:
0296: public void setBucket(String bucket) {
0297: this .bucket = bucket;
0298: }
0299:
0300: public void setBucketType(DataType bucketType) {
0301: this .bucketType = bucketType;
0302: }
0303:
0304: public String getCaption() {
0305: return caption;
0306: }
0307:
0308: public String getComponentName() {
0309: return compname;
0310: }
0311:
0312: public String getComponentType() {
0313: return comptype;
0314: }
0315:
0316: public String getFormat() {
0317: return format;
0318: }
0319:
0320: public String getHrefExpression() {
0321: return hrefexpression;
0322: }
0323:
0324: public boolean getDetailDisplay() {
0325: return detaildisplay;
0326: }
0327:
0328: public boolean getListDisplay() {
0329: return listdisplay;
0330: }
0331:
0332: public boolean getSearchDisplay() {
0333: return searchdisplay;
0334: }
0335:
0336: public boolean getLocked() {
0337: return locked;
0338: }
0339:
0340: public boolean getMandatory() {
0341: return mandatory;
0342: }
0343:
0344: public boolean getReadonly() {
0345: return readonly;
0346: }
0347:
0348: public boolean getCaseSensitive() {
0349: return casesensitive;
0350: }
0351:
0352: public boolean getExactMatch() {
0353: return exactmatch;
0354: }
0355:
0356: public boolean getLeadingWildcard() {
0357: return leadingwildcard;
0358: }
0359:
0360: public boolean getPrecedence() {
0361: return precedence;
0362: }
0363:
0364: public boolean getNullable() {
0365: return nullable;
0366: }
0367:
0368: public boolean getPrimaryKey() {
0369: return primarykey;
0370: }
0371:
0372: public boolean getUpdateable() {
0373: return updateable;
0374: }
0375:
0376: public String getBucket() {
0377: return bucket;
0378: }
0379:
0380: public DataType getBucketType() {
0381: return bucketType;
0382: }
0383:
0384: public ColumnDefinition getColumnDefinition() {
0385: return def;
0386: }
0387:
0388: public void setColumnDefinition(ColumnDefinition def) {
0389: this .def = def;
0390: }
0391: }
0392:
0393: public class AliasDef {
0394: public String table, alias;
0395:
0396: public AliasDef(String table, String alias) {
0397: this .table = table;
0398: this .alias = alias;
0399: }
0400:
0401: public String toString() {
0402: if (alias == null)
0403: return table;
0404: else
0405: return alias + " (" + table + ")";
0406: }
0407: }
0408:
0409: public ListFormDialog(Frame owner) {
0410: super (owner, "Generate Form XML", true);
0411: _owner = owner;
0412: setModal(true);
0413: setResizable(false);
0414: //create a data dictionary object
0415: _dd = new DataDictionary(
0416: Props
0417: .getSystemProps()
0418: .getProperty(
0419: IDETool
0420: .getProjectProperty(Props.IDE_DEFAULT_FRAMEWORK_APP)));
0421: Props props = Props
0422: .getProps(
0423: Props
0424: .getSystemProps()
0425: .getProperty(
0426: IDETool
0427: .getProjectProperty(Props.IDE_DEFAULT_FRAMEWORK_APP)),
0428: "");
0429: String xmlPath = props.getProperty(Props.XML_DATA_PATH);
0430: int width = 780;
0431: int height = 580;
0432: Dimension frameBounds = Toolkit.getDefaultToolkit()
0433: .getScreenSize();
0434: int x = (frameBounds.width - width) / 2;
0435: int y = (frameBounds.height - height) / 2;
0436: setBounds(x, y, width, height);
0437: JPanel box = new JPanel();
0438:
0439: //main box
0440: _main = new JPanel();
0441: _main.setLayout(new BoxLayout(_main, BoxLayout.Y_AXIS));
0442: _main.setBorder(new EmptyBorder(10, 10, 10, 10));
0443:
0444: //row 1, class name
0445: box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
0446: box
0447: .add(DialogComponentFactory.makeLabel("XML File Name:",
0448: 150));
0449: box.add(_xmlName = DialogComponentFactory.makeTextField(150));
0450: box.add(Box.createRigidArea(new Dimension(2, 0)));
0451: box.add(_fileButton = DialogComponentFactory.makeButton("...",
0452: 40, 28));
0453: box.add(Box.createHorizontalGlue());
0454: _main.add(box);
0455: _main.add(Box.createRigidArea(new Dimension(0, 5)));
0456:
0457: //row 2, file drop down label, Columns in Data Store Label, Columns in sort label
0458: box = new JPanel();
0459: box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
0460: box.add(DialogComponentFactory.makeLabel(
0461: "Tables/Columns in DataBase:", 200));
0462:
0463: box.add(Box.createHorizontalGlue());
0464: _main.add(box);
0465:
0466: //row 3, name, updatable, format
0467: _main.add(Box.createRigidArea(new Dimension(0, 5)));
0468: box = new JPanel();
0469: box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
0470: box.add(_tables = DialogComponentFactory.makeComboBox(200));
0471: box.add(Box.createRigidArea(new Dimension(10, 0)));
0472: box.add(DialogComponentFactory.makeLabel("Bucket:", 87));
0473: box.add(_colBucket = DialogComponentFactory.makeTextField(44));
0474: box.add(Box.createRigidArea(new Dimension(2, 0)));
0475: box.add(DialogComponentFactory.makeLabel("Bucket Type:", 107));
0476: box.add(_bucketType = DialogComponentFactory.makeComboBox(150));
0477: _bucketType.addItem(new DataType(DataStore.DATATYPE_BYTEARRAY));
0478: _bucketType.addItem(new DataType(DataStore.DATATYPE_DATE));
0479: _bucketType.addItem(new DataType(DataStore.DATATYPE_DATETIME));
0480: _bucketType.addItem(new DataType(DataStore.DATATYPE_DOUBLE));
0481: _bucketType.addItem(new DataType(DataStore.DATATYPE_FLOAT));
0482: _bucketType.addItem(new DataType(DataStore.DATATYPE_INT));
0483: _bucketType.addItem(new DataType(DataStore.DATATYPE_LONG));
0484: _bucketType.addItem(new DataType(DataStore.DATATYPE_SHORT));
0485: _bucketType.addItem(new DataType(DataStore.DATATYPE_STRING));
0486: _bucketType.addItem(new DataType(DataStore.DATATYPE_TIME));
0487: box.add(Box.createHorizontalGlue());
0488: _main.add(box);
0489:
0490: //row 4, Columns, in model, in sort
0491: box = new JPanel();
0492: box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
0493: box.add(DialogComponentFactory.makeScrollPane(200, 170,
0494: _colList = DialogComponentFactory
0495: .makeList(new LModel())));
0496: JPanel box2Main = new JPanel();
0497: box2Main.setLayout(new BoxLayout(box2Main, BoxLayout.Y_AXIS));
0498: box2Main.add(Box.createRigidArea(new Dimension(0, 5)));
0499:
0500: JPanel box2 = new JPanel();
0501: box2.setLayout(new BoxLayout(box2, BoxLayout.X_AXIS));
0502: box2.add(Box.createRigidArea(new Dimension(10, 0)));
0503: box2.add(DialogComponentFactory.makeLabel("Attributes:", 67));
0504: box2.add(Box.createHorizontalGlue());
0505: box2Main.add(box2);
0506: box2 = new JPanel();
0507: box2.setLayout(new BoxLayout(box2, BoxLayout.X_AXIS));
0508: box2.add(Box.createRigidArea(new Dimension(10, 0)));
0509: box2.add(DialogComponentFactory.makeLabel("Caption:", 47));
0510: box2
0511: .add(_colCaption = DialogComponentFactory
0512: .makeTextField(44));
0513: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0514: box2.add(DialogComponentFactory.makeLabel("Component Name:",
0515: 107));
0516: box2.add(_colCompName = DialogComponentFactory
0517: .makeTextField(44));
0518: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0519: box2.add(DialogComponentFactory.makeLabel("Component Type:",
0520: 107));
0521: box2.add(_colCompType = DialogComponentFactory
0522: .makeComboBox(150));
0523: _colCompType.addItem("");
0524: _colCompType.addItem("HtmlCheckBox");
0525: _colCompType.addItem("HtmlDateComponent");
0526: _colCompType.addItem("HtmlEMailComponent");
0527: _colCompType.addItem("HtmlFileUpload");
0528: _colCompType.addItem("HtmlLink");
0529: _colCompType.addItem("HtmlMultiLineEdit");
0530: _colCompType.addItem("HtmlSSNComponent");
0531: _colCompType.addItem("HtmlStateComponent");
0532: _colCompType.addItem("HtmlTelephoneComponent");
0533: _colCompType.addItem("HtmlZipCodeComponent");
0534: box2.add(Box.createHorizontalGlue());
0535: box2Main.add(box2);
0536: box2 = new JPanel();
0537: box2.setLayout(new BoxLayout(box2, BoxLayout.X_AXIS));
0538: box2.add(Box.createRigidArea(new Dimension(10, 0)));
0539: box2.add(DialogComponentFactory.makeLabel("Format:", 47));
0540: box2.add(_colFormat = DialogComponentFactory.makeTextField(44));
0541: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0542: box2.add(DialogComponentFactory.makeLabel("Href Expression:",
0543: 107));
0544: box2.add(_colHref = DialogComponentFactory.makeTextField(44));
0545: box2.add(Box.createHorizontalGlue());
0546: box2Main.add(Box.createRigidArea(new Dimension(0, 5)));
0547: box2Main.add(box2);
0548: box2 = new JPanel();
0549: box2.setLayout(new BoxLayout(box2, BoxLayout.X_AXIS));
0550: box2.add(Box.createRigidArea(new Dimension(10, 0)));
0551: box2.add(DialogComponentFactory.makeLabel("Detail Display:",
0552: 107));
0553: box2.add(_detailDisplay = new JCheckBox());
0554: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0555: box2
0556: .add(DialogComponentFactory.makeLabel("List Display:",
0557: 107));
0558: box2.add(_listDisplay = new JCheckBox());
0559: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0560: box2.add(DialogComponentFactory.makeLabel("Search Display:",
0561: 107));
0562: box2.add(_searchDisplay = new JCheckBox());
0563: box2.add(Box.createHorizontalGlue());
0564: box2Main.add(Box.createRigidArea(new Dimension(0, 5)));
0565: box2Main.add(box2);
0566: box2 = new JPanel();
0567: box2.setLayout(new BoxLayout(box2, BoxLayout.X_AXIS));
0568: box2.add(Box.createRigidArea(new Dimension(10, 0)));
0569: box2.add(DialogComponentFactory.makeLabel("Locked:", 107));
0570: box2.add(_locked = new JCheckBox());
0571: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0572: box2.add(DialogComponentFactory.makeLabel("Mandatory:", 107));
0573: box2.add(_mandatory = new JCheckBox());
0574: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0575: box2.add(DialogComponentFactory.makeLabel("Read Only:", 107));
0576: box2.add(_readonly = new JCheckBox());
0577: box2.add(Box.createHorizontalGlue());
0578: box2Main.add(Box.createRigidArea(new Dimension(0, 5)));
0579: box2Main.add(box2);
0580: box2 = new JPanel();
0581: box2.setLayout(new BoxLayout(box2, BoxLayout.X_AXIS));
0582: box2.add(Box.createRigidArea(new Dimension(10, 0)));
0583: box2.add(DialogComponentFactory.makeLabel("Nullable:", 107));
0584: box2.add(_nullable = new JCheckBox());
0585: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0586: box2.add(DialogComponentFactory.makeLabel("Primary Key:", 107));
0587: box2.add(_primarykey = new JCheckBox());
0588: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0589: box2.add(DialogComponentFactory.makeLabel("Updateable:", 107));
0590: box2.add(_updateable = new JCheckBox());
0591: box2.add(Box.createHorizontalGlue());
0592: box2Main.add(Box.createRigidArea(new Dimension(0, 5)));
0593: box2Main.add(box2);
0594: box2 = new JPanel();
0595: box2.setLayout(new BoxLayout(box2, BoxLayout.X_AXIS));
0596: box2.add(Box.createRigidArea(new Dimension(10, 0)));
0597: box2.add(DialogComponentFactory.makeLabel("Case Sensitive:",
0598: 107));
0599: box2.add(_casesensitive = new JCheckBox());
0600: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0601: box2.add(DialogComponentFactory.makeLabel("Exact Match:", 107));
0602: box2.add(_exactmatch = new JCheckBox());
0603: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0604: box2.add(DialogComponentFactory.makeLabel("Leading WildCard:",
0605: 107));
0606: box2.add(_leadingwildcard = new JCheckBox());
0607: box2.add(Box.createRigidArea(new Dimension(2, 0)));
0608: box2.add(DialogComponentFactory.makeLabel("Precedence:", 107));
0609: box2.add(_precedence = new JCheckBox());
0610: box2.add(Box.createHorizontalGlue());
0611: box2Main.add(Box.createRigidArea(new Dimension(0, 5)));
0612: box2Main.add(box2);
0613: box.add(box2Main);
0614: box.add(Box.createHorizontalGlue());
0615: _main.add(Box.createRigidArea(new Dimension(0, 3)));
0616: _main.add(box);
0617:
0618: //row 3, name, updatable, format
0619: _main.add(Box.createRigidArea(new Dimension(0, 5)));
0620: box = new JPanel();
0621: box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
0622: box.add(DialogComponentFactory.makeLabel(
0623: "Columns in ListForm:", 200));
0624: box.add(Box.createRigidArea(new Dimension(10, 0)));
0625: box.add(_addCol = DialogComponentFactory.makeButton("Add", 60,
0626: 28));
0627: box.add(_delCol = DialogComponentFactory.makeButton("Del", 60,
0628: 28));
0629: box.add(_updateCol = DialogComponentFactory.makeButton(
0630: "Update", 75, 28));
0631: _clear = new JButton("Clear");
0632: _clear.addActionListener(this );
0633: box.add(Box.createRigidArea(new Dimension(50, 0)));
0634: box.add(_clear);
0635: box.add(Box.createHorizontalGlue());
0636: _main.add(box);
0637:
0638: _main.add(Box.createRigidArea(new Dimension(0, 5)));
0639: box = new JPanel();
0640: box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
0641: box.add(DialogComponentFactory.makeScrollPane(675, 170,
0642: _colsInListForm = DialogComponentFactory
0643: .makeList(new LModel())));
0644: box2 = new JPanel();
0645: box2.setLayout(new BoxLayout(box2, BoxLayout.Y_AXIS));
0646: _up = DialogComponentFactory.makeButton("Up", 80, 28);
0647: _up.addActionListener(this );
0648: _down = DialogComponentFactory.makeButton("Down", 80, 28);
0649: _down.addActionListener(this );
0650: box2.add(_up);
0651: box2.add(_down);
0652: box2.add(Box.createVerticalGlue());
0653: box.add(box2);
0654: box.add(Box.createHorizontalGlue());
0655: _main.add(box);
0656:
0657: //row 8, button bar
0658: _export = new JButton("Save");
0659: _export.addActionListener(this );
0660: _import = new JButton("Open");
0661: _import.addActionListener(this );
0662: _cancel = new JButton("Cancel");
0663: _cancel.addActionListener(this );
0664: JPanel buttonBar = new JPanel();
0665: buttonBar.setLayout(new BoxLayout(buttonBar, BoxLayout.X_AXIS));
0666: buttonBar.add(_export);
0667: buttonBar.add(_import);
0668: buttonBar.add(_cancel);
0669:
0670: //add it to the screen
0671: Container cp = getContentPane();
0672: cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
0673: cp.add(_main);
0674: cp.add(Box.createVerticalGlue());
0675: cp.add(buttonBar);
0676: cp.add(Box.createRigidArea(new Dimension(0, 20)));
0677:
0678: //add listeners
0679: _colList.addListSelectionListener(this );
0680: _colsInListForm.addListSelectionListener(this );
0681: _tables.addActionListener(this );
0682: _addCol.addActionListener(this );
0683: _delCol.addActionListener(this );
0684: _updateCol.addActionListener(this );
0685: _colBucket.addKeyListener(this );
0686: _xmlName.addKeyListener(this );
0687: _fileButton.addActionListener(this );
0688: _colList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
0689: _colsInListForm
0690: .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
0691: //fill drop downs and init the buttons
0692: enableDisableButtons();
0693: loadTables();
0694:
0695: _ds.addColumn("component", DataStore.DATATYPE_STRING);
0696: _ds.addColumn("componenttype", DataStore.DATATYPE_STRING);
0697: _ds.addColumn("internalname", DataStore.DATATYPE_STRING);
0698: _ds.addColumn("columnname", DataStore.DATATYPE_STRING);
0699: _ds.addColumn("columntype", DataStore.DATATYPE_STRING);
0700: _ds.addColumn("tablename", DataStore.DATATYPE_STRING);
0701: _ds.addColumn("schemaname", DataStore.DATATYPE_STRING);
0702: _ds.addColumn("isbucket", DataStore.DATATYPE_STRING);
0703: _ds.addColumn("nullable", DataStore.DATATYPE_STRING);
0704: _ds.addColumn("detaildisplay", DataStore.DATATYPE_STRING);
0705: _ds.addColumn("searchdisplay", DataStore.DATATYPE_STRING);
0706: _ds.addColumn("listdisplay", DataStore.DATATYPE_STRING);
0707: _ds.addColumn("precedence", DataStore.DATATYPE_STRING);
0708: _ds.addColumn("exactmatch", DataStore.DATATYPE_STRING);
0709: _ds.addColumn("leadingwildcard", DataStore.DATATYPE_STRING);
0710: _ds.addColumn("casesensitive", DataStore.DATATYPE_STRING);
0711: _ds.addColumn("primarykey", DataStore.DATATYPE_STRING);
0712: _ds.addColumn("updateable", DataStore.DATATYPE_STRING);
0713: _ds.addColumn("caption", DataStore.DATATYPE_STRING);
0714: _ds.addColumn("href", DataStore.DATATYPE_STRING);
0715: _xmlName.setText(xmlPath);
0716: String sXmlFile = IDETool.getXmlFile();
0717: if (sXmlFile != null && IDETool.isXMLNameValid(sXmlFile)
0718: && (new File(sXmlFile)).exists()) {
0719: _xmlName.setText(sXmlFile);
0720: importXML();
0721: }
0722: setVisible(true);
0723: }
0724:
0725: public void actionPerformed(ActionEvent e) {
0726: if (e.getSource() == _export) {
0727: if (exportXML()) {
0728: _clickedCancel = false;
0729: setVisible(false);
0730: } else {
0731: IDETool.displayError("Export Failed!");
0732: }
0733: } else if (e.getSource() == _import) {
0734: importXML();
0735: } else if (e.getSource() == _cancel) {
0736: _clickedCancel = true;
0737: setVisible(false);
0738: } else if (e.getSource() == _tables) {
0739: AliasDef def = (AliasDef) _tables.getSelectedItem();
0740: loadColumns(def.table);
0741: enableDisableButtons();
0742: } else if (e.getSource() == _addCol)
0743: addColumn();
0744: else if (e.getSource() == _delCol)
0745: deleteColumn();
0746: else if (e.getSource() == _updateCol)
0747: updateColumn();
0748: else if (e.getSource() == _fileButton) {
0749: JFileChooser c = new JFileChooser();
0750: c.setFileSelectionMode(JFileChooser.FILES_ONLY);
0751: c.setCurrentDirectory(new File(_xmlName.getText()));
0752: if (c.showOpenDialog(this ) == JFileChooser.APPROVE_OPTION) {
0753: _xmlName.setText(c.getSelectedFile().getAbsolutePath());
0754: }
0755: enableDisableButtons();
0756: } else if (e.getSource() == _up) {
0757: int i = _colsInListForm.getSelectedIndex();
0758: LModel lmodel = (LModel) _colsInListForm.getModel();
0759: ColumnDef cdef = (ColumnDef) lmodel.getElementAt(i);
0760: lmodel.setElementAt(lmodel.getElementAt(i - 1), i);
0761: lmodel.setElementAt(cdef, i - 1);
0762: _colsInListForm.setSelectedIndex(i - 1);
0763: enableDisableButtons();
0764: } else if (e.getSource() == _down) {
0765: int i = _colsInListForm.getSelectedIndex();
0766: LModel lmodel = (LModel) _colsInListForm.getModel();
0767: ColumnDef cdef = (ColumnDef) lmodel.getElementAt(i);
0768: lmodel.setElementAt(lmodel.getElementAt(i + 1), i);
0769: lmodel.setElementAt(cdef, i + 1);
0770: _colsInListForm.setSelectedIndex(i + 1);
0771: enableDisableButtons();
0772: } else if (e.getSource() == _clear) {
0773: _colList.clearSelection();
0774: _colsInListForm.clearSelection();
0775: _colBucket.setText("");
0776: _colCaption.setText("");
0777: _colCompName.setText("");
0778: _colFormat.setText("");
0779: _colHref.setText("");
0780: _colCompType.setSelectedIndex(0);
0781: _detailDisplay.setSelected(false);
0782: _listDisplay.setSelected(false);
0783: _searchDisplay.setSelected(false);
0784: _locked.setSelected(false);
0785: _mandatory.setSelected(false);
0786: _readonly.setSelected(false);
0787: _nullable.setSelected(false);
0788: _primarykey.setSelected(false);
0789: _updateable.setSelected(false);
0790: _casesensitive.setSelected(false);
0791: _exactmatch.setSelected(false);
0792: _leadingwildcard.setSelected(false);
0793: _precedence.setSelected(false);
0794: enableDisableButtons();
0795: }
0796: }
0797:
0798: private void addColumn() {
0799: Object val = _colList.getSelectedValue();
0800:
0801: String caption = _colCaption.getText().trim();
0802: String cname = _colCompName.getText().trim();
0803: String ctype = _colCompType.getSelectedItem() == null ? ""
0804: : _colCompType.getSelectedItem().toString();
0805: String format = _colFormat.getText().trim();
0806: String href = _colHref.getText().trim();
0807: boolean ddisp = _detailDisplay.isSelected();
0808: boolean ldisp = _listDisplay.isSelected();
0809: boolean sdisp = _searchDisplay.isSelected();
0810: boolean lock = _locked.isSelected();
0811: boolean mand = _mandatory.isSelected();
0812: boolean ronly = _readonly.isSelected();
0813: boolean csens = _casesensitive.isSelected();
0814: boolean ematch = _exactmatch.isSelected();
0815: boolean lcard = _leadingwildcard.isSelected();
0816: boolean pre = _precedence.isSelected();
0817: boolean nul = _nullable.isSelected();
0818: boolean pkey = _primarykey.isSelected();
0819: boolean updateble = _updateable.isSelected();
0820: String sBucket = _colBucket.getText().trim();
0821: if (sBucket.length() == 0) {
0822: ColumnDefinition col = ((ColumnDef) val).def;
0823: ColumnDef d = new ColumnDef(col, false);
0824: d.setCaption(caption);
0825: d.setCasesensitive(csens);
0826: d.setCompname(cname);
0827: d.setComptype(ctype);
0828: d.setDetaildisplay(ddisp);
0829: d.setExactmatch(ematch);
0830: d.setFormat(format);
0831: d.setHrefexpression(href);
0832: d.setLeadingwildcard(lcard);
0833: d.setListdisplay(ldisp);
0834: d.setLocked(lock);
0835: d.setMandatory(mand);
0836: d.setNullable(nul);
0837: d.setPrecedence(pre);
0838: d.setPrimarykey(pkey);
0839: d.setReadonly(ronly);
0840: d.setSearchdisplay(sdisp);
0841: d.setUpdateable(updateble);
0842: d.setHrefexpression(href);
0843: ((LModel) _colsInListForm.getModel()).addElement(d);
0844: } else {
0845: ColumnDef d = new ColumnDef(null, false);
0846: d.setBucket(sBucket);
0847: d.setBucketType((DataType) _bucketType.getSelectedItem());
0848: d.setCaption(caption);
0849: d.setCasesensitive(csens);
0850: d.setCompname(cname);
0851: d.setComptype(ctype);
0852: d.setDetaildisplay(ddisp);
0853: d.setExactmatch(ematch);
0854: d.setFormat(format);
0855: d.setHrefexpression(href);
0856: d.setLeadingwildcard(lcard);
0857: d.setListdisplay(ldisp);
0858: d.setLocked(lock);
0859: d.setMandatory(mand);
0860: d.setNullable(nul);
0861: d.setPrecedence(pre);
0862: d.setPrimarykey(pkey);
0863: d.setReadonly(ronly);
0864: d.setSearchdisplay(sdisp);
0865: d.setUpdateable(updateble);
0866: d.setHrefexpression(href);
0867: ((LModel) _colsInListForm.getModel()).addElement(d);
0868: }
0869: _colBucket.setText("");
0870: _bucketType.setSelectedIndex(0);
0871: _colCaption.setText("");
0872: _colCompName.setText("");
0873: _colCompType.setSelectedIndex(0);
0874: _colFormat.setText("");
0875: _colHref.setText("");
0876: _detailDisplay.setSelected(false);
0877: _listDisplay.setSelected(false);
0878: _searchDisplay.setSelected(false);
0879: _locked.setSelected(false);
0880: _mandatory.setSelected(false);
0881: _readonly.setSelected(false);
0882: _casesensitive.setSelected(false);
0883: _exactmatch.setSelected(false);
0884: _leadingwildcard.setSelected(false);
0885: _precedence.setSelected(false);
0886: _nullable.setSelected(false);
0887: _primarykey.setSelected(false);
0888: _updateable.setSelected(false);
0889: _colsInListForm.setSelectedIndex(_colsInListForm.getModel()
0890: .getSize() - 1);
0891: enableDisableButtons();
0892:
0893: }
0894:
0895: /**
0896: * Called when the caret position is updated.
0897: *
0898: * @param e the caret event
0899: */
0900: public void caretUpdate(CaretEvent e) {
0901: enableDisableButtons();
0902:
0903: }
0904:
0905: private void deleteColumn() {
0906: LModel colMod = (LModel) _colsInListForm.getModel();
0907: int iSel = _colsInListForm.getSelectedIndex();
0908: colMod.remove(iSel);
0909: if (colMod.getSize() > 0) {
0910: if (iSel < colMod.getSize())
0911: _colsInListForm.setSelectedIndex(iSel);
0912: else
0913: _colsInListForm.setSelectedIndex(iSel - 1);
0914: }
0915: enableDisableButtons();
0916: }
0917:
0918: private void enableDisableButtons() {
0919: _addCol.setEnabled(_colList.getSelectedIndices().length > 0
0920: || _colBucket.getText().trim().length() > 0);
0921: _export.setEnabled(IDETool.isXMLNameValid(_xmlName.getText())
0922: && (_colsInListForm.getModel().getSize() > 0));
0923: _import.setEnabled(IDETool.isXMLNameValid(_xmlName.getText())
0924: && (new File(_xmlName.getText())).exists());
0925: _updateCol
0926: .setEnabled(_colsInListForm.getSelectedIndices().length > 0);
0927: _delCol
0928: .setEnabled(_colsInListForm.getSelectedIndices().length > 0);
0929: _up.setEnabled(_colsInListForm.getSelectedIndices().length > 0
0930: && _colsInListForm.getSelectedIndex() > 0);
0931: _down
0932: .setEnabled(_colsInListForm.getSelectedIndices().length > 0
0933: && _colsInListForm.getSelectedIndex() < _colsInListForm
0934: .getModel().getSize() - 1);
0935: }
0936:
0937: private boolean exportXML() {
0938: LModel lmodel = (LModel) _colsInListForm.getModel();
0939: try {
0940: _ds.reset();
0941: for (int i = 0; i < lmodel.getSize(); i++) {
0942: ColumnDef cdef = (ColumnDef) lmodel.getElementAt(i);
0943: _ds.insertRow();
0944: _ds.setString("component", cdef.getComponentName());
0945: _ds.setString("componenttype", cdef.getComponentType());
0946: _ds.setString("columnname", cdef.getColumnName());
0947: _ds.setString("columntype", cdef.getColumnType());
0948: _ds.setString("tablename", cdef.getTableName());
0949: _ds.setString("caption", cdef.getCaption());
0950: _ds.setString("isbucket", new Boolean(cdef.isBucket())
0951: .toString());
0952: _ds.setString("nullable", new Boolean(cdef
0953: .getNullable()).toString());
0954: _ds.setString("detaildisplay", new Boolean(cdef
0955: .getDetailDisplay()).toString());
0956: _ds.setString("searchdisplay", new Boolean(cdef
0957: .getSearchDisplay()).toString());
0958: _ds.setString("listdisplay", new Boolean(cdef
0959: .getListDisplay()).toString());
0960: _ds.setString("precedence", new Boolean(cdef
0961: .getPrecedence()).toString());
0962: _ds.setString("exactmatch", new Boolean(cdef
0963: .getExactMatch()).toString());
0964: _ds.setString("leadingwildcard", new Boolean(cdef
0965: .getLeadingWildcard()).toString());
0966: _ds.setString("caseSensitive", new Boolean(cdef
0967: .getCaseSensitive()).toString());
0968: _ds.setString("primarykey", new Boolean(cdef
0969: .getPrimaryKey()).toString());
0970: _ds.setString("updateable", new Boolean(cdef
0971: .getUpdateable()).toString());
0972: _ds.setString("href", cdef.getHrefExpression());
0973: }
0974:
0975: FileOutputStream fos = new FileOutputStream(_xmlName
0976: .getText());
0977: PrintWriter pw = new PrintWriter(fos);
0978: XMLTransporter.xmlExportDataASMetaData(pw, _ds);
0979: pw.close();
0980: fos.close();
0981: return true;
0982: } catch (Exception ex) {
0983: ex.printStackTrace();
0984: return false;
0985: }
0986: }
0987:
0988: /**
0989: * Return true if the user clicked cancel to close the dialog
0990: */
0991: public boolean getCancelClicked() {
0992: return _clickedCancel;
0993: }
0994:
0995: /**
0996: * get list of columns
0997: */
0998: public ColumnDef[] getColumns() {
0999: LModel l = (LModel) _colsInListForm.getModel();
1000: ColumnDef[] ret = new ColumnDef[l.getSize()];
1001: for (int i = 0; i < l.getSize(); i++)
1002: ret[i] = (ColumnDef) l.getElementAt(i);
1003: return ret;
1004: }
1005:
1006: /**
1007: * Get the name of the class to save as
1008: */
1009: public String getXMLName() {
1010: return _xmlName.getName().trim();
1011: }
1012:
1013: private void importXML() {
1014: LModel lmodel = new LModel();
1015: try {
1016: _ds.reset();
1017: XMLTransporter.xmlImportMetaDataAsData(_xmlName.getText(),
1018: _ds, "", false);
1019: for (int i = 0; i < _ds.getRowCount(); i++) {
1020: ColumnDefinition def = null;
1021: ColumnDef cDefinition = null;
1022: boolean bBucket = new Boolean(_ds.getString(i,
1023: "isbucket")).booleanValue();
1024: String sColumnName = _ds.getString(i, "columnname");
1025: if (!bBucket) {
1026: String sTableName = _ds.getString(i, "tablename");
1027: for (int j = 0; j < _tables.getItemCount(); j++) {
1028: AliasDef ad = (AliasDef) _tables.getItemAt(j);
1029: if (ad.table.equals(sTableName)) {
1030: _tables.setSelectedIndex(j);
1031: break;
1032: }
1033: }
1034: for (int j = 0; j < _colList.getModel().getSize(); j++) {
1035: ColumnDef cdef = (ColumnDef) _colList
1036: .getModel().getElementAt(j);
1037: if (cdef.getColumnName().equals(sColumnName)) {
1038: def = cdef.def;
1039: break;
1040: }
1041: }
1042: if (def == null) {
1043: IDETool
1044: .displayError("Cannot Import. XML file not for this Application.");
1045: return;
1046: }
1047: }
1048: cDefinition = new ColumnDef(def, false);
1049: cDefinition.setCompname(_ds.getString(i, "component"));
1050: cDefinition.setComptype(_ds.getString(i,
1051: "componenttype"));
1052: cDefinition.setCaption(_ds.getString(i, "caption"));
1053: cDefinition.setBucket(def == null ? sColumnName : null);
1054: cDefinition.setBucketType(def == null ? new DataType(
1055: _ds.getString(i, "columntype")) : null);
1056: cDefinition.setNullable(Util.stringToBoolean(_ds
1057: .getString(i, "nullable")));
1058: cDefinition.setDetaildisplay(Util.stringToBoolean(_ds
1059: .getString(i, "detaildisplay")));
1060: cDefinition.setSearchdisplay(Util.stringToBoolean(_ds
1061: .getString(i, "searchdisplay")));
1062: cDefinition.setListdisplay(Util.stringToBoolean(_ds
1063: .getString(i, "listdisplay")));
1064: cDefinition.setPrecedence(Util.stringToBoolean(_ds
1065: .getString(i, "precedence")));
1066: cDefinition.setExactmatch(Util.stringToBoolean(_ds
1067: .getString(i, "exactmatch")));
1068: cDefinition.setLeadingwildcard(Util.stringToBoolean(_ds
1069: .getString(i, "leadingwildcard")));
1070: cDefinition.setCasesensitive(Util.stringToBoolean(_ds
1071: .getString(i, "casesensitive")));
1072: cDefinition.setPrimarykey(Util.stringToBoolean(_ds
1073: .getString(i, "primarykey")));
1074: cDefinition.setUpdateable(Util.stringToBoolean(_ds
1075: .getString(i, "updateable")));
1076: cDefinition.setHrefexpression(_ds.getString(i, "href"));
1077: lmodel.addElement(cDefinition);
1078: }
1079: _colsInListForm.setModel(lmodel);
1080: setTitle("Edit Form XML");
1081: } catch (Exception ex) {
1082: ex.printStackTrace();
1083: IDETool.displayError("Import Failed!");
1084: }
1085: }
1086:
1087: /**
1088: * Called whenever the value of the selection changes.
1089: * @param e the event that characterizes the change.
1090: */
1091: public void keyPressed(KeyEvent e) {
1092: }
1093:
1094: /**
1095: * Called whenever the value of the selection changes.
1096: * @param e the event that characterizes the change.
1097: */
1098: public void keyReleased(KeyEvent e) {
1099: if (e.getSource() == _colBucket || e.getSource() == _xmlName)
1100: enableDisableButtons();
1101: }
1102:
1103: /**
1104: * Called whenever the value of the selection changes.
1105: * @param e the event that characterizes the change.
1106: */
1107: public void keyTyped(KeyEvent e) {
1108: }
1109:
1110: private void loadColumns(String tableName) {
1111: if (tableName != null) {
1112: Vector v = _dd.getColumns(tableName);
1113: Vector mod = new Vector(v.size());
1114: for (int i = 0; i < v.size(); i++) {
1115: ColumnDefinition def = (ColumnDefinition) v
1116: .elementAt(i);
1117: mod.add(new ColumnDef(def, true));
1118: }
1119: _colList.setModel(new LModel(mod));
1120: }
1121: }
1122:
1123: private void loadTables() {
1124: Vector v = _dd.getTableNames();
1125: for (int i = 0; i < v.size(); i++) {
1126: _tables
1127: .addItem(new AliasDef((String) v.elementAt(i), null));
1128: }
1129: }
1130:
1131: /**
1132: * Reset the cancel clicked status button
1133: */
1134: public void resetCancel() {
1135: _clickedCancel = true;
1136: }
1137:
1138: private void updateColumn() {
1139: Object val = _colList.getSelectedValue();
1140: Object cDef = _colsInListForm.getSelectedValue();
1141: String caption = _colCaption.getText().trim();
1142: String cname = _colCompName.getText().trim();
1143: String ctype = _colCompType.getSelectedItem() == null ? ""
1144: : _colCompType.getSelectedItem().toString();
1145: String format = _colFormat.getText().trim();
1146: String href = _colHref.getText().trim();
1147: boolean ddisp = _detailDisplay.isSelected();
1148: boolean ldisp = _listDisplay.isSelected();
1149: boolean sdisp = _searchDisplay.isSelected();
1150: boolean lock = _locked.isSelected();
1151: boolean mand = _mandatory.isSelected();
1152: boolean ronly = _readonly.isSelected();
1153: boolean csens = _casesensitive.isSelected();
1154: boolean ematch = _exactmatch.isSelected();
1155: boolean lcard = _leadingwildcard.isSelected();
1156: boolean pre = _precedence.isSelected();
1157: boolean nul = _nullable.isSelected();
1158: boolean pkey = _primarykey.isSelected();
1159: boolean updateble = _updateable.isSelected();
1160: String sBucket = _colBucket.getText().trim();
1161: if (sBucket.length() == 0) {
1162: ColumnDefinition col = ((ColumnDef) val).def;
1163: ColumnDef d = (ColumnDef) cDef;
1164: d.setColumnDefinition(col);
1165: d.setBucket("");
1166: d.setBucketType(null);
1167: d.setCaption(caption);
1168: d.setCasesensitive(csens);
1169: d.setCompname(cname);
1170: d.setComptype(ctype);
1171: d.setDetaildisplay(ddisp);
1172: d.setExactmatch(ematch);
1173: d.setFormat(format);
1174: d.setHrefexpression(href);
1175: d.setLeadingwildcard(lcard);
1176: d.setListdisplay(ldisp);
1177: d.setLocked(lock);
1178: d.setMandatory(mand);
1179: d.setNullable(nul);
1180: d.setPrecedence(pre);
1181: d.setPrimarykey(pkey);
1182: d.setReadonly(ronly);
1183: d.setSearchdisplay(sdisp);
1184: d.setUpdateable(updateble);
1185: ((LModel) _colsInListForm.getModel()).setElementAt(d,
1186: _colsInListForm.getSelectedIndex());
1187: } else {
1188: ColumnDef d = (ColumnDef) cDef;
1189: d.setColumnDefinition(null);
1190: d.setBucket(sBucket);
1191: d.setBucketType((DataType) _bucketType.getSelectedItem());
1192: d.setCaption(caption);
1193: d.setCasesensitive(csens);
1194: d.setCompname(cname);
1195: d.setComptype(ctype);
1196: d.setDetaildisplay(ddisp);
1197: d.setExactmatch(ematch);
1198: d.setFormat(format);
1199: d.setHrefexpression(href);
1200: d.setLeadingwildcard(lcard);
1201: d.setListdisplay(ldisp);
1202: d.setLocked(lock);
1203: d.setMandatory(mand);
1204: d.setNullable(nul);
1205: d.setPrecedence(pre);
1206: d.setPrimarykey(pkey);
1207: d.setReadonly(ronly);
1208: d.setSearchdisplay(sdisp);
1209: d.setUpdateable(updateble);
1210: ((LModel) _colsInListForm.getModel()).setElementAt(d,
1211: _colsInListForm.getSelectedIndex());
1212: }
1213: _colBucket.setText("");
1214: _bucketType.setSelectedIndex(0);
1215: _colCaption.setText("");
1216: _colCompName.setText("");
1217: _colCompType.setSelectedIndex(0);
1218: _colFormat.setText("");
1219: _colHref.setText("");
1220: _detailDisplay.setSelected(false);
1221: _listDisplay.setSelected(false);
1222: _searchDisplay.setSelected(false);
1223: _locked.setSelected(false);
1224: _mandatory.setSelected(false);
1225: _readonly.setSelected(false);
1226: _casesensitive.setSelected(false);
1227: _exactmatch.setSelected(false);
1228: _leadingwildcard.setSelected(false);
1229: _precedence.setSelected(false);
1230: _nullable.setSelected(false);
1231: _primarykey.setSelected(false);
1232: _updateable.setSelected(false);
1233: _colList.clearSelection();
1234: _colsInListForm.clearSelection();
1235: enableDisableButtons();
1236:
1237: }
1238:
1239: /**
1240: * Called whenever the value of the selection changes.
1241: * @param e the event that characterizes the change.
1242: */
1243: public void valueChanged(ListSelectionEvent e) {
1244: if (e.getSource() == _colList) {
1245: int i = _colList.getSelectedIndex();
1246: if (i >= 0) {
1247: ColumnDef cdef = (ColumnDef) _colList.getModel()
1248: .getElementAt(i);
1249: if (cdef.def.isPkey()) {
1250: _primarykey.setSelected(true);
1251: } else {
1252: _primarykey.setSelected(false);
1253: }
1254: if (cdef.def.isNullable()) {
1255: _nullable.setSelected(true);
1256: } else {
1257: _nullable.setSelected(false);
1258: }
1259: }
1260: enableDisableButtons();
1261: }
1262: if (e.getSource() == _colsInListForm) {
1263: LModel colMod = (LModel) _colsInListForm.getModel();
1264: int iSelected = _colsInListForm.getSelectedIndex();
1265: if (iSelected >= 0) {
1266: ColumnDef dDef = (ColumnDef) colMod
1267: .getElementAt(iSelected);
1268: if (dDef.getBucket() == null
1269: || dDef.getBucket().trim().length() == 0) {
1270: String sTableName = dDef.def.getTableName();
1271: for (int i = 0; i < _tables.getItemCount(); i++) {
1272: AliasDef adef = (AliasDef) _tables.getItemAt(i);
1273: if (adef.table.equals(sTableName)) {
1274: _tables.setSelectedIndex(i);
1275: break;
1276: }
1277: }
1278: loadColumns(sTableName);
1279: String sColName = dDef.def.getColumnName();
1280: for (int i = 0; i < _colList.getModel().getSize(); i++) {
1281: ColumnDef cdef = (ColumnDef) _colList
1282: .getModel().getElementAt(i);
1283: if (cdef.def.getColumnName().equals(sColName)) {
1284: _colList.setSelectedIndex(i);
1285: break;
1286: }
1287: }
1288: _colBucket.setText("");
1289: } else {
1290: _colBucket.setText(dDef.getBucket());
1291: _bucketType.setSelectedItem(dDef.getBucketType());
1292: _colList.clearSelection();
1293: }
1294: _colCaption.setText(dDef.getCaption());
1295: _colCompName.setText(dDef.getComponentName());
1296: _colCompType.setSelectedItem(dDef.getComponentType());
1297: _colFormat.setText(dDef.getFormat());
1298: _colHref.setText(dDef.getHrefExpression());
1299: _detailDisplay.setSelected(dDef.getDetailDisplay());
1300: _listDisplay.setSelected(dDef.getListDisplay());
1301: _searchDisplay.setSelected(dDef.getSearchDisplay());
1302: _locked.setSelected(dDef.getLocked());
1303: _mandatory.setSelected(dDef.getMandatory());
1304: _readonly.setSelected(dDef.getReadonly());
1305: _casesensitive.setSelected(dDef.getCaseSensitive());
1306: _exactmatch.setSelected(dDef.getExactMatch());
1307: _leadingwildcard.setSelected(dDef.getLeadingWildcard());
1308: _precedence.setSelected(dDef.getPrecedence());
1309: _nullable.setSelected(dDef.getNullable());
1310: _primarykey.setSelected(dDef.getPrimaryKey());
1311: _updateable.setSelected(dDef.getUpdateable());
1312: _colHref.setText(dDef.getHrefExpression());
1313: }
1314: }
1315: }
1316: }
|