From d27d7d84242f10c8d0bf93f876ca164bb322778c Mon Sep 17 00:00:00 2001 From: Ralf Wisser Date: Wed, 16 Nov 2022 14:56:10 +0100 Subject: [PATCH] Extended Copy, WIP --- .../engine/net/sf/jailer/JailerVersion.java | 3 + .../net/sf/jailer/ui/ExtendetCopyPanel.form | 139 ++++++- .../net/sf/jailer/ui/ExtendetCopyPanel.java | 356 ++++++++++++++++-- .../ui/databrowser/BrowserContentPane.java | 17 +- .../ui/databrowser/DesktopAnchorManager.java | 9 + .../sf/jailer/ui/databrowser/DetailsView.form | 12 + .../sf/jailer/ui/databrowser/DetailsView.java | 66 +++- .../ui/databrowser/metadata/MDTable.java | 2 +- .../net/sf/jailer/ui/resource/maximize.png | Bin 0 -> 294 bytes .../net/sf/jailer/ui/resource/unmaximize.png | Bin 0 -> 395 bytes 10 files changed, 562 insertions(+), 42 deletions(-) create mode 100644 src/main/gui/net/sf/jailer/ui/resource/maximize.png create mode 100644 src/main/gui/net/sf/jailer/ui/resource/unmaximize.png diff --git a/src/main/engine/net/sf/jailer/JailerVersion.java b/src/main/engine/net/sf/jailer/JailerVersion.java index e89191109..a0aea9853 100644 --- a/src/main/engine/net/sf/jailer/JailerVersion.java +++ b/src/main/engine/net/sf/jailer/JailerVersion.java @@ -44,4 +44,7 @@ public class JailerVersion { System.out.print(VERSION); } + // TODO + // TODO jpack JDK instead of JRE + } diff --git a/src/main/gui/net/sf/jailer/ui/ExtendetCopyPanel.form b/src/main/gui/net/sf/jailer/ui/ExtendetCopyPanel.form index d7f8ea0b2..97664cc06 100644 --- a/src/main/gui/net/sf/jailer/ui/ExtendetCopyPanel.form +++ b/src/main/gui/net/sf/jailer/ui/ExtendetCopyPanel.form @@ -1,6 +1,6 @@ -
+ @@ -11,20 +11,147 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ - + + + + + - + -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/gui/net/sf/jailer/ui/ExtendetCopyPanel.java b/src/main/gui/net/sf/jailer/ui/ExtendetCopyPanel.java index d5b9c0284..3f6826518 100644 --- a/src/main/gui/net/sf/jailer/ui/ExtendetCopyPanel.java +++ b/src/main/gui/net/sf/jailer/ui/ExtendetCopyPanel.java @@ -15,15 +15,27 @@ */ package net.sf.jailer.ui; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.Point; import java.awt.Window; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import javax.swing.JFrame; +import javax.swing.ImageIcon; +import javax.swing.JDialog; +import javax.swing.JLabel; import javax.swing.JTable; +import javax.swing.JViewport; +import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +import net.sf.jailer.util.LogUtil; /** * Extendet Copy Panel. @@ -35,34 +47,177 @@ public class ExtendetCopyPanel extends javax.swing.JPanel { public static void openDialog(JTable jTable) { Window owner = SwingUtilities.getWindowAncestor(jTable); - JFrame frame; - frame = new JFrame("Extended Copy"); - frame.setAlwaysOnTop(true); - frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - frame.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - UIUtil.checkTermination(); - } - }); + JDialog window = new JDialog(owner, "Extended Copy"); + window.setModal(false); + + window.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); ExtendetCopyPanel copyPanel = new ExtendetCopyPanel(); - frame.getContentPane().add(copyPanel); + copyPanel.initContentTable(jTable); - frame.pack(); + window.getContentPane().add(copyPanel); - Point mid = new Point(jTable.getParent().getWidth() / 2 - frame.getWidth() / 2, jTable.getParent().getHeight() / 2 - frame.getHeight() / 2); + window.pack(); + window.setSize(Math.max(window.getWidth(), jTable.getParent().getWidth()), window.getHeight()); + copyPanel.jPanel3.setMinimumSize(new Dimension(1, 160)); + copyPanel.jPanel3.setPreferredSize(copyPanel.jPanel3.getMinimumSize()); + + Point off = new Point(); + off = SwingUtilities.convertPoint(copyPanel, off, copyPanel.contentTable.getParent()); + + Point mid = new Point(off.x + -window.getContentPane().getLocation().x - window.getInsets().left, off.y + -window.getContentPane().getLocation().y - window.getInsets().top); // jTable.getParent().getWidth() / 2 - frame.getWidth() / 2, jTable.getParent().getHeight() / 2 - frame.getHeight() / 2); SwingUtilities.convertPointToScreen(mid, jTable.getParent()); - mid.x = Math.min(mid.x, owner.getX() + owner.getWidth() - frame.getWidth() - 4); - mid.y = Math.min(mid.y, owner.getY() + owner.getHeight() - frame.getHeight() - 4); + int maxX = owner.getX() + owner.getWidth() - window.getWidth() - 4; + mid.x = Math.min(mid.x, maxX); + int maxY = owner.getY() + owner.getHeight() - window.getHeight() - 4; + mid.y = Math.min(mid.y, maxY); mid.x = Math.max(mid.x, owner.getX() + 4); mid.y = Math.max(mid.y, owner.getY() + 4); - frame.setLocation(mid); - frame.setVisible(true); + + window.setLocation(mid); + window.setSize(window.getWidth() + Math.max(0, Math.min(300, maxX - window.getX())), window.getHeight() + Math.max(0, Math.min(500, maxY - window.getY()))); + + window.revalidate(); + int h = copyPanel.jScrollPane1.getHeight() - copyPanel.contentTable.getHeight() - 48; + if (h > 0) { + h = window.getHeight() - h; + window.setSize(window.getWidth(), h); + window.revalidate(); + } + window.setVisible(true); } - private ExtendetCopyPanel() { + private void initContentTable(JTable jTable) { + // TODO + // TODO resp. column order: resp. order in Copy2CB too + // TODO resp. row order + Object[] colNames = new Object[jTable.getColumnCount()]; + for (int i = 0; i < colNames.length; ++i) { + colNames[i] = jTable.getColumnName(i); + } + Object[][] data = new Object[jTable.getRowCount()][]; + for (int row = 0; row < data.length; ++row) { + data[row] = new Object[colNames.length]; + int ri = jTable.getRowSorter().convertRowIndexToModel(row); + for (int col = 0; col < colNames.length; ++col) { + data[row][col] = jTable.getModel().getValueAt(ri, col); + } + } + DefaultTableModel dtm = new DefaultTableModel(data, colNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + contentTable.setModel(dtm); + contentTable.setIntercellSpacing(new Dimension(0, 0)); + contentTable.setAutoCreateRowSorter(true); + contentTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); + + for (int i = 0; i < colNames.length; ++i) { + contentTable.getColumnModel().getColumn(i).setPreferredWidth(jTable.getColumnModel().getColumn(i).getWidth()); + colNames[i] = jTable.getColumnName(i); + } + + jScrollPane1.getViewport().setViewPosition(((JViewport) jTable.getParent()).getViewPosition()); + + contentTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + contentTable.setRowSelectionAllowed(true); + contentTable.setColumnSelectionAllowed(true); + contentTable.setCellSelectionEnabled(true); + contentTable.setName("contentTable"); + contentTable.setDefaultRenderer(Object.class, new TableCellRenderer() { + final Color BG = new Color(220, 230, 255); + // TODO + // TODO check +// final Color BGSELECTED = new Color(255, 230, 220); + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + int dmColumn = column; +// if (dmColumn > 0) { +// --dmColumn; +// } + Component render = jTable.getCellRenderer(row, dmColumn).getTableCellRendererComponent(contentTable, value, isSelected, hasFocus, row, dmColumn); + if (render instanceof JLabel) { + if (UIUtil.TABLE_BACKGROUND_COLOR_1.equals(render.getBackground())) { +// render.setBackground(BG); + // TODO ? idea was: slight diff visually to indicate other dialog. But whot about wysiwyg? + // TODO vorlaeufig: lass das so + + // TODO + // TODO render selected cells w/o changing text position ("ruhiger machen") + } + +// if (column == 0) { +// ((JLabel) render).setBackground(BGCOLUMNS); +// } +// if (column == 0) { +// String text = ((JLabel) render).getText(); +// String tabName = useTableName? tableName.get(row) : null; +// if (tabName != null) { +// JLabel tab = new JLabel(" " + tabName + " "); +// tab.setForeground(new Color(0, 0, 180)); +// tab.setBackground(render.getBackground()); +// tab.setOpaque(render.isOpaque()); +// JPanel panel = new JPanel(new GridBagLayout()); +// panel.setToolTipText(text); +// GridBagConstraints gridBagConstraints; +// gridBagConstraints = new java.awt.GridBagConstraints(); +// gridBagConstraints.gridx = 1; +// gridBagConstraints.gridy = 1; +// gridBagConstraints.fill = GridBagConstraints.BOTH; +// gridBagConstraints.weightx = 1; +// gridBagConstraints.weighty = 1; +// gridBagConstraints.anchor = GridBagConstraints.WEST; +// panel.add(tab, gridBagConstraints); +// gridBagConstraints = new java.awt.GridBagConstraints(); +// gridBagConstraints.gridx = 3; +// gridBagConstraints.gridy = 1; +// gridBagConstraints.anchor = GridBagConstraints.EAST; +// gridBagConstraints.fill = GridBagConstraints.BOTH; +// gridBagConstraints.weighty = 1; +// panel.add(render, gridBagConstraints); +// ((JLabel) render).setText(text + " "); +// return panel; +// } +// ((JLabel) render).setText(" " + text); +// } + if ("found".equals(render.getName())) { + Color background = render.getBackground(); + render.setBackground( + new Color( + Math.max((int)(background.getRed()), 0), + Math.max((int)(background.getGreen() * 0.90), 0), + Math.max((int)(background.getBlue() * 0.91), 0), + background.getAlpha())); + } + } + return render; + } + }); + try { + ((DefaultTableCellRenderer) contentTable.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(JLabel.LEFT); + for (int i = 0; i < jTable.getColumnModel().getColumnCount(); ++i) { + TableColumn col = jTable.getColumnModel().getColumn(i); + contentTable.getColumnModel().getColumn(i).setModelIndex(col.getModelIndex()); + } + contentTable.getSelectionModel(); + for (int r: jTable.getSelectedRows()) { + contentTable.addRowSelectionInterval(r, r); + } + contentTable.setColumnSelectionInterval(0, contentTable.getColumnCount() - 1); + } catch (Exception e) { + LogUtil.warn(e); + } + + // TODO select.change.listener: events zusammenfassen (invokeLater) + + } + + private ExtendetCopyPanel() { initComponents(); + maximizeButton.setIcon(maximizeIcon); } /** @@ -74,21 +229,170 @@ public class ExtendetCopyPanel extends javax.swing.JPanel { private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; - jButton1 = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + contentTable = new javax.swing.JTable(); + jLabel1 = new javax.swing.JLabel(); + jToolBar1 = new javax.swing.JToolBar(); + maximizeButton = new javax.swing.JToggleButton(); + jPanel3 = new javax.swing.JPanel(); + jScrollPane2 = new javax.swing.JScrollPane(); + jEditorPane1 = new javax.swing.JEditorPane(); + jPanel2 = new javax.swing.JPanel(); + copyCloseButton = new javax.swing.JButton(); setLayout(new java.awt.GridBagLayout()); - jButton1.setText("Copy and CLose"); + jPanel1.setLayout(new java.awt.GridBagLayout()); + + contentTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + )); + jScrollPane1.setViewportView(contentTable); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + jPanel1.add(jScrollPane1, gridBagConstraints); + + jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getSize()-1f)); + jLabel1.setForeground(java.awt.Color.gray); + jLabel1.setText("Shift-Click: Add row/column to selection. Ctrl-Click: Toggle row/column selection."); + jLabel1.setToolTipText("Shift-Click: Add row/column to selection.
\nCtrl-Click: Toggle row/column selection."); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0); + jPanel1.add(jLabel1, gridBagConstraints); + + jToolBar1.setFloatable(false); + jToolBar1.setRollover(true); + + maximizeButton.setText("Maximize"); + maximizeButton.setToolTipText("Maximize size of dialog"); + maximizeButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + maximizeButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + maximizeButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + maximizeButtonActionPerformed(evt); + } + }); + jToolBar1.add(maximizeButton); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 2; + jPanel1.add(jToolBar1, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(jPanel1, gridBagConstraints); + + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Preview")); + jPanel3.setLayout(new java.awt.GridBagLayout()); + + jScrollPane2.setViewportView(jEditorPane1); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + jPanel3.add(jScrollPane2, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0); + add(jPanel3, gridBagConstraints); + + jPanel2.setLayout(new java.awt.GridBagLayout()); + + copyCloseButton.setText("Copy and CLose"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; - gridBagConstraints.insets = new java.awt.Insets(138, 163, 139, 164); - add(jButton1, gridBagConstraints); + jPanel2.add(copyCloseButton, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 3; + add(jPanel2, gridBagConstraints); }// //GEN-END:initComponents + private Point oldLoc; + private Dimension oldSize; + + private void maximizeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maximizeButtonActionPerformed + Window dialog = SwingUtilities.getWindowAncestor(this); + if (dialog != null) { + Window owner = dialog.getOwner(); + if (owner != null) { + if (oldLoc != null) { + dialog.setLocation(oldLoc); + dialog.setSize(oldSize); + oldLoc = null; + oldSize = null; + maximizeButton.setIcon(maximizeIcon); + } else { + oldLoc = dialog.getLocation(); + oldSize = dialog.getSize(); + Insets insets = owner.getInsets(); + int b = 32; + insets.top += b; + insets.bottom += b; + insets.left += b; + insets.right += b; + dialog.setLocation(owner.getLocation().x + insets.left, owner.getLocation().y + insets.top - 1); + dialog.setSize(owner.getSize().width - insets.left - insets.right + 1, owner.getSize().height - insets.top - insets.bottom); + maximizeButton.setIcon(unmaximizeIcon); + } + } + } + }//GEN-LAST:event_maximizeButtonActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton jButton1; + private javax.swing.JTable contentTable; + private javax.swing.JButton copyCloseButton; + private javax.swing.JEditorPane jEditorPane1; + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JToolBar jToolBar1; + private javax.swing.JToggleButton maximizeButton; // End of variables declaration//GEN-END:variables + + private static ImageIcon maximizeIcon; + private static ImageIcon unmaximizeIcon; + static { + // load images + maximizeIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/maximizec.png")); + unmaximizeIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/unmaximize.png")); + } + } diff --git a/src/main/gui/net/sf/jailer/ui/databrowser/BrowserContentPane.java b/src/main/gui/net/sf/jailer/ui/databrowser/BrowserContentPane.java index fccb84e5d..3a14d9bd8 100644 --- a/src/main/gui/net/sf/jailer/ui/databrowser/BrowserContentPane.java +++ b/src/main/gui/net/sf/jailer/ui/databrowser/BrowserContentPane.java @@ -1305,7 +1305,7 @@ public abstract class BrowserContentPane extends javax.swing.JPanel { public void actionPerformed(ActionEvent e) { UIUtil.copyToClipboard(rowsTable, copyAllColumns()); // TODO - // ExtendetCopyPanel.openDialog(rowsTable); + ExtendetCopyPanel.openDialog(rowsTable); } }; am.put(key, a); @@ -1420,6 +1420,7 @@ public abstract class BrowserContentPane extends javax.swing.JPanel { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, final int row, final int column) { boolean cellSelected = isSelected; + boolean isContentTable = "contentTable".equals(table.getName()); if (BrowserContentPane.this.getQueryBuilderDialog() != null || // SQL Console table.getSelectedColumnCount() <= 1 && table.getSelectedRowCount() <= 1) { @@ -1432,9 +1433,9 @@ public abstract class BrowserContentPane extends javax.swing.JPanel { TableColumnModel columnModel = rowsTable.getColumnModel(); boolean found = !foundColumn.isEmpty() && column < columnModel.getColumnCount() && foundColumn.contains(columnModel.getColumn(column).getModelIndex()); - isSelected = !found && (currentRowSelection == row || currentRowSelection == -2); + isSelected = !isContentTable && !found && (currentRowSelection == row || currentRowSelection == -2); int bgRow = row; - if (table != rowsTable) { + if (table != rowsTable && !isContentTable) { isSelected = false; ++bgRow; if (table.getSelectedRows().length <= 1 && table.getSelectedColumns().length <= 1) { @@ -1477,9 +1478,9 @@ public abstract class BrowserContentPane extends javax.swing.JPanel { ((JLabel) render).setBorder(cellSelected? BorderFactory.createEtchedBorder() : null); int convertedColumnIndex = rowsTable.convertColumnIndexToModel(column); Table type = getResultSetTypeForColumn(convertedColumnIndex); - if (!isSelected && (table == rowsTable || !cellSelected)) { + if (isContentTable || (!isSelected && (table == rowsTable || !cellSelected))) { if (BrowserContentPane.this.getQueryBuilderDialog() != null && // SQL Console - !found && + !isContentTable && !found && BrowserContentPane.this.rowsClosure.currentClosureRowIDs != null && row < rows.size() && row < rowSorter.getViewRowCount() && @@ -1495,7 +1496,7 @@ public abstract class BrowserContentPane extends javax.swing.JPanel { } } } else { - if (isEditMode && r != null && (r.rowId != null && !r.rowId.isEmpty()) && browserContentCellEditor.isEditable(type, convertedColumnIndex, r.values[convertedColumnIndex]) + if (!isContentTable && isEditMode && r != null && (r.rowId != null && !r.rowId.isEmpty()) && browserContentCellEditor.isEditable(type, convertedColumnIndex, r.values[convertedColumnIndex]) && isPKComplete(type, r) && !rowIdSupport.getPrimaryKey(type, BrowserContentPane.this.session).getColumns().isEmpty()) { ((JLabel) render).setBackground((bgRow % 2 == 0) ? BG1_EM : BG2_EM); render.setName("final"); @@ -1555,7 +1556,7 @@ public abstract class BrowserContentPane extends javax.swing.JPanel { } } boolean isNumber = false; - if (table == rowsTable) { + if (table == rowsTable || isContentTable) { synchronized (rowColumnTypes) { int ci = columnModel.getColumn(column).getModelIndex(); if (rowColumnTypes.size() > ci) { @@ -7025,7 +7026,7 @@ public abstract class BrowserContentPane extends javax.swing.JPanel { detailsView.setSortColumns(currentRowsSortedReference == null? sortColumnsCheckBox.isSelected() : currentRowsSortedReference.get()); d.pack(); d.setLocation(x - 16, y + 2); - d.setSize(600, Math.max(152 + 16, d.getHeight())); + d.setSize(600, Math.max(152 + 16, d.getHeight()) + 16); UIUtil.fit(d); Window p = SwingUtilities.getWindowAncestor(rowsTable); if (p != null) { diff --git a/src/main/gui/net/sf/jailer/ui/databrowser/DesktopAnchorManager.java b/src/main/gui/net/sf/jailer/ui/databrowser/DesktopAnchorManager.java index 99d2495eb..8d844e440 100644 --- a/src/main/gui/net/sf/jailer/ui/databrowser/DesktopAnchorManager.java +++ b/src/main/gui/net/sf/jailer/ui/databrowser/DesktopAnchorManager.java @@ -371,6 +371,15 @@ public abstract class DesktopAnchorManager { Point locO = new Point(); locO = SwingUtilities.convertPoint(tableBrowser.internalFrame.getParent().getParent(), locO, anchorPanel); loc = new Point(Math.max(locO.x - anchorPanel.getWidth(), loc.x) - 1, Math.max(locO.y, loc.y + 1)); + if (anchorPanel.getComponentCount() > 1 && !anchorPanel.getComponents()[0].isEnabled() && !anchorPanel.getComponents()[1].isEnabled()) { + loc = new Point(loc.x, loc.y + anchorPanel.getComponents()[0].getHeight()); + anchorPanel.setSize(anchorPanel.getWidth(), anchorPanel.getHeight() - anchorPanel.getComponents()[0].getHeight()); + for (Component c: anchorPanel.getComponents()) { + c.setLocation(c.getX(), c.getY() - anchorPanel.getComponents()[0].getHeight()); + } + anchorPanel.getComponents()[0].setVisible(false); + anchorPanel.getComponents()[1].setVisible(false); + } anchorPanel.setLocation(loc); anchorButton.setVisible(true); anchorPanel.setVisible(true); diff --git a/src/main/gui/net/sf/jailer/ui/databrowser/DetailsView.form b/src/main/gui/net/sf/jailer/ui/databrowser/DetailsView.form index c54cb0539..4f0ea967d 100644 --- a/src/main/gui/net/sf/jailer/ui/databrowser/DetailsView.form +++ b/src/main/gui/net/sf/jailer/ui/databrowser/DetailsView.form @@ -215,6 +215,18 @@ + + + + + + + + + + + + diff --git a/src/main/gui/net/sf/jailer/ui/databrowser/DetailsView.java b/src/main/gui/net/sf/jailer/ui/databrowser/DetailsView.java index b6f3502ec..9c6b96012 100644 --- a/src/main/gui/net/sf/jailer/ui/databrowser/DetailsView.java +++ b/src/main/gui/net/sf/jailer/ui/databrowser/DetailsView.java @@ -23,6 +23,7 @@ import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.Point; import java.awt.Window; import java.awt.event.FocusEvent; @@ -712,7 +713,7 @@ public abstract class DetailsView extends javax.swing.JPanel { Dimension preferredSize = new Dimension(1, 1); p.setPreferredSize(preferredSize); p.setOpaque(true); - p.setBackground(i % 2 == 0? BG1 : BG2); + p.setBackground(BG2); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.weightx = 1; gridBagConstraints.weighty = 1; @@ -870,6 +871,7 @@ public abstract class DetailsView extends javax.swing.JPanel { sortCheckBox = new javax.swing.JCheckBox(); editModeToggleButton = new javax.swing.JToggleButton(); pinToggleButton = new javax.swing.JToggleButton(); + maximizeButton = new javax.swing.JButton(); setLayout(new java.awt.GridBagLayout()); @@ -992,6 +994,18 @@ public abstract class DetailsView extends javax.swing.JPanel { }); jToolBar1.add(pinToggleButton); + maximizeButton.setText("jButton1"); + maximizeButton.setToolTipText("Maximize"); + maximizeButton.setFocusable(false); + maximizeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + maximizeButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + maximizeButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + maximizeButtonActionPerformed(evt); + } + }); + jToolBar1.add(maximizeButton); + gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 1; @@ -1050,6 +1064,40 @@ public abstract class DetailsView extends javax.swing.JPanel { selectButton.setEnabled(false); }//GEN-LAST:event_pinToggleButtonActionPerformed + private Point oldLoc; + private Dimension oldSize; + private boolean oldIsPinned; + + private void maximizeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maximizeButtonActionPerformed + Window dialog = SwingUtilities.getWindowAncestor(this); + if (dialog != null) { + Window owner = dialog.getOwner(); + if (owner != null) { + if (oldLoc != null) { + dialog.setLocation(oldLoc); + dialog.setSize(oldSize); + oldLoc = null; + oldSize = null; + maximizeButton.setIcon(maximizeIcon); + if (oldIsPinned ^ pinToggleButton.isSelected()) { + pinToggleButton.doClick(); + } + } else { + oldLoc = dialog.getLocation(); + oldSize = dialog.getSize(); + oldIsPinned = pinToggleButton.isSelected(); + if (!pinToggleButton.isSelected()) { + pinToggleButton.doClick(); + } + final Insets insets = owner.getInsets(); + dialog.setLocation(owner.getLocation().x + insets.left, owner.getLocation().y + insets.top - 1); + dialog.setSize(owner.getSize().width - insets.left - insets.right + 1, owner.getSize().height - insets.top - insets.bottom); + maximizeButton.setIcon(unmaximizeIcon); + } + } + } + }//GEN-LAST:event_maximizeButtonActionPerformed + public boolean isPinned() { return pinToggleButton.isSelected(); } @@ -1071,6 +1119,7 @@ public abstract class DetailsView extends javax.swing.JPanel { private javax.swing.JPanel jPanel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JToolBar jToolBar1; + private javax.swing.JButton maximizeButton; private javax.swing.JToggleButton pinToggleButton; protected javax.swing.JSpinner rowSpinner; private javax.swing.JButton selectButton; @@ -1146,6 +1195,14 @@ public abstract class DetailsView extends javax.swing.JPanel { textPanel.add(tabContentPanel.textTabPanel, BorderLayout.CENTER); JPanel movePanel = new MovePanel(); + movePanel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) { + maximizeButton.doClick(); + } + } + }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; @@ -1155,6 +1212,9 @@ public abstract class DetailsView extends javax.swing.JPanel { gridBagConstraints.weightx = 1.0; jPanel3.add(movePanel, gridBagConstraints); + maximizeButton.setText(null); + maximizeButton.setIcon(maximizeIcon); + SmallButton closeButton = new SmallButton(closeIcon, closeOverIcon, false) { @Override protected void onClick(MouseEvent e) { @@ -1219,10 +1279,14 @@ public abstract class DetailsView extends javax.swing.JPanel { private static ImageIcon pinIcon; private static ImageIcon closeIcon; private static ImageIcon closeOverIcon; + private static ImageIcon maximizeIcon; + private static ImageIcon unmaximizeIcon; static { // load images editdetails = UIUtil.readImage("/editdetails.png"); pinIcon = UIUtil.readImage("/pin.png"); + maximizeIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/maximize.png")); + unmaximizeIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/unmaximize.png")); closeIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/close.png"), 1.55); closeOverIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/close_over.png"), 1.55); } diff --git a/src/main/gui/net/sf/jailer/ui/databrowser/metadata/MDTable.java b/src/main/gui/net/sf/jailer/ui/databrowser/metadata/MDTable.java index b1993f254..f65501846 100644 --- a/src/main/gui/net/sf/jailer/ui/databrowser/metadata/MDTable.java +++ b/src/main/gui/net/sf/jailer/ui/databrowser/metadata/MDTable.java @@ -89,7 +89,7 @@ public class MDTable extends MDObject { * @param schema the tables schema */ public MDTable(String name, MDSchema schema, boolean isView, boolean isSynonym) { - super(name, schema.getMetaDataSource()); + super(name, schema != null? schema.getMetaDataSource() : null); this.isView = isView; this.isSynonym = isSynonym; this.schema = schema; diff --git a/src/main/gui/net/sf/jailer/ui/resource/maximize.png b/src/main/gui/net/sf/jailer/ui/resource/maximize.png new file mode 100644 index 0000000000000000000000000000000000000000..2c4fda1d824c9d675217d2642c459e4c18b8488c GIT binary patch literal 294 zcmeAS@N?(olHy`uVBq!ia0vp^GC-`r!3HE5w@NsHsNx`ZCx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=Dh+L6~vJ#O${~!QGxNjv*f2Z>JjaH8}{liZ7XbWD>K7_v22R zS?(Vc%C==BWqLMkG<@}c$4$SqR5OvZxK9yANB?uHbkClBX8rve2ic}=c#y!vf8((7 z9j{j1n8Vt83Jn@n*F507Ceu^crgQlaPuk8o;*IClOF6ZL{AeWQ%)A^9r7Z^C~8PlmE~(SCCl2Z!mbe`njxgN@xNA*8_3i literal 0 HcmV?d00001 diff --git a/src/main/gui/net/sf/jailer/ui/resource/unmaximize.png b/src/main/gui/net/sf/jailer/ui/resource/unmaximize.png new file mode 100644 index 0000000000000000000000000000000000000000..df9e6d27f00542714e1d67dc7a444694bbb3e432 GIT binary patch literal 395 zcmeAS@N?(olHy`uVBq!ia0vp^GC-`r!3HE5w@NsHsNx`ZCx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=Dh+L6~vJ#O${~4GNwvjv*f2Z>R0$I%FWy`uO~^2QQefTs?ZT z{o}mP7)Wu9WU zeKD20x5B|<;lt0$op=Ar%yL}(CEU0|*Y?HJqoM+3(@Mp=I6GQDYTC(PY}m1ZyNmsZ z>&AwBWsZfHoReI)W^i{22W>DZG&PXh*W`2O^Ji18swFRZBNNYrO;5CWQ+_OGLzT)S z_6_;1*%{nNb1L^tllyY&Am5Hf5icg*U90~_6lC7VX{0m$I#>gTe~DWM4f8ik}< literal 0 HcmV?d00001