/**
* Executes the current action.
*/
public void handle(final NlpModelDeltaImpl delta) {
if ((delta.getResource() instanceof IProject)) {
final IResourceDelta resourceDelta = delta.getResourceDelta();
final IProject project = (IProject) delta.getResource();
if ((resourceDelta.getFlags() & IResourceDelta.OPEN) != 0) {
if (project.isOpen()) {
// add the nlp project
delta.setKind(Kind.ADDED);
mEventDispatcher.notify(delta.getKind(), delta);
// remove the old resource project
IResourceDelta removeProjectResourceDelta = new AbstractResourceDelta() {
@Override
public IResource getResource() {
return project;
}
@Override
public int getKind() {
return IResourceDelta.REMOVED;
}
@Override
public IPath getFullPath() {
return resourceDelta.getFullPath();
}
@Override
public IPath getProjectRelativePath() {
return resourceDelta.getProjectRelativePath();
}
@Override
public IResourceDelta[] getAffectedChildren() {
return new IResourceDelta[] {};
}
};
NlpModelDeltaImpl removeProjectDelta = new NlpModelDeltaImpl((NlpModelDeltaImpl) delta
.getParent(), removeProjectResourceDelta);
NlpModelDeltaImpl parent = (NlpModelDeltaImpl) delta.getParent();
parent.addChild(removeProjectDelta);
return;
} else {
// remove the nlp project
delta.setKind(Kind.REMOVED);
mEventDispatcher.notify(delta.getKind(), delta);
// add the closed project resource
IResourceDelta removeProjectResourceDelta = new AbstractResourceDelta() {
@Override
public IResource getResource() {
return project;
}
@Override
public int getKind() {
return IResourceDelta.ADDED;
}
@Override
public IPath getFullPath() {
return resourceDelta.getFullPath();
}
@Override
public IPath getProjectRelativePath() {
return resourceDelta.getProjectRelativePath();
}
@Override
public IResourceDelta[] getAffectedChildren() {
return new IResourceDelta[] {};
}
};
NlpModelDeltaImpl removeProjectDelta = new NlpModelDeltaImpl((NlpModelDeltaImpl) delta
.getParent(), removeProjectResourceDelta);
NlpModelDeltaImpl parent = (NlpModelDeltaImpl) delta.getParent();
parent.addChild(removeProjectDelta);
return;
}
}
// indicates that a nature was added to the project
else if ((resourceDelta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
if (project.isOpen()) {
IResourceDelta removeProjectResourceDelta = new AbstractResourceDelta() {
@Override
public IResource getResource() {
return project;
}