@@ -58,22 +58,48 @@ protected ILaunchConfigurationType getConfigurationType(){
5858ILaunchManager  lm  = DebugPlugin .getDefault ().getLaunchManager ();
5959return  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
6274public  void  launch (ISelection  selection , String  mode ) {
6375if  (selection  instanceof  IStructuredSelection ) {
6476Object  element  = ((IStructuredSelection )selection ).getFirstElement ();
6577if  (element  instanceof  IResource ){
6678IProject  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}
0 commit comments