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 9072c6db9..111b017be 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 @@ -474,5 +474,14 @@ public class SketchProject implements IProjectNature { public String getMainType() { return project.getName(); } + + /** + * Tries to export the sketch as an applet + * returns whether or not it was successful + */ + public boolean exportAsApplet() { + if (!wasLastBuildSuccessful) return false; + return false; + } } \ No newline at end of file diff --git a/editor/processing.plugin.ui/plugin.xml b/editor/processing.plugin.ui/plugin.xml index ff71b3bdd..daef80b4f 100644 --- a/editor/processing.plugin.ui/plugin.xml +++ b/editor/processing.plugin.ui/plugin.xml @@ -18,13 +18,21 @@ extensions="pde"> + + + + + id="processing.plugin.ui.newWizards" + name="Processing"> - - + - + + + * Has a single field corresponding to the sketchbook path. Paths are verified, then if they 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 new file mode 100644 index 000000000..7eda9f57d --- /dev/null +++ b/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletWizard.java @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2010 Chris Lonnen. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.opensource.org/licenses/eclipse-1.0.php + * + * Contributors: + * Chris Lonnen - initial API and implementation + */ +package processing.plugin.ui.wizards; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.IExportWizard; +import org.eclipse.ui.IWorkbench; + +import processing.plugin.core.builder.SketchProject; +import processing.plugin.ui.ProcessingPlugin; + +/** + * A wizard to export a Processing sketch project as an applet + *

+ * Contains a single page. + * @author lonnen + * + */ +public class ExportAsAppletWizard extends Wizard implements IExportWizard { + + /** single page */ + private ExportAsAppletWizardPage page; + + /** The project to be exported */ + private IProject project; + + /** The current selection when the export is called. */ + private IStructuredSelection fSelection; + + public ExportAsAppletWizard() {} + + /** + * Used to figure out what we're exporting. + *

+ * If more than one item is selected, the first one listed + * is the one that gets exported. Just to make sure, the wizard + * page prompts with the name of the sketch before continuing. + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + workbench.getActiveWorkbenchWindow().getActivePage(); + Iterator iter = selection.iterator(); + while (iter.hasNext()){ + Object selectedElement = iter.next(); + if (selectedElement instanceof IProject) { + IProject proj = (IProject) selectedElement; + if(SketchProject.isSketchProject(proj)){ + + } + } else if (selectedElement instanceof IResource){ + IProject proj = ((IResource) selectedElement).getProject(); + if(SketchProject.isSketchProject(proj)){ + setProject(proj); + break; + } + } + } + + } + + public void setProject(IProject project){ + this.project = project; + if (page != null) page.setProject(project); + } + + public void addPages(){ + page = new ExportAsAppletWizardPage("Export Sketch Wizard"); + page.setProject(project); + addPage(page); + } + + public boolean performFinish() { + return SketchProject.forProject(page.getProject()).exportAsApplet(); + } + +} diff --git a/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletWizardPage.java b/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletWizardPage.java new file mode 100644 index 000000000..0f618cf9d --- /dev/null +++ b/editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletWizardPage.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2010 Chris Lonnen. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.opensource.org/licenses/eclipse-1.0.php + * + * Contributors: + * Chris Lonnen - initial API and implementation + */ +package processing.plugin.ui.wizards; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +public class ExportAsAppletWizardPage extends WizardPage { + + IProject project; + + /** should only be instantiated by its corresponding wizard */ + protected ExportAsAppletWizardPage(String pageName) { + super(pageName); + setTitle("Export Sketch Wizard"); + setDescription("Export your sketch as an applet."); + } + + public void setProject(IProject project){ + this.project = project; + } + + /** nothing fancy here, just a confirmation. the core will handle most of it. */ + public void createControl(Composite parent) { + setPageComplete(false); + + Composite container = new Composite(parent, SWT.NULL); + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 3; + container.setLayout(gridLayout); + setControl(container); + + final Label label = new Label(container, SWT.NONE); + final Label label2 = new Label(container, SWT.NONE); + final GridData gridData = new GridData(); + gridData.horizontalSpan = 3; + label.setLayoutData(gridData); + label2.setLayoutData(gridData); + if (project != null ){ + label.setText( + "You're about to export " + project.getName() + " as an applet."); + label2.setText( + "Click finish to proceed or cancel to select a different sketch."); + setPageComplete(true); + } else { + label.setText( + "The wizard cannot figure out what you are trying to export."); + label2.setText( + "Click cancel to go back and select a different sketch or .pde file."); + } + } + + public IProject getProject(){ + return project; + } + +}