From: Jim Procter Date: Fri, 24 Sep 2021 16:23:24 +0000 (+0100) Subject: JAL-3829 open web page for 3d beacons structure by right-clicking and selecting pop... X-Git-Tag: Release_2_11_2_0~30^2^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Ffeatures%2Fr2_11_2%2FJAL-3829_3dbeacons;p=jalview.git JAL-3829 open web page for 3d beacons structure by right-clicking and selecting pop up menu item --- diff --git a/src/jalview/fts/service/threedbeacons/TDB_FTSData.java b/src/jalview/fts/service/threedbeacons/TDB_FTSData.java index 3418949..6745bb8 100644 --- a/src/jalview/fts/service/threedbeacons/TDB_FTSData.java +++ b/src/jalview/fts/service/threedbeacons/TDB_FTSData.java @@ -112,4 +112,9 @@ public class TDB_FTSData implements FTSData return (String) getField(Page_URL); } + public String getModelId() + { + return (String) getField(Model_id); + } + } diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 694b063..4807489 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -37,6 +37,7 @@ import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.table.AbstractTableModel; @@ -798,25 +799,18 @@ public class StructureChooser extends GStructureChooser } @Override - protected boolean showPopupFor(int selectedRow) + protected boolean showPopupFor(int selectedRow, int x, int y) { FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption .getSelectedItem()); String currentView = selectedFilterOpt.getView(); + if (currentView == VIEWS_FILTER && data instanceof ThreeDBStructureChooserQuerySource) { - TDB_FTSData row=null; - int i=1; - for (FTSData el:discoveredStructuresSet) { - if (i==selectedRow) { - row = (TDB_FTSData) el; - break; - } - i++; - } + TDB_FTSData row=((ThreeDBStructureChooserQuerySource)data).getFTSDataFor(getResultTable(), selectedRow, discoveredStructuresSet); String pageUrl = row.getModelViewUrl(); - JMenu popup = new JMenu("3D Beacons"); + JPopupMenu popup = new JPopupMenu("3D Beacons"); JMenuItem viewUrl = new JMenuItem("View model web page"); viewUrl.addActionListener( new ActionListener() { @@ -829,7 +823,7 @@ public class StructureChooser extends GStructureChooser ); popup.add(viewUrl); SwingUtilities.invokeLater(new Runnable() { - public void run() { popup.setVisible(true); } + public void run() { popup.show(getResultTable(), x, y); } }); return true; } diff --git a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java index 5a7f7d5..cdf456c 100644 --- a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java @@ -550,4 +550,20 @@ public class ThreeDBStructureChooserQuerySource return upResponse; } + public TDB_FTSData getFTSDataFor(JTable restable, int selectedRow, + Collection discoveredStructuresSet) + { + int idColumnIndex = restable.getColumn("Model id").getModelIndex(); + + String modelId = (String) restable.getValueAt(selectedRow, idColumnIndex); + for (FTSData row:discoveredStructuresSet) + { + if (row instanceof TDB_FTSData && ((TDB_FTSData)row).getModelId().equals(modelId)) + { + return ((TDB_FTSData)row); + } + } + return null; + } + } \ No newline at end of file diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index 8a72b37..fadfe6d 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -337,7 +337,7 @@ public abstract class GStructureChooser extends JPanel { Point pt = e.getPoint(); int selectedRow = tbl_summary.rowAtPoint(pt); - if (showPopupFor(selectedRow)) + if (showPopupFor(selectedRow,pt.x,pt.y)) { return true; } @@ -694,7 +694,7 @@ public abstract class GStructureChooser extends JPanel } -protected abstract boolean showPopupFor(int selectedRow); +protected abstract boolean showPopupFor(int selectedRow, int x, int y); protected void closeAction(int preferredHeight) { // System.out.println(">>>>>>>>>> closing internal frame!!!");