Skip to content

Commit c0e03e3

Browse files
committed
Merge pull request #2 from arduino/master
pull master
2 parents 3ed980f + 90f09e9 commit c0e03e3

File tree

305 files changed

+7105
-12393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

305 files changed

+7105
-12393
lines changed

app/src/cc/arduino/ConsoleOutputStream.java

+8-16
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
import javax.swing.*;
4242
import javax.swing.text.BadLocationException;
43-
import javax.swing.text.Document;
4443
import javax.swing.text.SimpleAttributeSet;
4544
import java.io.ByteArrayOutputStream;
4645
import java.io.PrintStream;
@@ -57,28 +56,23 @@ public class ConsoleOutputStream extends ByteArrayOutputStream {
5756
private final PrintStream printStream;
5857
private final StringBuilder buffer;
5958
private final Timer timer;
60-
private JScrollPane scrollPane;
61-
private Document document;
59+
private volatile EditorConsole editorConsole;
6260

6361
public ConsoleOutputStream(SimpleAttributeSet attributes, PrintStream printStream) {
6462
this.attributes = attributes;
6563
this.printStream = printStream;
6664
this.buffer = new StringBuilder();
6765

6866
this.timer = new Timer(100, (e) -> {
69-
if (scrollPane != null) {
70-
synchronized (scrollPane) {
71-
scrollPane.getHorizontalScrollBar().setValue(0);
72-
scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum());
73-
}
67+
if (editorConsole != null) {
68+
editorConsole.scrollDown();
7469
}
7570
});
7671
timer.setRepeats(false);
7772
}
7873

79-
public synchronized void setCurrentEditorConsole(EditorConsole console) {
80-
this.scrollPane = console;
81-
this.document = console.getDocument();
74+
public void setCurrentEditorConsole(EditorConsole console) {
75+
this.editorConsole = console;
8276
}
8377

8478
public synchronized void flush() {
@@ -102,7 +96,7 @@ private void handleAppend(String message) {
10296
}
10397

10498
private void resetBufferIfDocumentEmpty() {
105-
if (document != null && document.getLength() == 0) {
99+
if (editorConsole != null && editorConsole.isEmpty()) {
106100
buffer.setLength(0);
107101
}
108102
}
@@ -113,12 +107,10 @@ private void clearBuffer() {
113107

114108
printStream.print(line);
115109

116-
if (document != null) {
110+
if (editorConsole != null) {
117111
SwingUtilities.invokeLater(() -> {
118112
try {
119-
String lineWithoutCR = line.replace("\r\n", "\n").replace("\r", "\n");
120-
int offset = document.getLength();
121-
document.insertString(offset, lineWithoutCR, attributes);
113+
editorConsole.insertString(line, attributes);
122114
} catch (BadLocationException ble) {
123115
//ignore
124116
}

app/src/cc/arduino/contributions/BuiltInCoreIsNewerCheck.java

-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@
3333
import cc.arduino.contributions.filters.InstalledPredicate;
3434
import cc.arduino.contributions.packages.ContributedPackage;
3535
import cc.arduino.contributions.packages.ContributedPlatform;
36-
import cc.arduino.view.Event;
3736
import processing.app.Base;
3837
import processing.app.BaseNoGui;
3938
import processing.app.I18n;
4039
import processing.app.PreferencesData;
4140

4241
import javax.swing.*;
43-
import java.awt.event.ActionEvent;
4442
import java.util.Collection;
4543
import java.util.List;
4644
import java.util.stream.Collectors;

app/src/cc/arduino/contributions/libraries/LibraryTypeComparator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class LibraryTypeComparator implements Comparator<String> {
3838
private final List<String> types;
3939

4040
public LibraryTypeComparator() {
41-
this("Arduino", "Recommended", "Contributed");
41+
this("Arduino", "Partner", "Recommended", "Contributed");
4242
}
4343

4444
public LibraryTypeComparator(String... types) {

app/src/cc/arduino/packages/formatter/AStyle.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ public void run() {
9191
int line = getLineOfOffset(textArea);
9292
int lineOffset = getLineOffset(textArea, line);
9393

94-
editor.getTextArea().getUndoManager().beginInternalAtomicEdit();
94+
textArea.getUndoManager().beginInternalAtomicEdit();
95+
editor.removeAllLineHighlights();
9596
editor.setText(formattedText);
9697
editor.getSketch().setModified(true);
97-
editor.getTextArea().getUndoManager().endInternalAtomicEdit();
98+
textArea.getUndoManager().endInternalAtomicEdit();
9899

99100
if (line != -1 && lineOffset != -1) {
100101
try {

app/src/cc/arduino/view/NotificationPopup.java

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener, Stri
5353
public void componentMoved(ComponentEvent e) {
5454
updateLocation(parent);
5555
}
56+
57+
@Override
58+
public void componentResized(ComponentEvent e) {
59+
updateLocation(parent);
60+
}
5661
};
5762
parent.addComponentListener(parentMovedListener);
5863

app/src/cc/arduino/view/SplashScreenHelper.java

+36-19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737

3838
public class SplashScreenHelper {
3939

40+
private static final int X_OFFSET = 0;
41+
private static final int Y_OFFSET = 300;
42+
private static final int TEXTAREA_HEIGHT = 30;
43+
private static final int TEXTAREA_WIDTH = 475;
44+
4045
private final Map desktopHints;
4146
private final SplashScreen splash;
4247
private Rectangle2D.Double splashTextArea;
@@ -48,44 +53,56 @@ public SplashScreenHelper(SplashScreen splash) {
4853
desktopHints = (Map) tk.getDesktopProperty("awt.font.desktophints");
4954
}
5055

51-
public void splashText(String str) {
56+
public void splashText(String text) {
5257
if (splash == null) {
53-
printText(str);
58+
printText(text);
5459
return;
5560
}
61+
5662
if (!splash.isVisible()) {
5763
return;
5864
}
5965

6066
if (splashTextArea == null) {
61-
// stake out some area for our status information
62-
splashTextArea = new Rectangle2D.Double(0, 300, 520, 30);
63-
64-
// create the Graphics environment for drawing status info
65-
splashGraphics = splash.createGraphics();
66-
67-
if (desktopHints != null) {
68-
splashGraphics.addRenderingHints(desktopHints);
69-
}
67+
prepareTextAreaAndGraphics();
7068
}
7169

72-
// erase the last status text
73-
splashGraphics.setPaint(new Color(245, 245, 245));
74-
splashGraphics.fill(splashTextArea);
70+
eraseLastStatusText();
7571

76-
// draw the text
77-
splashGraphics.setPaint(Color.BLACK);
78-
FontMetrics metrics = splashGraphics.getFontMetrics();
79-
splashGraphics.drawString(str, (int) splashTextArea.getX() + 10, (int) splashTextArea.getY() + (30 - metrics.getHeight()) + 4);
72+
drawText(text);
8073

81-
// make sure it's displayed
74+
ensureTextIsDiplayed();
75+
}
76+
77+
private void ensureTextIsDiplayed() {
8278
synchronized (SplashScreen.class) {
8379
if (splash.isVisible()) {
8480
splash.update();
8581
}
8682
}
8783
}
8884

85+
private void drawText(String str) {
86+
splashGraphics.setPaint(Color.BLACK);
87+
FontMetrics metrics = splashGraphics.getFontMetrics();
88+
splashGraphics.drawString(str, (int) splashTextArea.getX() + 10, (int) splashTextArea.getY() + (TEXTAREA_HEIGHT - metrics.getHeight()) + 5);
89+
}
90+
91+
private void eraseLastStatusText() {
92+
splashGraphics.setPaint(new Color(229, 229, 229));
93+
splashGraphics.fill(splashTextArea);
94+
}
95+
96+
private void prepareTextAreaAndGraphics() {
97+
splashTextArea = new Rectangle2D.Double(X_OFFSET, Y_OFFSET, TEXTAREA_WIDTH, TEXTAREA_HEIGHT);
98+
99+
splashGraphics = splash.createGraphics();
100+
101+
if (desktopHints != null) {
102+
splashGraphics.addRenderingHints(desktopHints);
103+
}
104+
}
105+
89106
public void close() {
90107
if (splash == null) {
91108
return;

app/src/cc/arduino/view/findreplace/FindReplace.form

+12-11
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
<Properties>
55
<Property name="defaultCloseOperation" type="int" value="2"/>
66
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
7-
<Connection code="_(&quot;Find&quot;)" type="code"/>
7+
<Connection code="tr(&quot;Find&quot;)" type="code"/>
88
</Property>
9+
<Property name="resizable" type="boolean" value="false"/>
910
</Properties>
1011
<SyntheticProperties>
1112
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
@@ -84,7 +85,7 @@
8485
<Component class="javax.swing.JLabel" name="findLabel">
8586
<Properties>
8687
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
87-
<Connection code="_(&quot;Find:&quot;)" type="code"/>
88+
<Connection code="tr(&quot;Find:&quot;)" type="code"/>
8889
</Property>
8990
</Properties>
9091
<AuxValues>
@@ -100,7 +101,7 @@
100101
<Component class="javax.swing.JLabel" name="replaceLabel">
101102
<Properties>
102103
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
103-
<Connection code="_(&quot;Replace with:&quot;)" type="code"/>
104+
<Connection code="tr(&quot;Replace with:&quot;)" type="code"/>
104105
</Property>
105106
</Properties>
106107
<AuxValues>
@@ -117,22 +118,22 @@
117118
<Properties>
118119
<Property name="selected" type="boolean" value="true"/>
119120
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
120-
<Connection code="_(&quot;Ignore Case&quot;)" type="code"/>
121+
<Connection code="tr(&quot;Ignore Case&quot;)" type="code"/>
121122
</Property>
122123
</Properties>
123124
</Component>
124125
<Component class="javax.swing.JCheckBox" name="wrapAroundBox">
125126
<Properties>
126127
<Property name="selected" type="boolean" value="true"/>
127128
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
128-
<Connection code="_(&quot;Wrap Around&quot;)" type="code"/>
129+
<Connection code="tr(&quot;Wrap Around&quot;)" type="code"/>
129130
</Property>
130131
</Properties>
131132
</Component>
132133
<Component class="javax.swing.JCheckBox" name="searchAllFilesBox">
133134
<Properties>
134135
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
135-
<Connection code="_(&quot;Search all Sketch Tabs&quot;)" type="code"/>
136+
<Connection code="tr(&quot;Search all Sketch Tabs&quot;)" type="code"/>
136137
</Property>
137138
</Properties>
138139
</Component>
@@ -143,7 +144,7 @@
143144
<Component class="javax.swing.JButton" name="findButton">
144145
<Properties>
145146
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
146-
<Connection code="_(&quot;Find&quot;)" type="code"/>
147+
<Connection code="tr(&quot;Find&quot;)" type="code"/>
147148
</Property>
148149
</Properties>
149150
<Events>
@@ -153,7 +154,7 @@
153154
<Component class="javax.swing.JButton" name="previousButton">
154155
<Properties>
155156
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
156-
<Connection code="_(&quot;Previous&quot;)" type="code"/>
157+
<Connection code="tr(&quot;Previous&quot;)" type="code"/>
157158
</Property>
158159
</Properties>
159160
<Events>
@@ -163,7 +164,7 @@
163164
<Component class="javax.swing.JButton" name="replaceFindButton">
164165
<Properties>
165166
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
166-
<Connection code="_(&quot;Replace &amp; Find&quot;)" type="code"/>
167+
<Connection code="tr(&quot;Replace &amp; Find&quot;)" type="code"/>
167168
</Property>
168169
</Properties>
169170
<Events>
@@ -173,7 +174,7 @@
173174
<Component class="javax.swing.JButton" name="replaceButton">
174175
<Properties>
175176
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
176-
<Connection code="_(&quot;Replace&quot;)" type="code"/>
177+
<Connection code="tr(&quot;Replace&quot;)" type="code"/>
177178
</Property>
178179
</Properties>
179180
<Events>
@@ -183,7 +184,7 @@
183184
<Component class="javax.swing.JButton" name="replaceAllButton">
184185
<Properties>
185186
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
186-
<Connection code="_(&quot;Replace All&quot;)" type="code"/>
187+
<Connection code="tr(&quot;Replace All&quot;)" type="code"/>
187188
</Property>
188189
</Properties>
189190
<Events>

app/src/cc/arduino/view/findreplace/FindReplace.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ public FindReplace(Editor editor, Map<String, Object> state) {
6666
buttonsContainer.add(findButton);
6767
}
6868

69-
getRootPane().setDefaultButton(findButton);
70-
7169
Base.registerWindowCloseKeys(getRootPane(), e -> {
7270
setVisible(false);
7371
Base.FIND_DIALOG_STATE = findDialogState();
@@ -85,6 +83,13 @@ public void windowActivated(WindowEvent e) {
8583
restoreFindDialogState(state);
8684
}
8785

86+
@Override
87+
public void setVisible(boolean b) {
88+
getRootPane().setDefaultButton(findButton);
89+
90+
super.setVisible(b);
91+
}
92+
8893
private Map<String, Object> findDialogState() {
8994
Map<String, Object> state = new HashMap<>();
9095
state.put(FIND_TEXT, findField.getText());
@@ -138,6 +143,7 @@ private void initComponents() {
138143

139144
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
140145
setTitle(tr("Find"));
146+
setResizable(false);
141147

142148
findLabel.setText(tr("Find:"));
143149

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

+6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
public class Preferences extends javax.swing.JDialog {
4949

5050
private final Language[] languages;
51+
52+
// Languages that are not translated at least to 65% are
53+
// kept in the "missingLanguages" array until they have enough
54+
// translated strings.
55+
@SuppressWarnings("unused")
5156
private final Language[] missingLanguages;
57+
5258
private final WarningItem[] warningItems;
5359
private final Base base;
5460

app/src/processing/app/AbstractMonitor.java

-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
@SuppressWarnings("serial")
1414
public abstract class AbstractMonitor extends JFrame implements ActionListener {
1515

16-
private boolean monitorEnabled;
1716
private boolean closed;
1817

1918
private StringBuffer updateBuffer;
@@ -78,15 +77,13 @@ public void actionPerformed(ActionEvent event) {
7877
updateTimer = new Timer(33, this); // redraw serial monitor at 30 Hz
7978
updateTimer.start();
8079

81-
monitorEnabled = true;
8280
closed = false;
8381
}
8482

8583
protected abstract void onCreateWindow(Container mainPane);
8684

8785
public void enableWindow(boolean enable) {
8886
onEnableWindow(enable);
89-
monitorEnabled = enable;
9087
}
9188

9289
protected abstract void onEnableWindow(boolean enable);

app/src/processing/app/Base.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ public void handleNew() throws Exception {
748748
try {
749749
File file = createNewUntitled();
750750
if (file != null) {
751-
Editor editor = handleOpen(file, true);
751+
handleOpen(file, true);
752752
}
753753

754754
} catch (IOException e) {

0 commit comments

Comments
 (0)