Author: [email protected]
Date: Sat Jul 4 03:51:50 2009
New Revision: 3116
Modified:
trunk/src/ca/sqlpower/architect/swingui/action/ExportHTMLPanel.java
trunk/src/ca/sqlpower/architect/swingui/action/messages_de.properties
trunk/src/ca/sqlpower/architect/swingui/messages.properties
trunk/src/ca/sqlpower/architect/swingui/messages_de.properties
Log:
Implemented the suggestions from the code review
- Adjusted the german translation to the new wording in English
- Made enabling/disabling of the dropdown a bit more logical (ress
restrictive) especially when nothing has been selected so far
- made inner classes private
- put focus back to the dialog after showing JFileChooser
Modified:
trunk/src/ca/sqlpower/architect/swingui/action/ExportHTMLPanel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/action/ExportHTMLPanel.java
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/action/ExportHTMLPanel.java Sat
Jul 4 03:51:50 2009
@@ -189,8 +189,8 @@
/**
* Displays this selection panel to the user.
+ * The dialog is non-modal
*
- * @return true if the user clicked OK, false otherwise
*/
public void showDialog() {
@@ -234,6 +234,10 @@
return null;
}
+ /**
+ * Returns the filename of the (user-selected) output file.
+ *
+ */
public String getOutputFilename() {
return outputFile.getText();
}
@@ -249,27 +253,31 @@
} else if (e.getSource() == closeButton) {
closeDialog();
} else if (e.getSource() == xsltFile) {
- checkDropDown();
+ updateDropDownToolTip();
} else if (e.getSource() == builtin) {
- checkDropDown();
+ xsltFile.setEnabled(external.isSelected());
} else if (e.getSource() == external) {
- checkDropDown();
+ xsltFile.setEnabled(external.isSelected());
}
}
};
- private void checkDropDown() {
+ private void updateDropDownToolTip() {
File f = this.getXsltFile();
- if (f == null) {
- builtin.setSelected(true);
- xsltFile.setEnabled(false);
- } else {
- external.setSelected(true);
- xsltFile.setEnabled(true);
+ if (f != null) {
xsltFile.setToolTipText(getFullName(f));
}
}
+ private void setXsltFile(File xslt) {
+ ComboBoxFile cf = new ComboBoxFile(xslt);
+ external.setSelected(true);
+ xsltFile.setEnabled(true);
+ xsltFile.addItem(cf);
+ xsltFile.setSelectedItem(cf);
+ xsltFile.setToolTipText(getFullName(xslt));
+ }
+
private void syncDropDown() {
// if the user pasted the filename into the editable part
// of the dropdown, this will not be part of the actual
dropdown items
@@ -297,6 +305,8 @@
prefs.putBoolean(PREF_KEY_BUILTIN, builtin.isSelected());
prefs.put(PREF_KEY_OUTPUT, outputFile.getText());
+ // Add any pasted filename to the dropdown's model, so that it
+ // stored correctly in the user preferences
syncDropDown();
File f = getXsltFile();
@@ -326,8 +336,13 @@
final boolean useBuiltin = prefs.getBoolean(PREF_KEY_BUILTIN,
true);
builtin.setSelected(useBuiltin);
external.setSelected(!useBuiltin);
- EventQueue.invokeLater(new Runnable() {
+ xsltFile.setEnabled(!useBuiltin);
+ // I'm actively setting the focus, because by default the focus
is
+ // set to the "Internal" radio button. I think that initial
focus is
+ // a bit confusing when the "external" one is selected.
+
+ EventQueue.invokeLater(new Runnable() {
public void run() {
if (useBuiltin) {
builtin.requestFocusInWindow();
@@ -352,12 +367,14 @@
xsltFile.setSelectedItem(f);
}
outputFile.setText(prefs.get(PREF_KEY_OUTPUT, ""));
- checkDropDown();
}
public static String getFullName(File fo) {
if (fo == null) return null;
try {
+ // The canonical path is a bit more "user-friendly"
especially
+ // on Windows. But as it can throw an IOException
(why?) I need
+ // to wrap it here
return fo.getCanonicalPath();
} catch (IOException io) {
return fo.getAbsolutePath();
@@ -375,12 +392,8 @@
}
File file = chooser.getSelectedFile();
-
- ComboBoxFile cf = new ComboBoxFile(file);
- external.setSelected(true);
- xsltFile.setEnabled(true);
- xsltFile.addItem(cf);
- xsltFile.setSelectedItem(cf);
+ dialog.requestFocus();
+ setXsltFile(file);
}
private void closeDialog() {
@@ -412,7 +425,7 @@
} catch (IOException io) {
outputFile.setText(file.getAbsolutePath());
}
-
+ dialog.requestFocus();
}
/**
@@ -526,36 +539,49 @@
}
-}
-class ComboBoxFile
- extends File {
+ /**
+ * A class used for the items in the combobox.
+ * The only difference to the File class is, that the toString()
+ * method returns only the file name, not the full path.
+ * Otherwise the dropdown would be too wide.
+ *
+ * A better solution would be a dropdown that displays only the filename
+ * for the selected file, but shows the full names when it is opened.
+ * But unfortunately Swing cannot handle a dropdown where the popup is
wider
+ * than the actual component.
+ */
+ private class ComboBoxFile
+ extends File {
- public ComboBoxFile(File f) {
- super(f.getAbsolutePath());
- }
+ public ComboBoxFile(File f) {
+ super(f.getAbsolutePath());
+ }
- public ComboBoxFile(String pathname) {
- super(pathname);
- }
+ public ComboBoxFile(String pathname) {
+ super(pathname);
+ }
- public String toString() {
- return getName();
+ public String toString() {
+ return getName();
+ }
}
-}
-class ComboTooltipRenderer extends DefaultListCellRenderer {
+ private class ComboTooltipRenderer extends DefaultListCellRenderer {
- public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected,
- boolean cellHasFocus) {
+ public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected,
+ boolean cellHasFocus) {
- JComponent comp = (JComponent) super.getListCellRendererComponent(list,
value, index, isSelected,
- cellHasFocus);
+ JComponent comp = (JComponent) super.getListCellRendererComponent(list,
value, index, isSelected,
+ cellHasFocus);
- if (value instanceof File) {
-
comp.setToolTipText(ExportHTMLPanel.getFullName((File)value));
- } else {
- comp.setToolTipText(null);
+ if (value instanceof File) {
+
comp.setToolTipText(ExportHTMLPanel.getFullName((File)value));
+ } else {
+ comp.setToolTipText(null);
+ }
+ return comp;
}
- return comp;
}
}
+
+
Modified:
trunk/src/ca/sqlpower/architect/swingui/action/messages_de.properties
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/action/messages_de.properties
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/action/messages_de.properties
Sat Jul 4 03:51:50 2009
@@ -224,8 +224,8 @@
XSLTSelectionPanel.closeOption=Schliessen
XSLTSelectionPanel.saveAsTitle=HTML speichern unter
XSLTSelectionPanel.dialogTitle=HTML Report erstellen
-XSLTSelectionPanel.labelBuiltIn=Integrierte XSLT Transformation verwenden
-XSLTSelectionPanel.labelExternal=Eigene XSLT Transformation verwenden
+XSLTSelectionPanel.labelBuiltIn=Integrierten Report verwenden
+XSLTSelectionPanel.labelExternal=Eigenen Report verwenden (XSLT
Transformation)
XSLTSelectionPanel.labelOutput=Ausgabe in
XSLTSelectionPanel.labelTransformation=Transformation
XSLTSelectionPanel.fileAlreadyExists=Die Datei\n{0}\nexistiert bereits.
M\u00F6chten Sie die existierende Datei \u00FCberschreiben?
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 Sat Jul 4
03:51:50 2009
@@ -188,7 +188,7 @@
DefaultColumnPanel.remarks=Column Remarks By Default
DefaultColumnPanel.scale=Column Scale By Default
DefaultColumnPanel.type=Column Type By Default
-ExportHTMLReportAction.name=Export to HTML
+ExportHTMLReportAction.name=Export to HTML...
ExportHTMLReportAction.desc=Generates an HTML report of all the tables in
the playpen
ExportHTMLReportAction.fileAlreadyExists=The file\n{0}\nalready exists. Do
you want to overwrite it?
ExportHTMLReportAction.fileAlreadyExistsDialogTitle=File Exists
Modified: trunk/src/ca/sqlpower/architect/swingui/messages_de.properties
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/messages_de.properties
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/messages_de.properties Sat Jul
4 03:51:50 2009
@@ -186,6 +186,8 @@
DefaultColumnPanel.remarks=Standard Bemerkung f\u00FCr Spalten
DefaultColumnPanel.scale=Standard "Scale" f\u00FCr Spalten
DefaultColumnPanel.type=Standard Datentyp
+ExportHTMLReportAction.name=HTML Report erzeugen...
+ExportHTMLReportAction.desc=Errzeugt einen HTML Report aller Tabellen des
Playpen
ExportHTMLReportAction.fileAlreadyExists=Die Datei\n{0}\nexistiert
bereits. Soll die Datei \u00FCberschrieben werden?
ExportHTMLReportAction.fileAlreadyExistsDialogTitle=Datei vorhanden
IndexColumnTable.ascendingDescendingTableColumnName=Auf/Ab
@@ -399,5 +401,3 @@
WelcomeScreen.welcomeScreenTitle=Willkommen bei Power*Architect
DBTree.cannotAddConnectionType=Eine Datenquelle vom Type {0} kann nicht
hinzugef\u00FCgt werden
DBTree.cannotAddConnectionTypeTitle=Die Datenquelle konnte nicht
hinzugef\u00FCgt werden
-ExportHTMLReportAction.name=HTML Report erzeugen
-ExportHTMLReportAction.desc=Errzeugt einen HTML Report aller Tabellen des
Playpen