*/
package jalview.gui;
-import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
-import jalview.bin.Cache;
-import jalview.gui.Help.HelpId;
-import jalview.gui.StructureViewer.ViewerType;
-import jalview.io.FileFormatI;
-import jalview.io.JalviewFileChooser;
-import jalview.io.JalviewFileView;
-import jalview.jbgui.GPreferences;
-import jalview.jbgui.GSequenceLink;
-import jalview.schemes.ColourSchemeI;
-import jalview.schemes.ColourSchemes;
-import jalview.schemes.ResidueColourScheme;
-import jalview.urls.UrlLinkTableModel;
-import jalview.urls.api.UrlProviderFactoryI;
-import jalview.urls.api.UrlProviderI;
-import jalview.urls.desktop.DesktopUrlProviderFactory;
-import jalview.util.MessageManager;
-import jalview.util.Platform;
-import jalview.util.UrlConstants;
-import jalview.ws.sifts.SiftsSettings;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import javax.swing.table.TableRowSorter;
import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
+import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
+import jalview.bin.Cache;
+import jalview.gui.Help.HelpId;
+import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.BackupFiles;
+import jalview.io.BackupFilesPresetEntry;
+import jalview.io.FileFormatI;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.jbgui.GPreferences;
+import jalview.jbgui.GSequenceLink;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemes;
+import jalview.schemes.ResidueColourScheme;
+import jalview.urls.UrlLinkTableModel;
+import jalview.urls.api.UrlProviderFactoryI;
+import jalview.urls.api.UrlProviderI;
+import jalview.urls.desktop.DesktopUrlProviderFactory;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+import jalview.util.UrlConstants;
+import jalview.ws.sifts.SiftsSettings;
/**
* DOCUMENT ME!
private static final int MAX_FONT_SIZE = 30;
- public static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray;
-
- public static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white;
-
- public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray
- .darker();
+ private String previousProxyType;
/**
* Holds name and link separated with | character. Sequence ID must be
JInternalFrame frame;
- DasSourceBrowser dasSource;
-
private WsPreferences wsPrefs;
private OptionsParam promptEachTimeOpt = new OptionsParam(
*/
public Preferences()
{
- super();
+ new Preferences(0);
+ }
+
+ public Preferences(int selectTab)
+ {
+ super(selectTab);
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;
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));
/*
* Set overview panel defaults
*/
- gapColour.setBackground(
- Cache.getDefaultColour(GAP_COLOUR, OVERVIEW_DEFAULT_GAP));
- hiddenColour.setBackground(
- Cache.getDefaultColour(HIDDEN_COLOUR,
- OVERVIEW_DEFAULT_HIDDEN));
+ gapColour.setBackground(Cache.getDefaultColour(GAP_COLOUR,
+ jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
+ hiddenColour.setBackground(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));
+ .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, false));
/*
* Set Structure tab defaults.
}
}
- useProxy.setSelected(Cache.getDefault("USE_PROXY", false));
- useProxy_actionPerformed(); // make sure useProxy is correctly initialised
- proxyServerTB.setText(Cache.getDefault("PROXY_SERVER", ""));
- proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
+ String proxyTypeString = Cache.getDefault("USE_PROXY", "false");
+ previousProxyType = proxyTypeString;
+ switch (proxyTypeString)
+ {
+ case Cache.PROXYTYPE_NONE:
+ proxyType.setSelected(noProxy.getModel(), true);
+ break;
+ case Cache.PROXYTYPE_SYSTEM:
+ proxyType.setSelected(systemProxy.getModel(), true);
+ break;
+ case Cache.PROXYTYPE_CUSTOM:
+ proxyType.setSelected(customProxy.getModel(), true);
+ break;
+ default:
+ String message = "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
+ + proxyTypeString;
+ Cache.log.warn(message);
+ }
+ proxyServerHttpTB.setText(Cache.getDefault("PROXY_SERVER", ""));
+ proxyPortHttpTB.setText(Cache.getDefault("PROXY_PORT", ""));
+ proxyServerHttpsTB.setText(Cache.getDefault("PROXY_SERVER_HTTPS", ""));
+ proxyPortHttpsTB.setText(Cache.getDefault("PROXY_PORT_HTTPS", ""));
+ proxyAuth.setSelected(Cache.getDefault("PROXY_AUTH", false));
+ proxyAuthUsernameTB
+ .setText(Cache.getDefault("PROXY_AUTH_USERNAME", ""));
+ // we are not storing or retrieving proxy password from .jalview_properties
+ proxyAuthPasswordTB.setText(Cache.proxyAuthPassword == null ? ""
+ : Cache.proxyAuthPassword.toString());
+ setCustomProxyEnabled();
defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", ""));
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));
annotations_actionPerformed(null); // update the display of the annotation
// settings
+
+ /*
+ * Set Backups tab defaults
+ */
+ loadLastSavedBackupsOptions();
}
/**
Cache.applicationProperties.setProperty("DEFAULT_URL",
sequenceUrlLinks.getPrimaryUrlId());
- Cache.applicationProperties.setProperty("USE_PROXY",
- Boolean.toString(useProxy.isSelected()));
-
- Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
-
- Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
+ // Proxy settings
+ saveProxySettings();
- if (useProxy.isSelected())
- {
- System.setProperty("http.proxyHost", proxyServerTB.getText());
- System.setProperty("http.proxyPort", proxyPortTB.getText());
- }
- else
- {
- System.setProperty("http.proxyHost", "");
- System.setProperty("http.proxyPort", "");
- }
Cache.setProperty("VERSION_CHECK",
Boolean.toString(versioncheck.isSelected()));
if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected())
Cache.applicationProperties.setProperty("FIGURE_AUTOIDWIDTH",
Boolean.toString(autoIdWidth.isSelected()));
userIdWidth_actionPerformed();
- Cache.applicationProperties.setProperty("FIGURE_USERIDWIDTH",
+ Cache.applicationProperties.setProperty("FIGURE_FIXEDIDWIDTH",
userIdWidth.getText());
/*
Cache.applicationProperties.setProperty("PAD_GAPS",
Boolean.toString(padGaps.isSelected()));
- dasSource.saveProperties(Cache.applicationProperties);
wsPrefs.updateAndRefreshWsMenuConfig(false);
+
+ /*
+ * Save Backups settings
+ */
+ Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
+ Boolean.toString(enableBackupFiles.isSelected()));
+ int preset = getComboIntStringKey(backupfilesPresetsCombo);
+ Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET",
+ Integer.toString(preset));
+
+ if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
+ {
+ BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
+ BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
+ BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
+ Cache.applicationProperties.setProperty(
+ BackupFilesPresetEntry.CUSTOMCONFIG, customBFPE.toString());
+ }
+
+ BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
+ .get(preset);
+ Cache.applicationProperties.setProperty(
+ BackupFilesPresetEntry.SAVEDCONFIG, savedBFPE.toString());
+
Cache.saveProperties();
Desktop.instance.doConfigureStructurePrefs();
try
}
}
+ public void setProxyFromSettings()
+ {
+ String proxyType = Cache.getDefault("USE_PROXY",
+ Cache.PROXYTYPE_SYSTEM);
+ if (proxyType.equals(Cache.PROXYTYPE_NONE))
+ {
+ if (!previousProxyType.equals(proxyType))
+ Cache.log.info("Setting no proxy settings");
+ Cache.setProxyProperties(null, null, null, null, null, null, null,
+ null, null);
+ }
+ else if (proxyType.equals(Cache.PROXYTYPE_CUSTOM))
+ {
+ if (!previousProxyType.equals(proxyType))
+ Cache.log.info("Setting custom proxy settings");
+ boolean proxyAuthSet = Cache.getDefault("PROXY_AUTH", false);
+ Cache.setProxyProperties(Cache.getDefault("PROXY_SERVER", null),
+ Cache.getDefault("PROXY_PORT", null),
+ Cache.getDefault("PROXY_SERVER_HTTPS", null),
+ Cache.getDefault("PROXY_PORT_HTTPS", null),
+ proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
+ : null,
+ proxyAuthSet ? Cache.proxyAuthPassword : null,
+ proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
+ : null,
+ proxyAuthSet ? Cache.proxyAuthPassword : null, "localhost");
+ }
+ else // systemProxy should be selected and is sensible default anyway
+ {
+ if (!previousProxyType.equals(proxyType))
+ Cache.log.info("Setting system proxy settings");
+ Cache.resetProxyProperties();
+ }
+ }
+
+ public void saveProxySettings()
+ {
+ Cache.applicationProperties.setProperty("USE_PROXY",
+ customProxy.isSelected() ? Cache.PROXYTYPE_CUSTOM
+ : noProxy.isSelected() ? Cache.PROXYTYPE_NONE
+ : Cache.PROXYTYPE_SYSTEM);
+ Cache.setOrRemove("PROXY_SERVER", proxyServerHttpTB.getText());
+ Cache.setOrRemove("PROXY_PORT", proxyPortHttpTB.getText());
+ Cache.setOrRemove("PROXY_SERVER_HTTPS", proxyServerHttpsTB.getText());
+ Cache.setOrRemove("PROXY_PORT_HTTPS", proxyPortHttpsTB.getText());
+ Cache.setOrRemove("PROXY_AUTH",
+ Boolean.toString(proxyAuth.isSelected()));
+ Cache.setOrRemove("PROXY_AUTH_USERNAME", proxyAuthUsernameTB.getText());
+ Cache.proxyAuthPassword = proxyAuthPasswordTB.getPassword();
+ setProxyFromSettings();
+ }
+
/**
* Do any necessary validation before saving settings. Return focus to the
* first tab which fails validation.
boolean enabled = useLegacyGap.isSelected();
if (enabled)
{
- gapColour.setBackground(OVERVIEW_DEFAULT_LEGACY_GAP);
+ gapColour.setBackground(
+ jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
}
else
{
- gapColour.setBackground(OVERVIEW_DEFAULT_GAP);
+ gapColour.setBackground(
+ jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
}
gapColour.setEnabled(!enabled);
gapLabel.setEnabled(!enabled);
{
useLegacyGap.setSelected(false);
useLegacyGaps_actionPerformed(null);
- showHiddenAtStart.setSelected(true);
- hiddenColour.setBackground(OVERVIEW_DEFAULT_HIDDEN);
+ showHiddenAtStart.setSelected(false);
+ hiddenColour.setBackground(
+ jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
}
@Override
}
}
}
+
}