X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPreferences.java;h=50ee476bd9f8c5c0e036cc08d5948e63d6e3f02b;hb=e3c3367f89785a5cff5fb3bd419c92ccb4ac13ea;hp=c921331dba2806ded88253ff064e42c078a7989f;hpb=71c5a29a58e5505aaf7d63a8c9f1bea3ae93d629;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index c921331..50ee476 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -60,7 +60,7 @@ import java.util.ArrayList; import java.util.List; import javax.help.HelpSetException; -import javax.swing.JColorChooser; +import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JInternalFrame; import javax.swing.JPanel; @@ -212,13 +212,20 @@ public class Preferences extends GPreferences super(); frame = new JInternalFrame(); frame.setContentPane(this); - wsPrefs = new WsPreferences(); - wsTab.add(wsPrefs, BorderLayout.CENTER); - slivkaTab.add(slivkaPrefs = new SlivkaPreferences(), - BorderLayout.CENTER); + if (!Platform.isJS()) + /** + * Java only + * + * @j2sIgnore + */ + { + wsPrefs = new WsPreferences(); + wsTab.add(wsPrefs, BorderLayout.CENTER); + slivkaPrefs = new SlivkaPreferences(); + slivkaTab.add(slivkaPrefs, BorderLayout.CENTER); + } int width = 500, height = 450; - new jalview.util.Platform(); - if (Platform.isAMac()) + if (Platform.isAMacAndNotJS()) { width = 570; height = 480; @@ -337,7 +344,7 @@ public class Preferences extends GPreferences fontStyleCB.setSelectedItem( Cache.getDefault("FONT_STYLE", Font.PLAIN + "")); - smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false)); + smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", true)); scaleProteinToCdna .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false)); @@ -468,7 +475,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; @@ -587,23 +595,9 @@ public class Preferences extends GPreferences /* * Set Output tab defaults */ - epsRendering.addItem(promptEachTimeOpt); - epsRendering.addItem(lineArtOpt); - epsRendering.addItem(textOpt); - String defaultEPS = Cache.getDefault("EPS_RENDERING", - "Prompt each time"); - if (defaultEPS.equalsIgnoreCase("Text")) - { - epsRendering.setSelectedItem(textOpt); - } - else if (defaultEPS.equalsIgnoreCase("Lineart")) - { - epsRendering.setSelectedItem(lineArtOpt); - } - else - { - epsRendering.setSelectedItem(promptEachTimeOpt); - } + setupOutputCombo(epsRendering, "EPS_RENDERING"); + setupOutputCombo(htmlRendering, "HTML_RENDERING"); + setupOutputCombo(svgRendering, "SVG_RENDERING"); autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false)); userIdWidth.setEnabled(!autoIdWidth.isSelected()); userIdWidthlabel.setEnabled(!autoIdWidth.isSelected()); @@ -641,6 +635,39 @@ public class Preferences extends GPreferences } /** + * A helper method that sets the items and initial selection in a character + * rendering option list (Prompt each time/Lineart/Text) + * + * @param comboBox + * @param propertyKey + */ + protected void setupOutputCombo(JComboBox comboBox, + String propertyKey) + { + comboBox.addItem(promptEachTimeOpt); + comboBox.addItem(lineArtOpt); + comboBox.addItem(textOpt); + + /* + * JalviewJS doesn't support Lineart so force it to Text + */ + String defaultOption = Platform.isJS() ? "Text" + : Cache.getDefault(propertyKey, "Prompt each time"); + if (defaultOption.equalsIgnoreCase("Text")) + { + comboBox.setSelectedItem(textOpt); + } + else if (defaultOption.equalsIgnoreCase("Lineart")) + { + comboBox.setSelectedItem(lineArtOpt); + } + else + { + comboBox.setSelectedItem(promptEachTimeOpt); + } + } + + /** * Save user selections on the Preferences tabs to the Cache and write out to * file. * @@ -816,6 +843,10 @@ public class Preferences extends GPreferences */ Cache.applicationProperties.setProperty("EPS_RENDERING", ((OptionsParam) epsRendering.getSelectedItem()).getCode()); + Cache.applicationProperties.setProperty("HTML_RENDERING", + ((OptionsParam) htmlRendering.getSelectedItem()).getCode()); + Cache.applicationProperties.setProperty("SVG_RENDERING", + ((OptionsParam) svgRendering.getSelectedItem()).getCode()); /* * Save Connections settings @@ -925,7 +956,10 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("PAD_GAPS", Boolean.toString(padGaps.isSelected())); - wsPrefs.updateAndRefreshWsMenuConfig(false); + if (!Platform.isJS()) + { + wsPrefs.updateAndRefreshWsMenuConfig(false); + } /* * Save Backups settings @@ -989,6 +1023,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); @@ -1022,8 +1057,11 @@ public class Preferences extends GPreferences { try { - wsPrefs.updateWsMenuConfig(true); - wsPrefs.refreshWs_actionPerformed(e); + if (!Platform.isJS()) + { + wsPrefs.updateWsMenuConfig(true); + wsPrefs.refreshWs_actionPerformed(e); + } frame.setClosed(true); } catch (Exception ex) { @@ -1164,17 +1202,25 @@ 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 + if (!Platform.isJS()) // BH 2019 + /** + * Java only + * + * @j2sIgnore + */ + { + 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()); + } } - } /* @@ -1199,27 +1245,17 @@ 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 @@ -1227,28 +1263,18 @@ public class Preferences extends GPreferences { if (!useLegacyGap.isSelected()) { - Color col = JColorChooser.showDialog(this, + JalviewColourChooser.showColourChooser(this, MessageManager.getString("label.select_gap_colour"), - gapColour.getBackground()); - if (col != null) - { - gap.setBackground(col); - } - gap.repaint(); + gap); } } @Override public void hiddenColour_actionPerformed(JPanel hidden) { - Color col = JColorChooser.showDialog(this, + JalviewColourChooser.showColourChooser(this, MessageManager.getString("label.select_hidden_colour"), - hiddenColour.getBackground()); - if (col != null) - { - hidden.setBackground(col); - } - hidden.repaint(); + hidden); } @Override @@ -1296,12 +1322,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(""); } }