use of org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent in project jbosstools-hibernate by jbosstools.
the class JPAPostInstallFasetListener method handleEvent.
public void handleEvent(IFacetedProjectEvent event) {
if (event.getType() == Type.POST_INSTALL) {
IProject project = event.getProject().getProject();
IProjectFacetActionEvent pEvent = (IProjectFacetActionEvent) event;
if (pEvent.getProjectFacet().getId().equals(JpaProject.FACET_ID)) {
String platformId = HibernateEclipseUtils.getJpaPlatformID(project);
if (platformId != null && (platformId.equals(HibernateJpaPlatform.HIBERNATE_PLATFORM_ID) || platformId.equals(HibernateJpaPlatform.HIBERNATE2_0_PLATFORM_ID) || platformId.equals(HibernateJpaPlatform.HIBERNATE2_1_PLATFORM_ID))) {
if (checkPreConditions(project)) {
exportConnectionProfilePropertiesToPersistenceXml(project);
buildConsoleConfiguration(project, platformId);
}
}
}
}
}
use of org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent 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