From: Ben Soares Date: Sun, 12 Jul 2020 23:31:13 +0000 (+0100) Subject: JAL-3633 Remember system set proxy properties. Add options in Preferences for No... X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=9c1f8ee91bd7d4c3caf72449bac65865f18db067 JAL-3633 Remember system set proxy properties. Add options in Preferences for No proxy, system proxy, or custom proxy servers. --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 7f13528..094c390 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -591,13 +591,16 @@ label.gap_symbol = Gap Symbol label.prot_alignment_colour = Protein Alignment Colour label.nuc_alignment_colour = Nucleotide Alignment Colour label.address = Address +label.host = Host label.port = Port label.default_browser_unix = Default Browser (Unix) label.send_usage_statistics = Send usage statistics label.check_for_questionnaires = Check for questionnaires label.check_for_latest_version = Check for latest version label.url_linkfrom_sequence_id = URL link from Sequence ID -label.use_proxy_server = Use a proxy server +label.no_proxy = No proxy servers +label.system_proxy = System proxy servers (http={0}; https={1}) +label.use_proxy_server = Use these proxy servers label.eps_rendering_style = EPS rendering style label.append_start_end = Append /start-end (/15-380) label.full_sequence_id = Full Sequence Id diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index 25cca6b..826ba4c 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -543,13 +543,16 @@ label.database_references = Referencias a base de datos #label.scroll_highlighted_regions = Desplazarse hasta las regiones resaltadas label.gap_symbol = Símbolo del hueco label.address = Dirección +label.host = Host label.port = Puerto label.default_browser_unix = Navegador por defecto (Unix) label.send_usage_statistics = Enviar estadísticas de uso label.check_for_questionnaires = Comprobar los cuestionarios label.check_for_latest_version = Comprobar la última versión label.url_linkfrom_sequence_id = URL del enlace del ID de la secuencia -label.use_proxy_server = Utilizar un servidor proxy +label.no_proxy = Sin servidores proxy +label.system_proxy = Servidores proxy del sistema (http={0}; https={1}) +label.use_proxy_server = Utilizar estos servidores proxy label.eps_rendering_style = Estilo de visualización EPS label.append_start_end = Añadir /inicio-fin (/15-380) label.full_sequence_id = ID de la secuencia completo diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 6e44b0c..441c69d 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -269,6 +269,13 @@ public class Cache */ public static Logger log; + // save the proxy properties set at startup + public final static String[] startupProxyProperties = { + System.getProperty("http.proxyHost"), + System.getProperty("http.proxyPort"), + System.getProperty("https.proxyHost"), + System.getProperty("https.proxyPort") }; + /** Jalview Properties */ public static Properties applicationProperties = new Properties() { @@ -379,16 +386,44 @@ public class Cache System.out.println("Error reading properties file: " + ex); } + /* TO BE REPLACED WITH PROXY_TYPE SETTINGS if (getDefault("USE_PROXY", false)) { String proxyServer = getDefault("PROXY_SERVER", ""), proxyPort = getDefault("PROXY_PORT", "8080"); + } + */ - System.out.println("Using proxyServer: " + proxyServer - + " proxyPort: " + proxyPort); - - System.setProperty("http.proxyHost", proxyServer); - System.setProperty("http.proxyPort", proxyPort); + // PROXY TYPE settings (now three options "none", "false", "true", but using + // backward compatible strings) + String proxyType = getDefault("USE_PROXY", "false"); + // default to upgrading old settings + switch (proxyType) + { + case "none": + setProxyProperties(null, null, null, null); + break; + case "false": // use system settings + resetProxyProperties(); + break; + case "true": // use specified proxy settings + String httpHost = getDefault("PROXY_SERVER", ""); + String httpPort = getDefault("PROXY_PORT", "8080"); + String httpsHost = getDefault("PROXY_SERVER_HTTPS", httpHost); + String httpsPort = getDefault("PROXY_PORT_HTTPS", httpPort); + setProxyProperties(httpHost, httpPort, httpsHost, httpsPort); + break; + default: + String message = "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): " + + proxyType; + if (Cache.log == null) + { + System.out.println(message); + } + else + { + Cache.log.warn(message); + } } // LOAD THE AUTHORS FROM THE authors.props file @@ -1168,4 +1203,77 @@ public class Cache t.printStackTrace(pw); return sw.toString(); } + + // proxy properties methods + public static void resetProxyProperties() + { + setProxyProperties(startupProxyProperties[0], startupProxyProperties[1], + startupProxyProperties[2], startupProxyProperties[3]); + StringBuilder sb = new StringBuilder(); + sb.append("Setting proxy properties to: http.proxyHost=") + .append(startupProxyProperties[0]).append(", http.proxyPort=") + .append(startupProxyProperties[1]).append(", https.proxyHost=") + .append(startupProxyProperties[2]).append(", https.proxyPort=") + .append(startupProxyProperties[3]); + if (Cache.log == null) + { + System.err.println(sb.toString()); + } + else + { + Cache.log.debug(sb.toString()); + } + } + + public static void setProxyProperties(String host, String port) + { + setProxyProperties(host, port, host, port); + } + + public static void setProxyProperties(String httpHost, String httpPort, + String httpsHost, String httpsPort) + { + // cannot set property to null -- use clearProperty instead + + // http.proxyHost + if (httpHost == null) + { + System.clearProperty("http.proxyHost"); + } + else + { + System.setProperty("http.proxyHost", httpHost); + } + + // http.proxyPort + if (httpPort == null) + { + System.clearProperty("http.proxyPort"); + } + else + { + System.setProperty("http.proxyPort", httpPort); + } + + // https.proxyHost + if (httpsHost == null) + { + System.clearProperty("https.proxyHost"); + } + else + { + System.setProperty("https.proxyHost", httpsHost); + } + + // https.proxyPort + if (httpsPort == null) + { + System.clearProperty("https.proxyPort"); + } + else + { + System.setProperty("https.proxyPort", httpsPort); + } + + } } diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 1f61bae..e27905c 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -20,29 +20,6 @@ */ 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.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; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -74,6 +51,28 @@ import javax.swing.table.TableModel; 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! @@ -317,12 +316,10 @@ public class Preferences extends GPreferences /* * Set overview panel defaults */ - gapColour.setBackground( - Cache.getDefaultColour(GAP_COLOUR, - jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP)); - hiddenColour.setBackground( - Cache.getDefaultColour(HIDDEN_COLOUR, - jalview.renderer.OverviewResColourFinder.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()); @@ -487,10 +484,27 @@ public class Preferences extends GPreferences } } - 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"); + switch (proxyTypeString) + { + case "none": + proxyType.setSelected(noProxy.getModel(), true); + break; + case "false": + proxyType.setSelected(systemProxy.getModel(), true); + break; + case "true": + 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", "")); defaultBrowser.setText(Cache.getDefault("DEFAULT_BROWSER", "")); @@ -548,8 +562,7 @@ public class Preferences extends GPreferences annotations_actionPerformed(null); // update the display of the annotation // settings - - + /* * Set Backups tab defaults */ @@ -727,22 +740,35 @@ public class Preferences extends GPreferences sequenceUrlLinks.getPrimaryUrlId()); Cache.applicationProperties.setProperty("USE_PROXY", - Boolean.toString(useProxy.isSelected())); + customProxy.isSelected() ? "true" + : noProxy.isSelected() ? "none" : "false"); - Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText()); + Cache.setOrRemove("PROXY_SERVER", proxyServerHttpTB.getText()); - Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText()); + Cache.setOrRemove("PROXY_PORT", proxyPortHttpTB.getText()); - if (useProxy.isSelected()) + Cache.setOrRemove("PROXY_SERVER_HTTPS", proxyServerHttpsTB.getText()); + + Cache.setOrRemove("PROXY_PORT_HTTPS", proxyPortHttpsTB.getText()); + + if (noProxy.isSelected()) { - System.setProperty("http.proxyHost", proxyServerTB.getText()); - System.setProperty("http.proxyPort", proxyPortTB.getText()); + Cache.log.warn("Setting no proxy settings"); + Cache.setProxyProperties(null, null, null, null); } - else + else if (customProxy.isSelected()) { - System.setProperty("http.proxyHost", ""); - System.setProperty("http.proxyPort", ""); + Cache.log.warn("Setting custom proxy settings"); + Cache.setProxyProperties(proxyServerHttpTB.getText(), + proxyPortHttpTB.getText(), proxyServerHttpsTB.getText(), + proxyPortHttpsTB.getText()); } + else // systemProxy should be selected and is sensible default + { + Cache.log.warn("Setting system proxy settings"); + Cache.resetProxyProperties(); + } + Cache.setProperty("VERSION_CHECK", Boolean.toString(versioncheck.isSelected())); if (Cache.getProperty("USAGESTATS") != null || usagestats.isSelected()) @@ -809,16 +835,16 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty(BackupFiles.ENABLED, Boolean.toString(enableBackupFiles.isSelected())); int preset = getComboIntStringKey(backupfilesPresetsCombo); - Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET", Integer.toString(preset)); + 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()); + Cache.applicationProperties.setProperty( + BackupFilesPresetEntry.CUSTOMCONFIG, customBFPE.toString()); } BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues @@ -1349,4 +1375,5 @@ public class Preferences extends GPreferences } } } + } diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 1b4a8bd..51ace5f 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -20,21 +20,6 @@ */ package jalview.jbgui; -import jalview.bin.Cache; -import jalview.fts.core.FTSDataColumnPreferences; -import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource; -import jalview.fts.service.pdb.PDBFTSRestClient; -import jalview.gui.Desktop; -import jalview.gui.JalviewBooleanRadioButtons; -import jalview.gui.JvOptionPane; -import jalview.gui.JvSwingUtils; -import jalview.gui.StructureViewer.ViewerType; -import jalview.io.BackupFilenameParts; -import jalview.io.BackupFiles; -import jalview.io.BackupFilesPresetEntry; -import jalview.io.IntKeyStringValueEntry; -import jalview.util.MessageManager; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -86,6 +71,21 @@ import javax.swing.event.ChangeListener; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; +import jalview.bin.Cache; +import jalview.fts.core.FTSDataColumnPreferences; +import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource; +import jalview.fts.service.pdb.PDBFTSRestClient; +import jalview.gui.Desktop; +import jalview.gui.JalviewBooleanRadioButtons; +import jalview.gui.JvOptionPane; +import jalview.gui.JvSwingUtils; +import jalview.gui.StructureViewer.ViewerType; +import jalview.io.BackupFilenameParts; +import jalview.io.BackupFiles; +import jalview.io.BackupFilesPresetEntry; +import jalview.io.IntKeyStringValueEntry; +import jalview.util.MessageManager; + /** * Base class for the Preferences panel. * @@ -226,17 +226,35 @@ public class GPreferences extends JPanel protected JButton userOnly = new JButton(); + protected JLabel httpLabel = new JLabel(); + + protected JLabel httpsLabel = new JLabel(); + protected JLabel portLabel = new JLabel(); protected JLabel serverLabel = new JLabel(); - protected JTextField proxyServerTB = new JTextField(); + protected JLabel portLabel2 = new JLabel(); + + protected JLabel serverLabel2 = new JLabel(); + + protected JTextField proxyServerHttpTB = new JTextField(); + + protected JTextField proxyPortHttpTB = new JTextField(); + + protected JTextField proxyServerHttpsTB = new JTextField(); - protected JTextField proxyPortTB = new JTextField(); + protected JTextField proxyPortHttpsTB = new JTextField(); protected JTextField defaultBrowser = new JTextField(); - protected JCheckBox useProxy = new JCheckBox(); + protected ButtonGroup proxyType = new ButtonGroup(); + + protected JRadioButton noProxy = new JRadioButton(); + + protected JRadioButton systemProxy = new JRadioButton(); + + protected JRadioButton customProxy = new JRadioButton(); protected JCheckBox usagestats = new JCheckBox(); @@ -840,39 +858,145 @@ public class GPreferences extends JPanel private JPanel initConnTabProxyPanel() { // Label for server text box - serverLabel.setText(MessageManager.getString("label.address")); + serverLabel.setText(MessageManager.getString("label.host") + ": "); serverLabel.setHorizontalAlignment(SwingConstants.RIGHT); serverLabel.setFont(LABEL_FONT); + serverLabel2.setText(MessageManager.getString("label.host") + ": "); + serverLabel2.setHorizontalAlignment(SwingConstants.RIGHT); + serverLabel2.setFont(LABEL_FONT); // Proxy server and port text boxes - proxyServerTB.setFont(LABEL_FONT); - proxyPortTB.setFont(LABEL_FONT); + proxyServerHttpTB.setFont(LABEL_FONT); + proxyServerHttpTB.setColumns(40); + proxyPortHttpTB.setFont(LABEL_FONT); + proxyPortHttpTB.setColumns(4); + proxyServerHttpsTB.setFont(LABEL_FONT); + proxyServerHttpsTB.setColumns(40); + proxyPortHttpsTB.setFont(LABEL_FONT); + proxyPortHttpsTB.setColumns(4); // Label for Port text box portLabel.setFont(LABEL_FONT); portLabel.setHorizontalAlignment(SwingConstants.RIGHT); - portLabel.setText(MessageManager.getString("label.port")); - - // Use proxy server checkbox - useProxy.setFont(LABEL_FONT); - useProxy.setHorizontalAlignment(SwingConstants.RIGHT); - useProxy.setHorizontalTextPosition(SwingConstants.LEADING); - useProxy.setText(MessageManager.getString("label.use_proxy_server")); - useProxy.addActionListener(new ActionListener() + portLabel.setText(MessageManager.getString("label.port") + ": "); + portLabel2.setFont(LABEL_FONT); + portLabel2.setHorizontalAlignment(SwingConstants.RIGHT); + portLabel2.setText(MessageManager.getString("label.port") + ": "); + + httpLabel.setText("HTTP"); + httpLabel.setFont(LABEL_FONT_BOLD); + httpLabel.setHorizontalAlignment(SwingConstants.LEFT); + httpsLabel.setText("HTTPS"); + httpsLabel.setFont(LABEL_FONT_BOLD); + httpsLabel.setHorizontalAlignment(SwingConstants.LEFT); + + // Proxy type radio buttons + noProxy.setFont(LABEL_FONT); + noProxy.setHorizontalAlignment(SwingConstants.LEFT); + // noProxy.setHorizontalTextPosition(SwingConstants.LEADING); + noProxy.setText(MessageManager.getString("label.no_proxy")); + systemProxy.setFont(LABEL_FONT); + systemProxy.setHorizontalAlignment(SwingConstants.LEFT); + // systemProxy.setHorizontalTextPosition(SwingConstants.LEADING); + systemProxy.setText(MessageManager.formatMessage("label.system_proxy", + displayHostPort(Cache.startupProxyProperties[0], + Cache.startupProxyProperties[1]), + displayHostPort(Cache.startupProxyProperties[2], + Cache.startupProxyProperties[3]))); + customProxy.setFont(LABEL_FONT); + customProxy.setHorizontalAlignment(SwingConstants.LEFT); + // customProxy.setHorizontalTextPosition(SwingConstants.LEADING); + customProxy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - useProxy_actionPerformed(); + customProxy_actionPerformed(); } }); + customProxy.setText( + MessageManager.getString("label.use_proxy_server") + ":"); + proxyType.add(noProxy); + proxyType.add(systemProxy); + proxyType.add(customProxy); // Make proxy server panel JPanel proxyPanel = new JPanel(); TitledBorder titledBorder1 = new TitledBorder( MessageManager.getString("label.proxy_server")); proxyPanel.setBorder(titledBorder1); + GridBagConstraints gbc = new GridBagConstraints(); proxyPanel.setLayout(new GridBagLayout()); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.gridheight = 1; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.BOTH; + + gbc.gridwidth = 5; + proxyPanel.add(noProxy, gbc); + + gbc.gridy++; + proxyPanel.add(systemProxy, gbc); + + gbc.gridy++; + proxyPanel.add(customProxy, gbc); + + gbc.gridwidth = 1; + gbc.gridy++; + gbc.gridx = 0; + gbc.weightx = 0.1; + proxyPanel.add(httpLabel, gbc); + + gbc.gridx++; + gbc.anchor = GridBagConstraints.EAST; + gbc.weightx = 0.15; + proxyPanel.add(serverLabel, gbc); + + gbc.gridx++; + gbc.anchor = GridBagConstraints.WEST; + gbc.weightx = 0.5; + proxyPanel.add(proxyServerHttpTB, gbc); + + gbc.gridx++; + gbc.anchor = GridBagConstraints.EAST; + gbc.weightx = 0.15; + proxyPanel.add(portLabel, gbc); + + gbc.gridx++; + gbc.anchor = GridBagConstraints.WEST; + gbc.weightx = 0.1; + proxyPanel.add(proxyPortHttpTB, gbc); + + gbc.gridy++; + gbc.gridx = 0; + gbc.anchor = GridBagConstraints.WEST; + gbc.weightx = 0.1; + proxyPanel.add(httpsLabel, gbc); + + gbc.gridx++; + gbc.anchor = GridBagConstraints.EAST; + gbc.weightx = 0.15; + proxyPanel.add(serverLabel2, gbc); + + gbc.gridx++; + gbc.anchor = GridBagConstraints.WEST; + gbc.weightx = 0.5; + proxyPanel.add(proxyServerHttpsTB, gbc); + + gbc.gridx++; + gbc.anchor = GridBagConstraints.EAST; + gbc.weightx = 0.15; + proxyPanel.add(portLabel2, gbc); + + gbc.gridx++; + gbc.anchor = GridBagConstraints.WEST; + gbc.weightx = 0.1; + proxyPanel.add(proxyPortHttpsTB, gbc); + + /* proxyPanel.add(serverLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, @@ -893,10 +1017,30 @@ public class GPreferences extends JPanel new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 2, 0), 263, 1)); + */ return proxyPanel; } + private String displayHostPort(String host, String port) + { + boolean hostBlank = (host == null || host.isEmpty()); + boolean portBlank = (port == null || port.isEmpty()); + if (hostBlank && portBlank) + { + return MessageManager.getString("label.none"); + } + + StringBuilder sb = new StringBuilder(); + sb.append(hostBlank ? "" : host); + if (!portBlank) + { + sb.append(":"); + sb.append(port); + } + return sb.toString(); + } + /** * Initialises the checkboxes in the Connections tab */ @@ -1784,7 +1928,6 @@ public class GPreferences extends JPanel } }); - // enable checkbox 1 col gbc.gridwidth = 1; gbc.gridheight = 1; @@ -1857,8 +2000,8 @@ public class GPreferences extends JPanel presetsComboLabel = new JLabel(title + ":"); presetsPanel.add(presetsComboLabel, gbc); - List entries = Arrays - .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries); + List entries = Arrays.asList( + (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries); List tooltips = Arrays.asList( BackupFilesPresetEntry.backupfilesPresetEntryDescriptions); backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries, @@ -1885,7 +2028,8 @@ public class GPreferences extends JPanel { if (customiseCheckbox.isSelected()) { - // got here by clicking on customiseCheckbox so don't change the values + // got here by clicking on customiseCheckbox so don't change the + // values backupfilesCustomOptionsSetEnabled(); } else @@ -1964,13 +2108,11 @@ public class GPreferences extends JPanel private JPanel initBackupsTabFilenameExamplesPanel() { - String title = MessageManager - .getString("label.scheme_examples"); + String title = MessageManager.getString("label.scheme_examples"); TitledBorder tb = new TitledBorder(title); exampleFilesPanel.setBorder(tb); exampleFilesPanel.setLayout(new GridBagLayout()); - backupfilesExampleLabel.setEditable(false); backupfilesExampleLabel .setBackground(exampleFilesPanel.getBackground()); @@ -2031,8 +2173,7 @@ public class GPreferences extends JPanel } protected void setComboIntStringKey( - JComboBox backupfilesPresetsCombo2, - int key) + JComboBox backupfilesPresetsCombo2, int key) { for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++) { @@ -2302,9 +2443,8 @@ public class GPreferences extends JPanel JPanel jp = new JPanel(); jp.setLayout(new FlowLayout()); - oldBackupFilesLabel - .setText(MessageManager - .getString("label.autodelete_old_backup_files")); + oldBackupFilesLabel.setText( + MessageManager.getString("label.autodelete_old_backup_files")); oldBackupFilesLabel.setFont(LABEL_FONT); oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT); jp.add(oldBackupFilesLabel); @@ -2464,7 +2604,8 @@ public class GPreferences extends JPanel } - // add some extra empty lines to pad out the example files box. ugh, please tell + // add some extra empty lines to pad out the example files box. ugh, please + // tell // me how to do this better int remainingLines = lowersurround + uppersurround + 1 - lineNumber; if (remainingLines > 0) @@ -2543,8 +2684,7 @@ public class GPreferences extends JPanel private void backupfilesKeepAllSetEnabled(boolean tryEnabled) { boolean enabled = tryEnabled && enableBackupFiles.isSelected() - && customiseCheckbox.isSelected() - && suffixTemplate.getText() + && customiseCheckbox.isSelected() && suffixTemplate.getText() .indexOf(BackupFiles.NUM_PLACEHOLDER) > -1; keepfilesPanel.setEnabled(enabled); backupfilesKeepAll.setEnabled(enabled); @@ -2756,13 +2896,17 @@ public class GPreferences extends JPanel } - public void useProxy_actionPerformed() + public void customProxy_actionPerformed() { - boolean enabled = useProxy.isSelected(); + boolean enabled = customProxy.isSelected(); portLabel.setEnabled(enabled); serverLabel.setEnabled(enabled); - proxyServerTB.setEnabled(enabled); - proxyPortTB.setEnabled(enabled); + httpLabel.setEnabled(enabled); + httpsLabel.setEnabled(enabled); + proxyServerHttpTB.setEnabled(enabled); + proxyPortHttpTB.setEnabled(enabled); + proxyServerHttpsTB.setEnabled(enabled); + proxyPortHttpsTB.setEnabled(enabled); } /** @@ -2837,4 +2981,3 @@ public class GPreferences extends JPanel } } -