Author: daceywang
Date: Fri Apr 3 15:23:00 2009
New Revision: 2973
Modified:
trunk/regress/ca/sqlpower/architect/swingui/TestColumnEditPanel.java
trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java
trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java
trunk/src/ca/sqlpower/architect/swingui/TableEditPanel.java
trunk/src/ca/sqlpower/architect/swingui/messages.properties
Log:
Used name of SQLObject as the field for logical name instead of creating a
new variable logicalName. Modified test cases and editing panels for tables
and columns. This is still in its initial stage and so now it won't work
for forward and reverse engineering.
Modified:
trunk/regress/ca/sqlpower/architect/swingui/TestColumnEditPanel.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/swingui/TestColumnEditPanel.java
(original)
+++ trunk/regress/ca/sqlpower/architect/swingui/TestColumnEditPanel.java
Fri Apr 3 15:23:00 2009
@@ -50,6 +50,7 @@
col3 = new SQLColumn(null,"Column 3",1,2,3);
col4 = new SQLColumn(null,"Column 4",1,2,3);
+ col2.setPhysicalName("Physical Name 2");
col2.setAutoIncrement(false);
col2.setNullable(DatabaseMetaData.columnNoNulls);
col2.setPrimaryKeySeq(0);
@@ -81,7 +82,7 @@
panel = new ColumnEditPanel(col3, session);
- assertEquals("Wrong column technical
name",col3.getName(),panel.getColPhysicalName().getText());
+ assertEquals("Wrong column logical
name",col3.getName(),panel.getColLogicalName().getText());
assertEquals("Wrong Precision",col3.getPrecision(),((Integer)
(panel.getColPrec().getValue())).intValue());
assertEquals("Wrong
type",col3.getType(),((SQLType)(panel.getColType().getSelectedItem())).getType());
assertEquals("Wrong Scale",col3.getScale(),((Integer)
(panel.getColScale().getValue())).intValue());
@@ -92,7 +93,7 @@
panel = new ColumnEditPanel(col2, session);
- assertEquals("Wrong column technical
name",col2.getName(),panel.getColPhysicalName().getText());
+ assertEquals("Wrong column logical
name",col2.getName(),panel.getColLogicalName().getText());
assertEquals("Wrong Precision",col2.getPrecision(),((Integer)
(panel.getColPrec().getValue())).intValue());
assertEquals("Wrong
type",col2.getType(),((SQLType)(panel.getColType().getSelectedItem())).getType());
assertEquals("Wrong Scale",col2.getScale(),((Integer)
(panel.getColScale().getValue())).intValue());
@@ -117,8 +118,8 @@
panel.applyChanges();
assertEquals("Panel check boxes
borked",true,panel.getColAutoInc().getModel().isSelected());
- assertEquals("Wrong column technical
name","CHANGED",col2.getName());
- assertEquals("Wrong column alias name","Easier Use Column
Name",col2.getLogicalName());
+ assertEquals("Wrong column physical
name","CHANGED",col2.getPhysicalName());
+ assertEquals("Wrong column logical name","Easier Use Column
Name",col2.getName());
assertEquals("Wrong Precision",1234,col2.getPrecision());
assertEquals("Wrong type",16,col2.getType());
assertEquals("Wrong Scale",5432,col2.getScale());
@@ -138,8 +139,8 @@
panel.getColNullable().getModel().setSelected(true);
panel.discardChanges();
- assertEquals("Wrong column technical name","Column
2",col2.getName());
- assertEquals("Wrong column alias
name","",col2.getLogicalName());
+ assertEquals("Wrong column physical name","Physical Name
2",col2.getPhysicalName());
+ assertEquals("Wrong column logical name","Column
2",col2.getName());
assertEquals("Wrong Precision",3,col2.getPrecision());
assertEquals("Wrong type",2,col2.getType());
assertEquals("Wrong Scale",4,col2.getScale());
Modified: trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java Fri Apr 3
15:23:00 2009
@@ -106,9 +106,9 @@
*/
private final JLabel sourceLabel;
- private final JTextField colPhysicalName;
-
private final JTextField colLogicalName;
+
+ private final JTextField colPhysicalName;
private final JComboBox colType;
@@ -186,27 +186,27 @@
row++;
layout.appendRow(RowSpec.decode("p"));
-
panel.add(makeTitle(Messages.getString("ColumnEditPanel.physicalName")),
cc.xyw(2, row++, 4)); //$NON-NLS-1$
+
panel.add(makeTitle(Messages.getString("ColumnEditPanel.logicalName")),
cc.xyw(2, row++, 4)); //$NON-NLS-1$
layout.appendRow(RowSpec.decode("p"));
cb = new JCheckBox();
if (cols.size() > 1) {
panel.add(cb, cc.xy(1, row));
}
- panel.add(colPhysicalName = new JTextField(), cc.xyw(2, row++, 4));
- componentEnabledMap.put(colPhysicalName, cb);
- colPhysicalName.getDocument().addDocumentListener(new
DocumentCheckboxEnabler(cb));
- colPhysicalName.addComponentListener(new ComponentAdapter() {
+ panel.add(colLogicalName = new JTextField(), cc.xyw(2, row++, 4));
+ componentEnabledMap.put(colLogicalName, cb);
+ colLogicalName.getDocument().addDocumentListener(new
DocumentCheckboxEnabler(cb));
+ colLogicalName.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
- colPhysicalName.requestFocusInWindow();
+ colLogicalName.requestFocusInWindow();
}
});
- colPhysicalName.addFocusListener(new FocusAdapter() {
+ colLogicalName.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
if(logger.isDebugEnabled()) {
logger.debug("focus Gained : " + e);
}
- colPhysicalName.selectAll();
+ colLogicalName.selectAll();
}
});
@@ -214,27 +214,27 @@
row++;
layout.appendRow(RowSpec.decode("p"));
-
panel.add(makeTitle(Messages.getString("ColumnEditPanel.logicalName")),
cc.xyw(2, row++, 4)); //$NON-NLS-1$
+
panel.add(makeTitle(Messages.getString("ColumnEditPanel.physicalName")),
cc.xyw(2, row++, 4)); //$NON-NLS-1$
layout.appendRow(RowSpec.decode("p"));
cb = new JCheckBox();
if (cols.size() > 1) {
panel.add(cb, cc.xy(1, row));
}
- panel.add(colLogicalName = new JTextField(), cc.xyw(2, row++, 4));
- componentEnabledMap.put(colLogicalName, cb);
- colLogicalName.getDocument().addDocumentListener(new
DocumentCheckboxEnabler(cb));
- colLogicalName.addComponentListener(new ComponentAdapter() {
+ panel.add(colPhysicalName = new JTextField(), cc.xyw(2, row++, 4));
+ componentEnabledMap.put(colPhysicalName, cb);
+ colPhysicalName.getDocument().addDocumentListener(new
DocumentCheckboxEnabler(cb));
+ colPhysicalName.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
- colLogicalName.requestFocusInWindow();
+ colPhysicalName.requestFocusInWindow();
}
});
- colLogicalName.addFocusListener(new FocusAdapter() {
+ colPhysicalName.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
if(logger.isDebugEnabled()) {
logger.debug("focus Gained : " + e);
}
- colLogicalName.selectAll();
+ colPhysicalName.selectAll();
}
});
@@ -455,8 +455,8 @@
sourceColumn.getParentTable()) + "." +
sourceColumn.getName());
}
- updateComponent(colPhysicalName, col.getName());
- updateComponent(colLogicalName, col.getLogicalName());
+ updateComponent(colLogicalName, col.getName());
+ updateComponent(colPhysicalName, col.getPhysicalName());
updateComponent(colType, SQLType.getType(col.getType()));
updateComponent(colScale, Integer.valueOf(col.getScale()));
@@ -606,15 +606,15 @@
compoundEditRoot.startCompoundEdit(Messages.getString("ColumnEditPanel.compoundEditName"));
//$NON-NLS-1$
for (SQLColumn column : columns) {
- if (componentEnabledMap.get(colPhysicalName).isSelected())
{
- if (colPhysicalName.getText().trim().length() == 0) {
+ if (componentEnabledMap.get(colLogicalName).isSelected()) {
+ if (colLogicalName.getText().trim().length() == 0) {
errors.add(Messages.getString("ColumnEditPanel.columnNameRequired"));
//$NON-NLS-1$
} else {
- column.setName(colPhysicalName.getText());
+ column.setName(colLogicalName.getText());
}
}
- if (componentEnabledMap.get(colLogicalName).isSelected()) {
- column.setLogicalName(colLogicalName.getText());
+ if (componentEnabledMap.get(colPhysicalName).isSelected())
{
+ column.setPhysicalName(colPhysicalName.getText());
}
if (componentEnabledMap.get(colType).isSelected()) {
column.setType(((SQLType)
colType.getSelectedItem()).getType());
Modified: trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java Fri Apr 3
15:23:00 2009
@@ -1222,7 +1222,6 @@
if (sourceCol != null) {
propNames.put("source-column-ref",
sqlObjectSaveIdMap.get(sourceCol)); //$NON-NLS-1$
}
- propNames.put("logicalName", ((SQLColumn)
o).getLogicalName()); //$NON-NLS-1$
propNames.put("type", new Integer(((SQLColumn) o).getType()));
//$NON-NLS-1$
propNames.put("sourceDataTypeName", ((SQLColumn)
o).getSourceDataTypeName()); //$NON-NLS-1$
propNames.put("scale", new Integer(((SQLColumn)
o).getScale())); //$NON-NLS-1$
Modified: trunk/src/ca/sqlpower/architect/swingui/TableEditPanel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/TableEditPanel.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/TableEditPanel.java Fri Apr 3
15:23:00 2009
@@ -52,8 +52,8 @@
*/
private JDialog editDialog;
protected SQLTable table;
- JTextField technicalName;
- JTextField aliasName;
+ JTextField logicalName;
+ JTextField physicalName;
JTextField pkName;
JTextArea remarks;
private JComboBox bgColor;
@@ -68,10 +68,10 @@
super(new FormLayout());
this.session = session;
this.tp = session.getPlayPen().findTablePane(t);
- add(new
JLabel(Messages.getString("TableEditPanel.tableTechnicalNameLabel")));
//$NON-NLS-1$
- add(technicalName = new JTextField("", 30)); //$NON-NLS-1$
- add(new
JLabel(Messages.getString("TableEditPanel.tableAliasNameLabel")));
//$NON-NLS-1$
- add(aliasName = new JTextField("", 30)); //$NON-NLS-1$
+ add(new JLabel(Messages.getString("TableEditPanel.tableLogicalName")));
//$NON-NLS-1$
+ add(logicalName = new JTextField("", 30)); //$NON-NLS-1$
+ add(new
JLabel(Messages.getString("TableEditPanel.tablePhysicalName")));
//$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$
@@ -102,7 +102,8 @@
private void editTable(SQLTable t) {
table = t;
- technicalName.setText(t.getName());
+ logicalName.setText(t.getName());
+ physicalName.setText(t.getPhysicalName());
try {
if (t.getPrimaryKeyIndex() == null) {
pkName.setEnabled(false);
@@ -115,7 +116,7 @@
throw new SQLObjectRuntimeException(e);
}
remarks.setText(t.getRemarks());
- technicalName.selectAll();
+ logicalName.selectAll();
if (tp != null) {
bgColor.setSelectedItem(tp.getBackgroundColor());
@@ -137,7 +138,7 @@
StringBuffer warnings = new StringBuffer();
//We need to check if the table name and/or primary key name
is empty or not
//if they are, we need to warn the user since it will mess up
the SQLScripts we create
- if (technicalName.getText().trim().length() == 0) {
+ if (logicalName.getText().trim().length() == 0) {
warnings.append(Messages.getString("TableEditPanel.blankTableNameWarning"));
//$NON-NLS-1$
}
@@ -159,7 +160,8 @@
table.getPrimaryKeyIndex().setName(pkName.getText());
}
- table.setName(technicalName.getText());
+ table.setName(logicalName.getText());
+ table.setPhysicalName(physicalName.getText());
table.setRemarks(remarks.getText());
if (tp != null) {
@@ -202,11 +204,11 @@
}
public String getNameText() {
- return technicalName.getText();
+ return logicalName.getText();
}
public void setNameText(String newName) {
- technicalName.setText(newName);
+ logicalName.setText(newName);
}
public String getPkNameText() {
Modified: trunk/src/ca/sqlpower/architect/swingui/messages.properties
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/messages.properties (original)
+++ trunk/src/ca/sqlpower/architect/swingui/messages.properties Fri Apr 3
15:23:00 2009
@@ -370,8 +370,8 @@
TableEditPanel.remarksLabel=Remarks
TableEditPanel.roundedCornersLabel=Rounded Corners
TableEditPanel.tableColourLabel=Table Colour
-TableEditPanel.tableTechnicalNameLabel=Technical Table Name
-TableEditPanel.tableAliasNameLabel= Alias Table Name
+TableEditPanel.tablePhysicalName=Physical Name
+TableEditPanel.tableLogicalName= Logical Name
TableEditPanel.textColourLabel=Text Colour
TablePane.alignTablesMenu=Align Tables
TablePane.editIndexTooltip=Edit Index