diff options
author | Silenio Quarti <silenio> | 2004-09-19 03:37:43 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2004-09-19 03:37:43 +0000 |
commit | d7b73d46c22502d651b01475d699f2c79498b0d0 (patch) | |
tree | 9886d93ab1b963c44f3f0e6a67c5f0f13733e395 | |
parent | 6bc4013f01dd4db86fad9491443b4489f80fbd57 (diff) | |
download | eclipse.platform.swt-d7b73d46c22502d651b01475d699f2c79498b0d0.tar.gz eclipse.platform.swt-d7b73d46c22502d651b01475d699f2c79498b0d0.tar.xz eclipse.platform.swt-d7b73d46c22502d651b01475d699f2c79498b0d0.zip |
progress
8 files changed, 124 insertions, 20 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java index 651712b647..f96b3a50d2 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java @@ -21,6 +21,7 @@ public abstract class JNIGenerator { String delimiter; PrintStream output; MetaData metaData; +ProgressMonitor progress; public JNIGenerator() { delimiter = System.getProperty("line.separator"); @@ -281,6 +282,10 @@ public String getPlatform() { return SWT.getPlatform(); } +public ProgressMonitor getProgressMonitor() { + return progress; +} + public void output(String str) { output.print(str); } @@ -306,4 +311,8 @@ public void setOutput(PrintStream output) { this.output = output; } +public void setProgressMonitor(ProgressMonitor progress) { + this.progress = progress; +} + } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java index 37f4b0184a..ea46b500c7 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java @@ -22,6 +22,7 @@ import org.eclipse.swt.SWT; public class JNIGeneratorApp { + ProgressMonitor progress; String mainClass, outputDir, classpath; MetaData metaData; @@ -48,7 +49,7 @@ public String getOutputDir() { return outputDir; } -void generateSTATS_C() { +void generateSTATS_C(Class[] classes) { try { String outputName = getClassName(mainClass).toLowerCase(); String inc = @@ -57,10 +58,11 @@ void generateSTATS_C() { metaData.setMetaData("swt_includes", inc); StatsGenerator gen = new StatsGenerator(); gen.setMetaData(metaData); + gen.setProgressMonitor(progress); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream print = new PrintStream(out); gen.setOutput(print); - gen.generateSourceFile(getNativesClasses()); + gen.generateSourceFile(classes); print.flush(); String extension = gen.getCPP() ? ".cpp" : ".c"; if (out.size() > 0) output(out.toByteArray(), outputDir + outputName + "_stats" + extension); @@ -70,17 +72,18 @@ void generateSTATS_C() { } } -void generateSTATS_H() { +void generateSTATS_H(Class[] classes) { try { String outputName = getClassName(mainClass).toLowerCase(); String inc = ""; metaData.setMetaData("swt_includes", inc); StatsGenerator gen = new StatsGenerator(); gen.setMetaData(metaData); + gen.setProgressMonitor(progress); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream print = new PrintStream(out); gen.setOutput(print); - gen.generateHeaderFile(getNativesClasses()); + gen.generateHeaderFile(classes); print.flush(); if (out.size() > 0) output(out.toByteArray(), outputDir + outputName + "_stats.h"); } catch (Exception e) { @@ -89,16 +92,17 @@ void generateSTATS_H() { } } -void generateSTRUCTS_H() { +void generateSTRUCTS_H(Class[] classes) { try { String outputName = getClassName(mainClass).toLowerCase(); metaData.setMetaData("swt_includes", "#include \"" + outputName + ".h\"\n"); StructsGenerator gen = new StructsGenerator(); gen.setMetaData(metaData); + gen.setProgressMonitor(progress); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream print = new PrintStream(out); gen.setOutput(print); - gen.generateHeaderFile(getStructureClasses()); + gen.generateHeaderFile(classes); print.flush(); if (out.size() > 0) output(out.toByteArray(), outputDir + outputName + "_structs.h"); } catch (Exception e) { @@ -108,7 +112,7 @@ void generateSTRUCTS_H() { } -void generateSTRUCTS_C() { +void generateSTRUCTS_C(Class[] classes) { try { String outputName = getClassName(mainClass).toLowerCase(); String inc = @@ -117,10 +121,11 @@ void generateSTRUCTS_C() { metaData.setMetaData("swt_includes", inc); StructsGenerator gen = new StructsGenerator(); gen.setMetaData(metaData); + gen.setProgressMonitor(progress); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream print = new PrintStream(out); gen.setOutput(print); - gen.generateSourceFile(getStructureClasses()); + gen.generateSourceFile(classes); print.flush(); String extension = gen.getCPP() ? ".cpp" : ".c"; if (out.size() > 0) output(out.toByteArray(), outputDir + outputName + "_structs" + extension); @@ -131,7 +136,7 @@ void generateSTRUCTS_C() { } -void generateSWT_C() { +void generateSWT_C(Class[] classes) { try { String outputName = getClassName(mainClass).toLowerCase(); String inc = @@ -141,10 +146,11 @@ void generateSWT_C() { metaData.setMetaData("swt_includes", inc); NativesGenerator gen = new NativesGenerator(); gen.setMetaData(metaData); + gen.setProgressMonitor(progress); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream print = new PrintStream(out); gen.setOutput(print); - gen.generate(getNativesClasses()); + gen.generate(classes); print.flush(); String extension = gen.getCPP() ? ".cpp" : ".c"; if (out.size() > 0) output(out.toByteArray(), outputDir + outputName + extension); @@ -159,6 +165,7 @@ void generateAllMetaData() { try { MetaDataGenerator gen = new MetaDataGenerator(); gen.setMetaData(metaData); + gen.setProgressMonitor(progress); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream print = new PrintStream(out); gen.setOutput(print); @@ -176,13 +183,41 @@ void generateAllMetaData() { } public void generate() { + generate(null); +} + +public void generate(ProgressMonitor progress) { if (mainClass == null) return; - generateSTRUCTS_H(); - generateSTRUCTS_C(); - generateSWT_C(); - generateSTATS_H(); - generateSTATS_C(); + if (progress != null) progress.setMessage("Initializing..."); + Class[] natives = getNativesClasses(); + Class[] structs = getStructureClasses(); + this.progress = progress; + if (progress != null) { + int nativeCount = 0; + for (int i = 0; i < natives.length; i++) { + Class clazz = natives[i]; + Method[] methods = clazz.getDeclaredMethods(); + for (int j = 0; j < methods.length; j++) { + Method method = methods[j]; + if ((method.getModifiers() & Modifier.NATIVE) != 0) nativeCount++; + } + } + progress.setTotal(nativeCount * 4 + structs.length * 3); + progress.setMessage("Generating structs.h ..."); + } + generateSTRUCTS_H(structs); + if (progress != null) progress.setMessage("Generating structs.c ..."); + generateSTRUCTS_C(structs); + if (progress != null) progress.setMessage("Generating natives ..."); + generateSWT_C(natives); + if (progress != null) progress.setMessage("Generating stats.h ..."); + generateSTATS_H(natives); + if (progress != null) progress.setMessage("Generating stats.c ..."); + generateSTATS_C(natives); + if (progress != null) progress.setMessage("Generating meta data ..."); generateAllMetaData(); + if (progress != null) progress.setMessage("Done."); + this.progress = null; } boolean compare(InputStream is1, InputStream is2) throws IOException { diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java index 7184aded52..12a71d1423 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java @@ -27,6 +27,8 @@ public class JNIGeneratorAppUI { Composite actionsPanel; Combo mainClassCb, outputDirCb; Table classesLt, membersLt, paramsLt; + ProgressBar progressBar; + Label progressLabel; FileDialog fileDialog; TableEditor paramTextEditor, memberTextEditor, classTextEditor; @@ -136,13 +138,41 @@ void generateAll() { shell.setEnabled(false); Control[] children = actionsPanel.getChildren(); for (int i = 0; i < children.length; i++) { - children[i].setEnabled(false); + Control child = children[i]; + if (child instanceof Button) child.setEnabled(false); } + progressLabel.setText(""); + progressBar.setSelection(0); + progressLabel.setVisible(true); + progressBar.setVisible(true); final boolean[] done = new boolean[1]; new Thread() { public void run() { try { - app.generate(); + app.generate(new ProgressMonitor() { + public void setTotal(final int total) { + display.syncExec(new Runnable() { + public void run() { + progressBar.setMaximum(total); + } + }); + } + public void step() { + display.syncExec(new Runnable() { + public void run() { + progressBar.setSelection(progressBar.getSelection() + 1); + } + }); + } + public void setMessage(final String message) { + display.syncExec(new Runnable() { + public void run() { + progressLabel.setText(message); + progressLabel.update(); + } + }); + } + }); } finally { done[0] = true; display.wake(); @@ -153,8 +183,11 @@ void generateAll() { if (!display.readAndDispatch()) display.sleep(); } for (int i = 0; i < children.length; i++) { - children[i].setEnabled(true); + Control child = children[i]; + if (child instanceof Button) child.setEnabled(true); } + progressBar.setVisible(false); + progressLabel.setVisible(false); shell.setEnabled(true); shell.setCursor(null); cursor.dispose(); @@ -833,6 +866,17 @@ void createActionButtons(Composite parent) { generateMetaData(); } }); + + Composite filler = new Composite(actionsPanel, SWT.NONE); + filler.setLayoutData(new GridData(GridData.FILL_BOTH)); + + progressLabel = new Label(actionsPanel, SWT.NONE); + progressLabel.setLayoutData(data); + progressLabel.setVisible(false); + + progressBar = new ProgressBar(actionsPanel, SWT.NONE); + progressBar.setLayoutData(data); + progressBar.setVisible(false); } public void run() { diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java index 599b4b31c5..6d55ee389b 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java @@ -41,6 +41,7 @@ public void generate(Field[] fields) { if ((mods & Modifier.STATIC) != 0) continue; generate(field); outputln(); + if (progress != null) progress.step(); } } @@ -60,6 +61,7 @@ public void generate(Method[] methods) { if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; generate(method); outputln(); + if (progress != null) progress.step(); } } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java index 4bbec60449..cb3b183fd2 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java @@ -15,7 +15,7 @@ import java.util.HashSet; import java.util.Iterator; public class NativesGenerator extends JNIGenerator { - + boolean nativeMacro, enterExitMacro, isCPP; public NativesGenerator() { @@ -96,6 +96,7 @@ public void generate(Method[] methods) { Method method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; generate(method); + if (progress != null) progress.step(); } } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ProgressMonitor.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ProgressMonitor.java new file mode 100644 index 0000000000..97d01f2ea0 --- /dev/null +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ProgressMonitor.java @@ -0,0 +1,9 @@ +package org.eclipse.swt.tools.internal; + +public interface ProgressMonitor { + +public void setTotal(int total); +public void setMessage(String message); +public void step(); + +} diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java index 498d99a2b1..3de9bd3f90 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java @@ -34,6 +34,7 @@ public void generate(Method[] methods) { Method method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; generateStringArray(method); + if (progress != null) progress.step(); } } @@ -202,6 +203,7 @@ void generateFunctionEnum(Method[] methods) { output("\t"); output(getFunctionName(method)); outputln("_FUNC,"); + if (progress != null) progress.step(); } Class clazz = methods[0].getDeclaringClass(); output("} "); diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java index 3e3c43014f..544e9d1dbb 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java @@ -15,7 +15,7 @@ import java.util.HashSet; import java.util.Iterator; public class StructsGenerator extends JNIGenerator { - + boolean isCPP; public boolean getCPP() { @@ -72,6 +72,7 @@ public void generateHeaderFile(Class[] classes) { ClassData classData = getMetaData().getMetaData(clazz); if (classData.getFlag("no_gen")) continue; generateHeaderFile(clazz); + if (progress != null) progress.step(); } } @@ -105,6 +106,7 @@ public void generateSourceFile(Class[] classes) { ClassData classData = getMetaData().getMetaData(clazz); if (classData.getFlag("no_gen")) continue; generateSourceFile(clazz); + if (progress != null) progress.step(); } } |