X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPreferences.java;h=92854ad7825bfeb160ddec363aa767dccbbdae28;hb=079d0d74b8aa7eacf7675b6efd23e7c2a34593a7;hp=6fdaa0d52b3636af656ef536ed1759b933ff4978;hpb=75d0279984e769ace9e422376b4104a4522cf0c3;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 6fdaa0d..92854ad 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -54,8 +54,6 @@ import java.util.ArrayList; import java.util.List; import javax.help.HelpSetException; -import javax.swing.JButton; -import javax.swing.JColorChooser; import javax.swing.JFileChooser; import javax.swing.JInternalFrame; import javax.swing.JPanel; @@ -110,6 +108,14 @@ public class Preferences extends GPreferences public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY"; + public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START"; + + public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP"; + + public static final String GAP_COLOUR = "GAP_COLOUR"; + + public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR"; + private static final int MIN_FONT_SIZE = 1; private static final int MAX_FONT_SIZE = 30; @@ -161,8 +167,6 @@ public class Preferences extends GPreferences JInternalFrame frame; - DasSourceBrowser dasSource; - private WsPreferences wsPrefs; private OptionsParam promptEachTimeOpt = new OptionsParam( @@ -183,8 +187,6 @@ public class Preferences extends GPreferences super(); frame = new JInternalFrame(); frame.setContentPane(this); - dasSource = new DasSourceBrowser(); - dasTab.add(dasSource, BorderLayout.CENTER); wsPrefs = new WsPreferences(); wsTab.add(wsPrefs, BorderLayout.CENTER); int width = 500, height = 450; @@ -308,10 +310,21 @@ public class Preferences extends GPreferences Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", Color.orange)); maxColour.setBackground( Cache.getDefaultColour("ANNOTATIONCOLOUR_MAX", Color.red)); + + /* + * Set overview panel defaults + */ gapColour.setBackground( - Cache.getDefaultColour("GAP_COLOUR", Color.lightGray)); + Cache.getDefaultColour(GAP_COLOUR, + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP)); hiddenColour.setBackground( - Cache.getDefaultColour("HIDDEN_COLOUR", Color.darkGray)); + Cache.getDefaultColour(HIDDEN_COLOUR, + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN)); + useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false)); + gapLabel.setEnabled(!useLegacyGap.isSelected()); + gapColour.setEnabled(!useLegacyGap.isSelected()); + showHiddenAtStart + .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, true)); /* * Set Structure tab defaults. @@ -368,7 +381,8 @@ public class Preferences extends GPreferences new RowSorter.SortKey(m.getNameColumn(), SortOrder.ASCENDING)); sorter.setSortKeys(sortKeys); - sorter.sort(); + // BH 2018 setSortKeys will do the sort + // sorter.sort(); // set up filtering ActionListener onReset; @@ -507,8 +521,10 @@ public class Preferences extends GPreferences autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false)); userIdWidth.setEnabled(!autoIdWidth.isSelected()); userIdWidthlabel.setEnabled(!autoIdWidth.isSelected()); - Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH"); + Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH"); userIdWidth.setText(wi == null ? "" : wi.toString()); + // TODO: refactor to use common enum via FormatAdapter and allow extension + // for new flat file formats blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true)); clustaljv.setSelected(Cache.getDefault("CLUSTAL_JVSUFFIX", true)); fastajv.setSelected(Cache.getDefault("FASTA_JVSUFFIX", true)); @@ -636,6 +652,16 @@ public class Preferences extends GPreferences maxColour.getBackground()); /* + * Save Overview settings + */ + Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground()); + Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground()); + Cache.applicationProperties.setProperty(USE_LEGACY_GAP, + Boolean.toString(useLegacyGap.isSelected())); + Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START, + Boolean.toString(showHiddenAtStart.isSelected())); + + /* * Save Structure settings */ Cache.applicationProperties.setProperty(ADD_TEMPFACT_ANN, @@ -754,7 +780,7 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH", Boolean.toString(autoIdWidth.isSelected())); userIdWidth_actionPerformed(); - Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH", + Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH", userIdWidth.getText()); /* @@ -767,7 +793,6 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("PAD_GAPS", Boolean.toString(padGaps.isSelected())); - dasSource.saveProperties(Cache.applicationProperties); wsPrefs.updateAndRefreshWsMenuConfig(false); Cache.saveProperties(); Desktop.instance.doConfigureStructurePrefs(); @@ -808,6 +833,7 @@ public class Preferences extends GPreferences @Override public void startupFileTextfield_mouseClicked() { + // TODO: JAL-3048 not needed for Jalview-JS String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT"); JalviewFileChooser chooser = JalviewFileChooser .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat); @@ -981,17 +1007,22 @@ public class Preferences extends GPreferences @Override public void defaultBrowser_mouseClicked(MouseEvent e) { - JFileChooser chooser = new JFileChooser("."); - chooser.setDialogTitle( - MessageManager.getString("label.select_default_browser")); + // TODO: JAL-3048 not needed for j2s + /* + * @j2sNative + */ + { + JFileChooser chooser = new JFileChooser("."); + chooser.setDialogTitle( + MessageManager.getString("label.select_default_browser")); - int value = chooser.showOpenDialog(this); + int value = chooser.showOpenDialog(this); - if (value == JFileChooser.APPROVE_OPTION) - { - defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath()); + if (value == JFileChooser.APPROVE_OPTION) + { + defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath()); + } } - } /* @@ -1016,53 +1047,64 @@ public class Preferences extends GPreferences @Override public void minColour_actionPerformed(JPanel panel) { - Color col = JColorChooser.showDialog(this, + JalviewColourChooser.showColourChooser(this, MessageManager.getString("label.select_colour_minimum_value"), - minColour.getBackground()); - if (col != null) - { - panel.setBackground(col); - } - panel.repaint(); + panel); } @Override public void maxColour_actionPerformed(JPanel panel) { - Color col = JColorChooser.showDialog(this, + JalviewColourChooser.showColourChooser(this, MessageManager.getString("label.select_colour_maximum_value"), - maxColour.getBackground()); - if (col != null) - { - panel.setBackground(col); - } - panel.repaint(); + panel); } @Override - public void gapColour_actionPerformed(JButton btn) + public void gapColour_actionPerformed(JPanel gap) { - Color col = JColorChooser.showDialog(this, - MessageManager.getString("label.select_gap_colour"), - gapColour.getForeground()); - if (col != null) + if (!useLegacyGap.isSelected()) { - btn.setForeground(col); + JalviewColourChooser.showColourChooser(this, + MessageManager.getString("label.select_gap_colour"), + gap); } - btn.repaint(); } @Override - public void hiddenColour_actionPerformed(JButton btn) + public void hiddenColour_actionPerformed(JPanel hidden) { - Color col = JColorChooser.showDialog(this, + JalviewColourChooser.showColourChooser(this, MessageManager.getString("label.select_hidden_colour"), - hiddenColour.getForeground()); - if (col != null) + hidden); + } + + @Override + protected void useLegacyGaps_actionPerformed(ActionEvent e) + { + boolean enabled = useLegacyGap.isSelected(); + if (enabled) { - btn.setForeground(col); + gapColour.setBackground( + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP); } - btn.repaint(); + else + { + gapColour.setBackground( + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP); + } + gapColour.setEnabled(!enabled); + gapLabel.setEnabled(!enabled); + } + + @Override + protected void resetOvDefaults_actionPerformed(ActionEvent e) + { + useLegacyGap.setSelected(false); + useLegacyGaps_actionPerformed(null); + showHiddenAtStart.setSelected(true); + hiddenColour.setBackground( + jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN); } @Override @@ -1082,12 +1124,12 @@ public class Preferences extends GPreferences } } catch (NumberFormatException x) { + userIdWidth.setText(""); JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager .getString("warn.user_defined_width_requirements"), MessageManager.getString("label.invalid_id_column_width"), JvOptionPane.WARNING_MESSAGE); - userIdWidth.setText(""); } }