JAL-3829 right click to view popup menu to show link - maybe better to have a link...
[jalview.git] / src / jalview / jbgui / GStructureChooser.java
index d43495e..8a72b37 100644 (file)
@@ -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;
@@ -88,7 +89,7 @@ public abstract class GStructureChooser extends JPanel
 {
   private static final Font VERDANA_12 = new Font("Verdana", 0, 12);
 
-  protected static final String VIEWS_FILTER = "VIEWS_FILTER";
+  public static final String VIEWS_FILTER = "VIEWS_FILTER";
 
   protected static final String VIEWS_FROM_FILE = "VIEWS_FROM_FILE";
 
@@ -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!!!");
@@ -704,91 +733,6 @@ protected void closeAction(int preferredHeight)
   }
 
   /**
-   * This inner class provides the data model for the structure filter combo-box
-   * 
-   * @author tcnofoegbu
-   *
-   */
-  public class FilterOption
-  {
-    private String name;
-
-    private String value;
-
-    private String view;
-
-    private boolean addSeparatorAfter;
-
-    /**
-     * Model for structure filter option
-     * 
-     * @param name
-     *          - the name of the Option
-     * @param value
-     *          - the value of the option
-     * @param view
-     *          - the category of the filter option
-     * @param addSeparatorAfter
-     *          - if true, a horizontal separator is rendered immediately after
-     *          this filter option, otherwise
-     */
-    public FilterOption(String name, String value, String view,
-            boolean addSeparatorAfter)
-    {
-      this.name = name;
-      this.value = value;
-      this.view = view;
-      this.addSeparatorAfter = addSeparatorAfter;
-    }
-
-    public String getName()
-    {
-      return name;
-    }
-
-    public void setName(String name)
-    {
-      this.name = name;
-    }
-
-    public String getValue()
-    {
-      return value;
-    }
-
-    public void setValue(String value)
-    {
-      this.value = value;
-    }
-
-    public String getView()
-    {
-      return view;
-    }
-
-    public void setView(String view)
-    {
-      this.view = view;
-    }
-
-    @Override
-    public String toString()
-    {
-      return this.name;
-    }
-
-    public boolean isAddSeparatorAfter()
-    {
-      return addSeparatorAfter;
-    }
-
-    public void setAddSeparatorAfter(boolean addSeparatorAfter)
-    {
-      this.addSeparatorAfter = addSeparatorAfter;
-    }
-  }
-
-  /**
    * This inner class provides the provides the data model for associate
    * sequence combo-box - cmb_assSeq
    *