indeterminate progress action working

This commit is contained in:
benfry
2011-01-29 03:23:13 +00:00
parent 44ee29743b
commit 77f61677ad
3 changed files with 60 additions and 21 deletions
+11 -6
View File
@@ -153,7 +153,6 @@ public class EditorStatus extends JPanel {
thread = new Thread() {
public void run() {
while (Thread.currentThread() == thread) {
System.out.println("knight rider");
repaint();
try {
Thread.sleep(1000 / 10);
@@ -217,13 +216,19 @@ public class EditorStatus extends JPanel {
if (indeterminate) {
int x = cancelButton.getX();
int y = cancelButton.getY();
int w = cancelButton.getWidth();
int h = cancelButton.getHeight();
g.setColor(fgcolor[mode]);
int y = getHeight() / 3;
int h = getHeight() / 3;
// int y = cancelButton.getY();
// int h = cancelButton.getHeight();
// g.setColor(fgcolor[mode]);
// g.setColor(Color.DARK_GRAY);
g.setColor(new Color(0x80000000, true));
g.drawRect(x, y, w, h);
int r = (int) (x + Math.random() * w);
g.drawLine(r, y, r, y+h);
for (int i = 0; i < 10; i++) {
int r = (int) (x + Math.random() * w);
g.drawLine(r, y, r, y+h);
}
}
screen.drawImage(offscreen, 0, 0, null);
@@ -61,7 +61,9 @@ class AndroidBuild extends JavaBuild {
srcFolder = new File(tmpFolder, "src");
// this folder isn't actually used, but it's used by the java preproc to
// figure out the classpath, so we have to set it to something
binFolder = new File(tmpFolder, "bin");
// binFolder = new File(tmpFolder, "bin");
// use the src folder, since 'bin' might be used by the ant build
binFolder = srcFolder;
if (processing.app.Base.DEBUG) {
Base.openFolder(tmpFolder);
}
@@ -96,7 +98,8 @@ class AndroidBuild extends JavaBuild {
try {
// Copy any imported libraries or code folder contents to the project
writeLibraries(libsFolder, assetsFolder);
copyLibraries(libsFolder, assetsFolder);
copyCodeFolder(libsFolder);
// Copy the data folder, if one exists, to the 'assets' folder of the
// project
@@ -473,8 +476,12 @@ class AndroidBuild extends JavaBuild {
// }
private void writeLibraries(final File libsFolder,
final File assetsFolder) throws IOException {
/**
* For each library, copy .jar and .zip files to the 'libs' folder,
* and copy anything else to the 'assets' folder.
*/
private void copyLibraries(final File libsFolder,
final File assetsFolder) throws IOException {
// Copy any libraries to the 'libs' folder
for (Library library : getImportedLibraries()) {
File libraryFolder = new File(library.getPath());
@@ -512,12 +519,16 @@ class AndroidBuild extends JavaBuild {
name.substring(0, name.length() - 4) + ".jar";
Base.copyFile(exportFile, new File(libsFolder, jarName));
} else {
// just copy other files over directly
Base.copyFile(exportFile, new File(assetsFolder, name));
}
}
}
}
}
private void copyCodeFolder(final File libsFolder) throws IOException {
// Copy files from the 'code' directory into the 'libs' folder
final File codeFolder = sketch.getCodeFolder();
if (codeFolder != null && codeFolder.exists()) {
@@ -38,7 +38,9 @@ import javax.swing.JMenu;
import javax.swing.JMenuItem;
import processing.app.Base;
import processing.app.EditorToolbar;
import processing.app.Mode;
import processing.app.RunnerListener;
import processing.app.SketchException;
import processing.core.PApplet;
import processing.mode.java.JavaEditor;
@@ -105,6 +107,17 @@ public class AndroidEditor extends JavaEditor implements DeviceListener {
}
public EditorToolbar createToolbar() {
return new AndroidToolbar(this, base);
}
// inherit from the parent
// public Formatter createFormatter() {
// return new AutoFormat();
// }
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -345,11 +358,16 @@ public class AndroidEditor extends JavaEditor implements DeviceListener {
* @param target "debug" or "release"
*/
private void runSketchOnDevice(final Future<Device> deviceFuture,
final String target) throws MonitorCanceled {
final String target,
RunnerListener listener) throws MonitorCanceled {
final IndeterminateProgressMonitor monitor =
new IndeterminateProgressMonitor(this,
"Building and launching...",
"Creating project...");
listener.startIndeterminate();
listener.statusNotice("Building and launching...");
build = new AndroidBuild(sketch, amode.getSDK());
try {
try {
@@ -522,22 +540,27 @@ public class AndroidEditor extends JavaEditor implements DeviceListener {
* Build the sketch and run it inside an emulator with the debugger.
*/
public void handleRunEmulator() {
prepareRun();
AVD.ensureEclairAVD(amode.getSDK());
try {
runSketchOnDevice(Environment.getInstance().getEmulator(), "debug");
} catch (final MonitorCanceled ok) {
sketchStopped();
statusNotice("Canceled.");
}
new Thread() {
public void run() {
prepareRun();
AVD.ensureEclairAVD(amode.getSDK());
try {
runSketchOnDevice(Environment.getInstance().getEmulator(), "debug", AndroidEditor.this);
} catch (final MonitorCanceled ok) {
sketchStopped();
statusNotice("Canceled.");
}
}
}.start();
}
/**
* Build the sketch and run it on a device with the debugger connected.
*/
public void handleRunDevice() {
try {
runSketchOnDevice(Environment.getInstance().getHardware(), "debug");
runSketchOnDevice(Environment.getInstance().getHardware(), "debug", this);
} catch (final MonitorCanceled ok) {
sketchStopped();
statusNotice("Canceled.");