Revision: 3636
Author: [email protected]
Date: Thu Jun 24 12:17:51 2010
Log: Cleaned up the profile result viewer to use a FancyExportableJTable with the column view to make exporting easier.

Also updated the buttons with saving so you only see save buttons that relate to the screen you are on. The save buttons on the table view have been split to make exporting to PDF more visible as it was a previously somewhat hidden feature.
http://code.google.com/p/power-architect/source/detail?r=3636

Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/ProfileResultsViewer.java /trunk/src/main/java/ca/sqlpower/architect/swingui/action/SaveProfileAction.java /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages.properties /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_de.properties /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_ko.properties /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_pt.properties /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_ru.properties
 /trunk/src/main/resources/ca/sqlpower/architect/swingui/messages.properties

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ProfileResultsViewer.java Tue Jun 22 15:19:40 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ProfileResultsViewer.java Thu Jun 24 12:17:51 2010
@@ -22,7 +22,6 @@
 import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.WindowAdapter;
@@ -31,6 +30,8 @@
 import java.util.Collection;
 import java.util.List;

+import javax.swing.AbstractAction;
+import javax.swing.Action;
 import javax.swing.JButton;
 import javax.swing.JDialog;
 import javax.swing.JFrame;
@@ -52,18 +53,21 @@
 import ca.sqlpower.architect.profile.event.ProfileChangeEvent;
 import ca.sqlpower.architect.profile.event.ProfileChangeListener;
 import ca.sqlpower.architect.profile.output.ProfileColumn;
+import ca.sqlpower.architect.swingui.Messages;
 import ca.sqlpower.architect.swingui.action.SaveProfileAction;
 import ca.sqlpower.architect.swingui.table.MultiFreqValueCountTableModel;
 import ca.sqlpower.architect.swingui.table.ProfileJTable;
 import ca.sqlpower.architect.swingui.table.ProfileTableModel;
 import ca.sqlpower.sqlobject.SQLColumn;
 import ca.sqlpower.swingui.SPSUtils;
+import ca.sqlpower.swingui.table.FancyExportableJTable;
 import ca.sqlpower.swingui.table.TableModelColumnAutofit;
 import ca.sqlpower.swingui.table.TableModelSearchDecorator;
 import ca.sqlpower.swingui.table.TableModelSortDecorator;
-import ca.sqlpower.swingui.table.TableTextConverter;
 import ca.sqlpower.swingui.table.TableUtils;

+import com.jgoodies.forms.builder.ButtonBarBuilder;
+
 /**
  * A class that manages a viewer component for a set of Profile Results.
  */
@@ -171,6 +175,15 @@
         }
     }

+    /**
+     * The standard close action for this viewer.
+     */
+    private final Action closeAction = new AbstractAction(
+            Messages.getString("ProfileResultsViewer.closeButton")) {
+        public void actionPerformed(ActionEvent e) {
+            frame.dispose();
+        }
+    };

     /**
      * Creates but does not show a new profile result viewer dialog.
@@ -222,11 +235,17 @@
         editorScrollPane.setPreferredSize(new Dimension(800, 600));
         editorScrollPane.setMinimumSize(new Dimension(10, 10));

+        JPanel profilePanel = new JPanel(new BorderLayout());
         ProfilePanel p = new ProfilePanel(tm);
         p.setViewTable(viewTable);
         p.setTabPane(tabPane);
         p.setTableModel(tm);
- tabPane.addTab(Messages.getString("ProfileResultsViewer.graphViewTab"),p); //$NON-NLS-1$
+        profilePanel.add(p, BorderLayout.CENTER);
+        ButtonBarBuilder profileButtons = new ButtonBarBuilder();
+        profileButtons.addGlue();
+        profileButtons.addFixed(new JButton(closeAction));
+        profilePanel.add(profileButtons.getPanel(), BorderLayout.SOUTH);
+ tabPane.addTab(Messages.getString("ProfileResultsViewer.graphViewTab"), profilePanel); //$NON-NLS-1$

         JPanel tableViewPane = new JPanel(new BorderLayout());

@@ -239,42 +258,47 @@
         searchPanel.add(searchLabel);
         searchPanel.add(searchField);
         tableViewPane.add(searchPanel,BorderLayout.NORTH);
+        ButtonBarBuilder tableButtons = new ButtonBarBuilder();
+        tableButtons.addGlue();
+        tableButtons.addFixed(new JButton(new SaveProfileAction(frame,
+ Messages.getString("ProfileResultsViewer.PDFExport"), viewTable,
+                SaveProfileAction.SaveableFileType.PDF)));
+        tableButtons.addFixed(new JButton(new SaveProfileAction(frame,
+ Messages.getString("ProfileResultsViewer.CSVExport"), viewTable,
+                SaveProfileAction.SaveableFileType.CSV)));
+        tableButtons.addFixed(new JButton(new SaveProfileAction(frame,
+ Messages.getString("ProfileResultsViewer.HTMLExport"), viewTable,
+                SaveProfileAction.SaveableFileType.HTML)));
+        tableButtons.addFixed(new JButton(closeAction));
+        tableViewPane.add(tableButtons.getPanel(), BorderLayout.SOUTH);
tabPane.addTab(Messages.getString("ProfileResultsViewer.tableViewTab"), tableViewPane ); //$NON-NLS-1$

final MultiFreqValueCountTableModel columnTableModel = new MultiFreqValueCountTableModel(tm);
-
-        //Setup a search and sort decorator on the table
-        TableModelSearchDecorator columnSearchDecorator =
-            new TableModelSearchDecorator(columnTableModel);
-        final TableModelSortDecorator columnTableModelSortDecorator =
-            new TableModelSortDecorator(columnSearchDecorator);
- final JTable columnTable = new JTable(columnTableModelSortDecorator); - columnSearchDecorator.setTableTextConverter(new TableTextConverter() {
-            public int modelIndex(int viewIndex) {
-                return columnTableModelSortDecorator.modelIndex(viewIndex);
-            }
-
-            public String getTextForCell(int row, int col) {
- // note: this will only work because we know all the renderers are jlabels - JLabel renderer = (JLabel) columnTable.getCellRenderer(row, col). - getTableCellRendererComponent(columnTable, columnTable.getModel().getValueAt(row, - columnTable.getColumnModel().getColumn(col).getModelIndex()),
-                        false, false, row, col);
-                return renderer.getText();
-            }
-        });
- columnTableModelSortDecorator.setTableHeader(columnTable.getTableHeader());
+
+        JTextField columnSearchField = new JTextField("",25); //$NON-NLS-1$
+ FancyExportableJTable columnTable = new FancyExportableJTable(columnTableModel, columnSearchField.getDocument());

         for (int i = 0; i < columnTableModel.getColumnCount(); i++) {
columnTable.getColumnModel().getColumn(i).setCellRenderer(columnTableModel.getCellRenderer(i));
         }
         JPanel columnViewerPanel = new JPanel(new BorderLayout());
columnViewerPanel.add(new JScrollPane(columnTable), BorderLayout.CENTER);
+
JPanel columnSearchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); columnSearchPanel.add(new JLabel(Messages.getString("ProfileResultsViewer.search"))); //$NON-NLS-1$ - JTextField columnSearchField = new JTextField(columnSearchDecorator.getDoc(),"",25); //$NON-NLS-1$
         columnSearchPanel.add(columnSearchField);
         columnViewerPanel.add(columnSearchPanel, BorderLayout.NORTH);
+
+        ButtonBarBuilder columnButtonBar = new ButtonBarBuilder();
+        columnButtonBar.addGlue();
+ final JButton csvExportButton = new JButton(columnTable.getExportCSVAction()); + csvExportButton.setText(Messages.getString("ProfileResultsViewer.CSVExport"));
+        columnButtonBar.addFixed(csvExportButton);
+ final JButton htmlExportButton = new JButton(columnTable.getExportHTMLAction()); + htmlExportButton.setText(Messages.getString("ProfileResultsViewer.HTMLExport"));
+        columnButtonBar.addFixed(htmlExportButton);
+        columnButtonBar.addFixed(new JButton(closeAction));
+ columnViewerPanel.add(columnButtonBar.getPanel(), BorderLayout.SOUTH); tabPane.addTab(Messages.getString("ProfileResultsViewer.columnViewTab"),
                 columnViewerPanel);

@@ -290,19 +314,7 @@

         frame.add(tabPane, BorderLayout.CENTER);

-        JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
-        JButton save = new JButton(
-                new SaveProfileAction(frame, viewTable));
-        bottomPanel.add(save);
- JButton closeButton = new JButton(Messages.getString("ProfileResultsViewer.closeButton")); //$NON-NLS-1$
-        bottomPanel.add(closeButton);
-        frame.add(bottomPanel,BorderLayout.SOUTH);
         frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
-        closeButton.addActionListener(new ActionListener() {
-            public void actionPerformed(ActionEvent e) {
-                frame.dispose();
-            }
-        });
         frame.pack();
         frame.setLocationRelativeTo(null);
         SPSUtils.makeJDialogCancellable(frame, null);
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/action/SaveProfileAction.java Wed Jun 25 14:00:16 2008 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/action/SaveProfileAction.java Thu Jun 24 12:17:51 2010
@@ -81,7 +81,24 @@
     }

     /** The set of valid file types for saving the report in */
-    private enum SaveableFileType { HTML, PDF, CSV }
+    public enum SaveableFileType {
+        HTML(SPSUtils.HTML_FILE_FILTER),
+        PDF(SPSUtils.PDF_FILE_FILTER),
+        CSV(SPSUtils.CSV_FILE_FILTER);
+
+        /**
+         * A file filter that matches the type in the enum.
+         */
+        private final FileFilter filter;
+
+        private SaveableFileType(FileFilter filter) {
+            this.filter = filter;
+        }
+
+        public FileFilter getFilter() {
+            return filter;
+        }
+    }

     /**
* The component whose window ancestor will own dialogs created by this action.
@@ -90,6 +107,13 @@

     private ProfileJTable viewTable;

+    /**
+     * These file types are the available types for exporting to for this
+     * action. The file types will be available to be selected in the file
+     * chooser dialog.
+     */
+    private final SaveableFileType[] fileTypes;
+
     /**
* Creates a new action which will, when invoked, offer to save profile results
      * in one of several deluxe file formats.
@@ -98,10 +122,11 @@
* @param viewTable The (eww) jtable which contains the profile results to be exported. * XXX this should be a collection of TableProfileResult objects, not a view component that houses them
      */
- public SaveProfileAction(Component dialogOwner, ProfileJTable viewTable) {
-        super(Messages.getString("SaveProfileAction.name")); //$NON-NLS-1$
+ public SaveProfileAction(Component dialogOwner, String name, ProfileJTable viewTable, SaveableFileType ... fileTypes) {
+        super(name); //$NON-NLS-1$
         this.dialogOwner = dialogOwner;
         this.viewTable = viewTable;
+        this.fileTypes = fileTypes;
     }


@@ -167,10 +192,10 @@

         JFileChooser chooser = new JFileChooser();

-        chooser.addChoosableFileFilter(SPSUtils.HTML_FILE_FILTER);
-        chooser.addChoosableFileFilter(SPSUtils.PDF_FILE_FILTER);
-        chooser.addChoosableFileFilter(SPSUtils.CSV_FILE_FILTER);
chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter());
+        for (SaveableFileType type : fileTypes) {
+            chooser.addChoosableFileFilter(type.getFilter());
+        }

         File file = null;
         SaveableFileType type;
=======================================
--- /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages.properties Fri Mar 26 14:32:44 2010 +++ /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages.properties Thu Jun 24 12:17:51 2010
@@ -183,7 +183,6 @@
 SaveProfileAction.couldNotSaveReport=Could not generate/save report file
SaveProfileAction.fileAlreadyExists=The file\n{0}\nalready exists. Do you want to overwrite it?
 SaveProfileAction.fileAlreadyExistsDialogTitle=File Exists
-SaveProfileAction.name=Save...
 SaveProfileAction.saveEntireTableOption=Save Entire Table
SaveProfileAction.saveOnlySelectedPortion=You have selected only part of a table.\nDo you want to save only this portion? SaveProfileAction.saveOnlySelectedPortionDialogTitle=Your selection contains partial table(s)
=======================================
--- /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_de.properties Fri Mar 26 14:32:44 2010 +++ /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_de.properties Thu Jun 24 12:17:51 2010
@@ -186,7 +186,6 @@
SaveProfileAction.couldNotSaveReport=Die Report-Datei konnte nicht angelegt werden SaveProfileAction.fileAlreadyExists=Die Datei\n{0}\nexistiert bereits. M\u00F6chte Sie die existierende Datei \u00FCberschreiben?
 SaveProfileAction.fileAlreadyExistsDialogTitle=Datei vorhanden
-SaveProfileAction.name=Speichern...
 SaveProfileAction.saveEntireTableOption=Tabelle speichern
SaveProfileAction.saveOnlySelectedPortion=Sie haben nur einen Teil der Tabellendaten markiert.\nM\u00F6chten Sie nur diesen Teil speichern? SaveProfileAction.saveOnlySelectedPortionDialogTitle=Ihre Markierung enth\u00E4lt unvollst\u00E4ndige Tabellen
=======================================
--- /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_ko.properties Fri Mar 26 14:32:44 2010 +++ /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_ko.properties Thu Jun 24 12:17:51 2010
@@ -183,7 +183,6 @@
SaveProfileAction.couldNotSaveReport=\ub9ac\ud3ec\ud2b8 \ud30c\uc77c\uc744 \uc0dd\uc131/\uc800\uc7a5\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4 SaveProfileAction.fileAlreadyExists=\ud30c\uc77c\n{0}\n\uac00 \uc774\ubbf8 \uc874\uc7ac\ud569\ub2c8\ub2e4. \uacb9\uccd0\uc4f0\uc2dc\uaca0\uc2b5\ub2c8\uae4c? SaveProfileAction.fileAlreadyExistsDialogTitle=\ud30c\uc77c\uc774 \uc874\uc7ac\ud569\ub2c8\ub2e4
-SaveProfileAction.name=\uc800\uc7a5...
SaveProfileAction.saveEntireTableOption=\uc804\uccb4 \ud14c\uc774\ube14 \uc800\uc7a5 SaveProfileAction.saveOnlySelectedPortion=\ud14c\uc774\ube14\uc758 \uc77c\ubd80\ub9cc \uc120\ud0dd\ud558\uc600\uc2b5\ub2c8\ub2e4.\n\ubd80\ubd84\ub9cc \uc800\uc7a5\ud558\uc2dc\uaca0\uc2b5\ub2c8\uae4c? SaveProfileAction.saveOnlySelectedPortionDialogTitle=\uc77c\ubd80 \ud14c\uc774\ube14\ub9cc \uc120\ud0dd\uc5d0 \ud3ec\ud568\ub418\uc5c8\uc2b5\ub2c8\ub2e4.
=======================================
--- /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_pt.properties Fri Mar 26 14:32:44 2010 +++ /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_pt.properties Thu Jun 24 12:17:51 2010
@@ -183,7 +183,6 @@
SaveProfileAction.couldNotSaveReport=N\u00e3o foi poss\u00edvel gerar/salvar o arquivo de relat\u00f3rio SaveProfileAction.fileAlreadyExists=O arquivo\n{0}\nj\u00e1 existe. Gostaria de sobrescrev\u00ea-lo?
 SaveProfileAction.fileAlreadyExistsDialogTitle=Arquivo existe
-SaveProfileAction.name=Salvar...
 SaveProfileAction.saveEntireTableOption=Salvar toda a tabela
SaveProfileAction.saveOnlySelectedPortion=Voc\u00ea selecionou a tabela parcialmente.\nGostaria de salvar apenas esta por\u00e7\u00e3o? SaveProfileAction.saveOnlySelectedPortionDialogTitle=Sua sele\u00e7\u00e3o possui tabela(s) parcial(is)
=======================================
--- /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_ru.properties Fri Mar 26 14:32:44 2010 +++ /trunk/src/main/resources/ca/sqlpower/architect/swingui/action/messages_ru.properties Thu Jun 24 12:17:51 2010
@@ -182,7 +182,6 @@
SaveProfileAction.couldNotSaveReport=\u041d\u0435 \u0441\u043c\u043e\u0433 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c/\u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0442\u0447\u0435\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. SaveProfileAction.fileAlreadyExists=\u0424\u0430\u0439\u043b \n{0}\n \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0435\u0433\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c? SaveProfileAction.fileAlreadyExistsDialogTitle= \u0424\u0430\u0439\u043b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.
-SaveProfileAction.name=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c...
SaveProfileAction.saveEntireTableOption= \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u044e \u0422\u0430\u0431\u043b\u0438\u0446\u0443. SaveProfileAction.saveOnlySelectedPortion=\u0412\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c \u0422\u0430\u0431\u043b\u0438\u0446\u044b. \n\u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c? SaveProfileAction.saveOnlySelectedPortionDialogTitle=\u0412 \u0412\u0430\u0448\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u0435 \u0435\u0441\u0442\u044c \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u0422\u0430\u0431\u043b\u0438\u0446\u044b.
=======================================
--- /trunk/src/main/resources/ca/sqlpower/architect/swingui/messages.properties Tue Jun 22 15:19:40 2010 +++ /trunk/src/main/resources/ca/sqlpower/architect/swingui/messages.properties Thu Jun 24 12:17:51 2010
@@ -288,8 +288,11 @@
 ProfileManagerView.viewSelectedActionName=View Selected
 ProfileResultsViewer.closeButton=Close
 ProfileResultsViewer.columnViewTab=Column View
+ProfileResultsViewer.CSVExport=CSV Export...
 ProfileResultsViewer.frameTitle=Table Profiles
 ProfileResultsViewer.graphViewTab=Graph View
+ProfileResultsViewer.HTMLExport=HTML Export...
+ProfileResultsViewer.PDFExport=PDF Export...
 ProfileResultsViewer.search=Search:
 ProfileResultsViewer.tableViewTab=Table View
 ProjectSettingsPanel.directLineOption=Direct Lines

Reply via email to