Skip to content

Commit c8dbbaf

Browse files
committed
Feature: #620 Equipped the file export dialog with a vertical scrollbar when needed.
To better support this, the dialog was partly rearranged.
1 parent a5177d5 commit c8dbbaf

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

sql12/core/doc/changes.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Not yet released, available in our GIT repository, snapshots and future releases
66

77
Enhancements:
88

9+
#620 Equipped the file export dialog with a vertical scrollbar when needed.
10+
To better support this, the dialog was partly rearranged.
11+
912
#620 UI table to MS Excel exports of SQL results now offers to create additional
1013
sheets containing the exported SQL statements.
1114
This is an extension of the original implementation of feature request 620.

sql12/core/src/net/sourceforge/squirrel_sql/fw/gui/action/fileexport/ExportDlg.java

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
import net.sourceforge.squirrel_sql.client.Main;
5+
import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
56
import net.sourceforge.squirrel_sql.fw.gui.MultipleLineLabel;
67
import net.sourceforge.squirrel_sql.fw.gui.buttontabcomponent.SmallToolTipInfoButton;
78
import net.sourceforge.squirrel_sql.fw.resources.LibraryResources;
@@ -17,12 +18,15 @@
1718
import javax.swing.JLabel;
1819
import javax.swing.JPanel;
1920
import javax.swing.JRadioButton;
21+
import javax.swing.JScrollPane;
2022
import javax.swing.JTextField;
23+
import javax.swing.ScrollPaneConstants;
2124
import java.awt.BorderLayout;
2225
import java.awt.Component;
2326
import java.awt.Cursor;
2427
import java.awt.GridBagConstraints;
2528
import java.awt.GridBagLayout;
29+
import java.awt.GridLayout;
2630
import java.awt.Insets;
2731
import java.awt.Window;
2832
import java.awt.event.MouseAdapter;
@@ -84,67 +88,59 @@ public ExportDlg(Window owner, JPanel exportSelectionPanel, ExportDialogType exp
8488
// i18n[TableExportCSVDlg.exportTitleNew=CSV / MS Excel / XML export]
8589
setTitle(s_stringMgr.getString("TableExportCSVDlg.exportTitleNew"));
8690

87-
getContentPane().setLayout(new GridBagLayout());
91+
JPanel pnlContent = new JPanel(new GridBagLayout());
92+
93+
pnlContent.setLayout(new GridBagLayout());
8894
GridBagConstraints gbc;
8995

9096
gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0);
9197
// i18n[TableExportCsvDlg.exportCsvFile=Export to file:]
92-
getContentPane().add(new JLabel(s_stringMgr.getString("TableExportCsvDlg.exportCsvFile")), gbc);
98+
pnlContent.add(new JLabel(s_stringMgr.getString("TableExportCsvDlg.exportCsvFile")), gbc);
9399

94100
gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0);
95-
getContentPane().add(getFilePanel(), gbc);
101+
pnlContent.add(getFilePanel(), gbc);
96102

97103
gbc = new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 5, 5), 0, 0);
98-
getContentPane().add(getExportFormatPanel(exportDialogType.isEnableColoring()), gbc);
104+
pnlContent.add(getExportFormatPanel(exportDialogType.isEnableColoring()), gbc);
99105

100106
// i18n[TableExportCsvDlg.withHeaders=Include column headers]
101107
chkWithHeaders = new JCheckBox(s_stringMgr.getString("TableExportCsvDlg.withHeaders"));
102108
gbc = new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0);
103-
getContentPane().add(chkWithHeaders, gbc);
109+
pnlContent.add(chkWithHeaders, gbc);
104110

105111

106112

107113
gbc = new GridBagConstraints(0, 4, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 5, 5), 0, 0);
108-
getContentPane().add(getSeparatorPanel(), gbc);
114+
pnlContent.add(getSeparatorPanel(), gbc);
109115

110116

111117
gbc = new GridBagConstraints(0, 5, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(15, 5, 5, 5), 0, 0);
112-
//switch (exportDialogType)
113-
//{
114-
// case UI_TABLE_EXPORT:
115-
// gbc = new GridBagConstraints(0, 5, 1, 1, 0, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(15, 5, 5, 5), 0, 0);
116-
// break;
117-
// case RESULT_SET_EXPORT:
118-
// gbc = new GridBagConstraints(0, 5, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 5, 5), 0, 0);
119-
// break;
120-
// default:
121-
// throw new UnsupportedOperationException("Unknown exportDialogType=" + exportDialogType);
122-
//
123-
//}
124-
getContentPane().add(exportSelectionPanel, gbc);
118+
pnlContent.add(exportSelectionPanel, gbc);
125119

126120
gbc = new GridBagConstraints(0, 6, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 5, 5), 0, 0);
127-
getContentPane().add(getFormattingPanel(), gbc);
121+
pnlContent.add(getFormattingPanel(), gbc);
128122

129123
chkExecCommand = new JCheckBox(s_stringMgr.getString("TableExportCsvDlg.executeCommand"));
130124
gbc = new GridBagConstraints(0, 7, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(15, 5, 5, 5), 0, 0);
131-
getContentPane().add(chkExecCommand, gbc);
125+
pnlContent.add(chkExecCommand, gbc);
132126

133127
gbc = new GridBagConstraints(0, 8, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 5, 5), 0, 0);
134-
getContentPane().add(getCommandPanel(), gbc);
128+
pnlContent.add(getCommandPanel(), gbc);
135129

136130

137131
gbc = new GridBagConstraints(0, 9, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 5, 5), 0, 0);
138-
getContentPane().add(getButtonPanel(), gbc);
132+
pnlContent.add(getButtonPanel(), gbc);
133+
134+
135+
136+
GUIUtils.setMinimumWidth(pnlContent, 1);
137+
GUIUtils.setPreferredWidth(pnlContent, 1);
139138

140-
//gbc = new GridBagConstraints(0, 10, 0, 0, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(10, 5, 10, 5), 0, 0);
141-
//getContentPane().add(createInfoLinkLabel(), gbc);
139+
getContentPane().setLayout(new GridLayout(1,1));
140+
JScrollPane scrollPane = new JScrollPane(pnlContent);
141+
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
142+
getContentPane().add(scrollPane);
142143

143-
//if(exportDialogType == ExportDialogType.RESULT_SET_EXPORT)
144-
//{
145-
// gbc = new GridBagConstraints(0, 10, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
146-
// getContentPane().add(new JPanel(), gbc);
147-
//}
148144
}
149145

150146

sql12/core/src/net/sourceforge/squirrel_sql/fw/gui/action/fileexport/TableExportSelectionPanel.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import javax.swing.JScrollPane;
1919
import javax.swing.JTextField;
2020
import javax.swing.ListSelectionModel;
21+
import java.awt.Color;
2122
import java.awt.GridBagConstraints;
2223
import java.awt.GridBagLayout;
2324
import java.awt.GridLayout;
@@ -94,6 +95,7 @@ else if(exportDialogType == ExportDialogType.RESULT_SET_EXPORT)
9495
bg.add(radMultipleSQLRes);
9596

9697
setBorder(BorderFactory.createEtchedBorder());
98+
setBorder(BorderFactory.createLineBorder(Color.red));
9799
}
98100

99101
private JPanel createButtonPanelForResultSetExport()
@@ -158,27 +160,26 @@ private JPanel createSQLResultExportListPanel()
158160
gbc = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
159161
lstSQLResultsToExport = new JList<>();
160162
lstSQLResultsToExport.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
161-
ret.add(new JScrollPane(lstSQLResultsToExport), gbc);
163+
ret.add(GUIUtils.setPreferredHeight(new JScrollPane(lstSQLResultsToExport), 50), gbc);
162164

163-
gbc = new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
164-
ret.add(createRightSideListEditButtons(), gbc);
165+
gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
166+
ret.add(createEditButtonsAtBottomOfList(), gbc);
165167

166168

167-
168-
gbc = new GridBagConstraints(0, 1, 2, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
169+
gbc = new GridBagConstraints(0, 2, 2, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0);
169170
txtExportFileOrDir = GUIUtils.styleTextFieldToCopyableLabel(new JTextField());
170171
ret.add(txtExportFileOrDir, gbc);
171172

172-
return GUIUtils.setPreferredHeight(ret, 200);
173+
return ret;
173174
}
174175

175-
private JPanel createRightSideListEditButtons()
176+
private JPanel createEditButtonsAtBottomOfList()
176177
{
177178
JPanel ret = new JPanel(new GridBagLayout());
178179

179180

180181
GridBagConstraints gbc;
181-
gbc = new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
182+
gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
182183
btnUp = new JButton(Main.getApplication().getResources().getIcon(SquirrelResources.IImageNames.ARROW_UP));
183184
btnUp.setToolTipText(s_stringMgr.getString("TableExportSelectionPanel.edit.excel.table_sheet.order.tooltip"));
184185
ret.add(GUIUtils.styleAsToolbarButton(btnUp), gbc);
@@ -188,27 +189,27 @@ private JPanel createRightSideListEditButtons()
188189
btnDown.setToolTipText(s_stringMgr.getString("TableExportSelectionPanel.edit.excel.table_sheet.order.tooltip"));
189190
ret.add(GUIUtils.styleAsToolbarButton(btnDown), gbc);
190191

191-
gbc = new GridBagConstraints(1, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 0, 0), 0, 0);
192+
gbc = new GridBagConstraints(2, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0);
192193
btnEdit = new JButton(Main.getApplication().getResources().getIcon(SquirrelResources.IImageNames.EDIT));
193194
btnEdit.setToolTipText(s_stringMgr.getString("TableExportSelectionPanel.edit.excel.table_sheet.name.tooltip"));
194195
ret.add(GUIUtils.styleAsToolbarButton(btnEdit), gbc);
195196

196-
gbc = new GridBagConstraints(1, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 0, 0), 0, 0);
197+
gbc = new GridBagConstraints(3, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0);
197198
btnDelete = new JButton(Main.getApplication().getResources().getIcon(SquirrelResources.IImageNames.DELETE));
198199
btnDelete.setToolTipText(s_stringMgr.getString("TableExportSelectionPanel.remove.sql.result.tooltip"));
199200
ret.add(GUIUtils.styleAsToolbarButton(btnDelete), gbc);
200201

201-
gbc = new GridBagConstraints(1, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 0, 0), 0, 0);
202+
gbc = new GridBagConstraints(4, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0);
202203
btnSaveNames = new JButton(Main.getApplication().getResources().getIcon(SquirrelResources.IImageNames.SAVE));
203204
btnSaveNames.setToolTipText(s_stringMgr.getString("TableExportSelectionPanel.save.names.tooltip"));
204205
ret.add(GUIUtils.styleAsToolbarButton(btnSaveNames), gbc);
205206

206-
gbc = new GridBagConstraints(1, 5, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 0, 0), 0, 0);
207+
gbc = new GridBagConstraints(5, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0);
207208
btnApplySavedNames = new JButton(Main.getApplication().getResources().getIcon(SquirrelResources.IImageNames.OPEN));
208209
btnApplySavedNames.setToolTipText(s_stringMgr.getString("TableExportSelectionPanel.apply.saved.names.tooltip"));
209210
ret.add(GUIUtils.styleAsToolbarButton(btnApplySavedNames), gbc);
210211

211-
gbc = new GridBagConstraints(1, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 0, 0), 0, 0);
212+
gbc = new GridBagConstraints(6, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0);
212213
btnInfo = new SmallToolTipInfoButton(s_stringMgr.getString("TableExportSelectionPanel.info.button"));
213214
ret.add(btnInfo.getButton(), gbc);
214215

0 commit comments

Comments
 (0)