public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int row, int column) { _pTable = (PropertyTable) table; _row = row; _column = column; _p = ((Property) _pTable.getProperties().elementAt(row)); oldpValue = _p.getValue(); // new PropertiesTableReader _pReader = new PropertiesTableReader(); String[] primitiveAry = {"java.lang.String", "java.lang.Integer", "java.lang.Double"}; String type = _p.getType(); int i = 0; while (!(_valueType.equals(TYPE_PRIMITIVE)) && i < primitiveAry.length) { if (type.equalsIgnoreCase(primitiveAry[i])) { _valueType = TYPE_PRIMITIVE; } i++; } if (type.equals("mcomponent.distribution.Transform")) { _valueType = TYPE_TRANSFORM; } else if (type.equals("mcomponent.distribution.Distribution")) { _valueType = TYPE_DISTRIBUTION; } if (type.equals("mcomponent.distribution.Transform")) { _valueType = TYPE_TRANSFORM; } else if (type.equals("mcomponent.distribution.ObjectCreator")) { _valueType = TYPE_OBJECT_CREATOR; } else if (type.equals("animation.Animation")) { _valueType = TYPE_ANIMATION; } else if (type.equals("mcomponent.distribution.SplitterModel")) { _valueType = TYPE_SPLITTERMODEL; } else if (type.equals("mcomponent.distribution.MergerModel")) { _valueType = TYPE_MERGERMODEL; } else if (type.equals("chart.Presentation")) { _valueType = TYPE_PRESENTATION; } else if (type.equals("chart.DataProcessor")) { _valueType = TYPE_DATA_PROCESSOR; } if (_valueType.equals(TYPE_PRIMITIVE)) { _tField = new TableTextField(); if (_p.getValue() == null) { _tField.setText(""); } else { _tField.setText(String.valueOf(_p.getValue())); } _editorComponent = _tField; } else if (_valueType.equals(TYPE_OBJECT_CREATOR)) { JButton jb = new JButton("..."); // Here's the code that brings up the dialog. jb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.err.println("Property:" + _p); System.err.println("Property(type):" + _p.getType()); System.err.println("Property(name):" + _p.getName()); System.err.println("Property(value):" + _p.getValue()); ObjectCreatorDialog ObjectCreatorDialog = new ObjectCreatorDialog(DiagramShape.getDiagram().getFrame(), _p, _tField); ObjectCreatorDialog.setVisible(true); _p.setValue(ObjectCreatorDialog.getPropertyValue()); } }); _tField = new TableTextField(); if (_p.getValue() != null) { String className = (_p.getValue().getClass().getName()); String classNameOnly = className.substring((className.lastIndexOf(".") + 1)); _tField.setText(classNameOnly); _tField.setObject(_p.getValue()); } _tField.setLayout(new BorderLayout()); _tField.add("East", jb); _tField.setEditable(false); _editorComponent = _tField; } else if (_valueType.equals(TYPE_TRANSFORM)) { JButton jb = new JButton("..."); // Here's the code that brings up the dialog. jb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.err.println("Property:" + _p); System.err.println("Property(type):" + _p.getType()); System.err.println("Property(name):" + _p.getName()); System.err.println("Property(value):" + _p.getValue()); TransformDialog transformDialog = new TransformDialog(DiagramShape.getDiagram().getFrame(), _p, _tField); transformDialog.setVisible(true); _p.setValue(transformDialog.getPropertyValue()); } }); _tField = new TableTextField(); if (_p.getValue() != null) { String className = (_p.getValue().getClass().getName()); String classNameOnly = className.substring((className.lastIndexOf(".") + 1)); _tField.setText(classNameOnly); _tField.setObject(_p.getValue()); } _tField.setLayout(new BorderLayout()); _tField.add("East", jb); _tField.setEditable(false); _editorComponent = _tField; } else if (_valueType.equals(TYPE_DISTRIBUTION)) { JButton jb = new JButton("..."); // Here's the code that brings up the dialog. jb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { DistributionDialog distributionDialog = new DistributionDialog(DiagramShape.getDiagram().getFrame(), _p, _tField); distributionDialog.setVisible(true); _p.setValue(distributionDialog.getPropertyValue()); } }); _tField = new TableTextField(); if (_p.getValue() != null) { String className = (_p.getValue().getClass().getName()); String classNameOnly = className.substring((className.lastIndexOf(".") + 1)); _tField.setText(classNameOnly); _tField.setObject(_p.getValue()); } _tField.setLayout(new BorderLayout()); _tField.add("East", jb); _tField.setEditable(false); _editorComponent = _tField; } else if (_valueType.equals(TYPE_ANIMATION)) { JButton jb = new JButton("..."); // Here's the code that brings up the dialog. jb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { AnimationTransformDialog animationTransformDialog = new AnimationTransformDialog(DiagramShape.getDiagram().getFrame(), _p, _tField); animationTransformDialog.setVisible(true); _p.setValue(animationTransformDialog.getPropertyValue()); } }); _tField = new TableTextField(); if (_p.getValue() != null) { String className = (_p.getValue().getClass().getName()); String classNameOnly = className.substring((className.lastIndexOf(".") + 1)); _tField.setText(classNameOnly); _tField.setObject(_p.getValue()); } _tField.setLayout(new BorderLayout()); _tField.add("East", jb); _tField.setEditable(false); _editorComponent = _tField; } else if (_valueType.equals(TYPE_SPLITTERMODEL)) { JButton jb = new JButton("..."); // Here's the code that brings up the dialog. jb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.err.println("Property:" + _p); System.err.println("Property(type):" + _p.getType()); System.err.println("Property(name):" + _p.getName()); System.err.println("Property(value):" + _p.getValue()); SplitterModelDialog splitterModelDialog = new SplitterModelDialog(DiagramShape.getDiagram().getFrame(), _p, _tField); splitterModelDialog.setVisible(true); _p.setValue(splitterModelDialog.getPropertyValue()); } }); _tField = new TableTextField(); if (_p.getValue() != null) { String className = (_p.getValue().getClass().getName()); String classNameOnly = className.substring((className.lastIndexOf(".") + 1)); _tField.setText(classNameOnly); _tField.setObject(_p.getValue()); } _tField.setLayout(new BorderLayout()); _tField.add("East", jb); _tField.setEditable(false); _editorComponent = _tField; } else if (_valueType.equals(TYPE_MERGERMODEL)) { JButton jb = new JButton("..."); // Here's the code that brings up the dialog. jb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.err.println("Property:" + _p); System.err.println("Property(type):" + _p.getType()); System.err.println("Property(name):" + _p.getName()); System.err.println("Property(value):" + _p.getValue()); MergerModelDialog mergerModelDialog = new MergerModelDialog(DiagramShape.getDiagram().getFrame(), _p, _tField); mergerModelDialog.setVisible(true); _p.setValue(mergerModelDialog.getPropertyValue()); } }); _tField = new TableTextField(); if (_p.getValue() != null) { String className = (_p.getValue().getClass().getName()); String classNameOnly = className.substring((className.lastIndexOf(".") + 1)); _tField.setText(classNameOnly); _tField.setObject(_p.getValue()); } _tField.setLayout(new BorderLayout()); _tField.add("East", jb); _tField.setEditable(false); _editorComponent = _tField; } else if (_valueType.equals(TYPE_PRESENTATION)) { JButton jb = new JButton("..."); // Here's the code that brings up the dialog. jb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.err.println("Property:" + _p); System.err.println("Property(type):" + _p.getType()); System.err.println("Property(name):" + _p.getName()); System.err.println("Property(value):" + _p.getValue()); DataProcessorDialog dataProcessorDialog = new DataProcessorDialog(DiagramShape.getDiagram().getFrame(), _p, _tField); dataProcessorDialog.setVisible(true); _p.setValue(dataProcessorDialog.getPropertyValue()); } }); _tField = new TableTextField(); if (_p.getValue() != null) { String className = (_p.getValue().getClass().getName()); String classNameOnly = className.substring((className.lastIndexOf(".") + 1)); _tField.setText(classNameOnly); _tField.setObject(_p.getValue()); } _tField.setLayout(new BorderLayout()); _tField.add("East", jb); _tField.setEditable(false); _editorComponent = _tField; } else if (_valueType.equals(TYPE_DATA_PROCESSOR)) { JButton jb = new JButton("..."); // Here's the code that brings up the dialog. jb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.err.println("Property:" + _p); System.err.println("Property(type):" + _p.getType()); System.err.println("Property(name):" + _p.getName()); System.err.println("Property(value):" + _p.getValue()); MergerModelDialog mergerModelDialog = new MergerModelDialog(DiagramShape.getDiagram().getFrame(), _p, _tField); mergerModelDialog.setVisible(true); _p.setValue(mergerModelDialog.getPropertyValue()); } }); _tField = new TableTextField(); if (_p.getValue() != null) { String className = (_p.getValue().getClass().getName()); String classNameOnly = className.substring((className.lastIndexOf(".") + 1)); _tField.setText(classNameOnly); _tField.setObject(_p.getValue()); } _tField.setLayout(new BorderLayout()); _tField.add("East", jb); _tField.setEditable(false); _editorComponent = _tField; } else { String[] typeAry = _pReader.getType(type); String[] choiceAry = new String[typeAry.length]; for (int j = 0; j < typeAry.length; j++) { StringTokenizer st = new StringTokenizer(typeAry[j], "."); int count = st.countTokens(); while (count != 1) { st.nextToken(); count--; } choiceAry[j] = st.nextToken(); _tComboBox = new TableComboBox(choiceAry); } if (_p.getValue() != null) { _tComboBox.setObject(_p.getValue()); } _editorComponent = _tComboBox; } return editorComponent(); }
public void setPropertyValue(Object object) { _p.setValue(object); _pTable.getProperties().setElementAt(_p, _row); }