From: Jim Procter Date: Fri, 24 Sep 2021 13:19:40 +0000 (+0100) Subject: JAL-3829 right click to view popup menu to show link - maybe better to have a link... X-Git-Tag: Release_2_11_2_0~30^2^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=752f89e5730d804d1982ce4a09ab0f9266dde03d;p=jalview.git JAL-3829 right click to view popup menu to show link - maybe better to have a link button in the table instead ? --- diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 9f9de6e..694b063 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -21,19 +21,22 @@ package jalview.gui; -import java.util.Locale; - +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; import java.util.concurrent.Executors; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuItem; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.table.AbstractTableModel; @@ -50,6 +53,7 @@ import jalview.fts.core.FTSDataColumnPreferences; import jalview.fts.core.FTSRestRequest; import jalview.fts.core.FTSRestResponse; import jalview.fts.service.pdb.PDBFTSRestClient; +import jalview.fts.service.threedbeacons.TDB_FTSData; import jalview.gui.structurechooser.PDBStructureChooserQuerySource; import jalview.gui.structurechooser.StructureChooserQuerySource; import jalview.gui.structurechooser.ThreeDBStructureChooserQuerySource; @@ -793,6 +797,45 @@ public class StructureChooser extends GStructureChooser .setEnabled(selectedCount > 1 || targetView.getItemCount() > 0); } + @Override + protected boolean showPopupFor(int selectedRow) + { + 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++; + } + String pageUrl = row.getModelViewUrl(); + JMenu popup = new JMenu("3D Beacons"); + JMenuItem viewUrl = new JMenuItem("View model web page"); + viewUrl.addActionListener( + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) + { + Desktop.showUrl(pageUrl); + } + } + ); + popup.add(viewUrl); + SwingUtilities.invokeLater(new Runnable() { + public void run() { popup.setVisible(true); } + }); + return true; + } + // event not handled by us + return false; + } /** * Validates inputs from the Manual PDB entry panel */ diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index 2a6c1f2..8a72b37 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -39,6 +39,7 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridLayout; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -244,7 +245,7 @@ public abstract class GStructureChooser extends JPanel + "...\"") : JvSwingUtils.wrapTooltip(true, toolTipText))); return toolTipText; - } + } }; public GStructureChooser() @@ -306,15 +307,42 @@ public abstract class GStructureChooser extends JPanel tbl_summary.addMouseListener(new MouseAdapter() { @Override + public void mousePressed(MouseEvent e) + { + if (!popupAction(e)) + { + super.mousePressed(e); + } + } + @Override public void mouseClicked(MouseEvent e) { - validateSelections(); + if (!popupAction(e)) + { + validateSelections(); + } } @Override public void mouseReleased(MouseEvent e) { + if (!popupAction(e)) + { validateSelections(); + } + } + boolean popupAction(MouseEvent e) + { + if (e.isPopupTrigger()) + { + Point pt = e.getPoint(); + int selectedRow = tbl_summary.rowAtPoint(pt); + if (showPopupFor(selectedRow)) + { + return true; + } + } + return false; } }); tbl_summary.addKeyListener(new KeyAdapter() @@ -666,6 +694,7 @@ public abstract class GStructureChooser extends JPanel } +protected abstract boolean showPopupFor(int selectedRow); protected void closeAction(int preferredHeight) { // System.out.println(">>>>>>>>>> closing internal frame!!!");