001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.applications.designstudio.propertiesdialogs;
016:
017: import java.awt.BorderLayout;
018: import java.awt.Dimension;
019:
020: import javax.swing.DefaultCellEditor;
021: import javax.swing.JComboBox;
022: import javax.swing.JPanel;
023: import javax.swing.JScrollPane;
024: import javax.swing.JTextArea;
025: import javax.swing.JTextField;
026: import javax.swing.table.AbstractTableModel;
027: import javax.swing.table.TableCellEditor;
028:
029: import com.metaboss.applications.designstudio.propertiesview.PropertiesTable;
030: import com.metaboss.applications.designstudio.propertiesview.PropertiesTableModel;
031: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
032: import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.NameConversionTypeEnum;
033: import com.metaboss.sdlctools.models.metabossmodel.technologylibrarymodel.RelationalStorageTechnology;
034:
035: /* RelationalStorageTechnology properties dialog */
036:
037: public class RelationalStorageTechnologyPropertiesDialog extends
038: ModelElementPropertiesDialog {
039: private JPanel mConstantsPanel = new JPanel();
040: // properties
041: private JTextField mImplementationGeneratorPackageField = new JTextField();
042: private JTextField mMetadataGeneratorPackage = new JTextField();
043: private JTextArea mDescriptionField = new JTextArea(8, 40);
044: // constants
045: private EditPropertiesTableModel mModel = new EditPropertiesTableModel();
046: private EditPropertiesTable mTable = new EditPropertiesTable(mModel);
047: private JComboBox mNameConversionField = new JComboBox();
048: private DefaultCellEditor mConversionEditor = new DefaultCellEditor(
049: mNameConversionField);
050:
051: public RelationalStorageTechnologyPropertiesDialog() {
052: super ("Relational Storage Technology", new Dimension(520, 378));
053:
054: mConstantsPanel.setLayout(new BorderLayout());
055:
056: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
057: addTextField(mPropertiesPanel,
058: "Implementation Generator Package: ",
059: mImplementationGeneratorPackageField, 2, false);
060: addTextField(mPropertiesPanel, "Metadata Generator Package: ",
061: mMetadataGeneratorPackage, 3, false);
062: addTextArea(mPropertiesPanel, "Description: ",
063: mDescriptionField, 4, false);
064:
065: mConstantsPanel.add(new JScrollPane(mTable),
066: BorderLayout.CENTER);
067: mConstantsPanel.setBorder(createEditorBorder());
068:
069: fillNameConversions();
070:
071: mTable.setCellSelectionEnabled(true);
072: mTable.setRowSelectionAllowed(true);
073:
074: mTabControl.insertTab("Constants", null, mConstantsPanel, null,
075: 1);
076: }
077:
078: // load datatype properties
079: public void loadProperties(ModelElement pObject) throws Exception {
080: if (pObject != null
081: && pObject instanceof RelationalStorageTechnology) {
082: RelationalStorageTechnology lStorageTechnology = (RelationalStorageTechnology) pObject;
083:
084: mNameField.setText(lStorageTechnology.getName());
085: mImplementationGeneratorPackageField
086: .setText(lStorageTechnology
087: .getImplementationGeneratorPackage());
088: mMetadataGeneratorPackage.setText(lStorageTechnology
089: .getMetadataGeneratorPackage());
090: mDescriptionField.setText(lStorageTechnology
091: .getDescription());
092:
093: mModel.loadRelationalProperties(lStorageTechnology);
094: }
095: super .loadProperties(pObject);
096: }
097:
098: // save datatype proeprties
099: public void saveProperties(ModelElement pObject) throws Exception {
100: super .saveProperties(pObject);
101: if (pObject != null
102: && pObject instanceof RelationalStorageTechnology) {
103: RelationalStorageTechnology lStorageTechnology = (RelationalStorageTechnology) pObject;
104:
105: lStorageTechnology.setName(mNameField.getText());
106: lStorageTechnology
107: .setImplementationGeneratorPackage(mImplementationGeneratorPackageField
108: .getText());
109: lStorageTechnology
110: .setMetadataGeneratorPackage(mMetadataGeneratorPackage
111: .getText());
112: lStorageTechnology.setDescription(mDescriptionField
113: .getText());
114:
115: if (mTable.getCellEditor() != null)
116: mTable.getCellEditor().stopCellEditing();
117: mModel.saveRelationalProperties(lStorageTechnology);
118: }
119: }
120:
121: // fill name conversions field with values
122: private void fillNameConversions() {
123: mNameConversionField.addItem(NameConversionTypeEnum.LOWER);
124: mNameConversionField
125: .addItem(NameConversionTypeEnum.LOWER_UNDERSCORED);
126: mNameConversionField.addItem(NameConversionTypeEnum.NONE);
127: mNameConversionField.addItem(NameConversionTypeEnum.UPPER);
128: mNameConversionField
129: .addItem(NameConversionTypeEnum.UPPER_UNDERSCORED);
130: }
131:
132: /* Auxilary classes */
133:
134: /* Properties Table */
135:
136: public class EditPropertiesTable extends PropertiesTable {
137: public EditPropertiesTable(AbstractTableModel pModel) {
138: super (pModel);
139: }
140:
141: public TableCellEditor getCellEditor(int row, int column) {
142: //Object lValue = mModel.getValueAt(row, column);
143: //if (lValue.getClass().equals(NameConversionTypeEnum.class))
144: if (row == 0 || row == 3 || row == 6 || row == 9
145: || row == 12 || row == 15 || row == 19 || row == 22
146: || row == 26 || row == 34 || row == 37 || row == 42)
147: return mConversionEditor;
148: else
149: return super .getCellEditor(row, column);
150: }
151:
152: public int getFirstColumnWidth() {
153: return 300;
154: }
155: }
156:
157: /* Table Model */
158:
159: public class EditPropertiesTableModel extends PropertiesTableModel {
160: // load data
161: public void loadRelationalProperties(
162: RelationalStorageTechnology pStorageTechnology) {
163: clear();
164: if (pStorageTechnology == null)
165: return;
166:
167: AddProperty(
168: "Association Primary Key Constraint Name Conversion Type",
169: pStorageTechnology
170: .getAssociationPrimaryKeyConstraintNameConversionType(),
171: false);
172: AddProperty(
173: "Association Primary Key Constraint Name Prefix",
174: pStorageTechnology
175: .getAssociationPrimaryKeyConstraintNamePrefix(),
176: false);
177: AddProperty(
178: "Association Primary Key Constraint Name Suffix",
179: pStorageTechnology
180: .getAssociationPrimaryKeyConstraintNameSuffix(),
181: false);
182:
183: AddProperty(
184: "AssociationRole Column Name Conversion Type",
185: pStorageTechnology
186: .getAssociationRoleColumnNameConversionType(),
187: false);
188: AddProperty("Association Role Column Name Prefix",
189: pStorageTechnology
190: .getAssociationRoleColumnNamePrefix(),
191: false);
192: AddProperty("Association Role Column Name Suffix",
193: pStorageTechnology
194: .getAssociationRoleColumnNameSuffix(),
195: false);
196:
197: AddProperty(
198: "AssociationRole Referential Constraint Name Conversion Type",
199: pStorageTechnology
200: .getAssociationRoleReferentialConstraintNameConversionType(),
201: false);
202: AddProperty(
203: "AssociationRole Referential Constraint Name Prefix",
204: pStorageTechnology
205: .getAssociationRoleReferentialConstraintNamePrefix(),
206: false);
207: AddProperty(
208: "AssociationRole Referential Constraint Name Suffix",
209: pStorageTechnology
210: .getAssociationRoleReferentialConstraintNameSuffix(),
211: false);
212:
213: AddProperty("Association Table Name Conversion Type",
214: pStorageTechnology
215: .getAssociationTableNameConversionType(),
216: false);
217: AddProperty("Association Table Name Prefix",
218: pStorageTechnology.getAssociationTableNamePrefix(),
219: false);
220: AddProperty("Association Table Name Suffix",
221: pStorageTechnology.getAssociationTableNameSuffix(),
222: false);
223:
224: AddProperty("Attribute Column Name Conversion Type",
225: pStorageTechnology
226: .getAttributeColumnNameConversionType(),
227: false);
228: AddProperty("Attribute Column Name Prefix",
229: pStorageTechnology.getAttributeColumnNamePrefix(),
230: false);
231: AddProperty("Attribute Column Name Suffix",
232: pStorageTechnology.getAttributeColumnNameSuffix(),
233: false);
234:
235: AddProperty(
236: "Entity Attribute Ref Constraint Name Conversion Type",
237: pStorageTechnology
238: .getEntityAttributeRefConstraintNameConversionType(),
239: false);
240: AddProperty(
241: "Entity Attribute Ref Constraint Name Prefix",
242: pStorageTechnology
243: .getEntityAttributeRefConstraintNamePrefix(),
244: false);
245: AddProperty(
246: "Entity Attribute Ref Constraint Name Suffix",
247: pStorageTechnology
248: .getEntityAttributeRefConstraintNameSuffix(),
249: false);
250:
251: AddProperty("Entity Instance Id Column Name",
252: pStorageTechnology.getEntityInstanceIdColumnName(),
253: false);
254:
255: AddProperty(
256: "Entity Natural Primary Key Constraint Name Conversion Type",
257: pStorageTechnology
258: .getEntityNaturalPrimaryKeyConstraintNameConversionType(),
259: false);
260: AddProperty(
261: "Entity Natural Primary Key Constraint Name Prefix",
262: pStorageTechnology
263: .getEntityNaturalPrimaryKeyConstraintNamePrefix(),
264: false);
265: AddProperty(
266: "Entity Natural Primary Key Constraint Name Suffix",
267: pStorageTechnology
268: .getEntityNaturalPrimaryKeyConstraintNameSuffix(),
269: false);
270:
271: AddProperty(
272: "Entity Primary Key Constraint Name Conversion Type",
273: pStorageTechnology
274: .getEntityPrimaryKeyConstraintNameConversionType(),
275: false);
276: AddProperty("Entity Primary Key Constraint Name Prefix",
277: pStorageTechnology
278: .getEntityPrimaryKeyConstraintNamePrefix(),
279: false);
280: AddProperty("Entity Primary Key Constraint Name Suffix",
281: pStorageTechnology
282: .getEntityPrimaryKeyConstraintNameSuffix(),
283: false);
284:
285: AddProperty("Entity State Column Name", pStorageTechnology
286: .getEntityStateColumnName(), false);
287:
288: AddProperty("Entity Table Name Conversion Type",
289: pStorageTechnology
290: .getEntityTableNameConversionType(), false);
291: AddProperty("Entity Table Name Prefix", pStorageTechnology
292: .getEntityTableNamePrefix(), false);
293: AddProperty("Entity Table Name Suffix", pStorageTechnology
294: .getEntityTableNameSuffix(), false);
295:
296: AddProperty("Entity Version Id Column Name",
297: pStorageTechnology.getEntityVersionIdColumnName(),
298: false);
299:
300: AddProperty("Max Column Name Length", new Integer(
301: pStorageTechnology.getMaxColumnNameLength()), false);
302: AddProperty("Max Constraint Name Length", new Integer(
303: pStorageTechnology.getMaxConstraintNameLength()),
304: false);
305: AddProperty("Max Table Name Length", new Integer(
306: pStorageTechnology.getMaxTableNameLength()), false);
307:
308: AddProperty("Reference Description Column Name",
309: pStorageTechnology
310: .getReferenceDescriptionColumnName(), false);
311:
312: AddProperty(
313: "Reference Primary Key Constraint Name Conversion Type",
314: pStorageTechnology
315: .getReferencePrimaryKeyConstraintNameConversionType(),
316: false);
317: AddProperty(
318: "Reference Primary Key Constraint Name Prefix",
319: pStorageTechnology
320: .getReferencePrimaryKeyConstraintNamePrefix(),
321: false);
322: AddProperty(
323: "Reference Primary Key Constraint Name Suffix",
324: pStorageTechnology
325: .getReferencePrimaryKeyConstraintNameSuffix(),
326: false);
327:
328: AddProperty("Reference Table Name Conversion Type",
329: pStorageTechnology
330: .getReferenceTableNameConversionType(),
331: false);
332: AddProperty("Reference Table Name Prefix",
333: pStorageTechnology.getReferenceTableNamePrefix(),
334: false);
335: AddProperty("Reference Table Name Suffix",
336: pStorageTechnology.getReferenceTableNameSuffix(),
337: false);
338: AddProperty("Reference Value Column Name",
339: pStorageTechnology.getReferenceValueColumnName(),
340: false);
341: AddProperty("Reference Weight Column Name",
342: pStorageTechnology.getReferenceWeightColumnName(),
343: false);
344:
345: AddProperty(
346: "Reference Weight Constraint Name Conversion Type",
347: pStorageTechnology
348: .getReferenceWeightConstraintNameConversionType(),
349: false);
350: AddProperty("Reference Weight Constraint Name Prefix",
351: pStorageTechnology
352: .getReferenceWeightConstraintNamePrefix(),
353: false);
354: AddProperty("Reference Weight Constraint Name Suffix",
355: pStorageTechnology
356: .getReferenceWeightConstraintNameSuffix(),
357: false);
358: }
359:
360: // save data
361: public void saveRelationalProperties(
362: RelationalStorageTechnology pStorageTechnology) {
363: //Association Primary Key Constraint Name Conversion Type
364: pStorageTechnology
365: .setAssociationPrimaryKeyConstraintNameConversionType((NameConversionTypeEnum) getValue(0));
366: //Association Primary Key Constraint Name Prefix
367: pStorageTechnology
368: .setAssociationPrimaryKeyConstraintNamePrefix((String) getValue(1));
369: //Association Primary Key Constraint Name Suffix
370: pStorageTechnology
371: .setAssociationPrimaryKeyConstraintNameSuffix((String) getValue(2));
372:
373: //AssociationRole Column Name Conversion Type
374: pStorageTechnology
375: .setAssociationRoleColumnNameConversionType((NameConversionTypeEnum) getValue(3));
376: //Association Role Column Name Prefix
377: pStorageTechnology
378: .setAssociationRoleColumnNamePrefix((String) getValue(4));
379: //Association Role Column Name Suffix
380: pStorageTechnology
381: .setAssociationRoleColumnNameSuffix((String) getValue(5));
382:
383: //AssociationRole Referential Constraint Name Conversion Type
384: pStorageTechnology
385: .setAssociationRoleReferentialConstraintNameConversionType((NameConversionTypeEnum) getValue(6));
386: //AssociationRole Referential Constraint Name Prefix
387: pStorageTechnology
388: .setAssociationRoleReferentialConstraintNamePrefix((String) getValue(7));
389: //AssociationRole Referential Constraint Name Suffix
390: pStorageTechnology
391: .setAssociationRoleReferentialConstraintNameSuffix((String) getValue(8));
392:
393: //Association Table Name Conversion Type
394: pStorageTechnology
395: .setAssociationTableNameConversionType((NameConversionTypeEnum) getValue(9));
396: //Association Table Name Prefix
397: pStorageTechnology
398: .setAssociationTableNamePrefix((String) getValue(10));
399: //Association Table Name Suffix
400: pStorageTechnology
401: .setAssociationTableNameSuffix((String) getValue(11));
402:
403: //Attribute Column Name Conversion Type
404: pStorageTechnology
405: .setAttributeColumnNameConversionType((NameConversionTypeEnum) getValue(12));
406: //Attribute Column Name Prefix
407: pStorageTechnology
408: .setAttributeColumnNamePrefix((String) getValue(13));
409: //Attribute Column Name Suffix
410: pStorageTechnology
411: .setAttributeColumnNameSuffix((String) getValue(14));
412:
413: //Entity Attribute Ref Constraint Name Conversion Type
414: pStorageTechnology
415: .setEntityAttributeRefConstraintNameConversionType((NameConversionTypeEnum) getValue(15));
416: //Entity Attribute Ref Constraint Name Prefix
417: pStorageTechnology
418: .setEntityAttributeRefConstraintNamePrefix((String) getValue(16));
419: //Entity Attribute Ref Constraint Name Suffix
420: pStorageTechnology
421: .setEntityAttributeRefConstraintNameSuffix((String) getValue(17));
422:
423: //Entity Instance Id Column Name
424: pStorageTechnology
425: .setEntityInstanceIdColumnName((String) getValue(18));
426:
427: //Entity Natural Primary Key Constraint Name Conversion Type
428: pStorageTechnology
429: .setEntityNaturalPrimaryKeyConstraintNameConversionType((NameConversionTypeEnum) getValue(19));
430: //Entity Natural Primary Key Constraint Name Prefix
431: pStorageTechnology
432: .setEntityNaturalPrimaryKeyConstraintNamePrefix((String) getValue(20));
433: //Entity Natural Primary Key Constraint Name Suffix
434: pStorageTechnology
435: .setEntityNaturalPrimaryKeyConstraintNameSuffix((String) getValue(21));
436:
437: //Entity Primary Key Constraint Name Conversion Type
438: pStorageTechnology
439: .setEntityPrimaryKeyConstraintNameConversionType((NameConversionTypeEnum) getValue(22));
440: //Entity Primary Key Constraint Name Prefix
441: pStorageTechnology
442: .setEntityPrimaryKeyConstraintNamePrefix((String) getValue(23));
443: //Entity Primary Key Constraint Name Suffix
444: pStorageTechnology
445: .setEntityPrimaryKeyConstraintNameSuffix((String) getValue(24));
446:
447: //Entity State Column Name
448: pStorageTechnology
449: .setEntityStateColumnName((String) getValue(25));
450:
451: //Entity Table Name Conversion Type
452: pStorageTechnology
453: .setEntityTableNameConversionType((NameConversionTypeEnum) getValue(26));
454: //Entity Table Name Prefix
455: pStorageTechnology
456: .setEntityTableNamePrefix((String) getValue(27));
457: //Entity Table Name Suffix
458: pStorageTechnology
459: .setEntityTableNameSuffix((String) getValue(28));
460:
461: //Entity Version Id Column Name
462: pStorageTechnology
463: .setEntityVersionIdColumnName((String) getValue(29));
464:
465: //Max Column Name Length
466: pStorageTechnology.setMaxColumnNameLength(getIntField(30));
467: //Max Constraint Name Length
468: pStorageTechnology
469: .setMaxConstraintNameLength(getIntField(31));
470: //Max Table Name Length
471: pStorageTechnology.setMaxTableNameLength(getIntField(32));
472:
473: //Reference Description Column Name
474: pStorageTechnology
475: .setReferenceDescriptionColumnName((String) getValue(33));
476:
477: //Reference Primary Key Constraint Name Conversion Type
478: pStorageTechnology
479: .setReferencePrimaryKeyConstraintNameConversionType((NameConversionTypeEnum) getValue(34));
480: //Reference Primary Key Constraint Name Prefix
481: pStorageTechnology
482: .setReferencePrimaryKeyConstraintNamePrefix((String) getValue(35));
483: //Reference Primary Key Constraint Name Suffix
484: pStorageTechnology
485: .setReferencePrimaryKeyConstraintNameSuffix((String) getValue(36));
486:
487: //Reference Table Name Conversion Type
488: pStorageTechnology
489: .setReferenceTableNameConversionType((NameConversionTypeEnum) getValue(37));
490: //Reference Table Name Prefix
491: pStorageTechnology
492: .setReferenceTableNamePrefix((String) getValue(38));
493: //Reference Table Name Suffix
494: pStorageTechnology
495: .setReferenceTableNameSuffix((String) getValue(39));
496: //Reference Value Column Name
497: pStorageTechnology
498: .setReferenceValueColumnName((String) getValue(40));
499: //Reference Weight Column Name
500: pStorageTechnology
501: .setReferenceWeightColumnName((String) getValue(41));
502:
503: //Reference Weight Constraint Name Conversion Type
504: pStorageTechnology
505: .setReferenceWeightConstraintNameConversionType((NameConversionTypeEnum) getValue(42));
506: //Reference Weight Constraint Name Prefix
507: pStorageTechnology
508: .setReferenceWeightConstraintNamePrefix((String) getValue(43));
509: //Reference Weight Constraint Name Suffix
510: pStorageTechnology
511: .setReferenceWeightConstraintNameSuffix((String) getValue(44));
512: }
513:
514: private int getIntField(int pIndex) {
515: Object lValue = getValue(pIndex);
516: if (lValue != null) {
517: if (lValue instanceof Integer)
518: return ((Integer) lValue).intValue();
519: else if (lValue instanceof String)
520: return new Integer((String) lValue).intValue();
521: }
522: return 0;
523: }
524: }
525: }
|