X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureSettings.java;h=f81ecce0e7a85853f21a51aea64cc4d977fff019;hb=b1613533d44e86c95bb2ae1e1428330b314df1f6;hp=44265ed24f36e46e20af245ea6f96ac24f672ad4;hpb=fab0afc9e1e7a5ca460f0cbd48545536f989a435;p=jalview.git diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 44265ed..f81ecce 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -22,7 +22,6 @@ package jalview.gui; import jalview.api.FeatureColourI; import jalview.api.FeatureSettingsControllerI; -import jalview.bin.Jalview; import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceI; import jalview.datamodel.features.FeatureMatcher; @@ -46,7 +45,6 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Font; import java.awt.Graphics; import java.awt.GridLayout; @@ -100,6 +98,7 @@ import javax.swing.border.Border; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.AbstractTableModel; +import javax.swing.table.JTableHeader; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; @@ -132,7 +131,8 @@ public class FeatureSettings extends JPanel private static final int MIN_HEIGHT = 400; - private final static String BASE_TOOLTIP = MessageManager.getString("label.click_to_edit"); + private final static String BASE_TOOLTIP = MessageManager + .getString("label.click_to_edit"); final FeatureRenderer fr; @@ -164,12 +164,6 @@ public class FeatureSettings extends JPanel int selectedRow = -1; - JButton fetchDAS = new JButton(); - - JButton saveDAS = new JButton(); - - JButton cancelDAS = new JButton(); - boolean resettingTable = false; /* @@ -231,13 +225,14 @@ 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: break; } - + return tip; } @@ -256,21 +251,23 @@ public class FeatureSettings extends JPanel return loc; } }; - table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12)); + JTableHeader tableHeader = table.getTableHeader(); + tableHeader.setFont(new Font("Verdana", Font.PLAIN, 12)); + tableHeader.setReorderingAllowed(false); + table.setFont(new Font("Verdana", Font.PLAIN, 12)); ToolTipManager.sharedInstance().registerComponent(table); - - table.setDefaultEditor(FeatureColour.class, new ColorEditor(this)); + table.setDefaultEditor(FeatureColour.class, new ColorEditor()); table.setDefaultRenderer(FeatureColour.class, new ColorRenderer()); - table.setDefaultEditor(FeatureMatcherSet.class, new FilterEditor(this)); + table.setDefaultEditor(FeatureMatcherSet.class, new FilterEditor()); table.setDefaultRenderer(FeatureMatcherSet.class, new FilterRenderer()); - + TableColumn colourColumn = new TableColumn(COLOUR_COLUMN, 75, - new ColorRenderer(), new ColorEditor(this)); + new ColorRenderer(), new ColorEditor()); table.addColumn(colourColumn); TableColumn filterColumn = new TableColumn(FILTER_COLUMN, 75, - new FilterRenderer(), new FilterEditor(this)); + new FilterRenderer(), new FilterEditor()); table.addColumn(filterColumn); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); @@ -285,8 +282,7 @@ public class FeatureSettings extends JPanel if (evt.isPopupTrigger()) { Object colour = table.getValueAt(selectedRow, COLOUR_COLUMN); - popupSort(selectedRow, type, colour, fr.getMinMax(), evt.getX(), - evt.getY()); + showPopupMenu(selectedRow, type, colour, evt.getPoint()); } else if (evt.getClickCount() == 2) { @@ -307,8 +303,7 @@ public class FeatureSettings extends JPanel { String type = (String) table.getValueAt(selectedRow, TYPE_COLUMN); Object colour = table.getValueAt(selectedRow, COLOUR_COLUMN); - popupSort(selectedRow, type, colour, fr.getMinMax(), evt.getX(), - evt.getY()); + showPopupMenu(selectedRow, type, colour, evt.getPoint()); } } }); @@ -371,18 +366,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( @@ -399,56 +385,31 @@ public class FeatureSettings extends JPanel inConstruction = false; } - protected void popupSort(final int rowSelected, final String type, - final Object typeCol, final Map minmax, int x, - int y) + /** + * Constructs and shows a popup menu of possible actions on the selected row + * and feature type + * + * @param rowSelected + * @param type + * @param typeCol + * @param pt + */ + 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")); variableColourCB.setSelected(!featureColour.isSimpleColour()); men.add(variableColourCB); - + /* * checkbox action listener doubles up as listener to OK * from the variable colour / filters dialog @@ -460,12 +421,16 @@ public class FeatureSettings extends JPanel { if (e.getSource() == variableColourCB) { + men.setVisible(true); // BH 2018 for JavaScript because this is a + // checkbox + men.setVisible(false); // BH 2018 for JavaScript because this is a + // checkbox if (featureColour.isSimpleColour()) { /* * 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 @@ -473,7 +438,8 @@ public class FeatureSettings extends JPanel /* * toggle variable to simple colour - show colour chooser */ - String title = MessageManager.getString("label.select_colour"); + String title = MessageManager + .formatMessage("label.select_colour_for", type); ColourChooserListener listener = new ColourChooserListener() { @Override @@ -482,15 +448,17 @@ 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 { + else + { if (e.getSource() instanceof FeatureTypeSettings) { /* @@ -499,12 +467,42 @@ public class FeatureSettings extends JPanel */ FeatureColourI fci = fr.getFeatureColours().get(type); table.setValueAt(fci, rowSelected, COLOUR_COLUMN); - table.validate(); + // BH 2018 setting a table value does not invalidate it. + // System.out.println("FeatureSettings is valied" + + // 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")); @@ -552,7 +550,7 @@ public class FeatureSettings extends JPanel men.add(clearCols); men.add(hideCols); men.add(hideOtherCols); - men.show(table, x, y); + men.show(table, pt.x, pt.y); } @Override @@ -765,8 +763,8 @@ public class FeatureSettings extends JPanel } /** - * Updates 'originalData' (used for restore on Cancel) if we detect that changes - * have been made outwith this dialog + * Updates 'originalData' (used for restore on Cancel) if we detect that + * changes have been made outwith this dialog *