diff --git a/app/src/cc/arduino/view/preferences/Preferences.form b/app/src/cc/arduino/view/preferences/Preferences.form index e7d0ac5a2..0bd84de95 100644 --- a/app/src/cc/arduino/view/preferences/Preferences.form +++ b/app/src/cc/arduino/view/preferences/Preferences.form @@ -31,23 +31,32 @@ - + + + + + + + + + + + + - - @@ -70,22 +79,12 @@ + + - - - - - - - - - - - - @@ -126,8 +125,6 @@ - - @@ -146,7 +143,7 @@ - + @@ -269,199 +266,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/cc/arduino/view/preferences/Preferences.java b/app/src/cc/arduino/view/preferences/Preferences.java index 3bfc2c41b..051a004ac 100644 --- a/app/src/cc/arduino/view/preferences/Preferences.java +++ b/app/src/cc/arduino/view/preferences/Preferences.java @@ -220,19 +220,6 @@ public class Preferences extends javax.swing.JDialog { verboseUploadBox = new javax.swing.JCheckBox(); javax.swing.JLabel comboWarningsLabel = new javax.swing.JLabel(); comboWarnings = new JComboBox(warningItems); - javax.swing.JPanel proxySettingsPanel = new javax.swing.JPanel(); - javax.swing.JLabel proxyHTTPServerLabel = new javax.swing.JLabel(); - proxyHTTPServer = new javax.swing.JTextField(); - javax.swing.JLabel proxyHTTPPortLabel = new javax.swing.JLabel(); - proxyHTTPPort = new javax.swing.JTextField(); - javax.swing.JLabel proxyHTTPSServerLabel = new javax.swing.JLabel(); - proxyHTTPSServer = new javax.swing.JTextField(); - javax.swing.JLabel proxyHTTPSPortLabel = new javax.swing.JLabel(); - proxyHTTPSPort = new javax.swing.JTextField(); - javax.swing.JLabel proxyUserLabel = new javax.swing.JLabel(); - proxyUser = new javax.swing.JTextField(); - javax.swing.JLabel proxyPasswordLabel = new javax.swing.JLabel(); - proxyPassword = new javax.swing.JPasswordField(); javax.swing.JLabel additionalBoardsManagerLabel = new javax.swing.JLabel(); additionalBoardsManagerField = new javax.swing.JTextField(); javax.swing.JButton extendedAdditionalUrlFieldWindow = new javax.swing.JButton(); @@ -282,93 +269,6 @@ public class Preferences extends javax.swing.JDialog { comboWarningsLabel.setText(_("Compiler warnings: ")); - proxySettingsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(_("Proxy Settings"))); - - proxyHTTPServerLabel.setText(_("Server (HTTP):")); - - proxyHTTPServer.setColumns(10); - - proxyHTTPPortLabel.setText(_("Port (HTTP):")); - - proxyHTTPPort.setColumns(10); - - proxyHTTPSServerLabel.setText(_("Server (HTTPS):")); - - proxyHTTPSServer.setColumns(10); - - proxyHTTPSPortLabel.setText(_("Port (HTTPS):")); - - proxyHTTPSPort.setColumns(10); - - proxyUserLabel.setText(_("Username:")); - - proxyUser.setColumns(10); - - proxyPasswordLabel.setText(_("Password:")); - - proxyPassword.setColumns(10); - - javax.swing.GroupLayout proxySettingsPanelLayout = new javax.swing.GroupLayout(proxySettingsPanel); - proxySettingsPanel.setLayout(proxySettingsPanelLayout); - proxySettingsPanelLayout.setHorizontalGroup( - proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(proxySettingsPanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(proxyHTTPSServerLabel) - .addGroup(proxySettingsPanelLayout.createSequentialGroup() - .addGap(8, 8, 8) - .addComponent(proxyHTTPServerLabel))) - .addComponent(proxyUserLabel)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(proxyHTTPServer) - .addComponent(proxyHTTPSServer) - .addComponent(proxyUser, javax.swing.GroupLayout.Alignment.TRAILING)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(proxyHTTPSPortLabel) - .addComponent(proxyPasswordLabel, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(proxyHTTPPortLabel, javax.swing.GroupLayout.Alignment.TRAILING)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(proxyHTTPSPort, javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(proxyHTTPPort, javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(proxyPassword, javax.swing.GroupLayout.Alignment.LEADING)) - .addContainerGap()) - ); - proxySettingsPanelLayout.setVerticalGroup( - proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(proxySettingsPanelLayout.createSequentialGroup() - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(proxySettingsPanelLayout.createSequentialGroup() - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(proxyHTTPServerLabel) - .addComponent(proxyHTTPServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(proxyHTTPSServerLabel) - .addComponent(proxyHTTPSServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(proxyUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(proxyUserLabel))) - .addGroup(proxySettingsPanelLayout.createSequentialGroup() - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(proxyHTTPPortLabel) - .addComponent(proxyHTTPPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(proxyHTTPSPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(proxyHTTPSPortLabel)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(proxySettingsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(proxyPasswordLabel) - .addComponent(proxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - additionalBoardsManagerLabel.setText(_("Additional Boards Manager URLs: ")); additionalBoardsManagerLabel.setToolTipText(_("Enter a comma separated list of urls")); @@ -446,21 +346,28 @@ public class Preferences extends javax.swing.JDialog { .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(proxySettingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(sketchbookLocationField) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(browseButton)) .addComponent(checkboxesContainer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(okButton) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cancelButton)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(additionalBoardsManagerLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(additionalBoardsManagerField, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(extendedAdditionalUrlFieldWindow, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(arduinoNotRunningLabel) .addComponent(sketchbookLocationLabel) .addGroup(layout.createSequentialGroup() .addComponent(comboWarningsLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(comboWarnings, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(morePreferencesLabel) .addGroup(layout.createSequentialGroup() .addComponent(showVerboseLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -478,18 +385,10 @@ public class Preferences extends javax.swing.JDialog { .addComponent(comboLanguage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(requiresRestartLabel)))) + .addComponent(arduinoNotRunningLabel) + .addComponent(morePreferencesLabel) .addComponent(preferencesFileLabel)) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(okButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cancelButton)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(additionalBoardsManagerLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(additionalBoardsManagerField, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(extendedAdditionalUrlFieldWindow, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( @@ -522,8 +421,6 @@ public class Preferences extends javax.swing.JDialog { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(checkboxesContainer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(proxySettingsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(additionalBoardsManagerLabel) @@ -539,7 +436,7 @@ public class Preferences extends javax.swing.JDialog { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cancelButton) .addComponent(okButton)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); pack(); @@ -612,12 +509,6 @@ public class Preferences extends javax.swing.JDialog { private javax.swing.JCheckBox externalEditorBox; private javax.swing.JTextField fontSizeField; private javax.swing.JLabel preferencesFileLabel; - private javax.swing.JTextField proxyHTTPPort; - private javax.swing.JTextField proxyHTTPSPort; - private javax.swing.JTextField proxyHTTPSServer; - private javax.swing.JTextField proxyHTTPServer; - private javax.swing.JPasswordField proxyPassword; - private javax.swing.JTextField proxyUser; private javax.swing.JCheckBox saveVerifyUploadBox; private javax.swing.JTextField sketchbookLocationField; private javax.swing.JCheckBox updateExtensionBox; @@ -686,21 +577,6 @@ public class Preferences extends javax.swing.JDialog { PreferencesData.setBoolean("editor.save_on_verify", saveVerifyUploadBox.isSelected()); - PreferencesData.set("proxy.http.server", proxyHTTPServer.getText()); - try { - PreferencesData.set("proxy.http.port", Integer.valueOf(proxyHTTPPort.getText()).toString()); - } catch (NumberFormatException e) { - PreferencesData.remove("proxy.http.port"); - } - PreferencesData.set("proxy.https.server", proxyHTTPSServer.getText()); - try { - PreferencesData.set("proxy.https.port", Integer.valueOf(proxyHTTPSPort.getText()).toString()); - } catch (NumberFormatException e) { - PreferencesData.remove("proxy.https.port"); - } - PreferencesData.set("proxy.user", proxyUser.getText()); - PreferencesData.set("proxy.password", new String(proxyPassword.getPassword())); - PreferencesData.set("boardsmanager.additional.urls", additionalBoardsManagerField.getText().replace("\r\n", "\n").replace("\r", "\n").replace("\n", ",")); //editor.applyPreferences(); @@ -743,21 +619,6 @@ public class Preferences extends javax.swing.JDialog { saveVerifyUploadBox.setSelected(PreferencesData.getBoolean("editor.save_on_verify")); - proxyHTTPServer.setText(PreferencesData.get("proxy.http.server")); - try { - proxyHTTPPort.setText(Integer.toString(PreferencesData.getInteger("proxy.http.port", 8080))); - } catch (NumberFormatException e) { - proxyHTTPPort.setText(""); - } - proxyHTTPSServer.setText(PreferencesData.get("proxy.https.server")); - try { - proxyHTTPSPort.setText(Integer.toString(PreferencesData.getInteger("proxy.https.port", 8443))); - } catch (NumberFormatException e) { - proxyHTTPSPort.setText(""); - } - proxyUser.setText(PreferencesData.get("proxy.user")); - proxyPassword.setText(PreferencesData.get("proxy.password")); - additionalBoardsManagerField.setText(PreferencesData.get("boardsmanager.additional.urls")); } } diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 0771b3768..d3ca957d6 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -124,6 +124,7 @@ public class Base { static public void main(String args[]) throws Exception { System.setProperty("awt.useSystemAAFontSettings", "on"); System.setProperty("swing.aatext", "true"); + System.setProperty("java.net.useSystemProxies", "true"); splashScreenHelper.splashText(_("Loading configuration...")); @@ -1748,8 +1749,6 @@ public class Base { if (activeEditor != null) { dialog.setLocationRelativeTo(activeEditor); } - dialog.pack(); - dialog.setMinimumSize(dialog.getSize()); dialog.setVisible(true); } diff --git a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java index 83358a32b..5e7127c2a 100644 --- a/arduino-core/src/cc/arduino/utils/network/FileDownloader.java +++ b/arduino-core/src/cc/arduino/utils/network/FileDownloader.java @@ -36,9 +36,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.RandomAccessFile; -import java.net.HttpURLConnection; -import java.net.SocketTimeoutException; -import java.net.URL; +import java.net.*; import java.util.Observable; public class FileDownloader extends Observable { @@ -122,29 +120,9 @@ public class FileDownloader extends Observable { setStatus(Status.CONNECTING); - System.getProperties().remove("http.proxyHost"); - System.getProperties().remove("http.proxyPort"); - System.getProperties().remove("https.proxyHost"); - System.getProperties().remove("https.proxyPort"); - System.getProperties().remove("http.proxyUser"); - System.getProperties().remove("http.proxyPassword"); + Proxy proxy = ProxySelector.getDefault().select(downloadUrl.toURI()).get(0); - if (PreferencesData.has("proxy.http.server") && PreferencesData.get("proxy.http.server") != null && !PreferencesData.get("proxy.http.server").equals("")) { - System.getProperties().put("http.proxyHost", PreferencesData.get("proxy.http.server")); - System.getProperties().put("http.proxyPort", PreferencesData.get("proxy.http.port")); - } - if (PreferencesData.has("proxy.https.server") && PreferencesData.get("proxy.https.server") != null && !PreferencesData.get("proxy.https.server").equals("")) { - System.getProperties().put("https.proxyHost", PreferencesData.get("proxy.https.server")); - System.getProperties().put("https.proxyPort", PreferencesData.get("proxy.https.port")); - } - if (PreferencesData.has("proxy.user") && PreferencesData.get("proxy.user") != null && !PreferencesData.get("proxy.user").equals("")) { - System.getProperties().put("http.proxyUser", PreferencesData.get("proxy.user")); - System.getProperties().put("http.proxyPassword", PreferencesData.get("proxy.password")); - System.getProperties().put("https.proxyUser", PreferencesData.get("proxy.user")); - System.getProperties().put("https.proxyPassword", PreferencesData.get("proxy.password")); - } - - HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection(); + HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection(proxy); if (downloadUrl.getUserInfo() != null) { String auth = "Basic " + new String(new Base64().encode(downloadUrl.getUserInfo().getBytes())); @@ -160,10 +138,12 @@ public class FileDownloader extends Observable { int resp = connection.getResponseCode(); if (resp == HttpURLConnection.HTTP_MOVED_PERM || resp == HttpURLConnection.HTTP_MOVED_TEMP) { - String newUrl = connection.getHeaderField("Location"); + URL newUrl = new URL(connection.getHeaderField("Location")); + + proxy = ProxySelector.getDefault().select(newUrl.toURI()).get(0); // open the new connnection again - connection = (HttpURLConnection) new URL(newUrl).openConnection(); + connection = (HttpURLConnection) newUrl.openConnection(proxy); if (downloadUrl.getUserInfo() != null) { String auth = "Basic " + new String(new Base64().encode(downloadUrl.getUserInfo().getBytes())); connection.setRequestProperty("Authorization", auth); diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java index fa4a27215..8741aab52 100644 --- a/arduino-core/src/processing/app/BaseNoGui.java +++ b/arduino-core/src/processing/app/BaseNoGui.java @@ -742,8 +742,10 @@ public class BaseNoGui { } static public void main(String args[]) throws Exception { - if (args.length == 0) + if (args.length == 0) { showError(_("No parameters"), _("No command line parameters found"), null); + } + System.setProperty("java.net.useSystemProxies", "true"); Runtime.getRuntime().addShutdownHook(new Thread(DeleteFilesOnShutdown.INSTANCE));