From d76aa79f03716c6b8efe633980b6d3ccd5b6d6f0 Mon Sep 17 00:00:00 2001 From: lonnen Date: Wed, 22 Sep 2010 22:46:50 +0000 Subject: [PATCH] Changed missing sketchName.pde from warning to error. Finished all exporter UI stuff. --- .../plugin/core/builder/SketchBuilder.java | 7 +- .../plugin/core/builder/SketchProject.java | 68 ++++++++++++------- ...xportAsAppletSelectProjectsWizardPage.java | 15 +++- .../ui/wizards/ExportAsAppletWizard.java | 16 ++++- 4 files changed, 73 insertions(+), 33 deletions(-) diff --git a/editor/processing.plugin.core/src/processing/plugin/core/builder/SketchBuilder.java b/editor/processing.plugin.core/src/processing/plugin/core/builder/SketchBuilder.java index 6da60c009..b365e866a 100644 --- a/editor/processing.plugin.core/src/processing/plugin/core/builder/SketchBuilder.java +++ b/editor/processing.plugin.core/src/processing/plugin/core/builder/SketchBuilder.java @@ -202,12 +202,13 @@ public class SketchBuilder extends IncrementalProjectBuilder{ return null; } - IFile mainFile = sketch.getFile( sketch.getName() + ".pde"); + IFile mainFile = sketchProject.getMainFile(); if (!mainFile.isAccessible()){ reportProblem( - "Could not find "+ sketch.getName() + ".pde, so things may get wierd.", - sketch, -1, false + "Could not find "+ sketch.getName() + ".pde, please rename your primary sketch file.", + sketch, -1, true ); + return null; } monitor.beginTask("Sketch Build", 40); // not sure how much work to do here diff --git a/editor/processing.plugin.core/src/processing/plugin/core/builder/SketchProject.java b/editor/processing.plugin.core/src/processing/plugin/core/builder/SketchProject.java index 92db25b4b..749b15f5d 100644 --- a/editor/processing.plugin.core/src/processing/plugin/core/builder/SketchProject.java +++ b/editor/processing.plugin.core/src/processing/plugin/core/builder/SketchProject.java @@ -256,12 +256,16 @@ public class SketchProject implements IProjectNature { } } - /** Return the sketch's code folder or null if it cannot be retrieved. */ public IFolder getAppletFolder(){ + return getAppletFolder(false); + } + + /** Return the sketch's code folder or null if it cannot be retrieved. */ + public IFolder getAppletFolder(boolean delete){ try{ IFolder applet = project.getFolder("applet"); - if(!applet.exists()) - applet.create(IResource.NONE, true, null); + if(delete && applet.exists()) applet.delete(true, null); + if(!applet.exists()) applet.create(IResource.NONE, true, null); return project.getFolder("applet"); } catch (Exception e){ ProcessingLog.logError("Applet folder could not be created.", e); @@ -500,34 +504,46 @@ public class SketchProject implements IProjectNature { if (!project.isAccessible()) return false; IFile code = this.getMainFile(); - if (!code.isAccessible()) return false; + if (code == null) return false; - HashMap zipFileContents = new HashMap(); + IFolder exportFolder = getAppletFolder(true); // true nukes the folder if it exists - int wide = this.getWidth(); - int high = this.getHeight(); - - String codeContents = Utilities.readFile(code); - - String description =""; - String[] javadoc = Utilities.match(codeContents, "/\\*{2,}(.*)\\*+/"); - if (javadoc != null){ - StringBuffer dbuffer = new StringBuffer(); - String[] pieces = Utilities.split(javadoc[1], '\n'); - for (String line : pieces){ - // if this line starts with * characters, remove em - String[] m = Utilities.match(line, "^\\s*\\*+(.*)"); - dbuffer.append(m != null ? m[1] : line); - dbuffer.append('\n'); + // if the code folder has stuff, dump it to a jar + try{ + IFolder codeFolder = getCodeFolder(); + if(codeFolder != null){ + if(codeFolder.members().length > 0){ + for(IResource r : codeFolder.members()){ + + } + } } - description = dbuffer.toString(); - ProcessingLog.logInfo(description); + } catch (CoreException e) { + ProcessingLog.logError("Could not export. CoreException while getting code folder.", e); + return false; } - IJavaProject jproject = this.getJavaProject(); - //export - +// int wide = this.getWidth(); +// int high = this.getHeight(); +// +// String codeContents = Utilities.readFile(code); +// +// String description =""; +// String[] javadoc = Utilities.match(codeContents, "/\\*{2,}(.*)\\*+/"); +// if (javadoc != null){ +// StringBuffer dbuffer = new StringBuffer(); +// String[] pieces = Utilities.split(javadoc[1], '\n'); +// for (String line : pieces){ +// // if this line starts with * characters, remove em +// String[] m = Utilities.match(line, "^\\s*\\*+(.*)"); +// dbuffer.append(m != null ? m[1] : line); +// dbuffer.append('\n'); +// } +// description = dbuffer.toString(); +// ProcessingLog.logInfo(description); +// } + return false; } - + } \ No newline at end of file diff --git a/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletSelectProjectsWizardPage.java b/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletSelectProjectsWizardPage.java index d690f15ba..8a969b5d2 100644 --- a/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletSelectProjectsWizardPage.java +++ b/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletSelectProjectsWizardPage.java @@ -85,7 +85,7 @@ public class ExportAsAppletSelectProjectsWizardPage extends WizardPage { public boolean setEntry(SketchProject project){ if (project == null) return false; sp = project; - System.out.println("Adding: " + project.getProject().getName()); +// System.out.println("Adding: " + project.getProject().getName()); return true; } @@ -117,8 +117,8 @@ public class ExportAsAppletSelectProjectsWizardPage extends WizardPage { /** Gets the column text */ public String getColumnText(Object element, int columnIndex) { - System.out.println(element.toString()); - System.out.println(columnIndex); +// System.out.println(element.toString()); +// System.out.println(columnIndex); switch (columnIndex) { case 0: // project if (element instanceof ProjectTableEntryModel) @@ -190,5 +190,14 @@ public class ExportAsAppletSelectProjectsWizardPage extends WizardPage { * and builds everything itself. */ super.setVisible(visible); } + + public SketchProject[] getSelectedProjects(){ + Object[] elements = projectTable.getCheckedElements(); + SketchProject[] selectedProjects = new SketchProject[elements.length]; + for(int i=0; i couldNotExport = new ArrayList(); + for(SketchProject sp : page.getSelectedProjects()){ +// System.out.println(sp.getProject().getName()); + if (!sp.exportAsApplet()) couldNotExport.add(sp.getProject().getName()); + } + + if (couldNotExport.size() > 0) + for(String s : couldNotExport) ProcessingLog.logInfo( "Unable to export " + s + "."); + + return true; } }