Skip to content

Commit d2ac1a4

Browse files
author
Federico Fissore
committed
Added link to unofficial boards support url in secondary modal. Fixes #3327
First java 8 syntax goodness: yum!
1 parent ad8046d commit d2ac1a4

File tree

4 files changed

+84
-55
lines changed

4 files changed

+84
-55
lines changed

app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.form

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@
3333
<Group type="102" attributes="0">
3434
<EmptySpace max="-2" attributes="0"/>
3535
<Group type="103" groupAlignment="0" attributes="0">
36-
<Group type="102" attributes="0">
37-
<EmptySpace min="0" pref="332" max="32767" attributes="0"/>
36+
<Group type="102" alignment="0" attributes="0">
37+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
3838
<Component id="ok" min="-2" max="-2" attributes="0"/>
3939
<EmptySpace max="-2" attributes="0"/>
4040
<Component id="cancel" min="-2" max="-2" attributes="0"/>
4141
</Group>
42-
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
43-
<Group type="102" alignment="0" attributes="0">
44-
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
42+
<Component id="jScrollPane1" alignment="0" pref="538" max="32767" attributes="0"/>
43+
<Group type="102" attributes="0">
44+
<Group type="103" groupAlignment="0" attributes="0">
45+
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
46+
<Component id="unofficialListURLLabel" alignment="0" min="-2" max="-2" attributes="0"/>
47+
</Group>
4548
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
4649
</Group>
4750
</Group>
@@ -55,13 +58,15 @@
5558
<EmptySpace max="-2" attributes="0"/>
5659
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
5760
<EmptySpace max="-2" attributes="0"/>
58-
<Component id="jScrollPane1" pref="118" max="32767" attributes="0"/>
61+
<Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
62+
<EmptySpace max="-2" attributes="0"/>
63+
<Component id="unofficialListURLLabel" min="-2" max="-2" attributes="0"/>
5964
<EmptySpace max="-2" attributes="0"/>
6065
<Group type="103" groupAlignment="3" attributes="0">
61-
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
6266
<Component id="ok" alignment="3" min="-2" max="-2" attributes="0"/>
67+
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
6368
</Group>
64-
<EmptySpace max="-2" attributes="0"/>
69+
<EmptySpace max="32767" attributes="0"/>
6570
</Group>
6671
</Group>
6772
</DimensionLayout>
@@ -127,5 +132,20 @@
127132
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
128133
</AuxValues>
129134
</Component>
135+
<Component class="javax.swing.JLabel" name="unofficialListURLLabel">
136+
<Properties>
137+
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
138+
<Connection code="_(&quot;Click for a list of unofficial boards support URLs&quot;)" type="code"/>
139+
</Property>
140+
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
141+
<Color id="Cursore mano"/>
142+
</Property>
143+
</Properties>
144+
<Events>
145+
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="unofficialListURLLabelMouseClicked"/>
146+
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="unofficialListURLLabelMouseExited"/>
147+
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="unofficialListURLLabelMouseEntered"/>
148+
</Events>
149+
</Component>
130150
</SubComponents>
131151
</Form>

app/src/cc/arduino/view/preferences/AdditionalBoardsManagerURLTextArea.java

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929

3030
package cc.arduino.view.preferences;
3131

32-
import com.google.common.base.Function;
3332
import com.google.common.base.Joiner;
34-
import com.google.common.base.Predicate;
3533
import com.google.common.collect.FluentIterable;
3634
import processing.app.Base;
3735

@@ -53,13 +51,7 @@ public AdditionalBoardsManagerURLTextArea(Window parent) {
5351
initComponents();
5452
setLocationRelativeTo(parent);
5553

56-
Base.registerWindowCloseKeys(getRootPane(), new ActionListener() {
57-
@Override
58-
public void actionPerformed(ActionEvent e) {
59-
cancelActionPerformed(e);
60-
}
61-
});
62-
54+
Base.registerWindowCloseKeys(getRootPane(), this::cancelActionPerformed);
6355
}
6456

6557
/**
@@ -75,6 +67,7 @@ private void initComponents() {
7567
javax.swing.JButton cancel = new javax.swing.JButton();
7668
javax.swing.JButton ok = new javax.swing.JButton();
7769
javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
70+
unofficialListURLLabel = new javax.swing.JLabel();
7871

7972
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
8073
setTitle(_("Additional Boards Manager URLs"));
@@ -102,6 +95,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
10295

10396
jLabel1.setText(_("Enter additional URLs, one for each row"));
10497

98+
unofficialListURLLabel.setText(_("Click for a list of unofficial boards support URLs"));
99+
unofficialListURLLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
100+
unofficialListURLLabel.addMouseListener(new java.awt.event.MouseAdapter() {
101+
public void mouseClicked(java.awt.event.MouseEvent evt) {
102+
unofficialListURLLabelMouseClicked(evt);
103+
}
104+
105+
public void mouseExited(java.awt.event.MouseEvent evt) {
106+
unofficialListURLLabelMouseExited(evt);
107+
}
108+
109+
public void mouseEntered(java.awt.event.MouseEvent evt) {
110+
unofficialListURLLabelMouseEntered(evt);
111+
}
112+
});
113+
105114
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
106115
getContentPane().setLayout(layout);
107116
layout.setHorizontalGroup(
@@ -110,13 +119,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
110119
.addContainerGap()
111120
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
112121
.addGroup(layout.createSequentialGroup()
113-
.addGap(0, 332, Short.MAX_VALUE)
122+
.addGap(0, 0, Short.MAX_VALUE)
114123
.addComponent(ok)
115124
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
116125
.addComponent(cancel))
117-
.addComponent(jScrollPane1)
126+
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE)
118127
.addGroup(layout.createSequentialGroup()
119-
.addComponent(jLabel1)
128+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
129+
.addComponent(jLabel1)
130+
.addComponent(unofficialListURLLabel))
120131
.addGap(0, 0, Short.MAX_VALUE)))
121132
.addContainerGap())
122133
);
@@ -126,12 +137,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
126137
.addContainerGap()
127138
.addComponent(jLabel1)
128139
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
129-
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
140+
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
141+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
142+
.addComponent(unofficialListURLLabel)
130143
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
131144
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
132-
.addComponent(cancel)
133-
.addComponent(ok))
134-
.addContainerGap())
145+
.addComponent(ok)
146+
.addComponent(cancel))
147+
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
135148
);
136149

137150
pack();
@@ -147,24 +160,26 @@ private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:even
147160
cancelActionPerformed(evt);
148161
}//GEN-LAST:event_okActionPerformed
149162

163+
private void unofficialListURLLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_unofficialListURLLabelMouseEntered
164+
unofficialListURLLabel.setForeground(new Color(0, 0, 140));
165+
}//GEN-LAST:event_unofficialListURLLabelMouseEntered
166+
167+
private void unofficialListURLLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_unofficialListURLLabelMouseExited
168+
unofficialListURLLabel.setForeground(new Color(76, 76, 76));
169+
}//GEN-LAST:event_unofficialListURLLabelMouseExited
170+
171+
private void unofficialListURLLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_unofficialListURLLabelMouseClicked
172+
Base.openURL("https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls");
173+
}//GEN-LAST:event_unofficialListURLLabelMouseClicked
174+
150175
public void setText(String text) {
151176
Collection<String> urls = splitAndTrim(text, ",");
152177
additionalBoardsManagerURLs.setText(Joiner.on("\n").skipNulls().join(urls));
153178
}
154179

155180
private Collection<String> splitAndTrim(String text, String separator) {
156181
Collection<String> urls = Arrays.asList(text.split(separator));
157-
return FluentIterable.from(urls).transform(new Function<String, String>() {
158-
@Override
159-
public String apply(String input) {
160-
return input.trim();
161-
}
162-
}).filter(new Predicate<String>() {
163-
@Override
164-
public boolean apply(String input) {
165-
return !input.isEmpty();
166-
}
167-
}).toList();
182+
return FluentIterable.from(urls).transform(String::trim).filter(url -> !url.isEmpty()).toList();
168183
}
169184

170185
public String getText() {
@@ -174,6 +189,7 @@ public String getText() {
174189

175190
// Variables declaration - do not modify//GEN-BEGIN:variables
176191
private final javax.swing.JTextArea additionalBoardsManagerURLs = new javax.swing.JTextArea();
192+
private javax.swing.JLabel unofficialListURLLabel;
177193
// End of variables declaration//GEN-END:variables
178194

179195
public void onOk(ActionListener listener) {

app/src/cc/arduino/view/preferences/Preferences.form

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@
323323
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
324324
<Connection code="PreferencesData.getPreferencesFile().getAbsolutePath()" type="code"/>
325325
</Property>
326+
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
327+
<Color id="Cursore mano"/>
328+
</Property>
326329
</Properties>
327330
<Events>
328331
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="preferencesFileLabelMousePressed"/>

app/src/cc/arduino/view/preferences/Preferences.java

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@
2929

3030
package cc.arduino.view.preferences;
3131

32-
import processing.app.*;
32+
import processing.app.Base;
33+
import processing.app.BaseNoGui;
34+
import processing.app.I18n;
35+
import processing.app.PreferencesData;
3336
import processing.app.helpers.FileUtils;
3437
import processing.app.legacy.PApplet;
3538

3639
import javax.swing.*;
3740
import java.awt.*;
38-
import java.awt.event.ActionEvent;
39-
import java.awt.event.ActionListener;
4041
import java.awt.event.WindowEvent;
4142
import java.io.File;
4243
import java.util.LinkedList;
@@ -188,12 +189,7 @@ public Preferences(Window parent, Base base) {
188189

189190
initComponents();
190191

191-
Base.registerWindowCloseKeys(getRootPane(), new ActionListener() {
192-
@Override
193-
public void actionPerformed(ActionEvent e) {
194-
cancelButtonActionPerformed(e);
195-
}
196-
});
192+
Base.registerWindowCloseKeys(getRootPane(), this::cancelButtonActionPerformed);
197193

198194
showPrerefencesData();
199195
}
@@ -286,6 +282,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
286282
morePreferencesLabel.setText(_("More preferences can be edited directly in the file"));
287283

288284
preferencesFileLabel.setText(PreferencesData.getPreferencesFile().getAbsolutePath());
285+
preferencesFileLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
289286
preferencesFileLabel.addMouseListener(new java.awt.event.MouseAdapter() {
290287
public void mousePressed(java.awt.event.MouseEvent evt) {
291288
preferencesFileLabelMousePressed(evt);
@@ -461,12 +458,7 @@ private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
461458
private void extendedAdditionalUrlFieldWindowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_extendedAdditionalUrlFieldWindowActionPerformed
462459
final AdditionalBoardsManagerURLTextArea additionalBoardsManagerURLTextArea = new AdditionalBoardsManagerURLTextArea(this);
463460
additionalBoardsManagerURLTextArea.setText(additionalBoardsManagerField.getText());
464-
additionalBoardsManagerURLTextArea.onOk(new ActionListener() {
465-
@Override
466-
public void actionPerformed(ActionEvent e) {
467-
additionalBoardsManagerField.setText(additionalBoardsManagerURLTextArea.getText());
468-
}
469-
});
461+
additionalBoardsManagerURLTextArea.onOk(e -> additionalBoardsManagerField.setText(additionalBoardsManagerURLTextArea.getText()));
470462
additionalBoardsManagerURLTextArea.setVisible(true);
471463
}//GEN-LAST:event_extendedAdditionalUrlFieldWindowActionPerformed
472464

@@ -479,7 +471,7 @@ private void preferencesFileLabelMousePressed(java.awt.event.MouseEvent evt) {//
479471
}//GEN-LAST:event_preferencesFileLabelMousePressed
480472

481473
private void preferencesFileLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_preferencesFileLabelMouseExited
482-
preferencesFileLabel.setForeground(Color.BLACK);
474+
preferencesFileLabel.setForeground(new Color(76, 76, 76));
483475
}//GEN-LAST:event_preferencesFileLabelMouseExited
484476

485477
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
@@ -494,9 +486,7 @@ private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
494486
}
495487

496488
savePreferencesData();
497-
for (Editor editor : base.getEditors()) {
498-
editor.applyPreferences();
499-
}
489+
base.getEditors().forEach(processing.app.Editor::applyPreferences);
500490
cancelButtonActionPerformed(evt);
501491
}//GEN-LAST:event_okButtonActionPerformed
502492

@@ -519,7 +509,7 @@ private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
519509
// End of variables declaration//GEN-END:variables
520510

521511
private java.util.List<String> validateData() {
522-
java.util.List<String> errors = new LinkedList<String>();
512+
java.util.List<String> errors = new LinkedList<>();
523513
if (FileUtils.isSubDirectory(new File(sketchbookLocationField.getText()), new File(PreferencesData.get("runtime.ide.path")))) {
524514
errors.add(_("The specified sketchbook folder contains your copy of the IDE.\nPlease choose a different folder for your sketchbook."));
525515
}

0 commit comments

Comments
 (0)