use of org.eclipse.wst.common.project.facet.core.IFacetedProject.Action.Type in project liferay-ide by liferay.
the class LiferayFacetedProjectListener method handleEvent.
public void handleEvent(IFacetedProjectEvent event) {
if (event.getType() != IFacetedProjectEvent.Type.POST_INSTALL) {
return;
}
IProjectFacetActionEvent actionEvent = (IProjectFacetActionEvent) event;
if (!JSDT_FACET.equals(actionEvent.getProjectFacet().getId())) {
return;
}
Job uninstall = new WorkspaceJob("uninstall jsdt facet") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
IFacetedProject fProject = actionEvent.getProject();
Set<IProjectFacet> fixedFacets = fProject.getFixedProjectFacets();
Set<IProjectFacet> updatedFacets = new HashSet<>();
for (IProjectFacet f : fixedFacets) {
if (!JSDT_FACET.equals(f.getId())) {
updatedFacets.add(f);
}
}
fProject.setFixedProjectFacets(updatedFacets);
} catch (Exception e) {
ProjectCore.logError("Unable to removed fixed jsdt facet", e);
}
try {
Set<Action> actions = new HashSet<>();
Type type = Type.valueOf("uninstall");
Action uninstallJsdt = new Action(type, actionEvent.getProjectFacetVersion(), null);
actions.add(uninstallJsdt);
actionEvent.getProject().modify(actions, monitor);
// try to remove unneeded jsdt files
IProject project = actionEvent.getProject().getProject();
IFile jsdtscope = project.getFile(".settings/.jsdtscope");
if (FileUtil.exists(jsdtscope)) {
jsdtscope.delete(true, monitor);
}
IFile container = project.getFile(".settings/org.eclipse.wst.jsdt.ui.superType.container");
if (FileUtil.exists(container)) {
container.delete(true, monitor);
}
IFile name = project.getFile(".settings/org.eclipse.wst.jsdt.ui.superType.name");
if (FileUtil.exists(name)) {
name.delete(true, monitor);
}
} catch (CoreException ce) {
ProjectCore.logError("Unable to uninstall jsdt facet", ce);
}
return Status.OK_STATUS;
}
};
uninstall.schedule();
}
Aggregations