File tree Expand file tree Collapse file tree 2 files changed +74
-0
lines changed
topcat/src/main/uk/ac/starlink/topcat Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ package uk .ac .starlink .topcat ;
2+
3+ import java .awt .Component ;
4+ import java .awt .Dimension ;
5+ import javax .swing .JTextArea ;
6+
7+ /**
8+ * Window for defining up a mutually exclusive group of subsets
9+ * based on the values of a given table expression.
10+ *
11+ * @author Fergus Baker
12+ * @since 06 Mar 2026
13+ */
14+ public class CellViewWindow extends AuxWindow {
15+ String cellString_ ;
16+ JTextArea textArea_ ;
17+
18+ /**
19+ * Constructor.
20+ *
21+ * Initialises the Cell View window without any display text.
22+ *
23+ * @param title The title for this window.
24+ * @param parent The parent component.
25+ */
26+ @ SuppressWarnings ("this-escape" )
27+ public CellViewWindow ( String title , Component parent ) {
28+ super (title , parent );
29+ textArea_ = new JTextArea ( 5 , 25 );
30+ textArea_ .setEditable ( false );
31+ textArea_ .setLineWrap ( true );
32+ textArea_ .setWrapStyleWord ( true );
33+
34+ /* These cause the this-escape warning, but are perfectly safe in this
35+ * context. */
36+ setPreferredSize ( new Dimension ( 300 , 200 ) );
37+ getContentPane ().add ( textArea_ );
38+ addHelp ( null );
39+ }
40+
41+ /**
42+ * Used to set the text to display in the Cell View window.
43+ *
44+ * @param text Text to display in this component.
45+ */
46+ public void setText ( String text ) {
47+ textArea_ .selectAll ();
48+ textArea_ .replaceSelection ( text );
49+ }
50+ }
Original file line number Diff line number Diff line change @@ -563,6 +563,30 @@ public void actionPerformed( ActionEvent evt ) {
563563 popper .add ( explodeAct );
564564 }
565565
566+ popper .addSeparator ();
567+
568+ /* Get the current row that is being selected. */
569+ final int jrow = rowSelectionModel_ .getMinSelectionIndex ();
570+
571+ /* Action to open the cell text in a viewer. */
572+ Action viewCellAct =
573+ new BasicAction ( "View Cell" , ResourceIcon .ZOOM_IN ,
574+ "View the cell contents in a viewer." ) {
575+ public void actionPerformed ( ActionEvent evt ) {
576+ CellViewWindow cell_view =
577+ new CellViewWindow ( "Cell Viewer" , parent );
578+ TableModel tm = jtable_ .getModel ();
579+ String selectedCell = tm .getValueAt ( jrow , jcol ).toString ();
580+ cell_view .setText ( selectedCell );
581+ cell_view .setVisible ( true );
582+ }
583+ };
584+
585+ /* Only enable the Cell View option if something is selected. If no row
586+ * column is selected, it will be displayed in deactived state. */
587+ viewCellAct .setEnabled ( jrow >= 0 && jcol >= 0 );
588+ popper .add ( viewCellAct );
589+
566590 return popper ;
567591 }
568592
You can’t perform that action at this time.
0 commit comments