Revision: 3468
Author: silva.josemanuel1
Date: Thu Apr 22 12:03:52 2010
Log: The edit panels for tables, columns, relationship, and indexes now
listen to the object they are editing for changes from other users, and
notify the user(s) editing it appropriately.
http://code.google.com/p/power-architect/source/detail?r=3468
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnMappingPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/IndexEditPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/RelationshipEditPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/TabbedDataEntryPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/TableEditPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CreateTableAction.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/EditRelationshipAction.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
Wed Mar 17 14:29:59 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
Thu Apr 22 12:03:52 2010
@@ -27,6 +27,7 @@
import java.awt.event.ComponentEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
+import java.beans.PropertyChangeEvent;
import java.sql.DatabaseMetaData;
import java.util.ArrayList;
import java.util.Collection;
@@ -68,9 +69,11 @@
import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.sqlobject.SQLObjectUtils;
import ca.sqlpower.sqlobject.SQLType;
-import ca.sqlpower.swingui.DataEntryPanel;
+import ca.sqlpower.swingui.ChangeListeningDataEntryPanel;
+import ca.sqlpower.swingui.DataEntryPanelChangeUtil;
import ca.sqlpower.swingui.SPSUtils;
import ca.sqlpower.util.SQLPowerUtils;
+import ca.sqlpower.util.TransactionEvent;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
@@ -81,7 +84,7 @@
* of one or more columns. The user interface is slightly different in
multi-column
* edit mode.
*/
-public class ColumnEditPanel implements ActionListener, DataEntryPanel {
+public class ColumnEditPanel extends ChangeListeningDataEntryPanel
implements ActionListener, SPListener {
private static final Logger logger =
Logger.getLogger(ColumnEditPanel.class);
@@ -90,7 +93,7 @@
/**
* The column we're editing.
*/
- private final Collection<SQLColumn> columns;
+ private final List<SQLColumn> columns;
private final JPanel panel;
@@ -150,7 +153,6 @@
private final ArchitectSession session;
-
public ColumnEditPanel(SQLColumn col, ArchitectSwingSession session)
throws SQLObjectException {
this(Collections.singleton(col), session);
}
@@ -166,7 +168,14 @@
if (cols == null || cols.isEmpty()) {
throw new NullPointerException("Null or empty collection of
columns is not allowed"); //$NON-NLS-1$
}
- columns = new ArrayList<SQLColumn>(cols);
+ columns = new ArrayList<SQLColumn>(cols);
+
+// if (columns.get(0).getParent() != null) {
+//
columns.get(0).getParent().getPrimaryKeyIndex().addSPListener(this);
+// for (SQLColumn col : columns) {
+// col.addSPListener(this);
+// }
+// }
FormLayout layout = new FormLayout(
"pref, pref:grow, 4dlu, pref, pref:grow",
@@ -287,7 +296,7 @@
if (cols.size() > 1) {
panel.add(cb, cc.xy(1, row));
}
- panel.add(colInPK = new
JCheckBox(Messages.getString("ColumnEditPanel.inPrimaryKey")), cc.xyw(2,
row++, 4)); //$NON-NLS-1$
+ panel.add(colInPK = new
JCheckBox(Messages.getString("ColumnEditPanel.inPrimaryKey")), cc.xyw(2,
row++, 4)); //$NON-NLS-1$
componentEnabledMap.put(colInPK, cb);
colInPK.addActionListener(this);
colInPK.addActionListener(checkboxEnabler);
@@ -425,6 +434,7 @@
colPhysicalName.selectAll();
SQLPowerUtils.listenToHierarchy(session.getRootObject(),
obsolesenceListener);
+ SQLPowerUtils.listenToHierarchy(session.getRootObject(), this);
panel.addAncestorListener(cleanupListener);
}
@@ -717,6 +727,7 @@
* enter on a text field.
*/
public boolean applyChanges() {
+ SQLPowerUtils.unlistenToHierarchy(session.getRootObject(), this);
List<String> errors = updateModel();
if (!errors.isEmpty()) {
JOptionPane.showMessageDialog(panel, errors.toString());
@@ -730,7 +741,7 @@
* Does nothing. The column's properties will not have been modified.
*/
public void discardChanges() {
- // nothing to do
+ SQLPowerUtils.unlistenToHierarchy(session.getRootObject(), this);
}
/* docs inherit from interface */
@@ -881,10 +892,75 @@
public void ancestorMoved(AncestorEvent event) { /* don't care */ }
public void ancestorRemoved(AncestorEvent event) {
- SQLPowerUtils.unlistenToHierarchy(session.getRootObject(),
obsolesenceListener);
+ SQLPowerUtils.unlistenToHierarchy(session.getRootObject(),
obsolesenceListener);
}
};
-
+
+ public void childAdded(SPChildEvent e) {
+ try {
+ if (e.getSource() ==
columns.get(0).getParent().getPrimaryKeyIndex()) {
+ // The column that was added may not be the one at index
0, but
+ // e.getChild() is a copied column, and it doesn't matter
+ // so long as a change is flagged, which it will be.
+ propertyChanged(new
PropertyChangeEvent(columns.get(0), "inPK", false, true));
+ }
+ } catch (SQLObjectException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public void childRemoved(SPChildEvent e) {
+ try {
+ if (e.getSource() ==
columns.get(0).getParent().getPrimaryKeyIndex()) {
+ propertyChanged(new
PropertyChangeEvent(columns.get(0), "inPK", true, false));
+ }
+ } catch (SQLObjectException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public void propertyChanged(PropertyChangeEvent e) {
+ if (columns.contains(e.getSource())) {
+ String property = e.getPropertyName();
+ if (property.equals("name")) {
+ DataEntryPanelChangeUtil.incomingChange(colLogicalName, e);
+ } else if (property.equals("physicalName")) {
+ DataEntryPanelChangeUtil.incomingChange(colPhysicalName,
e);
+ } else if (property.equals("type")) {
+ DataEntryPanelChangeUtil.incomingChange(colType, e);
+ } else if (property.equals("precision")) {
+ DataEntryPanelChangeUtil.incomingChange(colPrec, e);
+ } else if (property.equals("scale")) {
+ DataEntryPanelChangeUtil.incomingChange(colScale, e);
+ } else if (property.equals("inPK")) {
+ DataEntryPanelChangeUtil.incomingChange(colInPK, e);
+ } else if (property.equals("isNullable")) {
+ DataEntryPanelChangeUtil.incomingChange(colNullable, e);
+ } else if (property.equals("autoIncrement")) {
+ DataEntryPanelChangeUtil.incomingChange(colAutoInc, e);
+ } else if (property.equals("autoIncrementSequenceName")) {
+
DataEntryPanelChangeUtil.incomingChange(colAutoIncSequenceName, e);
+ } else if (property.equals("remarks")) {
+ DataEntryPanelChangeUtil.incomingChange(colRemarks, e);
+ } else if (property.equals("defaultValue")) {
+ DataEntryPanelChangeUtil.incomingChange(colDefaultValue,
e);
+ } else return;
+ setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ }
+ }
+
+ public void transactionEnded(TransactionEvent e) {
+ //no-op
+ }
+
+ public void transactionRollback(TransactionEvent e) {
+ //no-op
+ }
+
+ public void transactionStarted(TransactionEvent e) {
+ //no-op
+ }
+
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnMappingPanel.java
Wed Mar 17 14:29:59 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnMappingPanel.java
Thu Apr 22 12:03:52 2010
@@ -28,6 +28,7 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
+import java.beans.PropertyChangeEvent;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -39,13 +40,18 @@
import org.apache.log4j.Logger;
import ca.sqlpower.object.ObjectDependentException;
+import ca.sqlpower.object.SPChildEvent;
+import ca.sqlpower.object.SPListener;
import ca.sqlpower.sqlobject.SQLColumn;
import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.sqlobject.SQLRelationship;
import ca.sqlpower.sqlobject.SQLTable;
import ca.sqlpower.sqlobject.SQLRelationship.ColumnMapping;
import ca.sqlpower.sqlobject.SQLRelationship.SQLImportedKey;
-import ca.sqlpower.swingui.DataEntryPanel;
+import ca.sqlpower.swingui.ChangeListeningDataEntryPanel;
+import ca.sqlpower.swingui.DataEntryPanelChangeUtil;
+import ca.sqlpower.util.SQLPowerUtils;
+import ca.sqlpower.util.TransactionEvent;
/**
* The ColumnMappingPanel presents a GUI for viewing and modifying
@@ -57,7 +63,7 @@
* new Relationship, throw it at this editor, then examine its mappings
* to build up any kind of mapping you want.
*/
-public class ColumnMappingPanel implements DataEntryPanel {
+public class ColumnMappingPanel extends ChangeListeningDataEntryPanel
implements SPListener {
private static final Logger logger =
Logger.getLogger(ColumnMappingPanel.class);
@@ -296,6 +302,8 @@
* The panel that contains the GUI.
*/
private final CustomPanel panel = new CustomPanel();
+
+ private final JScrollPane scrollPane;
/**
* Tracks whether or not any edits have been made on this panel.
@@ -324,6 +332,7 @@
PlayPen pp = new PlayPen(session);
lhsTable = new TablePane(r.getPkTable(), pp.getContentPane());
rhsTable = new TablePane(r.getFkTable(), pp.getContentPane());
+ SQLPowerUtils.listenToHierarchy(lhsTable.getModel().getParent(),
this);
// The playpen constructor hooks the playpen in as a hierarchy
listener
// on the entire SQLObject tree. Since we're not even using the
playpen,
@@ -332,10 +341,11 @@
lhsTable.setLocation(1, 1);
rhsTable.setLocation(lhsTable.getWidth() + gap, 1);
- updateMappingsFromRelationship();
+ updateMappingsFromRelationship();
MouseHandler mouseHandler = new MouseHandler();
panel.addMouseListener(mouseHandler);
panel.addMouseMotionListener(mouseHandler);
+ scrollPane = new JScrollPane(panel);
colourOtherRelationships();
}
@@ -365,7 +375,7 @@
* Updates the ColumnMapping children in {...@link #r} to match those in
this
* panel's internal representation of the mappings.
*/
- public void updateRelationshipFromMappings() throws SQLObjectException
{
+ private void updateRelationshipFromMappings() throws
SQLObjectException {
try {
r.begin("Modify Column Mappings"); //$NON-NLS-1$
logger.debug("Removing all mappings from relationship...");
//$NON-NLS-1$
@@ -390,7 +400,7 @@
* Updates this panel's internal representation of the mappings to
* match those in {...@link #r}.
*/
- public void updateMappingsFromRelationship() {
+ private void updateMappingsFromRelationship() {
mappings = new HashMap<SQLColumn, SQLColumn>();
for (SQLRelationship.ColumnMapping cm : r.getChildren(
SQLRelationship.ColumnMapping.class)) {
@@ -415,7 +425,7 @@
}
public JComponent getPanel() {
- return new JScrollPane(panel);
+ return scrollPane;
}
public boolean hasUnsavedChanges() {
@@ -427,7 +437,82 @@
* during the creation of this instance.
*/
private void cleanup() {
+ SQLPowerUtils.unlistenToHierarchy(lhsTable.getModel().getParent(),
this);
lhsTable.destroy();
rhsTable.destroy();
}
-}
+
+ public void childAdded(SPChildEvent e) {
+ panel.repaint();
+ if (e.getSource() instanceof SQLTable &&
+ (e.getChild() instanceof SQLRelationship || e.getChild()
instanceof SQLImportedKey)) {
+ TablePane tp;
+ if (lhsTable.getModel() == e.getSource()) tp = rhsTable;
+ else if (rhsTable.getModel() == e.getSource()) tp = lhsTable;
+ else return;
+ updateMappingsFromRelationship();
+
tp.setBackgroundColor(DataEntryPanelChangeUtil.NONCONFLICTING_COLOR);
+ setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ } else if (e.getChild() instanceof ColumnMapping) {
+ ColumnMapping cm = (ColumnMapping) e.getChild();
+ for (TablePane tp : new TablePane[] {lhsTable, rhsTable}) {
+ for (SQLColumn c : new SQLColumn[] {cm.getPkColumn(),
cm.getFkColumn()}) {
+ try {
+ if (tp.getModel().getColumns().contains(c)) {
+ updateMappingsFromRelationship();
+ tp.addColumnHighlight(c,
DataEntryPanelChangeUtil.DARK_NONCONFLICTING_COLOR);
+
setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ }
+ } catch (SQLObjectException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+ }
+ }
+
+ public void childRemoved(SPChildEvent e) {
+ panel.repaint();
+ if (e.getSource() instanceof SQLTable &&
+ (e.getChild() instanceof SQLRelationship || e.getChild()
instanceof SQLImportedKey)) {
+ TablePane tp;
+ if (lhsTable.getModel() == e.getSource()) tp = rhsTable;
+ else if (rhsTable.getModel() == e.getSource()) tp = lhsTable;
+ else return;
+ updateMappingsFromRelationship();
+
tp.setBackgroundColor(DataEntryPanelChangeUtil.NONCONFLICTING_COLOR);
+ setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ } else if (e.getChild() instanceof ColumnMapping) {
+ ColumnMapping cm = (ColumnMapping) e.getChild();
+ for (TablePane tp : new TablePane[] {lhsTable, rhsTable}) {
+ for (SQLColumn c : new SQLColumn[] {cm.getPkColumn(),
cm.getFkColumn()}) {
+ try {
+ if (tp.getModel().getColumns().contains(c)) {
+ updateMappingsFromRelationship();
+ tp.addColumnHighlight(c,
DataEntryPanelChangeUtil.DARK_NONCONFLICTING_COLOR);
+
setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ }
+ } catch (SQLObjectException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+ }
+ }
+
+ public void propertyChanged(PropertyChangeEvent e) {
+ panel.repaint();
+ }
+
+ public void transactionEnded(TransactionEvent e) {
+ // no-op
+ }
+
+ public void transactionRollback(TransactionEvent e) {
+ // no-op
+ }
+
+ public void transactionStarted(TransactionEvent e) {
+ // no-op
+ }
+}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/IndexEditPanel.java
Thu Feb 25 09:46:15 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/IndexEditPanel.java
Thu Apr 22 12:03:52 2010
@@ -20,6 +20,7 @@
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.List;
@@ -34,20 +35,25 @@
import javax.swing.JTextField;
import ca.sqlpower.object.ObjectDependentException;
+import ca.sqlpower.object.SPChildEvent;
+import ca.sqlpower.object.SPListener;
import ca.sqlpower.sql.JDBCDataSourceType;
import ca.sqlpower.sqlobject.SQLIndex;
import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.sqlobject.SQLObjectRuntimeException;
import ca.sqlpower.sqlobject.SQLTable;
import ca.sqlpower.sqlobject.SQLIndex.Column;
-import ca.sqlpower.swingui.DataEntryPanel;
+import ca.sqlpower.swingui.ChangeListeningDataEntryPanel;
+import ca.sqlpower.swingui.DataEntryPanelChangeUtil;
import ca.sqlpower.swingui.SPSUtils;
+import ca.sqlpower.util.SQLPowerUtils;
+import ca.sqlpower.util.TransactionEvent;
import com.jgoodies.forms.builder.PanelBuilder;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
-public class IndexEditPanel extends JPanel implements DataEntryPanel {
+public class IndexEditPanel extends ChangeListeningDataEntryPanel
implements SPListener {
protected SQLIndex index;
protected SQLTable parent;
@@ -66,10 +72,12 @@
IndexColumnTable columnsTable;
+ private JPanel panel;
+
/**
* This session that contains this index panel.
*/
- ArchitectSwingSession session;
+ ArchitectSwingSession session;
/**
* Identifier for the default index type.
@@ -77,22 +85,20 @@
private static String DEFAULT_INDEX_TYPE =
Messages.getString("IndexEditPanel.defaultIndexType"); //$NON-NLS-1$
public IndexEditPanel(SQLIndex index, ArchitectSwingSession session)
throws SQLObjectException {
- super(new FormLayout("pref,4dlu,pref,4dlu,pref:grow,4dlu,pref",
//$NON-NLS-1$
- "pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref:grow,4dlu,pref,4dlu"));
//$NON-NLS-1$
- this.session = session;
- createGUI(index, index.getParent(), session);
+ this(index, index.getParent(), session);
}
public IndexEditPanel(SQLIndex index, SQLTable parent,
ArchitectSwingSession session) throws SQLObjectException {
- super(new FormLayout("pref,4dlu,pref,4dlu,pref:grow,4dlu,pref",
//$NON-NLS-1$
+ panel = new JPanel(new
FormLayout("pref,4dlu,pref,4dlu,pref:grow,4dlu,pref", //$NON-NLS-1$
"pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref,4dlu,pref:grow,4dlu,pref,4dlu"));
//$NON-NLS-1$
this.session = session;
+ SQLPowerUtils.listenToHierarchy(index, this);
createGUI(index, parent, session);
}
private void createGUI(SQLIndex index, SQLTable parent,
ArchitectSwingSession session) throws SQLObjectException {
this.parent = parent;
- PanelBuilder pb = new PanelBuilder((FormLayout) this.getLayout(),
this);
+ PanelBuilder pb = new PanelBuilder((FormLayout) panel.getLayout(),
panel);
CellConstraints cc = new CellConstraints();
pb.add(new JLabel(Messages.getString("IndexEditPanel.indexName")),
cc.xy(1, 1)); //$NON-NLS-1$
pb.add(name = new JTextField("", 30), cc.xyw(3, 1, 4));
//$NON-NLS-1$
@@ -236,9 +242,9 @@
* returns true if saved, false otherwise
*/
public boolean applyChanges() {
+ SQLPowerUtils.unlistenToHierarchy(index, this);
columnsTable.cleanUp();
- columnsTable.finalizeIndex();
-
+ columnsTable.finalizeIndex();
// if this was done on the index, listeners would only start
listening after the index has
// been added to its parent and compound edit would not work.
Compound edits belong to the parent.
parent.begin(Messages.getString("IndexEditPanel.compoundEditName"));
//$NON-NLS-1$
@@ -286,7 +292,7 @@
index.cleanUpIfChildless();
return true;
} else {
- JOptionPane.showMessageDialog(this, warnings.toString());
+ JOptionPane.showMessageDialog(panel, warnings.toString());
//this is done so we can go back to this dialog after the
error message
return false;
}
@@ -302,10 +308,11 @@
}
public void discardChanges() {
+ SQLPowerUtils.unlistenToHierarchy(index, this);
}
public JPanel getPanel() {
- return this;
+ return panel;
}
public String getNameText() {
@@ -320,4 +327,62 @@
// TODO return whether this panel has been changed
return true;
}
-}
+
+ public void childAdded(SPChildEvent e) {
+ // XXX Make this actually check for a conflict or not.
+ if (e.getSource() == index) {
+
columnsTable.getTable().setBackground(DataEntryPanelChangeUtil.NONCONFLICTING_COLOR);
+ setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ }
+ }
+
+ public void childRemoved(SPChildEvent e) {
+ // XXX Make this actually check for a conflict or not.
+ if (e.getSource() == index) {
+
columnsTable.getTable().setBackground(DataEntryPanelChangeUtil.NONCONFLICTING_COLOR);
+ setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ }
+ }
+
+ public void propertyChanged(PropertyChangeEvent e) {
+ String property = e.getPropertyName();
+ boolean error = false;
+ if (e.getSource() == index) {
+ if (property.equals("name")) {
+ error = DataEntryPanelChangeUtil.incomingChange(name, e);
+ } else if (property.equals("unique")) {
+ error = DataEntryPanelChangeUtil.incomingChange(unique, e);
+ } else if (property.equals("clustered")) {
+ error = DataEntryPanelChangeUtil.incomingChange(clustered,
e);
+ } else if (property.equals("type")) {
+ Object oldValue = e.getOldValue();
+ Object newValue = e.getNewValue();
+ if (oldValue == null || oldValue.equals("")) oldValue
= "Platform Default";
+ if (newValue == null || oldValue.equals("")) newValue
= "Platform Default";
+ error = DataEntryPanelChangeUtil.incomingChange(indexType,
new PropertyChangeEvent(
+ e.getSource(), e.getPropertyName(), oldValue,
newValue));
+ }
+ } else if (e.getSource() instanceof Column) {
+ if (property.equals("ascendingOrDescending")) {
+ // XXX Make this find the appropriate checkbox and
highlight that.
+
columnsTable.getTable().setBackground(DataEntryPanelChangeUtil.NONCONFLICTING_COLOR);
+ error = true;
+ }
+ }
+ if (error) {
+ setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ }
+ }
+
+ public void transactionEnded(TransactionEvent e) {
+ // no-op
+ }
+
+ public void transactionRollback(TransactionEvent e) {
+ // no-op
+ }
+
+ public void transactionStarted(TransactionEvent e) {
+ // no-op
+ }
+}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java
Tue Apr 13 12:48:01 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java
Thu Apr 22 12:03:52 2010
@@ -231,7 +231,7 @@
} else {
components.add(pos, ppc);
}
- ppc.setParent(this);
+ ppc.setParent(this);
if (getPlayPen() != null) {
ppc.addSelectionListener(getPlayPen());
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/RelationshipEditPanel.java
Wed Mar 17 14:29:59 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/RelationshipEditPanel.java
Thu Apr 22 12:03:52 2010
@@ -20,7 +20,7 @@
import java.awt.Color;
import java.awt.event.ActionEvent;
-import java.util.List;
+import java.beans.PropertyChangeEvent;
import java.util.Vector;
import javax.swing.AbstractAction;
@@ -36,23 +36,24 @@
import org.apache.log4j.Logger;
-import ca.sqlpower.architect.ArchitectSession;
-import ca.sqlpower.object.AbstractPoolingSPListener;
import ca.sqlpower.object.SPChildEvent;
+import ca.sqlpower.object.SPListener;
import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.sqlobject.SQLRelationship;
import ca.sqlpower.sqlobject.SQLRelationship.Deferrability;
import ca.sqlpower.sqlobject.SQLRelationship.UpdateDeleteRule;
+import ca.sqlpower.swingui.ChangeListeningDataEntryPanel;
import ca.sqlpower.swingui.ColorCellRenderer;
-import ca.sqlpower.swingui.DataEntryPanel;
+import ca.sqlpower.swingui.DataEntryPanelChangeUtil;
import ca.sqlpower.swingui.SPSUtils;
import ca.sqlpower.util.SQLPowerUtils;
+import ca.sqlpower.util.TransactionEvent;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.debug.FormDebugPanel;
import com.jgoodies.forms.layout.FormLayout;
-public class RelationshipEditPanel extends AbstractPoolingSPListener
implements DataEntryPanel {
+public class RelationshipEditPanel extends ChangeListeningDataEntryPanel
implements SPListener {
private static final Logger logger =
Logger.getLogger(RelationshipEditPanel.class);
@@ -111,21 +112,14 @@
private JRadioButton deleteNoAction;
private JRadioButton deleteSetDefault;
- private JComboBox relationLineColor;
-
- private ArchitectSession session;
-
- private Color color;
-
- private List<Relationship> relationshipLines;
-
- public RelationshipEditPanel(ArchitectSwingSession session) {
- this.session = session;
-
- relationshipLines =
session.getPlayPen().getSelectedRelationShips();
- //Since now can only select one relationship to edit at the same
time,
- //so the number of selected relationships is only 1.
- this.color = relationshipLines.get(0).getForegroundColor();
+ private Relationship relationshipLine;
+ private JComboBox relationLineColor;
+ private Color color;
+
+ public RelationshipEditPanel(Relationship r) {
+
+ relationshipLine = r;
+ this.color = relationshipLine.getForegroundColor();
FormLayout layout = new FormLayout("pref, 4dlu, pref:grow, 4dlu,
pref, 4dlu, pref:grow, 4dlu, pref"); //$NON-NLS-1$
layout.setColumnGroups(new int[][] { { 3, 7 } });
@@ -238,6 +232,8 @@
deleteRuleGroup.add(deleteSetDefault);
fb.nextLine();
+ setRelationship(r.getModel());
+
//TODO Doesn't work!
relationshipName.selectAll();
@@ -246,7 +242,7 @@
}
- public void setRelationship(SQLRelationship r) {
+ private void setRelationship(SQLRelationship r) {
this.relationship = r;
relationshipName.setText(r.getName());
pkLabelTextField.setText(r.getTextForParentLabel());
@@ -310,15 +306,24 @@
deleteSetNull.setSelected(true);
}
- relationshipName.selectAll();
-
- SQLPowerUtils.listenToHierarchy(session.getRootObject(), this);
+ relationshipName.selectAll();
+ addListeners();
+ }
+
+ private void addListeners() {
+ SQLPowerUtils.listenToHierarchy(relationship.getParent(), this);
+ relationshipLine.addSPListener(this);
+ }
+
+ private void removeListeners() {
+ SQLPowerUtils.unlistenToHierarchy(relationship.getParent(), this);
+ relationshipLine.removeSPListener(this);
}
// ------------------ ARCHITECT PANEL INTERFACE ---------------------
public boolean applyChanges() {
- SQLPowerUtils.unlistenToHierarchy(session.getRootObject(), this);
+ removeListeners();
try {
relationship.begin(Messages.getString("RelationshipEditPanel.modifyRelationshipProperties"));
//$NON-NLS-1$
relationship.setName(relationshipName.getText());
@@ -332,61 +337,14 @@
} catch (SQLObjectException ex) {
logger.warn("Call to setIdentifying failed. Continuing with other
properties.", ex); //$NON-NLS-1$
}
-
- for(Relationship r: relationshipLines) {
- // set the color of relationship lines
-
r.setForegroundColor((Color)relationLineColor.getSelectedItem());
- }
-
- if (pkTypeZeroOne.isSelected()) {
- relationship.setPkCardinality(SQLRelationship.ZERO |
SQLRelationship.ONE);
- } else if (pkTypeZeroToMany.isSelected()) {
- relationship.setPkCardinality(SQLRelationship.ZERO |
SQLRelationship.ONE | SQLRelationship.MANY);
- } else if (pkTypeOneToMany.isSelected()) {
- relationship.setPkCardinality(SQLRelationship.ONE |
SQLRelationship.MANY);
- } else if (pkTypeOne.isSelected()) {
-
relationship.setPkCardinality(SQLRelationship.ONE);
- }
-
- if (fkTypeZeroOne.isSelected()) {
- relationship.setFkCardinality(SQLRelationship.ZERO |
SQLRelationship.ONE);
- } else if (fkTypeZeroToMany.isSelected()) {
- relationship.setFkCardinality(SQLRelationship.ZERO |
SQLRelationship.ONE | SQLRelationship.MANY);
- } else if (fkTypeOneToMany.isSelected()) {
- relationship.setFkCardinality(SQLRelationship.ONE |
SQLRelationship.MANY);
- }
-
- if (notDeferrable.isSelected()) {
-
relationship.setDeferrability(Deferrability.NOT_DEFERRABLE);
- } else if (initiallyDeferred.isSelected()) {
-
relationship.setDeferrability(Deferrability.INITIALLY_DEFERRED);
- } else if (initiallyImmediate.isSelected()) {
-
relationship.setDeferrability(Deferrability.INITIALLY_IMMEDIATE);
- }
-
- if (updateCascade.isSelected()) {
- relationship.setUpdateRule(UpdateDeleteRule.CASCADE);
- } else if (updateNoAction.isSelected()) {
- relationship.setUpdateRule(UpdateDeleteRule.NO_ACTION);
- } else if (updateRestrict.isSelected()) {
- relationship.setUpdateRule(UpdateDeleteRule.RESTRICT);
- } else if (updateSetDefault.isSelected()) {
- relationship.setUpdateRule(UpdateDeleteRule.SET_DEFAULT);
- } else if (updateSetNull.isSelected()) {
- relationship.setUpdateRule(UpdateDeleteRule.SET_NULL);
- }
-
- if (deleteCascade.isSelected()) {
- relationship.setDeleteRule(UpdateDeleteRule.CASCADE);
- } else if (deleteNoAction.isSelected()) {
- relationship.setDeleteRule(UpdateDeleteRule.NO_ACTION);
- } else if (deleteRestrict.isSelected()) {
- relationship.setDeleteRule(UpdateDeleteRule.RESTRICT);
- } else if (deleteSetDefault.isSelected()) {
- relationship.setDeleteRule(UpdateDeleteRule.SET_DEFAULT);
- } else if (deleteSetNull.isSelected()) {
- relationship.setDeleteRule(UpdateDeleteRule.SET_NULL);
- }
+
+
relationshipLine.setForegroundColor((Color)relationLineColor.getSelectedItem());
+
+
relationship.setPkCardinality(getSelectedPKCardinality());
+
relationship.setFkCardinality(getSelectedFKCardinality());
+
relationship.setDeferrability(getSelectedDeferrability());
+ relationship.setUpdateRule(getSelectedUpdateRule());
+ relationship.setDeleteRule(getSelectedDeleteRule());
relationship.commit();
} catch (Exception e) {
@@ -397,7 +355,7 @@
}
public void discardChanges() {
- SQLPowerUtils.unlistenToHierarchy(session.getRootObject(), this);
+ removeListeners();
}
public JPanel getPanel() {
@@ -407,21 +365,6 @@
public boolean hasUnsavedChanges() {
return true;
}
-
- /**
- * Checks to see if its respective relationship is removed from
- * playpen. If yes, exit the editing dialog window.
- */
- public void childRemovedImpl(SPChildEvent e) {
- logger.debug("SQLObject child was removed: "+e); //$NON-NLS-1$
-
- if (relationship.equals(e.getChild())) {
- SQLPowerUtils.unlistenToHierarchy(session.getRootObject(),
this);
- if (editDialog != null) {
- editDialog.dispose();
- }
- }
- }
public void setEditDialog(JDialog editDialog) {
this.editDialog = editDialog;
@@ -429,7 +372,7 @@
Action customColour = new AbstractAction("Custom...") {
public void actionPerformed(ActionEvent arg0) {
- Color colour =
ArchitectSwingSessionImpl.getCustomColour(relationshipLines.get(0).getForegroundColor(),
panel);
+ Color colour =
ArchitectSwingSessionImpl.getCustomColour(relationshipLine.getForegroundColor(),
panel);
if (colour != null) {
if (!containsColor(Relationship.SUGGESTED_COLOURS,
colour)) {
relationLineColor.addItem(colour);
@@ -457,4 +400,127 @@
}
return contains;
}
-}
+
+ private int getSelectedPKCardinality() {
+ if (pkTypeZeroOne.isSelected()) {
+ return SQLRelationship.ZERO | SQLRelationship.ONE;
+ } else if (pkTypeZeroToMany.isSelected()) {
+ return SQLRelationship.ZERO | SQLRelationship.ONE |
SQLRelationship.MANY;
+ } else if (pkTypeOneToMany.isSelected()) {
+ return SQLRelationship.ONE | SQLRelationship.MANY;
+ } else if (pkTypeOne.isSelected()) {
+ return SQLRelationship.ONE;
+ } else throw new IllegalStateException("No PK cardinality
selected");
+ }
+
+ private int getSelectedFKCardinality() {
+ if (fkTypeZeroOne.isSelected()) {
+ return SQLRelationship.ZERO | SQLRelationship.ONE;
+ } else if (fkTypeZeroToMany.isSelected()) {
+ return SQLRelationship.ZERO | SQLRelationship.ONE |
SQLRelationship.MANY;
+ } else if (fkTypeOneToMany.isSelected()) {
+ return SQLRelationship.ONE | SQLRelationship.MANY;
+ } else throw new IllegalStateException("No FK cardinality
selected");
+ }
+
+ private Deferrability getSelectedDeferrability() {
+ if (notDeferrable.isSelected()) {
+ return Deferrability.NOT_DEFERRABLE;
+ } else if (initiallyDeferred.isSelected()) {
+ return Deferrability.INITIALLY_DEFERRED;
+ } else if (initiallyImmediate.isSelected()) {
+ return Deferrability.INITIALLY_IMMEDIATE;
+ } else throw new IllegalStateException("No deferrability selected");
+ }
+
+ private UpdateDeleteRule getSelectedUpdateRule() {
+ if (updateCascade.isSelected()) {
+ return UpdateDeleteRule.CASCADE;
+ } else if (updateNoAction.isSelected()) {
+ return UpdateDeleteRule.NO_ACTION;
+ } else if (updateRestrict.isSelected()) {
+ return UpdateDeleteRule.RESTRICT;
+ } else if (updateSetDefault.isSelected()) {
+ return UpdateDeleteRule.SET_DEFAULT;
+ } else if (updateSetNull.isSelected()) {
+ return UpdateDeleteRule.SET_NULL;
+ } else throw new IllegalStateException("No update rule selected");
+ }
+
+ private UpdateDeleteRule getSelectedDeleteRule() {
+ if (deleteCascade.isSelected()) {
+ return UpdateDeleteRule.CASCADE;
+ } else if (deleteNoAction.isSelected()) {
+ return UpdateDeleteRule.NO_ACTION;
+ } else if (deleteRestrict.isSelected()) {
+ return UpdateDeleteRule.RESTRICT;
+ } else if (deleteSetDefault.isSelected()) {
+ return UpdateDeleteRule.SET_DEFAULT;
+ } else if (deleteSetNull.isSelected()) {
+ return UpdateDeleteRule.SET_NULL;
+ } else throw new IllegalStateException("No delete rule selected");
+ }
+
+ /**
+ * Checks to see if its respective relationship is removed from
+ * playpen. If yes, exit the editing dialog window.
+ */
+ public void childRemoved(SPChildEvent e) {
+ logger.debug("SQLObject child was removed: "+e); //$NON-NLS-1$
+ if (relationship.equals(e.getChild())) {
+ removeListeners();
+ if (editDialog != null) {
+ editDialog.dispose();
+ }
+ }
+ }
+
+ public void childAdded(SPChildEvent e) {
+ // no-op
+ }
+
+ public void propertyChanged(PropertyChangeEvent e) {
+ String property = e.getPropertyName();
+ boolean error = false;
+ if (e.getSource() == relationship) {
+ if (property.equals("name")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(relationshipName, e);
+ } else if (property.equals("textForParentLabel")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(pkLabelTextField, e);
+ } else if (property.equals("textForChildLabel")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(fkLabelTextField, e);
+ } else if (property.equals("identifying")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(identifyingGroup,
identifyingButton.isSelected(), e);
+ } else if (property.equals("pkCardinality")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(pkTypeGroup,
getSelectedPKCardinality(), e);
+ } else if (property.equals("fkCardinality")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(fkTypeGroup,
getSelectedFKCardinality(), e);
+ } else if (property.equals("deferrability")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(deferrabilityGroup,
getSelectedDeferrability(), e);
+ } else if (property.equals("updateRule")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(updateRuleGroup,
getSelectedUpdateRule(), e);
+ } else if (property.equals("deleteRule")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(deleteRuleGroup,
getSelectedDeleteRule(), e);
+ }
+ } else if (e.getSource() == relationshipLine) {
+ if (property.equals("foregroundColor")) {
+ error =
DataEntryPanelChangeUtil.incomingChange(relationLineColor, e);
+ }
+ }
+ if (error) {
+ setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ }
+ }
+
+ public void transactionEnded(TransactionEvent e) {
+ // no-op
+ }
+
+ public void transactionRollback(TransactionEvent e) {
+ // no-op
+ }
+
+ public void transactionStarted(TransactionEvent e) {
+ // no-op
+ }
+}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/TabbedDataEntryPanel.java
Fri Jun 27 12:38:43 2008
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/TabbedDataEntryPanel.java
Thu Apr 22 12:03:52 2010
@@ -26,7 +26,10 @@
import org.apache.log4j.Logger;
+import ca.sqlpower.swingui.ChangeListeningDataEntryPanel;
import ca.sqlpower.swingui.DataEntryPanel;
+import ca.sqlpower.swingui.DataEntryPanelChangeUtil;
+import ca.sqlpower.swingui.ChangeListeningDataEntryPanel.ErrorTextListener;
/**
* The TabbedDataEntryPanel aggregates one or more DataEntryPanel
@@ -35,7 +38,7 @@
* that "do the right thing" by broadcasting the corresponding request
* to all the panels being managed by the current instance.
*/
-public class TabbedDataEntryPanel implements DataEntryPanel {
+public class TabbedDataEntryPanel extends ChangeListeningDataEntryPanel
implements ErrorTextListener {
private static final Logger logger =
Logger.getLogger(TabbedDataEntryPanel.class);
@@ -61,6 +64,9 @@
public void addTab(String name, DataEntryPanel panel) {
tabbedPane.addTab(name, panel.getPanel());
panels.add(panel);
+ if (panel instanceof ChangeListeningDataEntryPanel) {
+ ((ChangeListeningDataEntryPanel)
panel).addErrorTextListener(this);
+ }
}
/**
@@ -104,5 +110,22 @@
}
return false;
}
+
+ public void textChanged(String s) {
+ setErrorText(s);
+
+ // Set the background color of error tabs.
+ for (DataEntryPanel p : panels) {
+ if (p instanceof ChangeListeningDataEntryPanel) {
+ String errorText = ((ChangeListeningDataEntryPanel)
p).getErrorText();
+ if (errorText != null && !errorText.equals("")) {
+ int index = tabbedPane.indexOfComponent(p.getPanel());
+ if (index >= 0) {
+ tabbedPane.setBackgroundAt(index,
DataEntryPanelChangeUtil.DARK_NONCONFLICTING_COLOR);
+ }
+ }
+ }
+ }
+ }
}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/TableEditPanel.java
Mon Jan 25 09:01:33 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/TableEditPanel.java
Thu Apr 22 12:03:52 2010
@@ -20,9 +20,11 @@
import java.awt.Color;
import java.beans.PropertyChangeEvent;
+import java.util.HashMap;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
+import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
@@ -38,13 +40,14 @@
import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.sqlobject.SQLObjectRuntimeException;
import ca.sqlpower.sqlobject.SQLTable;
+import ca.sqlpower.swingui.ChangeListeningDataEntryPanel;
import ca.sqlpower.swingui.ColorCellRenderer;
import ca.sqlpower.swingui.ColourScheme;
-import ca.sqlpower.swingui.DataEntryPanel;
+import ca.sqlpower.swingui.DataEntryPanelChangeUtil;
import ca.sqlpower.util.SQLPowerUtils;
import ca.sqlpower.util.TransactionEvent;
-public class TableEditPanel extends JPanel implements SPListener,
DataEntryPanel {
+public class TableEditPanel extends ChangeListeningDataEntryPanel
implements SPListener {
private static final Logger logger =
Logger.getLogger(TableEditPanel.class);
@@ -52,6 +55,7 @@
* The frame which this table edit panel resides in.
*/
private JDialog editDialog;
+ private JPanel panel;
protected SQLTable table;
JTextField logicalName;
JTextField physicalName;
@@ -64,44 +68,50 @@
private final ArchitectSwingSession session;
private final TablePane tp;
+
+ final HashMap<String, PropertyChangeEvent> propertyConflicts = new
HashMap<String, PropertyChangeEvent>();
+
+ final HashMap<String, JComponent> propertyFields = new HashMap<String,
JComponent>();
+
public TableEditPanel(ArchitectSwingSession session, SQLTable t) {
- super(new FormLayout());
+ this.panel = new JPanel(new FormLayout());
this.session = session;
this.tp = session.getPlayPen().findTablePane(t);
- add(new
JLabel(Messages.getString("TableEditPanel.tableLogicalNameLabel")));
//$NON-NLS-1$
- add(logicalName = new JTextField("", 30)); //$NON-NLS-1$
- add(new
JLabel(Messages.getString("TableEditPanel.tablePhysicalNameLabel")));
//$NON-NLS-1$
- add(physicalName = new JTextField("", 30)); //$NON-NLS-1$
- add(new
JLabel(Messages.getString("TableEditPanel.primaryKeyNameLabel")));
//$NON-NLS-1$
- add(pkName = new JTextField("", 30)); //$NON-NLS-1$
- add(new JLabel(Messages.getString("TableEditPanel.remarksLabel")));
//$NON-NLS-1$
- add(new JScrollPane(remarks = new JTextArea(4, 30)));
+ if (tp != null) tp.addSPListener(this);
+ panel.add(new
JLabel(Messages.getString("TableEditPanel.tableLogicalNameLabel")));
//$NON-NLS-1$
+ panel.add(logicalName = new JTextField("", 30)); //$NON-NLS-1$
+ panel.add(new
JLabel(Messages.getString("TableEditPanel.tablePhysicalNameLabel")));
//$NON-NLS-1$
+ panel.add(physicalName = new JTextField("", 30)); //$NON-NLS-1$
+ panel.add(new
JLabel(Messages.getString("TableEditPanel.primaryKeyNameLabel")));
//$NON-NLS-1$
+ panel.add(pkName = new JTextField("", 30)); //$NON-NLS-1$
+ panel.add(new
JLabel(Messages.getString("TableEditPanel.remarksLabel"))); //$NON-NLS-1$
+ panel.add(new JScrollPane(remarks = new JTextArea(4, 30)));
remarks.setLineWrap(true);
remarks.setWrapStyleWord(true);
- add(new JLabel(Messages.getString("TableEditPanel.tableColourLabel")));
//$NON-NLS-1$
+ panel.add(new
JLabel(Messages.getString("TableEditPanel.tableColourLabel")));
//$NON-NLS-1$
ColorCellRenderer renderer = new ColorCellRenderer(40, 20);
bgColor = new JComboBox(ColourScheme.BACKGROUND_COLOURS);
bgColor.setRenderer(renderer);
bgColor.addItem(new Color(240, 240, 240));
- add(bgColor);
-
- add(new JLabel(Messages.getString("TableEditPanel.textColourLabel")));
//$NON-NLS-1$
+ panel.add(bgColor);
+
+ panel.add(new
JLabel(Messages.getString("TableEditPanel.textColourLabel"))); //$NON-NLS-1$
fgColor = new JComboBox(ColourScheme.FOREGROUND_COLOURS);
fgColor.setRenderer(renderer);
fgColor.addItem(Color.BLACK);
- add(fgColor);
-
- add(new
JLabel(Messages.getString("TableEditPanel.dashedLinesLabel")));
//$NON-NLS-1$
- add(dashed = new JCheckBox());
- add(new
JLabel(Messages.getString("TableEditPanel.roundedCornersLabel")));
//$NON-NLS-1$
- add(rounded = new JCheckBox());
+ panel.add(fgColor);
+
+ panel.add(new
JLabel(Messages.getString("TableEditPanel.dashedLinesLabel")));
//$NON-NLS-1$
+ panel.add(dashed = new JCheckBox());
+ panel.add(new
JLabel(Messages.getString("TableEditPanel.roundedCornersLabel")));
//$NON-NLS-1$
+ panel.add(rounded = new JCheckBox());
editTable(t);
}
- private void editTable(SQLTable t) {
+ private void editTable(SQLTable t) {
table = t;
logicalName.setText(t.getName());
physicalName.setText(t.getPhysicalName());
@@ -112,7 +122,7 @@
pkName.setText(t.getPrimaryKeyName());
pkName.setEnabled(true);
}
- SQLPowerUtils.listenToHierarchy(session.getRootObject(), this);
+ SQLPowerUtils.listenToHierarchy(session.getRootObject(), this);
} catch (SQLObjectException e) {
throw new SQLObjectRuntimeException(e);
}
@@ -130,6 +140,7 @@
// --------------------- ArchitectPanel interface ------------------
public boolean applyChanges() {
SQLPowerUtils.unlistenToHierarchy(session.getRootObject(), this);
+ if (tp != null) tp.removeSPListener(this);
table.begin(Messages.getString("TableEditPanel.compoundEditName"));
//$NON-NLS-1$
try {
StringBuffer warnings = new StringBuffer();
@@ -177,7 +188,7 @@
}
return true;
} else {
- JOptionPane.showMessageDialog(this,warnings.toString());
+ JOptionPane.showMessageDialog(panel,warnings.toString());
//this is done so we can go back to this dialog after the
error message
return false;
}
@@ -190,10 +201,11 @@
public void discardChanges() {
SQLPowerUtils.unlistenToHierarchy(session.getRootObject(), this);
+ if (tp != null) tp.removeSPListener(this);
}
public JPanel getPanel() {
- return this;
+ return panel;
}
/**
@@ -261,6 +273,7 @@
logger.debug("SQLObject children got removed: " + e); //$NON-NLS-1$
if (table.equals(e.getChild())) {
SQLPowerUtils.unlistenToHierarchy(session.getRootObject(),
this);
+ tp.removeSPListener(this);
if (editDialog != null) {
editDialog.dispose();
}
@@ -268,7 +281,34 @@
}
public void propertyChanged(PropertyChangeEvent e) {
- // no-op
+ String property = e.getPropertyName();
+
+ boolean foundError = false;
+
+ if (e.getSource() == table) {
+ if (property.equals("name")) {
+ foundError =
DataEntryPanelChangeUtil.incomingChange(logicalName, e);
+ } else if (property.equals("physicalName")) {
+ foundError =
DataEntryPanelChangeUtil.incomingChange(physicalName, e);
+ } else if (property.equals("pkName")) {
+ foundError =
DataEntryPanelChangeUtil.incomingChange(pkName, e);
+ } else if (property.equals("remarks")) {
+ foundError =
DataEntryPanelChangeUtil.incomingChange(remarks, e);
+ }
+ } else if (e.getSource() == tp) {
+ if (property.equals("backgroundColor")) {
+ foundError =
DataEntryPanelChangeUtil.incomingChange(bgColor, e);
+ } else if (property.equals("foregroundColor")) {
+ foundError =
DataEntryPanelChangeUtil.incomingChange(fgColor, e);
+ } else if (property.equals("rounded")) {
+ foundError =
DataEntryPanelChangeUtil.incomingChange(rounded, e);
+ } else if (property.equals("dashed")) {
+ foundError =
DataEntryPanelChangeUtil.incomingChange(dashed, e);
+ }
+ }
+ if (foundError) {
+ setErrorText(DataEntryPanelChangeUtil.ERROR_MESSAGE);
+ }
}
public void transactionStarted(TransactionEvent e) {
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CreateTableAction.java
Wed Mar 17 14:29:59 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CreateTableAction.java
Thu Apr 22 12:03:52 2010
@@ -92,7 +92,7 @@
session.getWorkspace().rollback("Error creating table and
table pane");
throw new RuntimeException(t);
}
- DataEntryPanel editPanel = null;
+ DataEntryPanel editPanel = null;
playpen.selectNone();
tp.setSelected(true, SelectionEvent.SINGLE_SELECT);
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/EditRelationshipAction.java
Thu Mar 4 08:08:10 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/EditRelationshipAction.java
Thu Apr 22 12:03:52 2010
@@ -105,9 +105,8 @@
private void makeDialog(SQLRelationship sqr) {
logger.debug("making edit relationship dialog"); //$NON-NLS-1$
- RelationshipEditPanel editPanel = new
RelationshipEditPanel(session);
- editPanel.setRelationship(sqr);
-
+ Relationship r =
session.getPlayPen().getSelectedRelationShips().get(0);
+ RelationshipEditPanel editPanel = new RelationshipEditPanel(r);
ColumnMappingPanel mappingPanel = new ColumnMappingPanel(session,
sqr);
TabbedDataEntryPanel panel = new TabbedDataEntryPanel();
--
Subscription settings:
http://groups.google.com/group/architect-commits/subscribe?hl=en