Skip to content

Commit 6789cfe

Browse files
author
Federico Fissore
committed
New modal dialog for adding additional boards manager url: with a wide text area, inputing is much easier
1 parent 74ace66 commit 6789cfe

File tree

5 files changed

+354
-0
lines changed

5 files changed

+354
-0
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,11 @@ test-bin
5353
.directory
5454
hardware/arduino/avr/libraries/Bridge/examples/XivelyClient/passwords.h
5555
avr-toolchain-*.zip
56+
/app/nbproject/private/
57+
/arduino-core/nbproject/private/
58+
/app/build/
59+
/arduino-core/build/
60+
61+
manifest.mf
62+
nbbuild.xml
63+
nbproject
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
4+
<Properties>
5+
<Property name="defaultCloseOperation" type="int" value="2"/>
6+
<Property name="title" type="java.lang.String" value="_(&quot;Additional Boards Manager URLs: &quot;)"/>
7+
<Property name="modal" type="boolean" value="true"/>
8+
<Property name="modalExclusionType" type="java.awt.Dialog$ModalExclusionType" editor="org.netbeans.modules.form.editors.EnumEditor">
9+
<Value id="APPLICATION_EXCLUDE"/>
10+
</Property>
11+
</Properties>
12+
<SyntheticProperties>
13+
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
14+
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
15+
</SyntheticProperties>
16+
<AuxValues>
17+
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
18+
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
19+
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
20+
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
21+
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
22+
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
23+
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
24+
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
25+
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
26+
</AuxValues>
27+
28+
<Layout>
29+
<DimensionLayout dim="0">
30+
<Group type="103" groupAlignment="0" attributes="0">
31+
<Group type="102" attributes="0">
32+
<EmptySpace max="-2" attributes="0"/>
33+
<Group type="103" groupAlignment="0" attributes="0">
34+
<Group type="102" attributes="0">
35+
<EmptySpace min="0" pref="439" max="32767" attributes="0"/>
36+
<Component id="ok" min="-2" max="-2" attributes="0"/>
37+
<EmptySpace max="-2" attributes="0"/>
38+
<Component id="cancel" min="-2" max="-2" attributes="0"/>
39+
</Group>
40+
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
41+
</Group>
42+
<EmptySpace max="-2" attributes="0"/>
43+
</Group>
44+
</Group>
45+
</DimensionLayout>
46+
<DimensionLayout dim="1">
47+
<Group type="103" groupAlignment="0" attributes="0">
48+
<Group type="102" alignment="0" attributes="0">
49+
<EmptySpace max="-2" attributes="0"/>
50+
<Component id="jScrollPane1" pref="141" max="32767" attributes="0"/>
51+
<EmptySpace max="-2" attributes="0"/>
52+
<Group type="103" groupAlignment="3" attributes="0">
53+
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
54+
<Component id="ok" alignment="3" min="-2" max="-2" attributes="0"/>
55+
</Group>
56+
<EmptySpace max="-2" attributes="0"/>
57+
</Group>
58+
</Group>
59+
</DimensionLayout>
60+
</Layout>
61+
<SubComponents>
62+
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
63+
<AuxValues>
64+
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
65+
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
66+
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
67+
</AuxValues>
68+
69+
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
70+
<SubComponents>
71+
<Component class="javax.swing.JTextArea" name="additionalBoardsManagerURLs">
72+
<Properties>
73+
<Property name="columns" type="int" value="20"/>
74+
<Property name="rows" type="int" value="5"/>
75+
<Property name="name" type="java.lang.String" value="" noResource="true"/>
76+
</Properties>
77+
<AuxValues>
78+
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="18"/>
79+
</AuxValues>
80+
</Component>
81+
</SubComponents>
82+
</Container>
83+
<Component class="javax.swing.JButton" name="cancel">
84+
<Properties>
85+
<Property name="text" type="java.lang.String" value="Cancel"/>
86+
</Properties>
87+
<Events>
88+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelActionPerformed"/>
89+
</Events>
90+
<AuxValues>
91+
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
92+
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
93+
</AuxValues>
94+
</Component>
95+
<Component class="javax.swing.JButton" name="ok">
96+
<Properties>
97+
<Property name="text" type="java.lang.String" value="OK"/>
98+
</Properties>
99+
<Events>
100+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okActionPerformed"/>
101+
</Events>
102+
<AuxValues>
103+
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
104+
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
105+
</AuxValues>
106+
</Component>
107+
</SubComponents>
108+
</Form>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Copyright 2015 Arduino LLC (http://www.arduino.cc/)
5+
*
6+
* Arduino is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
* As a special exception, you may use this file as part of a free software
21+
* library without restriction. Specifically, if other files instantiate
22+
* templates or use macros or inline functions from this file, or you compile
23+
* this file and link it with other files to produce an executable, this
24+
* file does not by itself cause the resulting executable to be covered by
25+
* the GNU General Public License. This exception does not however
26+
* invalidate any other reasons why the executable file might be covered by
27+
* the GNU General Public License.
28+
*/
29+
30+
package cc.arduino.view.preferences;
31+
32+
import com.google.common.base.Function;
33+
import com.google.common.base.Joiner;
34+
import com.google.common.base.Predicate;
35+
import com.google.common.collect.FluentIterable;
36+
import processing.app.Base;
37+
38+
import java.awt.event.ActionEvent;
39+
import java.awt.event.ActionListener;
40+
import java.awt.event.WindowEvent;
41+
import java.util.Arrays;
42+
import java.util.Collection;
43+
44+
import static processing.app.I18n._;
45+
46+
public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
47+
48+
private ActionListener onOkListener;
49+
50+
public AdditionalBoardsManagerURLTextArea(java.awt.Frame parent) {
51+
super(parent);
52+
initComponents();
53+
setLocationRelativeTo(parent);
54+
55+
Base.registerWindowCloseKeys(getRootPane(), new ActionListener() {
56+
@Override
57+
public void actionPerformed(ActionEvent e) {
58+
cancelActionPerformed(e);
59+
}
60+
});
61+
62+
}
63+
64+
/**
65+
* This method is called from within the constructor to initialize the form.
66+
* WARNING: Do NOT modify this code. The content of this method is always
67+
* regenerated by the Form Editor.
68+
*/
69+
@SuppressWarnings("unchecked")
70+
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
71+
private void initComponents() {
72+
73+
javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
74+
javax.swing.JButton cancel = new javax.swing.JButton();
75+
javax.swing.JButton ok = new javax.swing.JButton();
76+
77+
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
78+
setTitle(_("Additional Boards Manager URLs"));
79+
setModal(true);
80+
setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
81+
82+
additionalBoardsManagerURLs.setColumns(20);
83+
additionalBoardsManagerURLs.setRows(5);
84+
additionalBoardsManagerURLs.setName(""); // NOI18N
85+
jScrollPane1.setViewportView(additionalBoardsManagerURLs);
86+
87+
cancel.setText(_("Cancel"));
88+
cancel.addActionListener(new java.awt.event.ActionListener() {
89+
public void actionPerformed(java.awt.event.ActionEvent evt) {
90+
cancelActionPerformed(evt);
91+
}
92+
});
93+
94+
ok.setText(_("OK"));
95+
ok.addActionListener(new java.awt.event.ActionListener() {
96+
public void actionPerformed(java.awt.event.ActionEvent evt) {
97+
okActionPerformed(evt);
98+
}
99+
});
100+
101+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
102+
getContentPane().setLayout(layout);
103+
layout.setHorizontalGroup(
104+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
105+
.addGroup(layout.createSequentialGroup()
106+
.addContainerGap()
107+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
108+
.addGroup(layout.createSequentialGroup()
109+
.addGap(0, 439, Short.MAX_VALUE)
110+
.addComponent(ok)
111+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
112+
.addComponent(cancel))
113+
.addComponent(jScrollPane1))
114+
.addContainerGap())
115+
);
116+
layout.setVerticalGroup(
117+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
118+
.addGroup(layout.createSequentialGroup()
119+
.addContainerGap()
120+
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
121+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
122+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
123+
.addComponent(cancel)
124+
.addComponent(ok))
125+
.addContainerGap())
126+
);
127+
128+
pack();
129+
}// </editor-fold>//GEN-END:initComponents
130+
131+
private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
132+
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
133+
}//GEN-LAST:event_cancelActionPerformed
134+
135+
private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
136+
ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "");
137+
onOkListener.actionPerformed(actionEvent);
138+
cancelActionPerformed(evt);
139+
}//GEN-LAST:event_okActionPerformed
140+
141+
/**
142+
* @param args the command line arguments
143+
*/
144+
public static void main(String args[]) {
145+
/* Set the Nimbus look and feel */
146+
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
147+
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
148+
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
149+
*/
150+
try {
151+
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
152+
if ("Nimbus".equals(info.getName())) {
153+
javax.swing.UIManager.setLookAndFeel(info.getClassName());
154+
break;
155+
}
156+
}
157+
} catch (ClassNotFoundException ex) {
158+
java.util.logging.Logger.getLogger(AdditionalBoardsManagerURLTextArea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
159+
} catch (InstantiationException ex) {
160+
java.util.logging.Logger.getLogger(AdditionalBoardsManagerURLTextArea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
161+
} catch (IllegalAccessException ex) {
162+
java.util.logging.Logger.getLogger(AdditionalBoardsManagerURLTextArea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
163+
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
164+
java.util.logging.Logger.getLogger(AdditionalBoardsManagerURLTextArea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
165+
}
166+
//</editor-fold>
167+
168+
/* Create and display the dialog */
169+
java.awt.EventQueue.invokeLater(new Runnable() {
170+
public void run() {
171+
AdditionalBoardsManagerURLTextArea dialog = new AdditionalBoardsManagerURLTextArea(new javax.swing.JFrame());
172+
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
173+
@Override
174+
public void windowClosing(java.awt.event.WindowEvent e) {
175+
System.exit(0);
176+
}
177+
});
178+
dialog.setVisible(true);
179+
}
180+
});
181+
}
182+
183+
public void setText(String text) {
184+
Collection<String> urls = splitAndTrim(text, ",");
185+
additionalBoardsManagerURLs.setText(Joiner.on("\n").skipNulls().join(urls));
186+
}
187+
188+
private Collection<String> splitAndTrim(String text, String separator) {
189+
Collection<String> urls = Arrays.asList(text.split(separator));
190+
return FluentIterable.from(urls).transform(new Function<String, String>() {
191+
@Override
192+
public String apply(String input) {
193+
return input.trim();
194+
}
195+
}).filter(new Predicate<String>() {
196+
@Override
197+
public boolean apply(String input) {
198+
return !input.isEmpty();
199+
}
200+
}).toList();
201+
}
202+
203+
public String getText() {
204+
Collection<String> urls = splitAndTrim(additionalBoardsManagerURLs.getText(), "\n");
205+
return Joiner.on(",").skipNulls().join(urls);
206+
}
207+
208+
// Variables declaration - do not modify//GEN-BEGIN:variables
209+
private final javax.swing.JTextArea additionalBoardsManagerURLs = new javax.swing.JTextArea();
210+
// End of variables declaration//GEN-END:variables
211+
212+
public void onOk(ActionListener listener) {
213+
this.onOkListener = listener;
214+
}
215+
}

app/src/processing/app/Preferences.java

+23
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121

2222
package processing.app;
2323

24+
import cc.arduino.view.preferences.AdditionalBoardsManagerURLTextArea;
25+
import com.google.common.base.Function;
26+
import com.google.common.base.Functions;
27+
import com.google.common.base.Joiner;
28+
import com.google.common.collect.Collections2;
2429
import processing.app.helpers.FileUtils;
2530
import processing.app.helpers.OSUtils;
2631
import processing.app.helpers.PreferencesHelper;
@@ -31,6 +36,8 @@
3136
import java.awt.*;
3237
import java.awt.event.*;
3338
import java.io.File;
39+
import java.util.*;
40+
import java.util.List;
3441

3542
import static processing.app.I18n._;
3643

@@ -489,6 +496,22 @@ public void actionPerformed(ActionEvent e) {
489496
box.add(label);
490497
additionalBoardsManagerField = new JTextField(30);
491498
box.add(additionalBoardsManagerField);
499+
JButton extendedAdditionalUrlFieldWindow = new JButton(new ImageIcon(Base.getThemeImage("newwindow.gif", dialog)));
500+
extendedAdditionalUrlFieldWindow.addActionListener(new ActionListener() {
501+
@Override
502+
public void actionPerformed(ActionEvent e) {
503+
final AdditionalBoardsManagerURLTextArea additionalBoardsManagerURLTextArea = new AdditionalBoardsManagerURLTextArea(dialog);
504+
additionalBoardsManagerURLTextArea.setText(additionalBoardsManagerField.getText());
505+
additionalBoardsManagerURLTextArea.onOk(new ActionListener() {
506+
@Override
507+
public void actionPerformed(ActionEvent e) {
508+
additionalBoardsManagerField.setText(additionalBoardsManagerURLTextArea.getText());
509+
}
510+
});
511+
additionalBoardsManagerURLTextArea.setVisible(true);
512+
}
513+
});
514+
box.add(extendedAdditionalUrlFieldWindow);
492515
pane.add(box);
493516
d = box.getPreferredSize();
494517
box.setBounds(left, top, d.width, d.height);

build/shared/lib/theme/newwindow.gif

91 Bytes
Loading

0 commit comments

Comments
 (0)