mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
Added progressbar (from wiring)
This commit is contained in:
parent
4c73aaf186
commit
42943b4de3
@ -1841,9 +1841,11 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
String appletClassName = sketch.build(false);
|
String appletClassName = sketch.build(false);
|
||||||
statusNotice("Done compiling.");
|
statusNotice("Done compiling.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
status.unprogress();
|
||||||
statusError(e);
|
statusError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status.unprogress();
|
||||||
toolbar.deactivate(EditorToolbar.RUN);
|
toolbar.deactivate(EditorToolbar.RUN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1856,9 +1858,11 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
String appletClassName = sketch.build(true);
|
String appletClassName = sketch.build(true);
|
||||||
statusNotice("Done compiling.");
|
statusNotice("Done compiling.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
status.unprogress();
|
||||||
statusError(e);
|
statusError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status.unprogress();
|
||||||
toolbar.deactivate(EditorToolbar.RUN);
|
toolbar.deactivate(EditorToolbar.RUN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2334,7 +2338,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
//if (!handleExportCheckModified()) return;
|
//if (!handleExportCheckModified()) return;
|
||||||
toolbar.activate(EditorToolbar.EXPORT);
|
toolbar.activate(EditorToolbar.EXPORT);
|
||||||
console.clear();
|
console.clear();
|
||||||
statusNotice("Uploading to I/O Board...");
|
status.progress("Uploading to I/O Board...");
|
||||||
|
|
||||||
new Thread(usingProgrammer ? exportAppHandler : exportHandler).start();
|
new Thread(usingProgrammer ? exportAppHandler : exportHandler).start();
|
||||||
}
|
}
|
||||||
@ -2363,10 +2367,12 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
} catch (RunnerException e) {
|
} catch (RunnerException e) {
|
||||||
//statusError("Error during upload.");
|
//statusError("Error during upload.");
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
|
status.unprogress();
|
||||||
statusError(e);
|
statusError(e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
status.unprogress();
|
||||||
uploading = false;
|
uploading = false;
|
||||||
//toolbar.clear();
|
//toolbar.clear();
|
||||||
toolbar.deactivate(EditorToolbar.EXPORT);
|
toolbar.deactivate(EditorToolbar.EXPORT);
|
||||||
@ -2397,10 +2403,12 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
} catch (RunnerException e) {
|
} catch (RunnerException e) {
|
||||||
//statusError("Error during upload.");
|
//statusError("Error during upload.");
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
|
status.unprogress();
|
||||||
statusError(e);
|
statusError(e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
status.unprogress();
|
||||||
uploading = false;
|
uploading = false;
|
||||||
//toolbar.clear();
|
//toolbar.clear();
|
||||||
toolbar.deactivate(EditorToolbar.EXPORT);
|
toolbar.deactivate(EditorToolbar.EXPORT);
|
||||||
|
@ -40,6 +40,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
|||||||
//static final int PROMPT = 2;
|
//static final int PROMPT = 2;
|
||||||
//static final int EDIT = 3;
|
//static final int EDIT = 3;
|
||||||
static final int EDIT = 2;
|
static final int EDIT = 2;
|
||||||
|
static final int PROGRESS = 5;
|
||||||
|
|
||||||
static final int YES = 1;
|
static final int YES = 1;
|
||||||
static final int NO = 2;
|
static final int NO = 2;
|
||||||
@ -66,6 +67,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
|||||||
JButton cancelButton;
|
JButton cancelButton;
|
||||||
JButton okButton;
|
JButton okButton;
|
||||||
JTextField editField;
|
JTextField editField;
|
||||||
|
JProgressBar progressBar;
|
||||||
|
|
||||||
//Thread promptThread;
|
//Thread promptThread;
|
||||||
int response;
|
int response;
|
||||||
@ -76,15 +78,21 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
|||||||
empty();
|
empty();
|
||||||
|
|
||||||
if (bgcolor == null) {
|
if (bgcolor == null) {
|
||||||
bgcolor = new Color[3]; //4];
|
bgcolor = new Color[6];
|
||||||
bgcolor[0] = Theme.getColor("status.notice.bgcolor");
|
bgcolor[0] = Theme.getColor("status.notice.bgcolor");
|
||||||
bgcolor[1] = Theme.getColor("status.error.bgcolor");
|
bgcolor[1] = Theme.getColor("status.error.bgcolor");
|
||||||
bgcolor[2] = Theme.getColor("status.edit.bgcolor");
|
bgcolor[2] = Theme.getColor("status.edit.bgcolor");
|
||||||
|
bgcolor[3] = null;
|
||||||
|
bgcolor[4] = null;
|
||||||
|
bgcolor[5] = Theme.getColor("status.notice.bgcolor");
|
||||||
|
|
||||||
fgcolor = new Color[3]; //4];
|
fgcolor = new Color[6];
|
||||||
fgcolor[0] = Theme.getColor("status.notice.fgcolor");
|
fgcolor[0] = Theme.getColor("status.notice.fgcolor");
|
||||||
fgcolor[1] = Theme.getColor("status.error.fgcolor");
|
fgcolor[1] = Theme.getColor("status.error.fgcolor");
|
||||||
fgcolor[2] = Theme.getColor("status.edit.fgcolor");
|
fgcolor[2] = Theme.getColor("status.edit.fgcolor");
|
||||||
|
fgcolor[3] = null;
|
||||||
|
fgcolor[4] = null;
|
||||||
|
fgcolor[5] = Theme.getColor("status.notice.fgcolor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +171,54 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
|||||||
empty();
|
empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void progress(String message)
|
||||||
|
{
|
||||||
|
mode = PROGRESS;
|
||||||
|
this.message = message;
|
||||||
|
progressBar.setIndeterminate(false);
|
||||||
|
progressBar.setVisible(true);
|
||||||
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void progressIndeterminate(String message)
|
||||||
|
{
|
||||||
|
mode = PROGRESS;
|
||||||
|
this.message = message;
|
||||||
|
progressBar.setIndeterminate(true);
|
||||||
|
progressBar.setValue(50);
|
||||||
|
progressBar.setVisible(true);
|
||||||
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void progressNotice(String message) {
|
||||||
|
//mode = NOTICE;
|
||||||
|
this.message = message;
|
||||||
|
//update();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void unprogress()
|
||||||
|
{
|
||||||
|
if (Preferences.getBoolean("editor.beep.compile")) {
|
||||||
|
Toolkit.getDefaultToolkit().beep();
|
||||||
|
}
|
||||||
|
progressBar.setVisible(false);
|
||||||
|
progressBar.setValue(0);
|
||||||
|
setCursor(null);
|
||||||
|
//empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void progressUpdate(int value)
|
||||||
|
{
|
||||||
|
progressBar.setValue(value);
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void update() {
|
public void update() {
|
||||||
@ -369,6 +425,19 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
|||||||
});
|
});
|
||||||
add(editField);
|
add(editField);
|
||||||
editField.setVisible(false);
|
editField.setVisible(false);
|
||||||
|
|
||||||
|
progressBar = new JProgressBar(JScrollBar.HORIZONTAL);
|
||||||
|
progressBar.setIndeterminate(false);
|
||||||
|
if (Base.isMacOS()) {
|
||||||
|
//progressBar.setBackground(bgcolor[PROGRESS]);
|
||||||
|
//progressBar.putClientProperty("JProgressBar.style", "circular");
|
||||||
|
}
|
||||||
|
progressBar.setValue(0);
|
||||||
|
progressBar.setBorderPainted(true);
|
||||||
|
//progressBar.setStringPainted(true);
|
||||||
|
add(progressBar);
|
||||||
|
progressBar.setVisible(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,11 +454,13 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
|||||||
//noButton.setLocation(noLeft, top);
|
//noButton.setLocation(noLeft, top);
|
||||||
cancelButton.setLocation(cancelLeft, top);
|
cancelButton.setLocation(cancelLeft, top);
|
||||||
okButton.setLocation(noLeft, top);
|
okButton.setLocation(noLeft, top);
|
||||||
|
progressBar.setLocation(noLeft, top);
|
||||||
|
|
||||||
//yesButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
//yesButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||||
//noButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
//noButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||||
cancelButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
cancelButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||||
okButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
okButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||||
|
progressBar.setSize(2*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||||
|
|
||||||
// edit field height is awkward, and very different between mac and pc,
|
// edit field height is awkward, and very different between mac and pc,
|
||||||
// so use at least the preferred height for now.
|
// so use at least the preferred height for now.
|
||||||
@ -398,6 +469,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
|
|||||||
int editTop = (1 + sizeH - editHeight) / 2; // add 1 for ceil
|
int editTop = (1 + sizeH - editHeight) / 2; // add 1 for ceil
|
||||||
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop,
|
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop,
|
||||||
editWidth, editHeight);
|
editWidth, editHeight);
|
||||||
|
progressBar.setBounds(noLeft, editTop, editWidth, editHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1507,6 +1507,7 @@ public class Sketch {
|
|||||||
throws RunnerException {
|
throws RunnerException {
|
||||||
|
|
||||||
// run the preprocessor
|
// run the preprocessor
|
||||||
|
editor.status.progressUpdate(20);
|
||||||
String primaryClassName = preprocess(buildPath);
|
String primaryClassName = preprocess(buildPath);
|
||||||
|
|
||||||
// compile the program. errors will happen as a RunnerException
|
// compile the program. errors will happen as a RunnerException
|
||||||
@ -1552,6 +1553,7 @@ public class Sketch {
|
|||||||
appletFolder.mkdirs();
|
appletFolder.mkdirs();
|
||||||
|
|
||||||
// build the sketch
|
// build the sketch
|
||||||
|
editor.status.progressNotice("Compiling sketch...");
|
||||||
String foundName = build(appletFolder.getPath(), false);
|
String foundName = build(appletFolder.getPath(), false);
|
||||||
// (already reported) error during export, exit this function
|
// (already reported) error during export, exit this function
|
||||||
if (foundName == null) return false;
|
if (foundName == null) return false;
|
||||||
@ -1565,12 +1567,18 @@ public class Sketch {
|
|||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
editor.status.progressNotice("Uploading...");
|
||||||
upload(appletFolder.getPath(), foundName, usingProgrammer);
|
upload(appletFolder.getPath(), foundName, usingProgrammer);
|
||||||
|
editor.status.progressUpdate(100);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setCompilingProgress(int percent) {
|
||||||
|
editor.status.progressUpdate(percent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void size(String buildPath, String suggestedClassName)
|
protected void size(String buildPath, String suggestedClassName)
|
||||||
throws RunnerException {
|
throws RunnerException {
|
||||||
long size = 0;
|
long size = 0;
|
||||||
|
@ -111,6 +111,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
// 0. include paths for core + all libraries
|
// 0. include paths for core + all libraries
|
||||||
|
|
||||||
|
sketch.setCompilingProgress(20);
|
||||||
List includePaths = new ArrayList();
|
List includePaths = new ArrayList();
|
||||||
includePaths.add(corePath);
|
includePaths.add(corePath);
|
||||||
if (pinsPath != null) includePaths.add(pinsPath);
|
if (pinsPath != null) includePaths.add(pinsPath);
|
||||||
@ -120,6 +121,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
// 1. compile the sketch (already in the buildPath)
|
// 1. compile the sketch (already in the buildPath)
|
||||||
|
|
||||||
|
sketch.setCompilingProgress(30);
|
||||||
objectFiles.addAll(
|
objectFiles.addAll(
|
||||||
compileFiles(avrBasePath, buildPath, includePaths,
|
compileFiles(avrBasePath, buildPath, includePaths,
|
||||||
findFilesInPath(buildPath, "S", false),
|
findFilesInPath(buildPath, "S", false),
|
||||||
@ -129,6 +131,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||||
|
|
||||||
|
sketch.setCompilingProgress(40);
|
||||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||||
File outputFolder = new File(buildPath, libraryFolder.getName());
|
File outputFolder = new File(buildPath, libraryFolder.getName());
|
||||||
File utilityFolder = new File(libraryFolder, "utility");
|
File utilityFolder = new File(libraryFolder, "utility");
|
||||||
@ -156,6 +159,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
// 3. compile the core, outputting .o files to <buildPath> and then
|
// 3. compile the core, outputting .o files to <buildPath> and then
|
||||||
// collecting them into the core.a library file.
|
// collecting them into the core.a library file.
|
||||||
|
|
||||||
|
sketch.setCompilingProgress(50);
|
||||||
includePaths.clear();
|
includePaths.clear();
|
||||||
includePaths.add(corePath); // include path for core only
|
includePaths.add(corePath); // include path for core only
|
||||||
if (pinsPath != null) includePaths.add(pinsPath);
|
if (pinsPath != null) includePaths.add(pinsPath);
|
||||||
@ -180,6 +184,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
// 4. link it all together into the .elf file
|
// 4. link it all together into the .elf file
|
||||||
|
|
||||||
|
sketch.setCompilingProgress(60);
|
||||||
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
|
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
|
||||||
avrBasePath + "avr-gcc",
|
avrBasePath + "avr-gcc",
|
||||||
"-Os",
|
"-Os",
|
||||||
@ -208,6 +213,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
List commandObjcopy;
|
List commandObjcopy;
|
||||||
|
|
||||||
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
|
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
|
||||||
|
sketch.setCompilingProgress(70);
|
||||||
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
||||||
commandObjcopy.add(2, "ihex");
|
commandObjcopy.add(2, "ihex");
|
||||||
commandObjcopy.set(3, "-j");
|
commandObjcopy.set(3, "-j");
|
||||||
@ -221,6 +227,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
execAsynchronously(commandObjcopy);
|
execAsynchronously(commandObjcopy);
|
||||||
|
|
||||||
// 6. build the .hex file
|
// 6. build the .hex file
|
||||||
|
sketch.setCompilingProgress(80);
|
||||||
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
commandObjcopy = new ArrayList(baseCommandObjcopy);
|
||||||
commandObjcopy.add(2, "ihex");
|
commandObjcopy.add(2, "ihex");
|
||||||
commandObjcopy.add(".eeprom"); // remove eeprom data
|
commandObjcopy.add(".eeprom"); // remove eeprom data
|
||||||
@ -228,6 +235,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".hex");
|
commandObjcopy.add(buildPath + File.separator + primaryClassName + ".hex");
|
||||||
execAsynchronously(commandObjcopy);
|
execAsynchronously(commandObjcopy);
|
||||||
|
|
||||||
|
sketch.setCompilingProgress(90);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user