diff --git a/editor/processing.plugin.core/src/processing/plugin/core/ProcessingUtilities.java b/editor/processing.plugin.core/src/processing/plugin/core/ProcessingUtilities.java index f3dd20839..ce8f0c2be 100644 --- a/editor/processing.plugin.core/src/processing/plugin/core/ProcessingUtilities.java +++ b/editor/processing.plugin.core/src/processing/plugin/core/ProcessingUtilities.java @@ -1219,7 +1219,6 @@ public class ProcessingUtilities implements PConstants{ } } - /** * Calculate the size of the contents of a folder. * Used to determine whether sketches are empty or not. 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 a049101a2..33f4ed8ac 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 @@ -307,9 +307,9 @@ public class SketchBuilder extends IncrementalProjectBuilder{ if (!output.exists()){ output.create(inStream, true, monitor); //TODO resource change listener to move trace back JDT errors - // IWorkspace w = ResourcesPlugin.getWorkspace(); - // IResourceChangeListener rcl = new ProblemListener(output); - // w.addResourceChangeListener(rcl); + // IWorkspace w = ResourcesPlugin.getWorkspace(); + // IResourceChangeListener rcl = new ProblemListener(output); + // w.addResourceChangeListener(rcl); } else { output.setContents(inStream, true, false, monitor); } diff --git a/editor/processing.plugin.ui/META-INF/MANIFEST.MF b/editor/processing.plugin.ui/META-INF/MANIFEST.MF index bccfc12ea..e919d1f27 100644 --- a/editor/processing.plugin.ui/META-INF/MANIFEST.MF +++ b/editor/processing.plugin.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Processing Plugin User Interface Elements Bundle-SymbolicName: processing.plugin.ui;singleton:=true -Bundle-Version: 0.2.3.0 +Bundle-Version: 0.2.3.1 Bundle-Activator: processing.plugin.ui.ProcessingPlugin Bundle-Vendor: Processing.org Require-Bundle: org.eclipse.ui, diff --git a/editor/processing.plugin.ui/plugin.xml b/editor/processing.plugin.ui/plugin.xml index 89e2e4ed8..b77a0f5b3 100644 --- a/editor/processing.plugin.ui/plugin.xml +++ b/editor/processing.plugin.ui/plugin.xml @@ -70,7 +70,6 @@ + + + + + + + + + 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 19e4fc733..403d35b65 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 @@ -92,7 +92,7 @@ public class ExportAsAppletSelectProjectsWizardPage extends WizardPage { public SketchProject getProject(){ return sp; } public String getAdditionalMessage(){ - return (sp.wasLastBuildSuccessful()) ? "" : "Warning: there were errors on the last build."; + return (sp.wasLastBuildSuccessful()) ? "" : "Warning: last build unsuccessful. May not export."; } } diff --git a/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletWizard.java b/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletWizard.java index 350d03158..2d1716f12 100644 --- a/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletWizard.java +++ b/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletWizard.java @@ -14,9 +14,13 @@ package processing.plugin.ui.wizards; //import org.eclipse.core.resources.IProject; //import org.eclipse.core.resources.IResource; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -89,10 +93,10 @@ public class ExportAsAppletWizard extends Wizard implements IExportWizard { } public boolean performFinish() { -// return SketchProject.forProject(page.getProject()).exportAsApplet(); + //return SketchProject.forProject(page.getProject()).exportAsApplet(); ArrayList couldNotExport = new ArrayList(); for(SketchProject sp : page.getSelectedProjects()){ -// System.out.println(sp.getProject().getName()); + //System.out.println(sp.getProject().getName()); if (!exportAsApplet(sp)) couldNotExport.add(sp.getProject().getName()); } @@ -111,14 +115,27 @@ public class ExportAsAppletWizard extends Wizard implements IExportWizard { */ public boolean exportAsApplet(SketchProject sp) { if (sp == null) return false; - if (!sp.wasLastBuildSuccessful()) return false; if (!sp.getProject().isAccessible()) return false; - + + try{ + sp.fullBuild(null); + } catch (CoreException e){ + ProcessingLog.logError(e); + return false; + } + if (!sp.wasLastBuildSuccessful()){ + ProcessingLog.logError("Could not export " + sp.getProject().getName() + + ". There were erros building the project.", null); + return false; + } + IFile code = sp.getMainFile(); if (code == null) return false; String codeContents = ProcessingUtilities.readFile(code); IFolder exportFolder = sp.getAppletFolder(true); // true to nuke the folder contents, if they exist + + HashMap zipFileContents = new HashMap(); // Get size and renderer info from the project int wide = sp.getWidth(); @@ -138,25 +155,38 @@ public class ExportAsAppletWizard extends Wizard implements IExportWizard { dbuffer.append('\n'); } description = dbuffer.toString(); - System.out.println(description); + //System.out.println(description); } - //Copy the source files to the target, since we like to encourage people to share their code + // Copy the source files to the target, since we like to encourage people to share their code + // Get links for each copied code file + StringBuffer sources = new StringBuffer(); try{ for(IResource r : sp.getProject().members()){ if(!(r instanceof IFile)) continue; if(r.getName().startsWith(".")) continue; if("pde".equalsIgnoreCase(r.getFileExtension())){ - r.copy(exportFolder.getFullPath().append(r.getName()), true, null); - System.out.println("Copied the source file " + r.getName() - + " to " + exportFolder.getFullPath().toString()); + try{ + r.copy(exportFolder.getFullPath().append(r.getName()), true, null); + sources.append("" + + r.getName().subSequence(0, r.getName().lastIndexOf(".")-1) + + " "); + } catch (CoreException e) { + ProcessingLog.logError("Sketch source files could not be included in export of " + + sp.getProject().getName() +". Trying to continue export anyway.", e); + } } } } catch (CoreException e){ - ProcessingLog.logError("Sketch source files could not be included in export of " - + sp.getProject().getName() +". Trying to continue export anyway. ", e); + ProcessingLog.logError(e); // problem getting members } + // Use separate jarfiles + boolean separateJar = true; + // = Preferences.getBoolean("export.applet.separate_jar_files)|| + // codeFolder.exists() || + // (libraryPath.length() != 0); + // Copy the loading gif to the applet String LOADING_IMAGE = "loading.gif"; IFile loadingImage = sp.getProject().getFile(LOADING_IMAGE); // user can specify their own loader @@ -168,7 +198,7 @@ public class ExportAsAppletWizard extends Wizard implements IExportWizard { try { File exportResourcesFolder = new File(ProcessingCore.getProcessingCore().getPluginResourceFolder().getCanonicalPath(), "export"); File loadingImageCoreResource = new File(exportResourcesFolder, LOADING_IMAGE); - ProcessingUtilities.copyFile(loadingImageCoreResource, new File(exportFolder.getFullPath().toString(), LOADING_IMAGE)); + ProcessingUtilities.copyFile(loadingImageCoreResource, new File(exportFolder.getLocation().toFile(), LOADING_IMAGE)); } catch (Exception ex) { // This is not expected, and should be reported, because we are about to bail ProcessingLog.logError("Could not access the Processing Plug-in Core resources. " + @@ -177,6 +207,22 @@ public class ExportAsAppletWizard extends Wizard implements IExportWizard { } } + // Create new .jar file + FileOutputStream zipOutputFile; + try { + zipOutputFile = new FileOutputStream(new File(exportFolder.getLocation().toFile(), sp.getProject().getName() + ".jar")); + } catch (FileNotFoundException fnfe) { + ProcessingLog.logError(" ",fnfe); + return false; + } + ZipOutputStream zos = new ZipOutputStream(zipOutputFile); + ZipEntry entry; + + StringBuffer archives = new StringBuffer(); + archives.append(sp.getProject().getName() + ".jar"); + + //addmanifest(zos); + // add the contents of the code folder to the jar IFolder codeFolder = sp.getCodeFolder(); if (codeFolder != null){ @@ -197,44 +243,47 @@ public class ExportAsAppletWizard extends Wizard implements IExportWizard { } // snag the opengl library path so we can test for it later - File openglLibraryFolder = new File(ProcessingCore.getProcessingCore().getCoreLibsFolder(), "opengl/library"); - String openglLibraryPath = openglLibraryFolder.getAbsolutePath(); + File openglLibrary = new File(ProcessingCore.getProcessingCore().getCoreLibsFolder(), "opengl/library/opengl.jar"); + String openglLibraryPath = openglLibrary.getAbsolutePath(); boolean openglApplet = false; // add the library jar files to the folder and detect if opengl is in use ArrayList sketchLibraryImportPaths = sp.getLibraryPaths(); if(sketchLibraryImportPaths != null){ for(IPath path : sketchLibraryImportPaths){ - File libraryFolder = new File(path.toOSString()); - if (path.toOSString().equalsIgnoreCase(openglLibraryPath)) openglApplet=true; - File exportSettings = new File(libraryFolder, "export.txt"); - HashMap exportTable = ProcessingUtilities.readSettings(exportSettings); - String appletList = (String) exportTable.get("applet"); - String exportList[] = null; - if(appletList != null){ - exportList = ProcessingUtilities.splitTokens(appletList, ", "); - } else { - exportList = libraryFolder.list(); - } - for (String s : exportList){ - if (s.equals(".") || s.equals("..")) continue; - - s = ProcessingUtilities.trim(s); - if (s.equals("")) continue; - - File exportFile = new File( libraryFolder, s); - if(!exportFile.exists()) { - ProcessingLog.logError("Export File " + s + " does not exist.", null); - } else if (exportFile.isDirectory()) { - ProcessingLog.logInfo("Ignoring sub-folder \"" + s + "\""); - } else if ( exportFile.getName().toLowerCase().endsWith(".zip") || - exportFile.getName().toLowerCase().endsWith(".jar")){ - // the PDE checks for separate jar boolean, but if we're here we have - // met the conditions that require it -// File exportFile = new File(codeFolder, s); - } - - } + if (path.toOSString().equals(openglLibraryPath)) openglApplet = true; + + +// File libraryFolder = new File(path.toOSString()); +// if (path.toOSString().equalsIgnoreCase(openglLibraryPath)) openglApplet=true; +// File exportSettings = new File(libraryFolder, "export.txt"); +// HashMap exportTable = ProcessingUtilities.readSettings(exportSettings); +// String appletList = (String) exportTable.get("applet"); +// String exportList[] = null; +// if(appletList != null){ +// exportList = ProcessingUtilities.splitTokens(appletList, ", "); +// } else { +// exportList = libraryFolder.list(); +// } +// for (String s : exportList){ +// if (s.equals(".") || s.equals("..")) continue; +// +// s = ProcessingUtilities.trim(s); +// if (s.equals("")) continue; +// +// File exportFile = new File( libraryFolder, s); +// if(!exportFile.exists()) { +// ProcessingLog.logError("Export File " + s + " does not exist.", null); +// } else if (exportFile.isDirectory()) { +// ProcessingLog.logInfo("Ignoring sub-folder \"" + s + "\""); +// } else if ( exportFile.getName().toLowerCase().endsWith(".zip") || +// exportFile.getName().toLowerCase().endsWith(".jar")){ +// // the PDE checks for separate jar boolean, but if we're here we have +// // met the conditions that require it +//// File exportFile = new File(codeFolder, s); +// } +// +// } } }