Skip to content

Commit 4ee5a1b

Browse files
committed
Fixed navigate dialog
2 parents 50dd673 + 7ba1a0b commit 4ee5a1b

File tree

4,711 files changed

+2676
-1995486
lines changed

Some content is hidden

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

4,711 files changed

+2676
-1995486
lines changed

app/src/processing/app/Base.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,10 @@ public boolean handleQuit() {
988988
// If quit is canceled, this will be replaced anyway
989989
// by a later handleQuit() that is not canceled.
990990
storeScreenDimensions();
991-
storeSketches();
991+
if (editors.size() == 1) {
992+
if (editors.get(0).getSketch().getFiles().length != 0)
993+
storeSketches();
994+
}
992995
try {
993996
Editor.serialMonitor.close();
994997
} catch (Exception e) {

app/src/processing/app/Editor.java

+80-80
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,18 @@ public class Editor extends JFrame implements RunnerListener {
107107
private int currentTabIndex = -1;
108108

109109
private static class ShouldSaveIfModified
110-
implements Predicate<SketchController> {
110+
implements Predicate<SketchController> {
111111

112112
@Override
113113
public boolean test(SketchController controller) {
114114
return PreferencesData.getBoolean("editor.save_on_verify")
115-
&& controller.getSketch().isModified()
116-
&& !controller.isReadOnly();
115+
&& controller.getSketch().isModified()
116+
&& !controller.isReadOnly();
117117
}
118118
}
119119

120120
private static class CanExportInSketchFolder
121-
implements Predicate<SketchController> {
121+
implements Predicate<SketchController> {
122122

123123
@Override
124124
public boolean test(SketchController controller) {
@@ -138,8 +138,8 @@ public boolean test(SketchController controller) {
138138
// set to blank, it's preferredSize() will be fukered
139139
private static final String EMPTY =
140140
" " +
141-
" " +
142-
" ";
141+
" " +
142+
" ";
143143

144144
/** Command on Mac OS X, Ctrl on Windows and Linux */
145145
private static final int SHORTCUT_KEY_MASK =
@@ -234,39 +234,39 @@ public Editor(Base ibase, File file, int[] storedLocation, int[] defaultLocation
234234

235235
// add listener to handle window close box hit event
236236
addWindowListener(new WindowAdapter() {
237-
public void windowClosing(WindowEvent e) {
238-
base.handleClose(Editor.this);
239-
}
240-
});
237+
public void windowClosing(WindowEvent e) {
238+
base.handleClose(Editor.this);
239+
}
240+
});
241241
// don't close the window when clicked, the app will take care
242242
// of that via the handleQuitInternal() methods
243243
// http://dev.processing.org/bugs/show_bug.cgi?id=440
244244
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
245245

246246
// When bringing a window to front, let the Base know
247247
addWindowListener(new WindowAdapter() {
248-
public void windowActivated(WindowEvent e) {
249-
base.handleActivated(Editor.this);
250-
}
251-
252-
// added for 1.0.5
253-
// http://dev.processing.org/bugs/show_bug.cgi?id=1260
254-
public void windowDeactivated(WindowEvent e) {
255-
List<Component> toolsMenuItemsToRemove = new LinkedList<>();
256-
for (Component menuItem : toolsMenu.getMenuComponents()) {
257-
if (menuItem instanceof JComponent) {
258-
Object removeOnWindowDeactivation = ((JComponent) menuItem).getClientProperty("removeOnWindowDeactivation");
259-
if (removeOnWindowDeactivation != null && Boolean.valueOf(removeOnWindowDeactivation.toString())) {
260-
toolsMenuItemsToRemove.add(menuItem);
261-
}
248+
public void windowActivated(WindowEvent e) {
249+
base.handleActivated(Editor.this);
250+
}
251+
252+
// added for 1.0.5
253+
// http://dev.processing.org/bugs/show_bug.cgi?id=1260
254+
public void windowDeactivated(WindowEvent e) {
255+
List<Component> toolsMenuItemsToRemove = new LinkedList<>();
256+
for (Component menuItem : toolsMenu.getMenuComponents()) {
257+
if (menuItem instanceof JComponent) {
258+
Object removeOnWindowDeactivation = ((JComponent) menuItem).getClientProperty("removeOnWindowDeactivation");
259+
if (removeOnWindowDeactivation != null && Boolean.valueOf(removeOnWindowDeactivation.toString())) {
260+
toolsMenuItemsToRemove.add(menuItem);
262261
}
263262
}
264-
for (Component menuItem : toolsMenuItemsToRemove) {
265-
toolsMenu.remove(menuItem);
266-
}
267-
toolsMenu.remove(portMenu);
268263
}
269-
});
264+
for (Component menuItem : toolsMenuItemsToRemove) {
265+
toolsMenu.remove(menuItem);
266+
}
267+
toolsMenu.remove(portMenu);
268+
}
269+
});
270270

271271
//PdeKeywords keywords = new PdeKeywords();
272272
//sketchbook = new Sketchbook(this);
@@ -353,8 +353,8 @@ public void windowDeactivated(WindowEvent e) {
353353

354354
// Set the minimum size for the editor window
355355
setMinimumSize(scale(new Dimension(
356-
PreferencesData.getInteger("editor.window.width.min"),
357-
PreferencesData.getInteger("editor.window.height.min"))));
356+
PreferencesData.getInteger("editor.window.width.min"),
357+
PreferencesData.getInteger("editor.window.height.min"))));
358358

359359
// Bring back the general options for the editor
360360
applyPreferences();
@@ -941,14 +941,14 @@ private String findClassInZipFile(String base, File file) {
941941
} finally {
942942
if (zipFile != null) {
943943
try {
944-
zipFile.close();
945-
} catch (IOException e) {
946-
// noop
947-
}
948-
}
949-
}
950-
return null;
951-
}
944+
zipFile.close();
945+
} catch (IOException e) {
946+
// noop
947+
}
948+
}
949+
}
950+
return null;
951+
}
952952

953953
public void updateKeywords(PdeKeywords keywords) {
954954
for (EditorTab tab : tabs)
@@ -1031,7 +1031,7 @@ private void selectSerialPort(String name) {
10311031
BaseNoGui.selectSerialPort(name);
10321032
try {
10331033
boolean reopenMonitor = ((serialMonitor != null && serialMonitor.isVisible()) ||
1034-
serialPlotter != null && serialPlotter.isVisible());
1034+
serialPlotter != null && serialPlotter.isVisible());
10351035
if (serialMonitor != null) {
10361036
serialMonitor.close();
10371037
}
@@ -1088,15 +1088,15 @@ private void populatePortMenu() {
10881088
ports = platform.filterPorts(ports, PreferencesData.getBoolean("serial.ports.showall"));
10891089

10901090
ports.stream() //
1091-
.filter(port -> port.getProtocolLabel() == null || port.getProtocolLabel().isEmpty())
1092-
.forEach(port -> {
1093-
int labelIdx = PROTOCOLS_ORDER.indexOf(port.getProtocol());
1094-
if (labelIdx != -1) {
1095-
port.setProtocolLabel(PROTOCOLS_LABELS.get(labelIdx));
1096-
} else {
1097-
port.setProtocolLabel(port.getProtocol());
1098-
}
1099-
});
1091+
.filter(port -> port.getProtocolLabel() == null || port.getProtocolLabel().isEmpty())
1092+
.forEach(port -> {
1093+
int labelIdx = PROTOCOLS_ORDER.indexOf(port.getProtocol());
1094+
if (labelIdx != -1) {
1095+
port.setProtocolLabel(PROTOCOLS_LABELS.get(labelIdx));
1096+
} else {
1097+
port.setProtocolLabel(port.getProtocol());
1098+
}
1099+
});
11001100

11011101
Collections.sort(ports, (port1, port2) -> {
11021102
String pr1 = port1.getProtocol();
@@ -1193,9 +1193,9 @@ private JMenu buildEditMenu() {
11931193
menu.add(undoItem);
11941194

11951195
if (!OSUtils.isMacOS()) {
1196-
redoItem = newJMenuItem(tr("Redo"), 'Y');
1196+
redoItem = newJMenuItem(tr("Redo"), 'Y');
11971197
} else {
1198-
redoItem = newJMenuItemShift(tr("Redo"), 'Z');
1198+
redoItem = newJMenuItemShift(tr("Redo"), 'Z');
11991199
}
12001200
redoItem.setName("menuEditRedo");
12011201
redoItem.addActionListener(event -> getCurrentTab().handleRedo());
@@ -1549,8 +1549,8 @@ public void reorderTabs() {
15491549
protected void addTab(SketchFile file, String contents) throws IOException {
15501550
EditorTab tab = new EditorTab(this, file, contents);
15511551
tab.getTextArea().getDocument()
1552-
.addDocumentListener(new DocumentTextChangeListener(
1553-
() -> updateUndoRedoState()));
1552+
.addDocumentListener(new DocumentTextChangeListener(
1553+
() -> updateUndoRedoState()));
15541554
tabs.add(tab);
15551555
reorderTabs();
15561556
}
@@ -1637,8 +1637,8 @@ public void run() {
16371637
statusNotice(tr("Done compiling."));
16381638
} catch (PreferencesMapException e) {
16391639
statusError(I18n.format(
1640-
tr("Error while compiling: missing '{0}' configuration parameter"),
1641-
e.getMessage()));
1640+
tr("Error while compiling: missing '{0}' configuration parameter"),
1641+
e.getMessage()));
16421642
} catch (Exception e) {
16431643
status.unprogress();
16441644
statusError(e);
@@ -1697,13 +1697,13 @@ protected boolean checkModified() {
16971697
toFront();
16981698

16991699
String prompt = I18n.format(tr("Save changes to \"{0}\"? "),
1700-
sketch.getName());
1700+
sketch.getName());
17011701

17021702
if (!OSUtils.hasMacOSStyleMenus()) {
17031703
int result =
17041704
JOptionPane.showConfirmDialog(this, prompt, tr("Close"),
1705-
JOptionPane.YES_NO_CANCEL_OPTION,
1706-
JOptionPane.QUESTION_MESSAGE);
1705+
JOptionPane.YES_NO_CANCEL_OPTION,
1706+
JOptionPane.QUESTION_MESSAGE);
17071707

17081708
switch (result) {
17091709
case JOptionPane.YES_OPTION:
@@ -1728,14 +1728,14 @@ protected boolean checkModified() {
17281728

17291729
JOptionPane pane =
17301730
new JOptionPane(tr("<html> " +
1731-
"<head> <style type=\"text/css\">"+
1732-
"b { font: 13pt \"Lucida Grande\" }"+
1733-
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
1734-
"</style> </head>" +
1735-
"<b>Do you want to save changes to this sketch<BR>" +
1736-
" before closing?</b>" +
1737-
"<p>If you don't save, your changes will be lost."),
1738-
JOptionPane.QUESTION_MESSAGE);
1731+
"<head> <style type=\"text/css\">"+
1732+
"b { font: 13pt \"Lucida Grande\" }"+
1733+
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
1734+
"</style> </head>" +
1735+
"<b>Do you want to save changes to this sketch<BR>" +
1736+
" before closing?</b>" +
1737+
"<p>If you don't save, your changes will be lost."),
1738+
JOptionPane.QUESTION_MESSAGE);
17391739

17401740
String[] options = new String[] {
17411741
tr("Save"), tr("Cancel"), tr("Don't Save")
@@ -1856,10 +1856,10 @@ public void updateTitle() {
18561856
} else {
18571857
if (current.isPrimary()) {
18581858
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(),
1859-
BaseNoGui.VERSION_NAME_LONG));
1859+
BaseNoGui.VERSION_NAME_LONG));
18601860
} else {
18611861
setTitle(I18n.format(tr("{0} - {1} | Arduino {2}"), sketch.getName(),
1862-
current.getFileName(), BaseNoGui.VERSION_NAME_LONG));
1862+
current.getFileName(), BaseNoGui.VERSION_NAME_LONG));
18631863
}
18641864
}
18651865
}
@@ -1888,10 +1888,10 @@ public boolean handleSave(boolean immediately) {
18881888

18891889
} else {
18901890
SwingUtilities.invokeLater(new Runnable() {
1891-
public void run() {
1892-
handleSave2();
1893-
}
1894-
});
1891+
public void run() {
1892+
handleSave2();
1893+
}
1894+
});
18951895
}
18961896
return true;
18971897
}
@@ -1997,8 +1997,8 @@ private boolean serialPrompt() {
19971997
}
19981998
String question = tr("Retry the upload with another serial port?");
19991999
BoardPortJCheckBoxMenuItem result = (BoardPortJCheckBoxMenuItem) JOptionPane
2000-
.showInputDialog(this, title + "\n" + question, title,
2001-
JOptionPane.PLAIN_MESSAGE, null, items.toArray(), 0);
2000+
.showInputDialog(this, title + "\n" + question, title,
2001+
JOptionPane.PLAIN_MESSAGE, null, items.toArray(), 0);
20022002
if (result == null)
20032003
return false;
20042004
result.doClick();
@@ -2072,8 +2072,8 @@ public void run() {
20722072
}
20732073
} catch (PreferencesMapException e) {
20742074
statusError(I18n.format(
2075-
tr("Error while uploading: missing '{0}' configuration parameter"),
2076-
e.getMessage()));
2075+
tr("Error while uploading: missing '{0}' configuration parameter"),
2076+
e.getMessage()));
20772077
} catch (RunnerException e) {
20782078
//statusError("Error during upload.");
20792079
//e.printStackTrace();
@@ -2106,7 +2106,7 @@ private void resumeOrCloseSerialMonitor() {
21062106
try {
21072107
Thread.sleep(200);
21082108
} catch (InterruptedException e) {
2109-
// noop
2109+
// noop
21102110
}
21112111
BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
21122112
long sleptFor = 0;
@@ -2132,7 +2132,7 @@ private void resumeOrCloseSerialMonitor() {
21322132
} catch (Exception e) {
21332133
statusError(e);
21342134
}
2135-
}
2135+
}
21362136
}
21372137

21382138
private void resumeOrCloseSerialPlotter() {
@@ -2151,7 +2151,7 @@ private void resumeOrCloseSerialPlotter() {
21512151
} catch (Exception e) {
21522152
statusError(e);
21532153
}
2154-
}
2154+
}
21552155
}
21562156

21572157
class TimeoutUploadHandler implements Runnable {
@@ -2164,7 +2164,7 @@ public void run() {
21642164
avoidMultipleOperations = false;
21652165
}
21662166
} catch (InterruptedException e) {
2167-
// noop
2167+
// noop
21682168
}
21692169
}
21702170
}

0 commit comments

Comments
 (0)