mirror of
https://github.com/Wisser/Jailer.git
synced 2026-05-24 11:39:31 -05:00
added "h-align" button to table browser
This commit is contained in:
@@ -211,6 +211,33 @@
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="hAlignButtonPanel">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="2" anchor="13" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="hAlignButtonLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Find Columns"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="4" insetsBottom="0" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="loadingPanel">
|
||||
|
||||
@@ -196,6 +196,7 @@ import net.sf.jailer.ui.scrollmenu.JScrollC2Menu;
|
||||
import net.sf.jailer.ui.scrollmenu.JScrollMenu;
|
||||
import net.sf.jailer.ui.syntaxtextarea.BasicFormatterImpl;
|
||||
import net.sf.jailer.ui.util.AnimationController;
|
||||
import net.sf.jailer.ui.util.UISettings;
|
||||
import net.sf.jailer.util.CancellationException;
|
||||
import net.sf.jailer.util.CancellationHandler;
|
||||
import net.sf.jailer.util.CellContentConverter;
|
||||
@@ -1010,6 +1011,75 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ImageIcon scaledhAlignButtonIcon1 = UIUtil.scaleIcon(this, hAlignButtonIcon1);
|
||||
ImageIcon scaledhAlignButtonIcon2 = UIUtil.scaleIcon(this, hAlignButtonIcon2);
|
||||
|
||||
hAlignButtonLabel.setText(getQueryBuilderDialog() != null? null : "Find Column");
|
||||
hAlignButtonLabel.setToolTipText("Align horizontally with predecessors");
|
||||
hAlignButtonLabel.setIcon(scaledhAlignButtonIcon1);
|
||||
if (UIUtil.plaf != PLAF.FLAT) {
|
||||
hAlignButtonLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
|
||||
}
|
||||
|
||||
hAlignButtonLabel.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
private boolean in = false;
|
||||
private boolean active = false;
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (hAlignButtonLabel.isEnabled()) {
|
||||
UIUtil.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateBorder();
|
||||
if (hAlignButtonPanel.isShowing()) {
|
||||
Point point = new Point(0, hAlignButtonPanel.getHeight());
|
||||
SwingUtilities.convertPointToScreen(point, hAlignButtonPanel);
|
||||
active = true;
|
||||
updateBorder();
|
||||
Timer timer = new Timer(600, e -> { active = false; updateBorder(); });
|
||||
timer.setRepeats(false);
|
||||
timer.start();
|
||||
++UISettings.s14;
|
||||
|
||||
userActions.forEach(action -> {
|
||||
if ("Align Horizontally".equals(action.description)) {
|
||||
if (action.isApplicable.get()) {
|
||||
action.action.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(java.awt.event.MouseEvent evt) {
|
||||
if (hAlignButtonLabel.isEnabled()) {
|
||||
in = true;
|
||||
updateBorder();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(java.awt.event.MouseEvent evt) {
|
||||
in = false;
|
||||
updateBorder();
|
||||
}
|
||||
|
||||
private void updateBorder() {
|
||||
if (UIUtil.plaf == PLAF.FLAT) {
|
||||
hAlignButtonPanel.setBackground(active? UIUtil.BG_FLATSELECTED : in? UIUtil.BG_FLATMOUSEOVER : null);
|
||||
} else {
|
||||
hAlignButtonLabel.setBorder(new javax.swing.border.SoftBevelBorder(in || active? javax.swing.border.BevelBorder.LOWERED : javax.swing.border.BevelBorder.RAISED));
|
||||
}
|
||||
hAlignButtonLabel.setIcon(in || active? scaledhAlignButtonIcon2 : scaledhAlignButtonIcon1);
|
||||
}
|
||||
});
|
||||
|
||||
andCondition = new JComboBox2();
|
||||
andCondition.setEditable(true);
|
||||
andCondition.setMaximumRowCount(12);
|
||||
@@ -2310,6 +2380,10 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setHAlignButtonEnabled(boolean enabled) {
|
||||
hAlignButtonLabel.setEnabled(enabled);
|
||||
}
|
||||
|
||||
private int currentSearchButtonColumnIndex = -1;
|
||||
private Point currentSearchButtonLocation = null;
|
||||
private ImageIcon currentSearchButtonIcon = null;
|
||||
@@ -5947,6 +6021,8 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
findColumnsPanel = new javax.swing.JPanel();
|
||||
findColumnsLabel = new javax.swing.JLabel();
|
||||
statusStrutLabel = new javax.swing.JLabel();
|
||||
hAlignButtonPanel = new javax.swing.JPanel();
|
||||
hAlignButtonLabel = new javax.swing.JLabel();
|
||||
loadingPanel = new javax.swing.JPanel();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
cancelLoadButton = new javax.swing.JButton();
|
||||
@@ -6100,6 +6176,21 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 0);
|
||||
statusPanel.add(statusStrutLabel, gridBagConstraints);
|
||||
|
||||
hAlignButtonPanel.setLayout(new java.awt.GridBagLayout());
|
||||
|
||||
hAlignButtonLabel.setText("Find Columns");
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 2);
|
||||
hAlignButtonPanel.add(hAlignButtonLabel, gridBagConstraints);
|
||||
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 1;
|
||||
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
|
||||
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
|
||||
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 2);
|
||||
statusPanel.add(hAlignButtonPanel, gridBagConstraints);
|
||||
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 1;
|
||||
gridBagConstraints.gridy = 2;
|
||||
@@ -6761,6 +6852,8 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
public javax.swing.JPanel findColumnsPanel;
|
||||
private javax.swing.JLabel from;
|
||||
private javax.swing.JPanel fullTextSearchContainerPanel;
|
||||
public javax.swing.JLabel hAlignButtonLabel;
|
||||
public javax.swing.JPanel hAlignButtonPanel;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel11;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
@@ -8021,6 +8114,8 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
private static ImageIcon selectIcon;
|
||||
private static ImageIcon menuIcon;
|
||||
private static ImageIcon allDotIcon;
|
||||
private static ImageIcon hAlignButtonIcon1;
|
||||
private static ImageIcon hAlignButtonIcon2;
|
||||
|
||||
static {
|
||||
// load images
|
||||
@@ -8050,6 +8145,8 @@ public abstract class BrowserContentPane extends javax.swing.JPanel {
|
||||
selectIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/select.png"));
|
||||
menuIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/menu.png"));
|
||||
allDotIcon = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/alldot.gif"));
|
||||
hAlignButtonIcon1 = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/anchor1.png"));
|
||||
hAlignButtonIcon2 = UIUtil.scaleIcon(new JLabel(""), UIUtil.readImage("/anchor0.png"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1193,6 +1193,7 @@ public class DataBrowser extends javax.swing.JFrame {
|
||||
desktopOutline = new DesktopOutline(navigationPanel, controlPanel, jScrollPane1, desktop, tableBrowser -> {
|
||||
if (anchorManager.isApplicable(tableBrowser)) {
|
||||
anchorManager.layout(tableBrowser);
|
||||
UISettings.s14 += 1000;
|
||||
}
|
||||
});
|
||||
java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints();
|
||||
|
||||
@@ -587,6 +587,8 @@ public abstract class Desktop extends JDesktopPane {
|
||||
desktopUndoManager.beforeModification("Remove \"" + title.replaceFirst("\\s*\\(\\d+\\)$", "") + "\"", "Add \"" + title.replaceFirst("\\s*\\(\\d+\\)$", "") + "\"");
|
||||
}
|
||||
|
||||
checkHAlignButtons();
|
||||
|
||||
final RowBrowser tableBrowser = new RowBrowser();
|
||||
final JInternalFrame jInternalFrame = new JInternalFrame(table == null ? "SQL" : title) {
|
||||
private BufferedImage m_offscreen;
|
||||
@@ -772,7 +774,7 @@ public abstract class Desktop extends JDesktopPane {
|
||||
|
||||
if (!becomeSelectedPending) {
|
||||
becomeSelectedPending = true;
|
||||
UIUtil.invokeLater(4, () -> {
|
||||
UIUtil.invokeLater(22, () -> {
|
||||
becomeSelectedPending = false;
|
||||
tableBrowsers.forEach(tb -> {
|
||||
if (tb.internalFrame.isSelected()) {
|
||||
@@ -1456,6 +1458,7 @@ public abstract class Desktop extends JDesktopPane {
|
||||
@Override
|
||||
public void internalFrameClosed(InternalFrameEvent e) {
|
||||
close(tableBrowser, true);
|
||||
checkHAlignButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3221,6 +3224,25 @@ public abstract class Desktop extends JDesktopPane {
|
||||
rowsClosure.hAlignedPath.clear();
|
||||
}
|
||||
}
|
||||
checkHAlignButtons();
|
||||
}
|
||||
|
||||
private boolean checkPending = false;
|
||||
|
||||
private void checkHAlignButtons() {
|
||||
if (desktopAnimation.isActive()) {
|
||||
UIUtil.invokeLater(() -> {
|
||||
checkHAlignButtons();
|
||||
});
|
||||
} else {
|
||||
if (!checkPending) {
|
||||
checkPending = true;
|
||||
UIUtil.invokeLater(() -> {
|
||||
checkPending = false;
|
||||
this.tableBrowsers.forEach(tb -> tb.browserContentPane.setHAlignButtonEnabled(anchorManager.isApplicable(tb)));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4355,46 +4377,47 @@ public abstract class Desktop extends JDesktopPane {
|
||||
updateMenuPendingTimer.setRepeats(false);
|
||||
updateMenuPendingTimer.start();
|
||||
|
||||
if (anchorManager.isApplicable(tableBrowser) || rowsClosure.hAlignedPathOnSelection) {
|
||||
checkHAlignedPath();
|
||||
}
|
||||
if (rowsClosure.hAlignedPath.isEmpty() || rowsClosure.hAlignedPathOnSelection) {
|
||||
rowsClosure.hAlignedPath.clear();
|
||||
|
||||
RowBrowser ct = tableBrowser;
|
||||
while (ct != null) {
|
||||
int y = ct.internalFrame.getY();
|
||||
Optional<RowBrowser> optCB = getChildBrowsers(ct, false).stream().filter(cb -> cb.internalFrame.getY() == y || cb.isHidden()).findAny();
|
||||
if (optCB.isPresent()) {
|
||||
ct = optCB.get();
|
||||
if (!ct.isHidden()) {
|
||||
rowsClosure.hAlignedPath.add(ct.browserContentPane);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO explicit Button for "h-align"?
|
||||
|
||||
if (tableBrowser.parent != null) {
|
||||
rowsClosure.hAlignedPath.add(tableBrowser.parent.browserContentPane);
|
||||
RowBrowser parent = tableBrowser.parent;
|
||||
while (parent != null && parent.parent != null && parent.isHidden()) {
|
||||
parent = parent.parent;
|
||||
rowsClosure.hAlignedPath.add(parent.browserContentPane);
|
||||
}
|
||||
for (RowBrowser ancBr = parent; ancBr != null; ancBr = ancBr.parent) {
|
||||
if (ancBr.isHidden() || ancBr.internalFrame.getY() == tableBrowser.parent.internalFrame.getY()) {
|
||||
rowsClosure.hAlignedPath.add(ancBr.browserContentPane);
|
||||
} else {
|
||||
break;
|
||||
if (!noArrangeLayoutOnNewTableBrowserWithAnchor) {
|
||||
if (anchorManager.isApplicable(tableBrowser) || rowsClosure.hAlignedPathOnSelection) {
|
||||
checkHAlignedPath();
|
||||
}
|
||||
if (rowsClosure.hAlignedPath.isEmpty() || rowsClosure.hAlignedPathOnSelection) {
|
||||
rowsClosure.hAlignedPath.clear();
|
||||
|
||||
if (!desktopAnimation.isActive()) {
|
||||
RowBrowser ct = tableBrowser;
|
||||
while (ct != null) {
|
||||
int y = ct.internalFrame.getY();
|
||||
Optional<RowBrowser> optCB = getChildBrowsers(ct, false).stream().filter(cb -> cb.internalFrame.getY() == y || cb.isHidden()).findAny();
|
||||
if (optCB.isPresent()) {
|
||||
ct = optCB.get();
|
||||
if (!ct.isHidden()) {
|
||||
rowsClosure.hAlignedPath.add(ct.browserContentPane);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rowsClosure.hAlignedPath.add(tableBrowser.browserContentPane);
|
||||
rowsClosure.hAlignedPathOnSelection = true;
|
||||
if (tableBrowser.parent != null) {
|
||||
rowsClosure.hAlignedPath.add(tableBrowser.parent.browserContentPane);
|
||||
RowBrowser parent = tableBrowser.parent;
|
||||
while (parent != null && parent.parent != null && parent.isHidden()) {
|
||||
parent = parent.parent;
|
||||
rowsClosure.hAlignedPath.add(parent.browserContentPane);
|
||||
}
|
||||
for (RowBrowser ancBr = parent; ancBr != null; ancBr = ancBr.parent) {
|
||||
// if (ancBr.isHidden() || ancBr.internalFrame.getY() == tableBrowser.parent.internalFrame.getY()) {
|
||||
rowsClosure.hAlignedPath.add(ancBr.browserContentPane);
|
||||
// } else {
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
rowsClosure.hAlignedPath.add(tableBrowser.browserContentPane);
|
||||
rowsClosure.hAlignedPathOnSelection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -155,6 +155,7 @@ public class UISettings {
|
||||
public static volatile int s11 = 1;
|
||||
public static volatile int s12;
|
||||
public static volatile int s13;
|
||||
public static volatile int s14;
|
||||
|
||||
public synchronized static void storeStats() {
|
||||
try {
|
||||
@@ -165,7 +166,7 @@ public class UISettings {
|
||||
}
|
||||
int i = 1;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int s: new int[] { s1, s2.get(), s3, s4, s5.get(), s6, s7.get(), s8, s9, 0, s11, s12, s13 }) {
|
||||
for (int s: new int[] { s1, s2.get(), s3, s4, s5.get(), s6, s7.get(), s8, s9, 0, s11, s12, s13, s14 }) {
|
||||
if (s != 0) {
|
||||
sb.append("&s" + i + "=" + s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user