Added link to unofficial boards support url in secondary modal. Fixes #3327

First java 8 syntax goodness: yum!
This commit is contained in:
Federico Fissore 2015-06-16 14:45:55 +02:00
parent ad8046dab5
commit d2ac1a4e6a
4 changed files with 84 additions and 55 deletions

View File

@ -33,15 +33,18 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="332" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="ok" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cancel" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="538" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="unofficialListURLLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
@ -55,13 +58,15 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="118" max="32767" attributes="0"/>
<Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="unofficialListURLLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="ok" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -127,5 +132,20 @@
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="unofficialListURLLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="_(&quot;Click for a list of unofficial boards support URLs&quot;)" type="code"/>
</Property>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Cursore mano"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="unofficialListURLLabelMouseClicked"/>
<EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="unofficialListURLLabelMouseExited"/>
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="unofficialListURLLabelMouseEntered"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -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()
.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<String> urls = splitAndTrim(text, ",");
additionalBoardsManagerURLs.setText(Joiner.on("\n").skipNulls().join(urls));
@ -154,17 +179,7 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
private Collection<String> splitAndTrim(String text, String separator) {
Collection<String> urls = Arrays.asList(text.split(separator));
return FluentIterable.from(urls).transform(new Function<String, String>() {
@Override
public String apply(String input) {
return input.trim();
}
}).filter(new Predicate<String>() {
@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) {

View File

@ -323,6 +323,9 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="PreferencesData.getPreferencesFile().getAbsolutePath()" type="code"/>
</Property>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Cursore mano"/>
</Property>
</Properties>
<Events>
<EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="preferencesFileLabelMousePressed"/>

View File

@ -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<String> validateData() {
java.util.List<String> errors = new LinkedList<String>();
java.util.List<String> 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."));
}