Revision: 3148
Author: jfuerth
Date: Thu Sep 3 15:07:19 2009
Log: Tweaked the horrid DDL warnings dialog to use a raw JDialog instead of
JOptionPane, because there is apparently a bug in JOptionPane on recent
(Windows?) JRE releases. The dialog was too small to use properly, and
wasn't
resizable.
As stated in a comment, this whole thing has to go. Fortunately, when
critics
are ready, we will be able to chuck it.
http://code.google.com/p/power-architect/source/detail?r=3148
Modified:
/trunk/src/ca/sqlpower/architect/swingui/action/ExportDDLAction.java
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/action/ExportDDLAction.java
Tue May 5 13:23:48 2009
+++ /trunk/src/ca/sqlpower/architect/swingui/action/ExportDDLAction.java
Thu Sep 3 15:07:19 2009
@@ -22,12 +22,15 @@
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
-
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
@@ -54,6 +57,9 @@
import ca.sqlpower.swingui.DataEntryPanelBuilder;
import ca.sqlpower.swingui.SPSwingWorker;
+import com.jgoodies.forms.builder.ButtonBarBuilder;
+import com.jgoodies.forms.factories.Borders;
+
public class ExportDDLAction extends AbstractArchitectAction {
private static final Logger logger =
Logger.getLogger(ExportDDLAction.class);
@@ -137,17 +143,39 @@
Messages.getString("ExportDDLAction.recheckOption") //$NON-NLS-1$
};
- int dialogChoice =
JOptionPane.showOptionDialog(
- frame,
- dialogPanel.getPanel(),
-
Messages.getString("ExportDDLAction.errorsInDDLDialogTitle"), //$NON-NLS-1$
- JOptionPane.DEFAULT_OPTION,
- JOptionPane.ERROR_MESSAGE,
- null, // JOptionPane gets icon
from owningComponent,
- options,
- options[options.length - 1]);
// blocking
- logger.debug(dialogChoice);
- switch (dialogChoice) {
+ // This used to be a JOptionPane, but a
resize bug made me change
+ // it to this. The whole thing is a
disaster and will go away when
+ // critics are ready.
+ final JDialog warningDialog = new
JDialog(frame, true);
+
warningDialog.setTitle(Messages.getString("ExportDDLAction.errorsInDDLDialogTitle"));
+
+ ButtonBarBuilder bbb = new
ButtonBarBuilder();
+ bbb.setDefaultButtonBarGapBorder();
+ final AtomicInteger dialogChoice = new
AtomicInteger(-1);
+ for (int i = 0; i < options.length; i++) {
+ final int ii = i;
+ JButton button = new
JButton(options[i]);
+ button.addActionListener(new
ActionListener() {
+ public void
actionPerformed(ActionEvent e) {
+ dialogChoice.set(ii);
+ warningDialog.dispose();
+ }
+ });
+ bbb.addGridded(button);
+ }
+
+ JPanel p = new JPanel(new BorderLayout());
+ p.add(dialogPanel.getPanel(),
BorderLayout.CENTER);
+ p.add(bbb.getPanel(), BorderLayout.SOUTH);
+ p.setBorder(Borders.DIALOG_BORDER);
+
+ warningDialog.setContentPane(p);
+ warningDialog.pack();
+ warningDialog.setLocationRelativeTo(d);
+ warningDialog.setVisible(true); // modal
dialog blocks
+
+ logger.debug(dialogChoice.get());
+ switch (dialogChoice.get()) {
case 0:
for (DDLWarning warning : warnings) {
if (warning.isQuickFixable()) {
@@ -159,7 +187,7 @@
done = true;
break;
case 2: // "Cancel"
- case -1: // Kill dialog
+ case -1: // no button was pressed--kill
dialog
return true;
case 3: // apply all changes made
for (DDLWarningComponent
warningComponent : warningComponents) {