Revision: 3620
Author: [email protected]
Date: Mon Jun 14 11:54:52 2010
Log: Changed the forward engineering dialog to allow for "offline" DDL generation. This means that the user does not need to have a valid target database to generate the DDL script. However, a valid target database is required to execute the script. Thus, the Execute button is disabled if this condition is not met.
http://code.google.com/p/power-architect/source/detail?r=3620

Modified:
 /trunk/src/main/java/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/DDLExportPanel.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/SQLScriptDialog.java
 /trunk/src/main/resources/ca/sqlpower/architect/swingui/messages.properties

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ddl/GenericDDLGenerator.java Tue May 18 11:21:10 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/ddl/GenericDDLGenerator.java Mon Jun 14 11:54:52 2010
@@ -219,7 +219,11 @@
                try {
                        if (allowConnection && tableList.size() > 0) {
SQLDatabase parentDb = SPObjectUtils.getAncestor(tableList.get(0), SQLDatabase.class);
-                               con = parentDb.getConnection();
+                if (parentDb.isPlayPenDatabase()) {
+                    con = null;
+                } else {
+                    con = parentDb.getConnection();
+                }
                        } else {
                                con = null;
                        }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/DDLExportPanel.java Mon Jun 14 09:32:54 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/DDLExportPanel.java Mon Jun 14 11:54:52 2010
@@ -18,6 +18,7 @@
  */
 package ca.sqlpower.architect.swingui;

+import java.awt.BorderLayout;
 import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -29,9 +30,9 @@
 import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JLabel;
-import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
+import javax.swing.SwingUtilities;

 import org.apache.log4j.Logger;

@@ -44,8 +45,6 @@
 import ca.sqlpower.sql.DatabaseListChangeListener;
 import ca.sqlpower.sql.JDBCDataSource;
 import ca.sqlpower.swingui.DataEntryPanel;
-import java.awt.BorderLayout;
-import javax.swing.SwingUtilities;


 public class DDLExportPanel implements DataEntryPanel {
@@ -271,18 +270,12 @@
                session.setLiquibaseSettings(lbOptions.getLiquibaseSettings());
                if (selectedGeneratorClass == GenericDDLGenerator.class) {
                        ddlg.setAllowConnection(true);
-                       JDBCDataSource dbcs = 
(JDBCDataSource)targetDB.getSelectedItem();
-                       if (dbcs == null
-                               || dbcs.getDriverClass() == null
-                               || dbcs.getDriverClass().length() == 0) {
-
-                               JOptionPane.showMessageDialog(panel,
- Messages.getString("DDLExportPanel.genericDdlGeneratorRequirements")); //$NON-NLS-1$
-
- ASUtils.showTargetDbcsDialog(session.getArchitectFrame(), session, targetDB);
-
-                               return false;
-                       }
+                       // Allow the DDLGenerator to generate scripts even 
though
+                       // there is no valid connection available. There may be 
situations
+                       // where the user wants to generate, see, and save the 
script
+                       // without needing to execute it. This removes the
+                       // restriction of requiring the user to work online.
+
                } else {
                        ddlg.setAllowConnection(false);
                }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/SQLScriptDialog.java Fri May 29 07:57:16 2009 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/SQLScriptDialog.java Mon Jun 14 11:54:52 2010
@@ -245,8 +245,14 @@
                pb.setDefaultDialogBorder();
                pb.add(new JLabel(header), cc.xy(2, 1));

-               if (targetDataSource != null) {
+               // Prevent the user from being able to execute the script if
+               // an invalid target database is selected.
+ if (targetDataSource != null && targetDataSource.get(JDBCDataSource.PL_UID) != null) { pb.add(new JLabel(Messages.getString("SQLScriptDialog.yourTargetDbIs")+ targetDataSource.getName() ), cc.xy(2, 3)); //$NON-NLS-1$
+                       executeButton.setEnabled(true);
+               } else {
+ pb.add(new JLabel(Messages.getString("SQLScriptDialog.yourTargetDbIsNotConfigured")), cc.xy(2, 3));
+                   executeButton.setEnabled(false);
                }
                pb.add(sp, cc.xy(2, 5));
                pb.add(barBuilder.getPanel(), cc.xy(2, 7, "c,c")); //$NON-NLS-1$
=======================================
--- /trunk/src/main/resources/ca/sqlpower/architect/swingui/messages.properties Tue Jun 8 13:39:34 2010 +++ /trunk/src/main/resources/ca/sqlpower/architect/swingui/messages.properties Mon Jun 14 11:54:52 2010
@@ -384,7 +384,8 @@
SQLScriptDialog.sqlStatementFailed=<html>A SQL statement in the script failed to execute.<br><br>Reason: <b>{0}</b>
 SQLScriptDialog.continuePrompt=Do you want to continue?
SQLScriptDialog.successfullyExecuted=Successfully executed {0} out of {1} statements.
-SQLScriptDialog.yourTargetDbIs=Your Target Database is
+SQLScriptDialog.yourTargetDbIs=Your Target Database is
+SQLScriptDialog.yourTargetDbIsNotConfigured=Your Target Database is not configured. SwingUIProject.cannotCreateOutputFile=Unable to create output file for save operation, data NOT saved.\n SwingUIProject.couldNotRenameFile=Could not rename current file to backup\nProject saved in {0}: {1} still contains old project SwingUIProject.couldNotRenameTempFile=Could not rename temp file to current\nProject saved in {0}: {1} still contains old project

Reply via email to