mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
All known problems not marked with a TODO are resolved. New Processing Sketch wizard creates projects and associates them with the nature / builder. The builder successfully captures change events and rebuilds. The builder writes files to the bin, but doesn't fully compile sketches.
This commit is contained in:
@@ -57,9 +57,6 @@
|
||||
<run class="org.processing.builder.ProcessingSketchNature"/>
|
||||
</runtime>
|
||||
<builder id="org.processing.editor.processingSketchBuilder"/>
|
||||
<requires-nature
|
||||
id="org.eclipse.jdt.core.javanature">
|
||||
</requires-nature>
|
||||
</extension>
|
||||
<extension id="processingSketchBuilder" name="Processing Sketch Builder" point="org.eclipse.core.resources.builders">
|
||||
<builder hasNature="true">
|
||||
|
||||
+1
-2
@@ -49,7 +49,7 @@ import processing.app.preproc.PreprocessResult;
|
||||
*/
|
||||
public class ProcessingSketchAuditor extends IncrementalProjectBuilder {
|
||||
|
||||
public static final String BUILDER_ID = ProcessingEditorPlugin.PLUGIN_ID + ".procesingSketchBuilder";
|
||||
public static final String BUILDER_ID = ProcessingEditorPlugin.PLUGIN_ID + ".processingSketchBuilder";
|
||||
|
||||
/**
|
||||
* Adds the processing builder to a project
|
||||
@@ -157,7 +157,6 @@ public class ProcessingSketchAuditor extends IncrementalProjectBuilder {
|
||||
// incrementalBuild(delta, monitor);
|
||||
// }
|
||||
// }
|
||||
System.out.println("BUILD!");
|
||||
|
||||
// every build is a full build for now, @see incrementalBuild
|
||||
fullBuild(monitor);
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
package org.processing.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IProjectNature;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.processing.editor.ProcessingEditorPlugin;
|
||||
import org.processing.editor.ProcessingLog;
|
||||
|
||||
public class ProcessingSketchNature implements IProjectNature {
|
||||
|
||||
private static final String NATURE_ID = "org.processing.editor.processingSketchNature";
|
||||
private IProject project;
|
||||
|
||||
/**
|
||||
@@ -62,6 +69,82 @@ public class ProcessingSketchNature implements IProjectNature {
|
||||
if (!project.isOpen())
|
||||
return;
|
||||
|
||||
// Get the description
|
||||
IProjectDescription description;
|
||||
|
||||
try {
|
||||
description = project.getDescription();
|
||||
}
|
||||
catch (CoreException e){
|
||||
ProcessingLog.logError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the project already has this nature we're done, otherwise keep going
|
||||
List<String> newIds = new ArrayList<String>();
|
||||
newIds.addAll(Arrays.asList(description.getNatureIds()));
|
||||
int index = newIds.indexOf(NATURE_ID);
|
||||
if (index != -1)
|
||||
return;
|
||||
|
||||
// Add the nature
|
||||
newIds.add(NATURE_ID);
|
||||
description.setNatureIds(newIds.toArray(new String[newIds.size()]));
|
||||
|
||||
// Save the description
|
||||
try {
|
||||
project.setDescription(description, null);
|
||||
} catch(CoreException e){
|
||||
ProcessingLog.logError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a project to see if it has the Processing nature
|
||||
*
|
||||
* IProject project to test
|
||||
* returns true if the project has the processing nature
|
||||
*/
|
||||
public static boolean hasNature(IProject project){
|
||||
try{
|
||||
return project.isOpen() && project.hasNature(NATURE_ID);
|
||||
} catch (CoreException e){
|
||||
ProcessingLog.logError(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeNature(IProject project){
|
||||
// Cannot modify closed projects
|
||||
if (!project.isOpen())
|
||||
return;
|
||||
|
||||
// Get the description
|
||||
IProjectDescription description;
|
||||
try {
|
||||
description = project.getDescription();
|
||||
} catch (CoreException e){
|
||||
ProcessingLog.logError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine if the project has the nature
|
||||
List<String> newIds = new ArrayList<String>();
|
||||
newIds.addAll(Arrays.asList(description.getNatureIds()));
|
||||
int index = newIds.indexOf(NATURE_ID);
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
// Remove the nature
|
||||
newIds.remove(index);
|
||||
description.setNatureIds(newIds.toArray(new String[newIds.size()]));
|
||||
|
||||
// Save the description
|
||||
try {
|
||||
project.setDescription(description,null);
|
||||
} catch (CoreException e){
|
||||
ProcessingLog.logError(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.processing.editor.util.ProcessingColorProvider;
|
||||
*/
|
||||
public class ProcessingEditorPlugin extends AbstractUIPlugin {
|
||||
|
||||
public static final String PLUGIN_ID = "org.processing.ProcessingEditor";
|
||||
public static final String PLUGIN_ID = "org.processing.editor";
|
||||
//public static final String JAVA_PARTITIONING= "__java_example_partitioning"; //$NON-NLS-1$
|
||||
public static final String PROCESSING_PARTITIONING= "__processing_partitioning"; //$NON-NLS-1$
|
||||
|
||||
|
||||
@@ -17,14 +17,13 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.ui.INewWizard;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
||||
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
|
||||
import org.processing.builder.ProcessingSketchNature;
|
||||
|
||||
/**
|
||||
* A wizard to create a new Processing sketch project.
|
||||
@@ -38,13 +37,11 @@ public class NewSketchWizard extends Wizard implements INewWizard {
|
||||
|
||||
/** The single page in the wizard */
|
||||
private NewSketchWizardPage page;
|
||||
|
||||
private IWorkbench workbench;
|
||||
/** The project to be created */
|
||||
private IProject project;
|
||||
|
||||
/** Constructor */
|
||||
public NewSketchWizard(){
|
||||
// TODO implement the dialog settings stuff
|
||||
// IDialogSettings processingSettings = ProcessingEditorPlugin.getDefault().getDialogSettings();
|
||||
// IDialogSettings wizardSettings = processingSettings.getSection("NewSketchWizard");
|
||||
// if (wizardSettings == null)
|
||||
@@ -89,8 +86,6 @@ public class NewSketchWizard extends Wizard implements INewWizard {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO update Perspective(config);
|
||||
// TODO re-enable this when the bigger problem is fixed BasicNewResourceWizard.selectAndReveal(project, workbench.getActiveWorkbenchWindow());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -134,13 +129,14 @@ public class NewSketchWizard extends Wizard implements INewWizard {
|
||||
if (monitor.isCanceled()){throw new OperationCanceledException();}
|
||||
|
||||
//create the main file
|
||||
addFileToProject(container, new Path(project.getName() + ".pde"), null, new SubProgressMonitor(monitor, 100));
|
||||
|
||||
|
||||
|
||||
addFileToContainer(container, new Path(project.getName() + ".pde"), null, new SubProgressMonitor(monitor, 100));
|
||||
} finally{
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
// this is a new project
|
||||
ProcessingSketchNature.addNature(proj);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +148,7 @@ public class NewSketchWizard extends Wizard implements INewWizard {
|
||||
* @param monitor report the progress back to the user
|
||||
* @throws CoreException if there are problems with the resource
|
||||
*/
|
||||
private void addFileToProject(IContainer container, Path path, InputStream contentStream, IProgressMonitor monitor) throws CoreException{
|
||||
private void addFileToContainer(IContainer container, Path path, InputStream contentStream, IProgressMonitor monitor) throws CoreException{
|
||||
final IFile file = container.getFile(path);
|
||||
if (contentStream == null){
|
||||
contentStream = new ByteArrayInputStream(" void setup(){} \n void draw(){} ".getBytes());
|
||||
|
||||
Reference in New Issue
Block a user