Skip to content

Adding a Project View to the Arduino IDE #11048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 4 additions & 1 deletion app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
@@ -988,7 +988,10 @@ public boolean handleQuit() {
// If quit is canceled, this will be replaced anyway
// by a later handleQuit() that is not canceled.
storeScreenDimensions();
storeSketches();
if (editors.size() == 1) {
if (editors.get(0).getSketch().getFiles().length != 0)
storeSketches();
}
try {
Editor.serialMonitor.close();
} catch (Exception e) {
160 changes: 80 additions & 80 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
@@ -107,18 +107,18 @@ public class Editor extends JFrame implements RunnerListener {
private int currentTabIndex = -1;

private static class ShouldSaveIfModified
implements Predicate<SketchController> {
implements Predicate<SketchController> {

@Override
public boolean test(SketchController controller) {
return PreferencesData.getBoolean("editor.save_on_verify")
&& controller.getSketch().isModified()
&& !controller.isReadOnly();
&& controller.getSketch().isModified()
&& !controller.isReadOnly();
}
}

private static class CanExportInSketchFolder
implements Predicate<SketchController> {
implements Predicate<SketchController> {

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

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

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

// When bringing a window to front, let the Base know
addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
base.handleActivated(Editor.this);
}

// added for 1.0.5
// http://dev.processing.org/bugs/show_bug.cgi?id=1260
public void windowDeactivated(WindowEvent e) {
List<Component> toolsMenuItemsToRemove = new LinkedList<>();
for (Component menuItem : toolsMenu.getMenuComponents()) {
if (menuItem instanceof JComponent) {
Object removeOnWindowDeactivation = ((JComponent) menuItem).getClientProperty("removeOnWindowDeactivation");
if (removeOnWindowDeactivation != null && Boolean.valueOf(removeOnWindowDeactivation.toString())) {
toolsMenuItemsToRemove.add(menuItem);
}
public void windowActivated(WindowEvent e) {
base.handleActivated(Editor.this);
}

// added for 1.0.5
// http://dev.processing.org/bugs/show_bug.cgi?id=1260
public void windowDeactivated(WindowEvent e) {
List<Component> toolsMenuItemsToRemove = new LinkedList<>();
for (Component menuItem : toolsMenu.getMenuComponents()) {
if (menuItem instanceof JComponent) {
Object removeOnWindowDeactivation = ((JComponent) menuItem).getClientProperty("removeOnWindowDeactivation");
if (removeOnWindowDeactivation != null && Boolean.valueOf(removeOnWindowDeactivation.toString())) {
toolsMenuItemsToRemove.add(menuItem);
}
}
for (Component menuItem : toolsMenuItemsToRemove) {
toolsMenu.remove(menuItem);
}
toolsMenu.remove(portMenu);
}
});
for (Component menuItem : toolsMenuItemsToRemove) {
toolsMenu.remove(menuItem);
}
toolsMenu.remove(portMenu);
}
});

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

// Set the minimum size for the editor window
setMinimumSize(scale(new Dimension(
PreferencesData.getInteger("editor.window.width.min"),
PreferencesData.getInteger("editor.window.height.min"))));
PreferencesData.getInteger("editor.window.width.min"),
PreferencesData.getInteger("editor.window.height.min"))));

// Bring back the general options for the editor
applyPreferences();
@@ -941,14 +941,14 @@ private String findClassInZipFile(String base, File file) {
} finally {
if (zipFile != null) {
try {
zipFile.close();
} catch (IOException e) {
// noop
}
}
}
return null;
}
zipFile.close();
} catch (IOException e) {
// noop
}
}
}
return null;
}

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

ports.stream() //
.filter(port -> port.getProtocolLabel() == null || port.getProtocolLabel().isEmpty())
.forEach(port -> {
int labelIdx = PROTOCOLS_ORDER.indexOf(port.getProtocol());
if (labelIdx != -1) {
port.setProtocolLabel(PROTOCOLS_LABELS.get(labelIdx));
} else {
port.setProtocolLabel(port.getProtocol());
}
});
.filter(port -> port.getProtocolLabel() == null || port.getProtocolLabel().isEmpty())
.forEach(port -> {
int labelIdx = PROTOCOLS_ORDER.indexOf(port.getProtocol());
if (labelIdx != -1) {
port.setProtocolLabel(PROTOCOLS_LABELS.get(labelIdx));
} else {
port.setProtocolLabel(port.getProtocol());
}
});

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

if (!OSUtils.isMacOS()) {
redoItem = newJMenuItem(tr("Redo"), 'Y');
redoItem = newJMenuItem(tr("Redo"), 'Y');
} else {
redoItem = newJMenuItemShift(tr("Redo"), 'Z');
redoItem = newJMenuItemShift(tr("Redo"), 'Z');
}
redoItem.setName("menuEditRedo");
redoItem.addActionListener(event -> getCurrentTab().handleRedo());
@@ -1549,8 +1549,8 @@ public void reorderTabs() {
protected void addTab(SketchFile file, String contents) throws IOException {
EditorTab tab = new EditorTab(this, file, contents);
tab.getTextArea().getDocument()
.addDocumentListener(new DocumentTextChangeListener(
() -> updateUndoRedoState()));
.addDocumentListener(new DocumentTextChangeListener(
() -> updateUndoRedoState()));
tabs.add(tab);
reorderTabs();
}
@@ -1637,8 +1637,8 @@ public void run() {
statusNotice(tr("Done compiling."));
} catch (PreferencesMapException e) {
statusError(I18n.format(
tr("Error while compiling: missing '{0}' configuration parameter"),
e.getMessage()));
tr("Error while compiling: missing '{0}' configuration parameter"),
e.getMessage()));
} catch (Exception e) {
status.unprogress();
statusError(e);
@@ -1697,13 +1697,13 @@ protected boolean checkModified() {
toFront();

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

if (!OSUtils.hasMacOSStyleMenus()) {
int result =
JOptionPane.showConfirmDialog(this, prompt, tr("Close"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);

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

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

String[] options = new String[] {
tr("Save"), tr("Cancel"), tr("Don't Save")
@@ -1856,10 +1856,10 @@ public void updateTitle() {
} else {
if (current.isPrimary()) {
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(),
BaseNoGui.VERSION_NAME_LONG));
BaseNoGui.VERSION_NAME_LONG));
} else {
setTitle(I18n.format(tr("{0} - {1} | Arduino {2}"), sketch.getName(),
current.getFileName(), BaseNoGui.VERSION_NAME_LONG));
current.getFileName(), BaseNoGui.VERSION_NAME_LONG));
}
}
}
@@ -1888,10 +1888,10 @@ public boolean handleSave(boolean immediately) {

} else {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
handleSave2();
}
});
public void run() {
handleSave2();
}
});
}
return true;
}
@@ -1997,8 +1997,8 @@ private boolean serialPrompt() {
}
String question = tr("Retry the upload with another serial port?");
BoardPortJCheckBoxMenuItem result = (BoardPortJCheckBoxMenuItem) JOptionPane
.showInputDialog(this, title + "\n" + question, title,
JOptionPane.PLAIN_MESSAGE, null, items.toArray(), 0);
.showInputDialog(this, title + "\n" + question, title,
JOptionPane.PLAIN_MESSAGE, null, items.toArray(), 0);
if (result == null)
return false;
result.doClick();
@@ -2072,8 +2072,8 @@ public void run() {
}
} catch (PreferencesMapException e) {
statusError(I18n.format(
tr("Error while uploading: missing '{0}' configuration parameter"),
e.getMessage()));
tr("Error while uploading: missing '{0}' configuration parameter"),
e.getMessage()));
} catch (RunnerException e) {
//statusError("Error during upload.");
//e.printStackTrace();
@@ -2106,7 +2106,7 @@ private void resumeOrCloseSerialMonitor() {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// noop
// noop
}
BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
long sleptFor = 0;
@@ -2132,7 +2132,7 @@ private void resumeOrCloseSerialMonitor() {
} catch (Exception e) {
statusError(e);
}
}
}
}

private void resumeOrCloseSerialPlotter() {
@@ -2151,7 +2151,7 @@ private void resumeOrCloseSerialPlotter() {
} catch (Exception e) {
statusError(e);
}
}
}
}

class TimeoutUploadHandler implements Runnable {
@@ -2164,7 +2164,7 @@ public void run() {
avoidMultipleOperations = false;
}
} catch (InterruptedException e) {
// noop
// noop
}
}
}
Loading
Oops, something went wrong.