View Javadoc
1 package com.bonevich.erj.ui.editor; 2 3 import com.bonevich.erj.model.*; 4 5 import java.util.*; 6 import java.awt.*; 7 import java.awt.event.*; 8 import javax.swing.*; 9 import javax.swing.border.TitledBorder; 10 11 /*** A model editor for attributes. 12 * 13 * @see Attribute 14 * @see ModelEditor 15 */ 16 public final class ForeignKeyEditor extends ModelEditor 17 { 18 ////////////////////////////////////////////////////////// 19 // Constants 20 public static final String CARDINALITY_STR = "Cardinality"; 21 public static final String NAME_EDIT_FOREIGNKEY = "Edit Foreign Key"; 22 23 ////////////////////////////////////////////////////////// 24 // Attributes 25 private JPanel _cardPane; 26 private TitledBorder _cardBorder; 27 private JComboBox _cardList; 28 29 ////////////////////////////////////////////////////////// 30 // Constructors 31 public ForeignKeyEditor(JTabbedPane parent, ForeignKey key) 32 { 33 super(parent,key); 34 } 35 36 ////////////////////////////////////////////////////////// 37 // Operations 38 protected void initTabs() 39 { 40 // we want the default tab 41 setDefaultLabel("Edit Foreign Key Properties"); 42 setDefaultTip("Edit the name, description and other properties of the key"); 43 setDefaultIndex(0); 44 45 super.initTabs(); 46 47 _cardPane = new JPanel(); 48 _cardBorder = BorderFactory.createTitledBorder(CARDINALITY_STR); 49 _cardBorder.setTitleFont(EDITOR_FONT); 50 _cardBorder.setTitleColor(EDITOR_COLOR); 51 _cardPane.setBorder(_cardBorder); 52 _cardPane.setLayout(new BoxLayout(_cardPane, BoxLayout.X_AXIS)); 53 _cardPane.setAlignmentX(Component.LEFT_ALIGNMENT); 54 _cardPane.setAlignmentY(Component.TOP_ALIGNMENT); 55 56 _cardList = new JComboBox(ForeignKey.CARDINALITY_ARRAY); 57 _cardList.setAlignmentX(Component.LEFT_ALIGNMENT); 58 _cardList.setEditable(false); 59 _cardPane.add(_cardList); 60 61 _propPane.add(_cardPane); 62 } 63 64 public boolean validate() 65 { 66 return true; 67 } 68 69 public void updateModel() 70 { 71 ForeignKey fk = (ForeignKey)getOwner(); 72 73 fk.setName(_nameText.getText()); 74 fk.setIdentifier(_identifierText.getText()); 75 fk.setDescription(_descText.getText()); 76 fk.setCardinality((ForeignKey.Cardinality) _cardList.getSelectedItem()); 77 78 ownerUpdated(); 79 } 80 81 public void updateEditor() 82 { 83 ForeignKey fk = (ForeignKey) getOwner(); 84 _nameText.setText(fk.getName()); 85 _identifierText.setText(fk.getIdentifier()); 86 _descText.setText(fk.getDescription()); 87 _cardList.setSelectedItem(fk.getCardinality()); 88 } 89 90 } /* end class ForeignKeyEditor */

This page was automatically generated by Maven