Skip to content

Commit 62864a7

Browse files
committed
More export wizard UI. Added a warning when running a sketch fails because the editor is in the wrong perspective.
1 parent 05b9467 commit 62864a7

File tree

2 files changed

+56
-16
lines changed

2 files changed

+56
-16
lines changed

editor/processing.plugin.ui/src/processing/plugin/ui/launching/RunSketchAsAppletShortcut.java

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,48 @@ protected ILaunchConfigurationType getConfigurationType(){
5858
ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
5959
return lm.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLET);
6060
}
61+
62+
public void launch(IProject proj, String mode){
63+
try{
64+
if (proj.hasNature("processing.plugin.core.sketchNature"))
65+
launch(createConfiguration(proj), mode);
66+
else
67+
ProcessingLog.logInfo("Sketch could not be launched. "
68+
+ "The selected project does not have the required Sketch nature.");
69+
} catch (CoreException e){
70+
ProcessingLog.logError("Launch aborted. CoreException error occured while accessing the project.", e);
71+
}
72+
}
6173

6274
public void launch(ISelection selection, String mode) {
6375
if (selection instanceof IStructuredSelection) {
6476
Object element = ((IStructuredSelection)selection).getFirstElement();
6577
if (element instanceof IResource){
6678
IProject proj = ((IResource)element).getProject();
67-
try{
68-
if (proj.hasNature("processing.plugin.core.sketchNature"))
69-
launch(createConfiguration(proj), mode);
70-
else
71-
ProcessingLog.logInfo("Sketch could not be launched. The selected project does not have the required Sketch nature.");
72-
} catch (CoreException e){
73-
ProcessingLog.logError("Launch aborted.", e);
79+
if (proj.isAccessible()){
80+
launch(proj, mode);
81+
} else {
82+
ProcessingLog.logInfo("Sketch could not be launched. " +
83+
"Project was not accessible.");
7484
}
75-
} else {
76-
ProcessingLog.logInfo("Sketch could not be launched. Launcher was provided with a non-resource selection.");
85+
// if (element instanceof JavaProject){
86+
// /* The Java perspective hijacks Processing sketches and reports them through the selection
87+
// * interface as JavaProjects instead of IProjects or IResources or SketchProjects, all of
88+
// * which they happen to be, so I'm stuck accessing restricted code. Great.
89+
// */
90+
// IProject project = ((JavaProject)element).getProject();
91+
// if(project.isAccessible()){
92+
// launch( project, mode);
93+
// } else {
94+
// ProcessingLog.logInfo("Sketch could not be launched. " +
95+
// "Project was not accessible. Try launching from the Processing Perspective");
96+
// }
97+
// }
98+
}else {
99+
// System.out.println(element.getClass().getName());
100+
ProcessingLog.logInfo("Sketch could not be launched. " +
101+
"The launcher could not find a Sketch project associated with the provided selection." +
102+
"Try relaunching from the Processing Perspective, or launching a specific *.pde file.");
77103
}
78104
}
79105
}

editor/processing.plugin.ui/src/processing/plugin/ui/wizards/ExportAsAppletSelectProjectsWizardPage.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public void updateProjectList(){
6666
if (entry.setEntry(p)) entries.add(entry);
6767
}
6868
}
69-
7069
}
7170

7271
}
@@ -168,13 +167,28 @@ public void createControl(Composite parent) {
168167
table.setLayoutData(formData);
169168
table.setHeaderVisible(true);
170169

171-
final TableColumn rightTableColumn = new TableColumn(table,SWT.NONE);
172-
rightTableColumn.setWidth(200);
173-
rightTableColumn.setText("Name");
174-
175170
final TableColumn leftTableColumn = new TableColumn(table,SWT.NONE);
176-
leftTableColumn.setWidth(250);
177-
leftTableColumn.setText("Notes");
171+
leftTableColumn.setWidth(200);
172+
leftTableColumn.setText("Name");
173+
174+
final TableColumn rightTableColumn = new TableColumn(table,SWT.NONE);
175+
rightTableColumn.setWidth(250);
176+
rightTableColumn.setText("Notes");
177+
}
178+
179+
/**
180+
* Override of setVisible to update and display the content only
181+
* when the page is becoming visible.
182+
* <p>
183+
* {@inheritDoc}
184+
*/
185+
public void setVisible(boolean visible){
186+
if (visible) projectTable.setInput(visible);
187+
/* setInput needs an object, but it really doesn't matter what is
188+
* handed to it as long as the content provider is the private class
189+
* ProjectTableConentProvider, because that provider ignores the object
190+
* and builds everything itself. */
191+
super.setVisible(visible);
178192
}
179193

180194
}

0 commit comments

Comments
 (0)