Added export wizard. not functional, yet, so it hasn't been pushed to the update site.

This commit is contained in:
lonnen
2010-09-11 01:19:39 +00:00
parent 5037980c2e
commit 418615d248
5 changed files with 193 additions and 10 deletions

View File

@@ -32,7 +32,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
import processing.plugin.core.ProcessingCorePreferences;
/**
/**
* Pref pane class for the Core preferences.
* <p>
* Has a single field corresponding to the sketchbook path. Paths are verified, then if they

View File

@@ -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
* <p>
* 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.
* <p>
* 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();
}
}

View File

@@ -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;
}
}