From 62864a71bcacc5d495033fb80efcb7642e7a6e09 Mon Sep 17 00:00:00 2001 From: lonnen Date: Mon, 20 Sep 2010 18:58:39 +0000 Subject: [PATCH] More export wizard UI. Added a warning when running a sketch fails because the editor is in the wrong perspective. --- .../launching/RunSketchAsAppletShortcut.java | 44 +++++++++++++++---- ...xportAsAppletSelectProjectsWizardPage.java | 28 +++++++++--- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/editor/processing.plugin.ui/src/processing/plugin/ui/launching/RunSketchAsAppletShortcut.java b/editor/processing.plugin.ui/src/processing/plugin/ui/launching/RunSketchAsAppletShortcut.java index a34563300..852646e8a 100644 --- a/editor/processing.plugin.ui/src/processing/plugin/ui/launching/RunSketchAsAppletShortcut.java +++ b/editor/processing.plugin.ui/src/processing/plugin/ui/launching/RunSketchAsAppletShortcut.java @@ -58,22 +58,48 @@ public class RunSketchAsAppletShortcut implements ILaunchShortcut { ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); return lm.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLET); } + + public void launch(IProject proj, String mode){ + try{ + if (proj.hasNature("processing.plugin.core.sketchNature")) + launch(createConfiguration(proj), mode); + else + ProcessingLog.logInfo("Sketch could not be launched. " + + "The selected project does not have the required Sketch nature."); + } catch (CoreException e){ + ProcessingLog.logError("Launch aborted. CoreException error occured while accessing the project.", e); + } + } public void launch(ISelection selection, String mode) { if (selection instanceof IStructuredSelection) { Object element = ((IStructuredSelection)selection).getFirstElement(); if (element instanceof IResource){ IProject proj = ((IResource)element).getProject(); - try{ - if (proj.hasNature("processing.plugin.core.sketchNature")) - launch(createConfiguration(proj), mode); - else - ProcessingLog.logInfo("Sketch could not be launched. The selected project does not have the required Sketch nature."); - } catch (CoreException e){ - ProcessingLog.logError("Launch aborted.", e); + if (proj.isAccessible()){ + launch(proj, mode); + } else { + ProcessingLog.logInfo("Sketch could not be launched. " + + "Project was not accessible."); } - } else { - ProcessingLog.logInfo("Sketch could not be launched. Launcher was provided with a non-resource selection."); +// if (element instanceof JavaProject){ +// /* The Java perspective hijacks Processing sketches and reports them through the selection +// * interface as JavaProjects instead of IProjects or IResources or SketchProjects, all of +// * which they happen to be, so I'm stuck accessing restricted code. Great. +// */ +// IProject project = ((JavaProject)element).getProject(); +// if(project.isAccessible()){ +// launch( project, mode); +// } else { +// ProcessingLog.logInfo("Sketch could not be launched. " + +// "Project was not accessible. Try launching from the Processing Perspective"); +// } +// } + }else { +// System.out.println(element.getClass().getName()); + ProcessingLog.logInfo("Sketch could not be launched. " + + "The launcher could not find a Sketch project associated with the provided selection." + + "Try relaunching from the Processing Perspective, or launching a specific *.pde 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 60e3a6560..d690f15ba 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 @@ -66,7 +66,6 @@ public class ExportAsAppletSelectProjectsWizardPage extends WizardPage { if (entry.setEntry(p)) entries.add(entry); } } - } } @@ -168,13 +167,28 @@ public class ExportAsAppletSelectProjectsWizardPage extends WizardPage { table.setLayoutData(formData); table.setHeaderVisible(true); - final TableColumn rightTableColumn = new TableColumn(table,SWT.NONE); - rightTableColumn.setWidth(200); - rightTableColumn.setText("Name"); - final TableColumn leftTableColumn = new TableColumn(table,SWT.NONE); - leftTableColumn.setWidth(250); - leftTableColumn.setText("Notes"); + leftTableColumn.setWidth(200); + leftTableColumn.setText("Name"); + + final TableColumn rightTableColumn = new TableColumn(table,SWT.NONE); + rightTableColumn.setWidth(250); + rightTableColumn.setText("Notes"); + } + + /** + * Override of setVisible to update and display the content only + * when the page is becoming visible. + *

+ * {@inheritDoc} + */ + public void setVisible(boolean visible){ + if (visible) projectTable.setInput(visible); + /* setInput needs an object, but it really doesn't matter what is + * handed to it as long as the content provider is the private class + * ProjectTableConentProvider, because that provider ignores the object + * and builds everything itself. */ + super.setVisible(visible); } }