Skip to content

Commit 24a1b7b

Browse files
committed
Feature: #48 (comment)
Cell data popup: When the popup is pinned it is updated by table selection change and single mouse click.
1 parent dae08a0 commit 24a1b7b

File tree

7 files changed

+74
-29
lines changed

7 files changed

+74
-29
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+
https://github.com/squirrel-sql-client/squirrel-sql-code/issues/48#issuecomment-2566434346
10+
Cell data popup: When the popup is pinned it is updated by table selection change and single mouse click.
11+
912
https://github.com/squirrel-sql-client/squirrel-sql-code/issues/54
1013
Object Tree: Content tabs now show the number of rows.
1114
If the number of rows is limited, the display indicates this,

sql12/core/src/net/sourceforge/squirrel_sql/client/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ public CellDetailDisplayModeManager getCellDetailDisplayModeManager()
15621562
}
15631563

15641564
@Override
1565-
public PinnedCellDataDialogHandler getStickyCellDataDialog()
1565+
public PinnedCellDataDialogHandler getPinnedCellDataDialogHandler()
15661566
{
15671567
return _pinnedCellDataDialogHandler;
15681568
}

sql12/core/src/net/sourceforge/squirrel_sql/client/IApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,5 +317,5 @@ interface IMenuIDs extends MainFrame.IMenuIDs
317317

318318
CellDetailDisplayModeManager getCellDetailDisplayModeManager();
319319

320-
PinnedCellDataDialogHandler getStickyCellDataDialog();
320+
PinnedCellDataDialogHandler getPinnedCellDataDialogHandler();
321321
}

sql12/core/src/net/sourceforge/squirrel_sql/fw/datasetviewer/DataSetViewerTablePanel.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2121
*/
2222

23+
import net.sourceforge.squirrel_sql.client.Main;
2324
import net.sourceforge.squirrel_sql.client.session.DataModelImplementationDetails;
2425
import net.sourceforge.squirrel_sql.client.session.ISession;
2526
import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.CellComponentFactory;
2627
import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.LimitReadLengthFeatureUnstable;
28+
import net.sourceforge.squirrel_sql.fw.datasetviewer.celldatapopup.CellDataDialogHandler;
2729
import net.sourceforge.squirrel_sql.fw.datasetviewer.tablefind.DefaultFindService;
2830
import net.sourceforge.squirrel_sql.fw.datasetviewer.tablefind.FindService;
2931

@@ -96,10 +98,11 @@ public void init(IDataSetUpdateableModel dataSetUpdateableModel, int listSelecti
9698

9799
private void onSelectionChanged(ListSelectionEvent e)
98100
{
99-
//if(e.getValueIsAdjusting())
100-
//{
101-
// return;
102-
//}
101+
if(false == e.getValueIsAdjusting())
102+
{
103+
Main.getApplication().getPinnedCellDataDialogHandler();
104+
CellDataDialogHandler.showSelectedValueInPinnedCellDataDialog(_table, isTableEditable());
105+
}
103106

104107
for(RowColSelectedCountListener l : _rowColSelectedCountListeners.toArray(new RowColSelectedCountListener[0]))
105108
{
@@ -300,14 +303,16 @@ public void moveColumnsToFront(ArrayList<ExtTableColumn> columnsToMoveToFront)
300303
* MyTable.isCellEditable(). We do not bother to distinguish between
301304
* editable and non-editable cells within the same table.
302305
*/
303-
public boolean isTableEditable() {
306+
public boolean isTableEditable()
307+
{
304308
return false;
305309
}
306310

307311
/**
308312
* Tell the table whether particular columns are editable.
309313
*/
310-
public boolean isColumnEditable(int col, Object originalValue) {
314+
public boolean isColumnEditable(int col, Object originalValue)
315+
{
311316
return false;
312317
}
313318

@@ -318,7 +323,8 @@ public boolean isColumnEditable(int col, Object originalValue) {
318323
* to be able to view the entire contents of the cell even if it was not
319324
* completely loaded during the initial table setup.
320325
*/
321-
public boolean needToReRead(int col, Object originalValue) {
326+
public boolean needToReRead(int col, Object originalValue)
327+
{
322328
// call the DataType object for this column and have it check the current value
323329
return CellComponentFactory.needToReRead(getColDefs()[col], originalValue);
324330
}

sql12/core/src/net/sourceforge/squirrel_sql/fw/datasetviewer/celldatapopup/CellDataDialog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ private void onToggleSticky(boolean sticky)
6969
{
7070
if(sticky)
7171
{
72-
Main.getApplication().getStickyCellDataDialog().setStickyCellDataDialog(this);
72+
Main.getApplication().getPinnedCellDataDialogHandler().setPinnedCellDataDialog(this);
7373
}
7474
else
7575
{
76-
Main.getApplication().getStickyCellDataDialog().clearStickyCellDataDialog();
76+
Main.getApplication().getPinnedCellDataDialogHandler().clearPinnedCellDataDialog();
7777
}
7878
}
7979

sql12/core/src/net/sourceforge/squirrel_sql/fw/datasetviewer/celldatapopup/CellDataDialogHandler.java

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import net.sourceforge.squirrel_sql.client.Main;
2222
import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
23+
import net.sourceforge.squirrel_sql.fw.datasetviewer.ExtTableColumn;
2324
import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
2425
import net.sourceforge.squirrel_sql.fw.props.Props;
2526
import net.sourceforge.squirrel_sql.fw.util.StringManager;
@@ -28,6 +29,7 @@
2829
import javax.swing.CellEditor;
2930
import javax.swing.JTable;
3031
import javax.swing.SwingUtilities;
32+
import javax.swing.table.TableColumn;
3133
import java.awt.Component;
3234
import java.awt.Dimension;
3335
import java.awt.Point;
@@ -70,17 +72,51 @@ public static void showDialog(JTable table,
7072
editor.cancelCellEditing();
7173
}
7274

73-
if(null == Main.getApplication().getStickyCellDataDialog().getStickyPopup())
75+
CellDataDialog pinnedCellDataDialog = Main.getApplication().getPinnedCellDataDialogHandler().getPinnedCellDataDialog();
76+
if(null == pinnedCellDataDialog)
7477
{
7578
createAndShowCellDataDialog(table, table.getColumnName(colIx), rowIx, colIx, colDef, obj, isModelEditable, evt);
7679
}
77-
else
80+
81+
// Redundant because handled by showSelectedValueInPinnedCellDataDialog(...) below
82+
//else
83+
//{
84+
// pinnedCellDataDialog.initCellDisplayPanel(table, table.getColumnName(colIx), rowIx, colIx, colDef, obj, isModelEditable, true);
85+
//}
86+
}
87+
88+
public static void showSelectedValueInPinnedCellDataDialog(JTable table, boolean isModelEditable)
89+
{
90+
CellDataDialog pinnedCellDataDialog = Main.getApplication().getPinnedCellDataDialogHandler().getPinnedCellDataDialog();
91+
92+
if(null == pinnedCellDataDialog)
93+
{
94+
return;
95+
}
96+
97+
int selectedRow = table.getSelectedRow();
98+
int selectedColumn = table.getSelectedColumn();
99+
100+
if(-1 == selectedRow || -1 == selectedColumn)
101+
{
102+
return;
103+
}
104+
105+
TableColumn column = table.getColumnModel().getColumn(selectedColumn);
106+
107+
if(false == column instanceof ExtTableColumn)
78108
{
79-
CellDataDialog cellDataDialog = Main.getApplication().getStickyCellDataDialog().getStickyPopup();
80-
cellDataDialog.initCellDisplayPanel(table, table.getColumnName(colIx), rowIx, colIx, colDef, obj, isModelEditable, true);
109+
return;
81110
}
111+
112+
Object obj = table.getValueAt(selectedRow, selectedColumn);
113+
ColumnDisplayDefinition colDef = ((ExtTableColumn) column).getColumnDisplayDefinition();
114+
115+
pinnedCellDataDialog.initCellDisplayPanel(table, table.getColumnName(selectedColumn), selectedRow, selectedColumn, colDef, obj, isModelEditable, true);
82116
}
83117

118+
119+
84120
private static void createAndShowCellDataDialog(JTable parentTable,
85121
String columnName,
86122
int rowIx,

sql12/core/src/net/sourceforge/squirrel_sql/fw/datasetviewer/celldatapopup/PinnedCellDataDialogHandler.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
public class PinnedCellDataDialogHandler
77
{
8-
private CellDataDialog _stickyCellDataDialog;
8+
private CellDataDialog _pinnedCellDataDialog;
99

1010
private WindowAdapter _windowAdapter;
1111

@@ -16,36 +16,36 @@ public PinnedCellDataDialogHandler()
1616
@Override
1717
public void windowClosing(WindowEvent e)
1818
{
19-
clearStickyCellDataDialog();
19+
clearPinnedCellDataDialog();
2020
}
2121

2222
@Override
2323
public void windowClosed(WindowEvent e)
2424
{
25-
clearStickyCellDataDialog();
25+
clearPinnedCellDataDialog();
2626
}
2727
};
2828
}
2929

30-
public void setStickyCellDataDialog(CellDataDialog stickyCellDataDialog)
30+
void setPinnedCellDataDialog(CellDataDialog pinnedCellDataDialog)
3131
{
32-
clearStickyCellDataDialog();
33-
_stickyCellDataDialog = stickyCellDataDialog;
34-
_stickyCellDataDialog.addWindowListener(_windowAdapter);
32+
clearPinnedCellDataDialog();
33+
_pinnedCellDataDialog = pinnedCellDataDialog;
34+
_pinnedCellDataDialog.addWindowListener(_windowAdapter);
3535
}
3636

37-
public void clearStickyCellDataDialog()
37+
void clearPinnedCellDataDialog()
3838
{
39-
if(null != _stickyCellDataDialog)
39+
if(null != _pinnedCellDataDialog)
4040
{
41-
_stickyCellDataDialog.switchOffPinned();
42-
_stickyCellDataDialog.removeWindowListener(_windowAdapter);
43-
_stickyCellDataDialog = null;
41+
_pinnedCellDataDialog.switchOffPinned();
42+
_pinnedCellDataDialog.removeWindowListener(_windowAdapter);
43+
_pinnedCellDataDialog = null;
4444
}
4545
}
4646

47-
public CellDataDialog getStickyPopup()
47+
CellDataDialog getPinnedCellDataDialog()
4848
{
49-
return _stickyCellDataDialog;
49+
return _pinnedCellDataDialog;
5050
}
5151
}

0 commit comments

Comments
 (0)