diff --git a/app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.form b/app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.form index a8b6eb4bd..e3b61f50d 100644 --- a/app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.form +++ b/app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.form @@ -33,15 +33,18 @@ - - + + - - - + + + + + + @@ -55,13 +58,15 @@ - + + + - + - + @@ -127,5 +132,20 @@ + + + + + + + + + + + + + + + diff --git a/app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.java b/app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.java index c4ed51e02..d4e30eb21 100644 --- a/app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.java +++ b/app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.java @@ -29,9 +29,7 @@ package cc.arduino.view.preferences; -import com.google.common.base.Function; import com.google.common.base.Joiner; -import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; import processing.app.Base; @@ -53,13 +51,7 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog { initComponents(); setLocationRelativeTo(parent); - Base.registerWindowCloseKeys(getRootPane(), new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - cancelActionPerformed(e); - } - }); - + Base.registerWindowCloseKeys(getRootPane(), this::cancelActionPerformed); } /** @@ -75,6 +67,7 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog { javax.swing.JButton cancel = new javax.swing.JButton(); javax.swing.JButton ok = new javax.swing.JButton(); javax.swing.JLabel jLabel1 = new javax.swing.JLabel(); + unofficialListURLLabel = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle(_("Additional Boards Manager URLs")); @@ -102,6 +95,22 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog { jLabel1.setText(_("Enter additional URLs, one for each row")); + unofficialListURLLabel.setText(_("Click for a list of unofficial boards support URLs")); + unofficialListURLLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); + unofficialListURLLabel.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + unofficialListURLLabelMouseClicked(evt); + } + + public void mouseExited(java.awt.event.MouseEvent evt) { + unofficialListURLLabelMouseExited(evt); + } + + public void mouseEntered(java.awt.event.MouseEvent evt) { + unofficialListURLLabelMouseEntered(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( @@ -110,13 +119,15 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog { .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addGap(0, 332, Short.MAX_VALUE) + .addGap(0, 0, Short.MAX_VALUE) .addComponent(ok) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cancel)) - .addComponent(jScrollPane1) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() - .addComponent(jLabel1) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(unofficialListURLLabel)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); @@ -126,12 +137,14 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog { .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(unofficialListURLLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(cancel) - .addComponent(ok)) - .addContainerGap()) + .addComponent(ok) + .addComponent(cancel)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); @@ -147,6 +160,18 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog { cancelActionPerformed(evt); }//GEN-LAST:event_okActionPerformed + private void unofficialListURLLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_unofficialListURLLabelMouseEntered + unofficialListURLLabel.setForeground(new Color(0, 0, 140)); + }//GEN-LAST:event_unofficialListURLLabelMouseEntered + + private void unofficialListURLLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_unofficialListURLLabelMouseExited + unofficialListURLLabel.setForeground(new Color(76, 76, 76)); + }//GEN-LAST:event_unofficialListURLLabelMouseExited + + private void unofficialListURLLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_unofficialListURLLabelMouseClicked + Base.openURL("https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls"); + }//GEN-LAST:event_unofficialListURLLabelMouseClicked + public void setText(String text) { Collection urls = splitAndTrim(text, ","); additionalBoardsManagerURLs.setText(Joiner.on("\n").skipNulls().join(urls)); @@ -154,17 +179,7 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog { private Collection splitAndTrim(String text, String separator) { Collection urls = Arrays.asList(text.split(separator)); - return FluentIterable.from(urls).transform(new Function() { - @Override - public String apply(String input) { - return input.trim(); - } - }).filter(new Predicate() { - @Override - public boolean apply(String input) { - return !input.isEmpty(); - } - }).toList(); + return FluentIterable.from(urls).transform(String::trim).filter(url -> !url.isEmpty()).toList(); } public String getText() { @@ -174,6 +189,7 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog { // Variables declaration - do not modify//GEN-BEGIN:variables private final javax.swing.JTextArea additionalBoardsManagerURLs = new javax.swing.JTextArea(); + private javax.swing.JLabel unofficialListURLLabel; // End of variables declaration//GEN-END:variables public void onOk(ActionListener listener) { diff --git a/app/src/cc/arduino/view/preferences/Preferences.form b/app/src/cc/arduino/view/preferences/Preferences.form index 2be500ad5..b0105a781 100644 --- a/app/src/cc/arduino/view/preferences/Preferences.form +++ b/app/src/cc/arduino/view/preferences/Preferences.form @@ -323,6 +323,9 @@ + + + diff --git a/app/src/cc/arduino/view/preferences/Preferences.java b/app/src/cc/arduino/view/preferences/Preferences.java index 2ad36ca44..7e0e1661f 100644 --- a/app/src/cc/arduino/view/preferences/Preferences.java +++ b/app/src/cc/arduino/view/preferences/Preferences.java @@ -29,14 +29,15 @@ package cc.arduino.view.preferences; -import processing.app.*; +import processing.app.Base; +import processing.app.BaseNoGui; +import processing.app.I18n; +import processing.app.PreferencesData; import processing.app.helpers.FileUtils; import processing.app.legacy.PApplet; import javax.swing.*; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.WindowEvent; import java.io.File; import java.util.LinkedList; @@ -188,12 +189,7 @@ public class Preferences extends javax.swing.JDialog { initComponents(); - Base.registerWindowCloseKeys(getRootPane(), new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - cancelButtonActionPerformed(e); - } - }); + Base.registerWindowCloseKeys(getRootPane(), this::cancelButtonActionPerformed); showPrerefencesData(); } @@ -286,6 +282,7 @@ public class Preferences extends javax.swing.JDialog { morePreferencesLabel.setText(_("More preferences can be edited directly in the file")); preferencesFileLabel.setText(PreferencesData.getPreferencesFile().getAbsolutePath()); + preferencesFileLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); preferencesFileLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { preferencesFileLabelMousePressed(evt); @@ -461,12 +458,7 @@ public class Preferences extends javax.swing.JDialog { private void extendedAdditionalUrlFieldWindowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_extendedAdditionalUrlFieldWindowActionPerformed final AdditionalBoardsManagerURLTextArea additionalBoardsManagerURLTextArea = new AdditionalBoardsManagerURLTextArea(this); additionalBoardsManagerURLTextArea.setText(additionalBoardsManagerField.getText()); - additionalBoardsManagerURLTextArea.onOk(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - additionalBoardsManagerField.setText(additionalBoardsManagerURLTextArea.getText()); - } - }); + additionalBoardsManagerURLTextArea.onOk(e -> additionalBoardsManagerField.setText(additionalBoardsManagerURLTextArea.getText())); additionalBoardsManagerURLTextArea.setVisible(true); }//GEN-LAST:event_extendedAdditionalUrlFieldWindowActionPerformed @@ -479,7 +471,7 @@ public class Preferences extends javax.swing.JDialog { }//GEN-LAST:event_preferencesFileLabelMousePressed private void preferencesFileLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_preferencesFileLabelMouseExited - preferencesFileLabel.setForeground(Color.BLACK); + preferencesFileLabel.setForeground(new Color(76, 76, 76)); }//GEN-LAST:event_preferencesFileLabelMouseExited private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed @@ -494,9 +486,7 @@ public class Preferences extends javax.swing.JDialog { } savePreferencesData(); - for (Editor editor : base.getEditors()) { - editor.applyPreferences(); - } + base.getEditors().forEach(processing.app.Editor::applyPreferences); cancelButtonActionPerformed(evt); }//GEN-LAST:event_okButtonActionPerformed @@ -519,7 +509,7 @@ public class Preferences extends javax.swing.JDialog { // End of variables declaration//GEN-END:variables private java.util.List validateData() { - java.util.List errors = new LinkedList(); + java.util.List errors = new LinkedList<>(); if (FileUtils.isSubDirectory(new File(sketchbookLocationField.getText()), new File(PreferencesData.get("runtime.ide.path")))) { errors.add(_("The specified sketchbook folder contains your copy of the IDE.\nPlease choose a different folder for your sketchbook.")); }