Merge branch 'docs/2_8_1_Release' into Release_2_8_1_Branch
[jalview.git] / src / jalview / gui / FeatureSettings.java
index 689a402..3787efa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
@@ -21,7 +21,6 @@ package jalview.gui;
 import java.io.*;
 import java.util.*;
 import java.util.List;
-
 import java.awt.*;
 import java.awt.event.*;
 import java.beans.PropertyChangeEvent;
@@ -100,12 +99,18 @@ public class FeatureSettings extends JPanel
       public void mousePressed(MouseEvent evt)
       {
         selectedRow = table.rowAtPoint(evt.getPoint());
-        if (javax.swing.SwingUtilities.isRightMouseButton(evt))
+        if (evt.isPopupTrigger())
         {
           popupSort(selectedRow, (String) table.getValueAt(selectedRow, 0),
                   table.getValueAt(selectedRow, 1), fr.minmax, evt.getX(),
                   evt.getY());
         }
+        else if (evt.getClickCount() == 2)
+        {
+          fr.ap.alignFrame.avc.markColumnsContainingFeatures(
+                  evt.isAltDown(),evt.isShiftDown() || evt.isMetaDown(), evt.isMetaDown(),
+                  (String) table.getValueAt(selectedRow, 0));
+        }
       }
     });
 
@@ -133,7 +138,8 @@ public class FeatureSettings extends JPanel
         }
       }
     });
-
+    table.setToolTipText("<html>"+JvSwingUtils
+            .wrapTooltip("Click/drag feature types up or down to change render order.<br/>Double click to select columns containing feature in alignment/current selection<br/>Pressing Alt will select columns outside features rather than inside<br/>Pressing Shift to modify current selection (rather than clear current selection)<br/>Press CTRL or Command/Meta to toggle columns in/outside features<br/>")+"</html>");
     scrollPane.setViewportView(table);
 
     dassourceBrowser = new DasSourceBrowser(this);
@@ -292,6 +298,28 @@ public class FeatureSettings extends JPanel
         });
       }
     }
+    JMenuItem selCols = new JMenuItem(MessageManager.getString("label.select_columns_containing"));
+    selCols.addActionListener(new ActionListener()
+    {
+      
+      @Override
+      public void actionPerformed(ActionEvent arg0)
+      {
+        fr.ap.alignFrame.avc.markColumnsContainingFeatures(false, false, false, type);
+      }
+    });
+    JMenuItem clearCols = new JMenuItem(MessageManager.getString("label.select_columns_not_containing"));
+    clearCols.addActionListener(new ActionListener()
+    {
+      
+      @Override
+      public void actionPerformed(ActionEvent arg0)
+      {
+        fr.ap.alignFrame.avc.markColumnsContainingFeatures(true, false, false, type);
+      }
+    });
+    men.add(selCols);
+    men.add(clearCols);
     men.show(table, x, y);
   }
 
@@ -1131,13 +1159,13 @@ public class FeatureSettings extends JPanel
   private String[] getDisplayedFeatureGroups()
   {
     String[] gps = null;
+    ArrayList<String> _gps = new ArrayList<String>();
     if (fr != null)
     {
 
       if (fr.featureGroups != null)
       {
         Iterator en = fr.featureGroups.keySet().iterator();
-        gps = new String[fr.featureColours.size()];
         int g = 0;
         boolean valid = false;
         while (en.hasNext())
@@ -1147,16 +1175,15 @@ public class FeatureSettings extends JPanel
           if (on != null && on.booleanValue())
           {
             valid = true;
-            gps[g++] = gp;
+            _gps.add(gp);
           }
         }
-        while (g < gps.length)
-        {
-          gps[g++] = null;
-        }
         if (!valid)
         {
           return null;
+        } else {
+          gps = new String[_gps.size()];
+          _gps.toArray(gps);
         }
       }
     }