Skip to content

Commit

Permalink
Merge pull request #114 from karakun/proxy-localhost
Browse files Browse the repository at this point in the history
Bypass Localhost in Proxy
  • Loading branch information
sclassen authored Dec 5, 2019
2 parents 7adf9e8 + 18289b2 commit 6bf1eda
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
Expand All @@ -40,6 +41,8 @@ public class ProxyConfigPanel extends FormPanel {

private final JRadioButton useManualSettings;

private final JCheckBox bypassLocalhostCheckbox;

private final JTextField pacUrlField;

private final JTextField proxyHostField;
Expand Down Expand Up @@ -165,6 +168,19 @@ public void focusLost(final FocusEvent e) {
advancedButtonContraints.weighty = 0;
advancedButtonContraints.fill = GridBagConstraints.HORIZONTAL;
manualSettingsDetailsPanel.add(advancedButton, advancedButtonContraints);

bypassLocalhostCheckbox = new JCheckBox(translator.translate("proxyPanel.bypassLocalhost.text"));
bypassLocalhostCheckbox.setToolTipText(translator.translate("proxyPanel.bypassLocalhost.description"));
final GridBagConstraints bypassLocalhostCheckboxContraints = new GridBagConstraints();
bypassLocalhostCheckboxContraints.gridx = 0;
bypassLocalhostCheckboxContraints.gridwidth=4;
bypassLocalhostCheckboxContraints.gridy = 1;
bypassLocalhostCheckboxContraints.weightx = 0;
bypassLocalhostCheckboxContraints.weighty = 0;
bypassLocalhostCheckboxContraints.fill = GridBagConstraints.HORIZONTAL;
manualSettingsDetailsPanel.add(bypassLocalhostCheckbox, bypassLocalhostCheckboxContraints);


final JPanel manualSettingsPanel = new JPanel(new BorderLayout());
manualSettingsPanel.add(useManualSettings, BorderLayout.NORTH);
manualSettingsPanel.add(manualSettingsDetailsPanel, BorderLayout.CENTER);
Expand All @@ -182,12 +198,13 @@ private void onRadioButtonSelected(final ProxyProviderType providerType) {

private void updateEnabledStateForProxyType(final ProxyProviderType providerType) {
final boolean isPac = providerType == ProxyProviderType.MANUAL_PAC_URL;
pacUrlField.setEnabled(isPac);
pacUrlField.setEnabled(isPac && !config.isLocked(ConfigurationConstants.KEY_PROXY_TYPE));

final boolean isManual = providerType == ProxyProviderType.MANUAL_HOSTS;
proxyHostField.setEnabled(isManual);
proxyPortField.setEnabled(isManual);
advancedButton.setEnabled(isManual);
proxyHostField.setEnabled(isManual && !config.isLocked(ConfigurationConstants.KEY_PROXY_TYPE));
proxyPortField.setEnabled(isManual && !config.isLocked(ConfigurationConstants.KEY_PROXY_TYPE));
advancedButton.setEnabled(isManual && !config.isLocked(ConfigurationConstants.KEY_PROXY_TYPE));
bypassLocalhostCheckbox.setEnabled(isManual && !config.isLocked(ConfigurationConstants.KEY_PROXY_TYPE));
}

private void updateConfig() {
Expand All @@ -206,6 +223,7 @@ private void updateConfig() {
config.setProperty(ConfigurationConstants.KEY_PROXY_AUTO_CONFIG_URL, pacUrlField.getText());
config.setProperty(ConfigurationConstants.KEY_PROXY_HTTP_HOST, proxyHostField.getText());
config.setProperty(ConfigurationConstants.KEY_PROXY_HTTP_PORT, proxyPortField.getText());
config.setProperty(ConfigurationConstants.KEY_PROXY_BYPASS_LOCAL, bypassLocalhostCheckbox.isSelected() + "");
}

private void updateUi() {
Expand Down Expand Up @@ -239,5 +257,8 @@ private void updateUi() {
pacUrlField.setText(config.getProperty(ConfigurationConstants.KEY_PROXY_AUTO_CONFIG_URL));
proxyHostField.setText(config.getProperty(ConfigurationConstants.KEY_PROXY_HTTP_HOST));
proxyPortField.setText(config.getProperty(ConfigurationConstants.KEY_PROXY_HTTP_PORT));

bypassLocalhostCheckbox.setSelected(Boolean.parseBoolean(config.getProperty(ConfigurationConstants.KEY_PROXY_BYPASS_LOCAL)));

}
}
3 changes: 2 additions & 1 deletion openwebstart/src/main/resources/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ proxyPanel.proxyPort.description=The proxy port
proxyPanel.advanced.text=advanced
proxyPanel.advanced.description=Define advanced proxy settings
proxyPanel.error.loadSettings=Error while loading proxy settings

proxyPanel.bypassLocalhost.text=Bypass localhost
proxyPanel.bypassLocalhost.description=Bypass localhost automatically
proxy.error.connectionFailed.title=Connection to proxy failed
proxy.error.connectionFailed.message=Connection failed for URL: {0}.\n\nDo you want to continue with no proxy or exit the application?
proxy.error.creationFailed.title=Creation of proxy failed
Expand Down
4 changes: 3 additions & 1 deletion openwebstart/src/main/resources/i18n_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ proxyPanel.proxyHost.description=Der Proxy Server
proxyPanel.proxyPort.description=Der Port auf dem Proxy Server
proxyPanel.advanced.text=Profi Einstellungen
proxyPanel.advanced.description=Einstellungen f\u00FCr Profis
proxyPanel.error.loadSettings=Fehler beim laden der Proxy Einstellungen
proxyPanel.bypassLocalhost.text=Zu Localhost direkt verbinden
proxyPanel.bypassLocalhost.description=F\u00FCr localhost keinen Proxy verwenden

proxyPanel.error.loadSettings=Fehler beim laden der Proxy Einstellungen
proxy.error.connectionFailed.title=Fehler beim Verbindungsaufbau mit dem Proxy
proxy.error.connectionFailed.message=Fehler bei der URL {0}.\n\nM\u00F6chten Sie ohne Proxy fortfahren oder die Applikation beenden?
proxy.error.creationFailed.title=Erstellen des Proxy fehlgeschlagen
Expand Down

0 comments on commit 6bf1eda

Please sign in to comment.