eclipse plugin: some name changes

This commit is contained in:
Timotei Dolean 2010-06-28 20:41:32 +00:00
parent 27837a1e39
commit 0fd414d395
4 changed files with 20 additions and 33 deletions

View file

@ -7,7 +7,7 @@
name="Sample Project Builder"
point="org.eclipse.core.resources.builders">
<builder hasNature="true">
<run class="wesnoth_eclipse_plugin.builder.SampleBuilder"/>
<run class="wesnoth_eclipse_plugin.builder.WesnothProjectBuilder"/>
</builder>
</extension>
<extension
@ -16,7 +16,7 @@
point="org.eclipse.core.resources.natures">
<runtime>
<run
class="wesnoth_eclipse_plugin.builder.SampleNature">
class="wesnoth_eclipse_plugin.builder.WesnothProjectNature">
</run>
</runtime>
<builder

View file

@ -71,7 +71,7 @@ public class ToggleNatureAction implements IObjectActionDelegate {
String[] natures = description.getNatureIds();
for (int i = 0; i < natures.length; ++i) {
if (SampleNature.NATURE_ID.equals(natures[i])) {
if (WesnothProjectNature.NATURE_ID.equals(natures[i])) {
// Remove the nature
String[] newNatures = new String[natures.length - 1];
System.arraycopy(natures, 0, newNatures, 0, i);
@ -86,7 +86,7 @@ public class ToggleNatureAction implements IObjectActionDelegate {
// Add the nature
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = SampleNature.NATURE_ID;
newNatures[natures.length] = WesnothProjectNature.NATURE_ID;
description.setNatureIds(newNatures);
project.setDescription(description, null);
} catch (CoreException e) {

View file

@ -2,6 +2,7 @@ package wesnoth_eclipse_plugin.builder;
import java.io.File;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.eclipse.core.resources.IFile;
@ -24,9 +25,9 @@ import wesnoth_eclipse_plugin.utils.AntUtils;
import wesnoth_eclipse_plugin.utils.GUIUtils;
import wesnoth_eclipse_plugin.utils.WorkspaceUtils;
public class SampleBuilder extends IncrementalProjectBuilder {
public class WesnothProjectBuilder extends IncrementalProjectBuilder {
public static final String BUILDER_ID = "Wesnoth_Eclipse_Plugin.sampleBuilder";
public static final String BUILDER_ID = "Wesnoth_Eclipse_Plugin.projectBuilder";
private static final String MARKER_TYPE = "Wesnoth_Eclipse_Plugin.configProblem";
class SampleDeltaVisitor implements IResourceDeltaVisitor {
@ -125,14 +126,20 @@ public class SampleBuilder extends IncrementalProjectBuilder {
void checkResource(IResource resource) {
// config files
if (resource instanceof IFile &&
(resource.getName().endsWith(".cfg") || resource.getName().endsWith(".CFG") )) {
try {
(resource.getName().toLowerCase(Locale.ENGLISH).endsWith(".cfg")))
{
try
{
IFile file = (IFile) resource;
deleteMarkers(file);
PreprocessorActions.preprocessFile(WorkspaceUtils.getPathRelativeToUserDir(file),
WorkspaceUtils.getTemporaryFolder(), null, true,false);
// TODO: here be dragons
// - add markers for wmllint, wmlscope
// - need a better output from wmltools
/*
IMarker[] resIMarkers = file.findMarkers(MARKER_TYPE, false, IResource.DEPTH_ZERO);
Logger.print("found markers: " + resIMarkers.length);

View file

@ -6,7 +6,7 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
public class SampleNature implements IProjectNature {
public class WesnothProjectNature implements IProjectNature {
/**
* ID of this project nature
@ -15,17 +15,12 @@ public class SampleNature implements IProjectNature {
private IProject project;
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
public void configure() throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(SampleBuilder.BUILDER_ID)) {
if (commands[i].getBuilderName().equals(WesnothProjectBuilder.BUILDER_ID)) {
return;
}
}
@ -33,47 +28,32 @@ public class SampleNature implements IProjectNature {
ICommand[] newCommands = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, newCommands, 0, commands.length);
ICommand command = desc.newCommand();
command.setBuilderName(SampleBuilder.BUILDER_ID);
command.setBuilderName(WesnothProjectBuilder.BUILDER_ID);
newCommands[newCommands.length - 1] = command;
desc.setBuildSpec(newCommands);
project.setDescription(desc, null);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#deconfigure()
*/
public void deconfigure() throws CoreException {
IProjectDescription description = getProject().getDescription();
ICommand[] commands = description.getBuildSpec();
for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(SampleBuilder.BUILDER_ID)) {
if (commands[i].getBuilderName().equals(WesnothProjectBuilder.BUILDER_ID)) {
ICommand[] newCommands = new ICommand[commands.length - 1];
System.arraycopy(commands, 0, newCommands, 0, i);
System.arraycopy(commands, i + 1, newCommands, i,
commands.length - i - 1);
description.setBuildSpec(newCommands);
project.setDescription(description, null);
project.setDescription(description, null);
return;
}
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#getProject()
*/
public IProject getProject() {
return project;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
*/
public void setProject(IProject project) {
this.project = project;
}