Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions topcat/src/main/uk/ac/starlink/topcat/CellViewWindow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package uk.ac.starlink.topcat;

import java.awt.Component;
import java.awt.Dimension;
import javax.swing.JTextArea;

/**
* Window for defining up a mutually exclusive group of subsets
* based on the values of a given table expression.
*
* @author Fergus Baker
* @since 06 Mar 2026
*/
public class CellViewWindow extends AuxWindow {
String cellString_;
JTextArea textArea_;

/**
* Constructor.
*
* Initialises the Cell View window without any display text.
*
* @param title The title for this window.
* @param parent The parent component.
*/
@SuppressWarnings("this-escape")
public CellViewWindow( String title, Component parent ) {
super(title, parent);
textArea_ = new JTextArea( 5, 25 );
textArea_.setEditable( false );
textArea_.setLineWrap( true );
textArea_.setWrapStyleWord( true );

/* These cause the this-escape warning, but are perfectly safe in this
* context. */
setPreferredSize( new Dimension( 300, 200 ) );
getContentPane().add( textArea_ );
addHelp( null );
}

/**
* Used to set the text to display in the Cell View window.
*
* @param text Text to display in this component.
*/
public void setText( String text ) {
textArea_.selectAll();
textArea_.replaceSelection( text );
}
}
24 changes: 24 additions & 0 deletions topcat/src/main/uk/ac/starlink/topcat/TableViewerWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,30 @@ public void actionPerformed( ActionEvent evt ) {
popper.add( explodeAct );
}

popper.addSeparator();

/* Get the current row that is being selected. */
final int jrow = rowSelectionModel_.getMinSelectionIndex();

/* Action to open the cell text in a viewer. */
Action viewCellAct =
new BasicAction( "View Cell", ResourceIcon.ZOOM_IN,
"View the cell contents in a viewer." ) {
public void actionPerformed( ActionEvent evt ) {
CellViewWindow cell_view =
new CellViewWindow( "Cell Viewer", parent );
TableModel tm = jtable_.getModel();
String selectedCell = tm.getValueAt( jrow, jcol ).toString();
cell_view.setText( selectedCell );
cell_view.setVisible( true );
}
};

/* Only enable the Cell View option if something is selected. If no row
* column is selected, it will be displayed in deactived state. */
viewCellAct.setEnabled( jrow >= 0 && jcol >= 0 );
popper.add( viewCellAct );

return popper;
}

Expand Down