diff --git a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/PatternAnalysisModel.java b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/PatternAnalysisModel.java index 3763f00..ad7b30a 100644 --- a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/PatternAnalysisModel.java +++ b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/PatternAnalysisModel.java @@ -177,7 +177,7 @@ public String getColumnName(final int columnIndex) { @Override public Class getColumnClass(final int columnIndex) { - if (columnIndex < 2) { + if (columnIndex == 0) { return String.class; } return Long.class; diff --git a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/PatternAnalysisPanel.java b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/PatternAnalysisPanel.java index 342aca3..ed3f573 100644 --- a/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/PatternAnalysisPanel.java +++ b/scitos.ais/scitos.ais.view/src/main/java/org/hmx/scitos/ais/view/swing/components/PatternAnalysisPanel.java @@ -37,8 +37,11 @@ import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; import javax.swing.table.TableModel; import org.hmx.scitos.ais.core.i18n.AisMessage; @@ -55,6 +58,8 @@ public final class PatternAnalysisPanel extends JPanel { /** The alternate row color, for easier readability in the result tables. */ static final Color ALTERNATE_ROW_COLOR = new Color(239, 239, 239); + /** The minimum width of a single table column. */ + private static final int MIN_COLUMN_WIDTH = 40; /** The associated view project, containing the interviews the displayed results are extracted from. */ final PatternAnalysisModel model; @@ -72,9 +77,9 @@ public PatternAnalysisPanel(final ScitosClient client, final AisViewProject proj this.model = new PatternAnalysisModel(project); this.setBorder(null); final JTabbedPane tabStack = new JTabbedPane(SwingConstants.TOP, JTabbedPane.WRAP_TAB_LAYOUT); - tabStack.add(AisMessage.ANALYSIS_SUMMARY.get(), this.createTableFromModel(this.model.getSummaryTableModel())); - tabStack.add(AisMessage.ANALYSIS_SEQUENCE.get(), this.createTableFromModel(this.model.getSequenceTableModel())); - tabStack.add(AisMessage.ANALYSIS_PATTERN.get(), this.createTableFromModel(this.model.getPatternTableModel())); + tabStack.add(AisMessage.ANALYSIS_SUMMARY.get(), this.createTableFromModel(this.model.getSummaryTableModel(), true)); + tabStack.add(AisMessage.ANALYSIS_SEQUENCE.get(), this.createTableFromModel(this.model.getSequenceTableModel(), false)); + tabStack.add(AisMessage.ANALYSIS_PATTERN.get(), this.createTableFromModel(this.model.getPatternTableModel(), true)); this.add(tabStack); this.addHierarchyListener(new HierarchyListener() { @@ -117,9 +122,11 @@ void refresh() { * * @param tableModel * table model to display + * @param sortable + * if the columns should be sortable * @return scrollable table taking up the whole view */ - private JScrollPane createTableFromModel(final TableModel tableModel) { + private JScrollPane createTableFromModel(final TableModel tableModel, final boolean sortable) { final JTable tableView = new JTable(tableModel) { @Override @@ -138,16 +145,31 @@ public void updateUI() { final Font contentFont = UIManager.getFont("Table.font"); if (contentFont != null) { this.setFont(new Font(contentFont.getAttributes()).deriveFont(contentFont.getSize2D() * scaleFactor)); - this.setRowHeight(2 + Math.round(this.getFont().getSize2D() * scaleFactor)); + this.setRowHeight(this.getRowMargin() + (int) Math.ceil(this.getFont().getSize2D() * scaleFactor)); } + PatternAnalysisPanel.this.adjustColumns(this); + } + + @Override + public void createDefaultColumnsFromModel() { + super.createDefaultColumnsFromModel(); + final JTable self = this; + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + PatternAnalysisPanel.this.adjustColumns(self); + } + }); } }; tableView.setBorder(null); tableView.setAutoCreateColumnsFromModel(true); - tableView.setAutoCreateRowSorter(true); + tableView.setAutoCreateRowSorter(sortable); + tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); tableView.setRowSelectionAllowed(true); tableView.setColumnSelectionAllowed(false); - tableView.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + tableView.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); final AlternateRowRenderer cellRenderer = new AlternateRowRenderer(); tableView.setDefaultRenderer(String.class, cellRenderer); tableView.setDefaultRenderer(Long.class, cellRenderer); @@ -157,6 +179,34 @@ public void updateUI() { return scrollableTable; } + /** + * Adjust the widths of all columns of the given table to fit the respective column's header and contents. + * + * @param table + * the table to adjust the columns for + */ + void adjustColumns(final JTable table) { + final int columnCount = table.getColumnCount(); + final int rowCount = table.getRowCount(); + for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { + final TableColumn column = table.getColumnModel().getColumn(columnIndex); + TableCellRenderer headerRenderer = column.getHeaderRenderer(); + if (headerRenderer == null) { + headerRenderer = table.getTableHeader().getDefaultRenderer(); + } + final Object headerValue = column.getHeaderValue(); + final Component headerCell = headerRenderer.getTableCellRendererComponent(table, headerValue, false, false, -1, columnIndex); + int columnWidth = headerCell.getPreferredSize().width; + for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { + final TableCellRenderer cellRenderer = table.getCellRenderer(rowIndex, columnIndex); + columnWidth = Math.max(columnWidth, table.prepareRenderer(cellRenderer, rowIndex, columnIndex).getPreferredSize().width); + } + final int preferredWidth = Math.max(PatternAnalysisPanel.MIN_COLUMN_WIDTH, columnWidth) + 4 + 2 * table.getIntercellSpacing().width; + column.setMaxWidth(preferredWidth + PatternAnalysisPanel.MIN_COLUMN_WIDTH / 2); + column.setPreferredWidth(preferredWidth); + } + } + /** Cell renderer to apply alternating row background color in order to improve the table's readability. */ private static final class AlternateRowRenderer extends DefaultTableCellRenderer { diff --git a/scitos.core/src/main/resources/org/hmx/scitos/core/i18n/Message.xml b/scitos.core/src/main/resources/org/hmx/scitos/core/i18n/Message.xml index 346fd3a..8494293 100644 --- a/scitos.core/src/main/resources/org/hmx/scitos/core/i18n/Message.xml +++ b/scitos.core/src/main/resources/org/hmx/scitos/core/i18n/Message.xml @@ -34,7 +34,9 @@ It might belong to a newer version. Please check if there is a newer version available. Save - The produced File could not be validated and might be corrupted. + The produced File could not be validated. +Please try to save it again (possibly at another Location?) or +Open the File in a Web Browser (e.g. Firefox) and compare it yourself. Save As... AIS Project Preferences diff --git a/scitos.core/src/main/resources/org/hmx/scitos/core/i18n/Message_de.xml b/scitos.core/src/main/resources/org/hmx/scitos/core/i18n/Message_de.xml index eb51ef0..2c35437 100644 --- a/scitos.core/src/main/resources/org/hmx/scitos/core/i18n/Message_de.xml +++ b/scitos.core/src/main/resources/org/hmx/scitos/core/i18n/Message_de.xml @@ -37,7 +37,7 @@ Lade gegebenenfalls die aktuelle Version von SciToS herunter. Speichern Die gespeicherte Datei konnte nicht vollständig validiert werden. Bitte versuche noch einmal es zu speichern (ggf. an einem anderen Ort?) oder -öffne die Datei in einem (modernen) Web Browser und kontrolliere es selbst. +öffne die Datei in einem Web Browser (z.B. Firefox) und vergleiche es selbst. Speichern unter... AIS Projekt Einstellungen diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/ScitosIcon.java b/scitos.view/src/main/java/org/hmx/scitos/view/ScitosIcon.java index 3f33967..9a7d219 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/ScitosIcon.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/ScitosIcon.java @@ -63,17 +63,23 @@ public enum ScitosIcon { UNDO_EDIT("/icons/eclipse/undo_edit.png"), /** Icon: redo entry in menu bar / tool bar. */ REDO_EDIT("/icons/eclipse/redo_edit.png"), + /** Icon: increase content (font) size entry in menu bar. */ + ZOOM_IN("/icons/fatcow/magnifier_zoom_in.png"), + /** Icon: reduce content (font) size entry in menu bar. */ + ZOOM_OUT("/icons/fatcow/magnifier_zoom_out.png"), + /** Icon: toggle icon for the main view's sidebar. */ + SIDEBAR("/icons/fatcow/layouts_select_sidebar.png"), /** Icon: vertical arrow pointing upwards for moving something up. */ ARROW_UP("/icons/eclipse/arrow_up.png"), /** Icon: vertical arrow pointing downwards for moving something down. */ ARROW_DOWN("/icons/eclipse/arrow_down.png"), /** Icon: config/preferences entry in menu bar. */ CONFIG("/icons/fatcow/cog.png"), - /** Icon: add entry e.g. in category tree table **/ + /** Icon: add entry e.g. in category tree table. **/ ADD("/icons/fatcow/add.png"), - /** Icon: remove entry e.g. in category tree table **/ + /** Icon: remove entry e.g. in category tree table. **/ DELETE("/icons/fatcow/cross.png"), - /** Icon: add entry e.g. in category tree table **/ + /** Icon: model entry e.g. in category tree table. **/ CATEGORY("/icons/fatcow/clipboard_invoice.png"); /** Location of the represented icon in the classpath. */ diff --git a/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosClient.java b/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosClient.java index e00cc9c..21e8120 100644 --- a/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosClient.java +++ b/scitos.view/src/main/java/org/hmx/scitos/view/swing/ScitosClient.java @@ -341,9 +341,9 @@ public void actionPerformed(final ActionEvent event) { */ private JMenu createViewMenu() { final JMenu viewMenu = new JMenu(Message.MENUBAR_VIEW.get()); - final JMenuItem scaleUpFontItem = viewMenu.add(new JMenuItem(Message.MENUBAR_VIEW_FONT_SCALE_UP.get())); + final JMenuItem scaleUpFontItem = viewMenu.add(new JMenuItem(Message.MENUBAR_VIEW_FONT_SCALE_UP.get(), ScitosIcon.ZOOM_IN.create())); scaleUpFontItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ScitosClient.SHORTCUT_MASK | InputEvent.SHIFT_DOWN_MASK)); - final JMenuItem scaleDownFontItem = viewMenu.add(new JMenuItem(Message.MENUBAR_VIEW_FONT_SCALE_DOWN.get())); + final JMenuItem scaleDownFontItem = viewMenu.add(new JMenuItem(Message.MENUBAR_VIEW_FONT_SCALE_DOWN.get(), ScitosIcon.ZOOM_OUT.create())); scaleDownFontItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ScitosClient.SHORTCUT_MASK | InputEvent.SHIFT_DOWN_MASK)); // allow the scaling only in the given range, with 10% change per step: 1.1^(-2 to +8) final AtomicInteger range = new AtomicInteger(0); @@ -365,7 +365,8 @@ public void actionPerformed(final ActionEvent event) { ScitosClient.this.setContentScaleFactor((float) Math.pow(1.1, range.get())); } }); - viewMenu.add(new JMenuItem(Message.MENUBAR_VIEW_TOGGLE_PROJECT_TREE.get())).addActionListener(new ActionListener() { + final JMenuItem toggleTreeItem = viewMenu.add(new JMenuItem(Message.MENUBAR_VIEW_TOGGLE_PROJECT_TREE.get(), ScitosIcon.SIDEBAR.create())); + toggleTreeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { diff --git a/scitos.view/src/main/resources/icons/fatcow/layouts_select_sidebar.png b/scitos.view/src/main/resources/icons/fatcow/layouts_select_sidebar.png new file mode 100644 index 0000000..f90ed08 Binary files /dev/null and b/scitos.view/src/main/resources/icons/fatcow/layouts_select_sidebar.png differ diff --git a/scitos.view/src/main/resources/icons/fatcow/magnifier_zoom_in.png b/scitos.view/src/main/resources/icons/fatcow/magnifier_zoom_in.png new file mode 100644 index 0000000..25f49df Binary files /dev/null and b/scitos.view/src/main/resources/icons/fatcow/magnifier_zoom_in.png differ diff --git a/scitos.view/src/main/resources/icons/fatcow/magnifier_zoom_out.png b/scitos.view/src/main/resources/icons/fatcow/magnifier_zoom_out.png new file mode 100644 index 0000000..9f58450 Binary files /dev/null and b/scitos.view/src/main/resources/icons/fatcow/magnifier_zoom_out.png differ