added Platform settings separating mouse use of win/mac difference
[jalview.git] / src / jalview / gui / FeatureSettings.java
index 93b5f31..26cb104 100644 (file)
@@ -98,7 +98,6 @@ import javax.swing.ToolTipManager;
 import javax.swing.border.Border;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
-import javax.swing.plaf.TableUI;
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.TableCellEditor;
 import javax.swing.table.TableCellRenderer;
@@ -258,7 +257,8 @@ public class FeatureSettings extends JPanel
           FeatureMatcherSet o = (FeatureMatcherSet) table.getValueAt(row,
                   column);
           tip = o.isEmpty()
-                  ? MessageManager.getString("label.filters_tooltip")
+                  ? MessageManager
+                          .getString("label.configure_feature_tooltip")
                   : o.toString();
           break;
         default:
@@ -403,18 +403,9 @@ public class FeatureSettings extends JPanel
 
     frame = new JInternalFrame();
     frame.setContentPane(this);
-    if (Platform.isAMac())
-    {
-      Desktop.addInternalFrame(frame,
-              MessageManager.getString("label.sequence_feature_settings"),
-              600, 480);
-    }
-    else
-    {
-      Desktop.addInternalFrame(frame,
-              MessageManager.getString("label.sequence_feature_settings"),
-              600, 450);
-    }
+    Desktop.addInternalFrame(frame,
+            MessageManager.getString("label.sequence_feature_settings"),
+            600, Platform.isAMacAndNotJS() ? 480 : 450);
     frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
 
     frame.addInternalFrameListener(
@@ -443,44 +434,13 @@ public class FeatureSettings extends JPanel
   protected void showPopupMenu(final int rowSelected, final String type,
           final Object typeCol, final Point pt)
   {
-    final FeatureColourI featureColour = (FeatureColourI) typeCol;
-
     JPopupMenu men = new JPopupMenu(MessageManager
             .formatMessage("label.settings_for_param", new String[]
             { type }));
-    JMenuItem scr = new JMenuItem(
-            MessageManager.getString("label.sort_by_score"));
-    men.add(scr);
-    final FeatureSettings me = this;
-    scr.addActionListener(new ActionListener()
-    {
-
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        me.af.avc
-                .sortAlignmentByFeatureScore(Arrays.asList(new String[]
-                { type }));
-      }
-    });
-    JMenuItem dens = new JMenuItem(
-            MessageManager.getString("label.sort_by_density"));
-    dens.addActionListener(new ActionListener()
-    {
-
-      @Override
-      public void actionPerformed(ActionEvent e)
-      {
-        me.af.avc
-                .sortAlignmentByFeatureDensity(Arrays.asList(new String[]
-                { type }));
-      }
-    });
-    men.add(dens);
+    final FeatureColourI featureColour = (FeatureColourI) typeCol;
 
     /*
-     * variable colour options include colour by label, by score,
-     * by selected attribute text, or attribute value
+     * menu option to select (or deselect) variable colour
      */
     final JCheckBoxMenuItem variableColourCB = new JCheckBoxMenuItem(
             MessageManager.getString("label.variable_colour"));
@@ -505,7 +465,7 @@ public class FeatureSettings extends JPanel
             /*
              * toggle simple colour to variable colour - show dialog
              */
-            FeatureTypeSettings fc = new FeatureTypeSettings(me.fr, type);
+            FeatureTypeSettings fc = new FeatureTypeSettings(fr, type);
             fc.addActionListener(this);
           }
           else
@@ -522,12 +482,13 @@ public class FeatureSettings extends JPanel
                 table.setValueAt(new FeatureColour(c), rowSelected,
                         COLOUR_COLUMN);
                 table.validate();
-                me.updateFeatureRenderer(
+                updateFeatureRenderer(
                         ((FeatureTableModel) table.getModel()).getData(),
                         false);
               }
             };
-            JalviewColourChooser.showColourChooser(me, title, featureColour.getMaxColour(), listener);
+            JalviewColourChooser.showColourChooser(FeatureSettings.this, title,
+               featureColour.getMaxColour(), listener);
           }
         }
         else    
@@ -541,12 +502,41 @@ public class FeatureSettings extends JPanel
             FeatureColourI fci = fr.getFeatureColours().get(type);
             table.setValueAt(fci, rowSelected, COLOUR_COLUMN);
             // BH 2018 setting a table value does not invalidate it.
-            System.out.println("FeatureSettings is valied" + table.isValid());
-//            table.validate();
+//                 System.out.println("FeatureSettings is valied" + table.isValid());
+//                 table.validate();
           }
         }
       }
     });
+    
+    men.addSeparator();
+
+    JMenuItem scr = new JMenuItem(
+            MessageManager.getString("label.sort_by_score"));
+    men.add(scr);
+    scr.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        af.avc.sortAlignmentByFeatureScore(Arrays.asList(new String[]
+                { type }));
+      }
+    });
+    JMenuItem dens = new JMenuItem(
+            MessageManager.getString("label.sort_by_density"));
+    dens.addActionListener(new ActionListener()
+    {
+
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        af.avc.sortAlignmentByFeatureDensity(Arrays.asList(new String[]
+                { type }));
+      }
+    });
+    men.add(dens);
 
     JMenuItem selCols = new JMenuItem(
             MessageManager.getString("label.select_columns_containing"));
@@ -1509,7 +1499,7 @@ public class FeatureSettings extends JPanel
     private String[] columnNames = {
         MessageManager.getString("label.feature_type"),
         MessageManager.getString("action.colour"),
-        MessageManager.getString("label.filter"),
+        MessageManager.getString("label.configuration"),
         MessageManager.getString("label.show") };
 
     private Object[][] data;
@@ -1713,8 +1703,6 @@ public class FeatureSettings extends JPanel
 class ColorEditor extends AbstractCellEditor
           implements TableCellEditor, ActionListener
   {
-//    FeatureSettings me;
-
     FeatureColourI currentColor;
 
     FeatureTypeSettings chooser;
@@ -1813,7 +1801,16 @@ class ColorEditor extends AbstractCellEditor
       }
     }
 
-    // Implement the one CellEditor method that AbstractCellEditor doesn't.
+    /**
+     * Override allows access to this method from anonymous inner classes 
+     */
+    @Override
+       protected void fireEditingStopped() 
+    {
+           super.fireEditingStopped();
+       }
+
+       // Implement the one CellEditor method that AbstractCellEditor doesn't.
     @Override
     public Object getCellEditorValue()
     {
@@ -1829,7 +1826,7 @@ class ColorEditor extends AbstractCellEditor
       this.rowSelected = row;
       type = table.getValueAt(row, TYPE_COLUMN).toString();
       button.setOpaque(true);
-      button.setBackground(getBackground());
+      button.setBackground(FeatureSettings.this.getBackground());
       if (!currentColor.isSimpleColour())
       {
         JLabel btn = new JLabel();
@@ -1944,7 +1941,7 @@ class FilterEditor extends AbstractCellEditor
       this.rowSelected = row;
       type = table.getValueAt(row, TYPE_COLUMN).toString();
       button.setOpaque(true);
-      button.setBackground(getBackground());
+      button.setBackground(FeatureSettings.this.getBackground());
       button.setText(currentFilter.toString());
       button.setIcon(null);
       return button;