diff --git a/pom.xml b/pom.xml index f228516e..37cccf8c 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.embl.mobie mobie-viewer-fiji - 5.1.7-SNAPSHOT + 5.1.8 diff --git a/src/main/java/org/embl/mobie/lib/table/TableView.java b/src/main/java/org/embl/mobie/lib/table/TableView.java index 8572a8eb..89cb4fc9 100644 --- a/src/main/java/org/embl/mobie/lib/table/TableView.java +++ b/src/main/java/org/embl/mobie/lib/table/TableView.java @@ -30,6 +30,7 @@ import de.embl.cba.tables.Logger; import de.embl.cba.tables.TableUIs; +import de.embl.cba.tables.Tables; import ij.IJ; import ij.gui.GenericDialog; import org.embl.mobie.io.util.IOHelper; @@ -198,6 +199,8 @@ private JMenuBar createMenuBar() menuBar.add( createComputeMenu() ); + menuBar.add( createMiscMenu() ); + return menuBar; } @@ -211,6 +214,13 @@ private JMenu createSelectionMenu() return menu; } + private JMenu createMiscMenu() + { + JMenu menu = new JMenu( "Misc" ); + menu.add( createColumnSearchMenuItem() ); + return menu; + } + private JMenu createComputeMenu() { JMenu menu = new JMenu( "Analyse" ); @@ -355,6 +365,28 @@ private JMenuItem createSelectAllMenuItem() return menuItem; } + private JMenuItem createColumnSearchMenuItem() + { + final JMenuItem menuItem = new JMenuItem( "Focus Column..." ); + menuItem.addActionListener( e -> + SwingUtilities.invokeLater( () -> + { + final String[] columnNames = Tables.getColumnNamesAsArray( jTable ); + final GenericDialog gd = new GenericDialog( "Focus Column" ); + gd.addChoice( "Column", columnNames, columnNames[ 0 ] ); + gd.showDialog(); + if ( gd.wasCanceled() ) return; + final String columnName = gd.getNextChoice(); + int columnIndex = jTable.getColumnModel().getColumnIndex( columnName ); + JViewport viewport = (JViewport) jTable.getParent(); + Rectangle rect = jTable.getCellRect(0, columnIndex, true); + Point pt = viewport.getViewPosition(); + rect.setLocation(rect.x - pt.x, rect.y - pt.y); + viewport.scrollRectToVisible(rect); + }) ); + return menuItem; + } + private JMenuItem createComputeDistanceMenuItem() { final JMenuItem menuItem = new JMenuItem( "Compute Distance to Selected Rows..." );