Revision: 3610
Author: [email protected]
Date: Fri Jun 11 14:23:35 2010
Log: Changed SQLColumn to implement SPVariableResolverProvider, so that
variables within the check constraint can be resolved by the
CheckConstraintVariableResolver. The TypePhysicalPropertiesEditorPanel
allows insertion of these variables in its check constraint text field.
These variables will only be resolved when generating DDL scripts.
As well, UI functionality with check constraints and enumerations have been
added. DDL generation has yet to be added to accommodate for this change.
Additionally, fixed several bugs with domains and types; in particular with
precision and scale.
http://code.google.com/p/power-architect/source/detail?r=3610
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/SQLTypeTreePopupAction.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
Thu May 27 14:27:01 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ColumnEditPanel.java
Fri Jun 11 14:23:35 2010
@@ -186,6 +186,10 @@
private final JComboBox colAutoInc;
+ private final JCheckBox colPrecCB;
+
+ private final JCheckBox colScaleCB;
+
/**
* Text field for the name of the sequence that will generate this
column's
* default values. In multi-edit mode, this component will be null.
@@ -362,7 +366,7 @@
panel.add(colPrec = createPrecisionEditor(), cc.xy(3, row));
colPrec.addChangeListener(checkboxEnabler);
SPSUtils.makeJSpinnerSelectAllTextOnFocus(colPrec);
- final JCheckBox colPrecCB = new JCheckBox();
+ colPrecCB = new JCheckBox();
panel.add(colPrecCB, cc.xy(2, row));
typeOverrideMap.put(colPrec, colPrecCB);
colPrecCB.addChangeListener(new ChangeListener() {
@@ -381,7 +385,7 @@
});
colPrec.setEnabled(false);
- final JCheckBox colScaleCB = new JCheckBox();
+ colScaleCB = new JCheckBox();
panel.add(colScaleCB, cc.xy(5, row));
panel.add(colScale = createScaleEditor(), cc.xy(6, row++));
typeOverrideMap.put(colScale, colScaleCB);
@@ -836,8 +840,7 @@
column.getUserDefinedSQLType().setUpstreamType(upstreamType);
// Set scale
- if (column.getScaleType() == PropertyType.CONSTANT
- || typeOverrideMap.get(colScale).isSelected())
{
+ if (typeOverrideMap.get(colScale).isSelected()) {
column.setScale(((Integer)
colScale.getValue()).intValue());
} else {
column.getUserDefinedSQLType().setScale(
@@ -846,8 +849,7 @@
}
// Set precision
- if (column.getPrecisionType() == PropertyType.CONSTANT
- || typeOverrideMap.get(colPrec).isSelected()) {
+ if (typeOverrideMap.get(colPrec).isSelected()) {
column.setPrecision(((Integer)
colPrec.getValue()).intValue());
} else {
column.getUserDefinedSQLType().setPrecision(
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/SQLTypeTreePopupAction.java
Fri May 14 11:58:04 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/SQLTypeTreePopupAction.java
Fri Jun 11 14:23:35 2010
@@ -21,6 +21,9 @@
import java.awt.Point;
import java.awt.event.ActionEvent;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import javax.swing.AbstractAction;
import javax.swing.Action;
@@ -47,6 +50,25 @@
private final JTree colType;
private final JButton typeChooserButton;
private PopupListenerHandler popupListenerHandler;
+
+ private final TreeSelectionListener treeListener = new
TreeSelectionListener() {
+ public void valueChanged(TreeSelectionEvent e) {
+ TreePath path = e.getNewLeadSelectionPath();
+ if (path != null) {
+ Object node = path.getLastPathComponent();
+ if (node instanceof UserDefinedSQLType) {
+ popupCleanup();
+ }
+ }
+ }
+ };
+
+ private final FocusListener focusListener = new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ popupCleanup();
+ }
+ };
/**
* Creates a new {...@link SQLTypeTreePopupAction} given the {...@link
JPanel} the
@@ -76,7 +98,7 @@
*/
public void actionPerformed(ActionEvent e) {
if (popupListenerHandler != null &&
popupListenerHandler.isPopupVisible()) {
- popupListenerHandler.cleanup();
+ popupCleanup();
} else {
Point windowLocation = new Point(0, 0);
SwingUtilities.convertPointToScreen(windowLocation,
typeChooserButton);
@@ -86,16 +108,27 @@
// popup listener handler to the tree
popupListenerHandler =
SPSUtils.popupComponent(panel, colType, windowLocation);
+ popupConnect();
+ }
+ }
+
+ private void popupConnect() {
+ if (popupListenerHandler != null) {
popupListenerHandler.connect();
- colType.addTreeSelectionListener(new TreeSelectionListener() {
- public void valueChanged(TreeSelectionEvent e) {
- TreePath path = e.getNewLeadSelectionPath();
- Object node = path.getLastPathComponent();
- if (node instanceof UserDefinedSQLType) {
- popupListenerHandler.cleanup();
- }
- }
- });
+ }
+ if (colType != null) {
+ colType.addTreeSelectionListener(treeListener);
+ colType.addFocusListener(focusListener);
+ }
+ }
+
+ private void popupCleanup() {
+ if (popupListenerHandler != null &&
popupListenerHandler.isPopupVisible()) {
+ popupListenerHandler.cleanup();
+ }
+ if (colType != null) {
+ colType.removeTreeSelectionListener(treeListener);
+ colType.removeFocusListener(focusListener);
}
}