use of org.eclipse.wst.common.project.facet.core.IProjectFacet in project webtools.sourceediting by eclipse.
the class FacetModuleCoreSupportDelegate method isWebFragmentProject.
/**
* @param project
* @return
* @throws CoreException
*/
static boolean isWebFragmentProject(IProject project) {
if (project == null)
return false;
try {
if (ProjectFacetsManager.isProjectFacetDefined(JST_WEBFRAGMENT_MODULE)) {
IFacetedProject faceted = ProjectFacetsManager.create(project);
IProjectFacet webModuleFacet = ProjectFacetsManager.getProjectFacet(JST_WEBFRAGMENT_MODULE);
if (faceted != null && faceted.hasProjectFacet(webModuleFacet)) {
return true;
}
}
} catch (CoreException e) {
Logger.logException(e);
}
return false;
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacet in project webtools.sourceediting by eclipse.
the class FacetModuleCoreSupportDelegate method isWebProject.
/**
* @param project
* @return
* @throws CoreException
*/
static boolean isWebProject(IProject project) {
boolean is = false;
try {
IFacetedProject faceted = ProjectFacetsManager.create(project);
if (ProjectFacetsManager.isProjectFacetDefined(JST_WEB_MODULE)) {
IProjectFacet facet = ProjectFacetsManager.getProjectFacet(JST_WEB_MODULE);
is = is || (faceted != null && faceted.hasProjectFacet(facet));
}
if (!is && ProjectFacetsManager.isProjectFacetDefined(WST_WEB_MODULE)) {
IProjectFacet facet = ProjectFacetsManager.getProjectFacet(WST_WEB_MODULE);
is = is || (faceted != null && faceted.hasProjectFacet(facet));
}
if (!is && ProjectFacetsManager.isProjectFacetDefined(JST_WEBFRAGMENT_MODULE)) {
IProjectFacet facet = ProjectFacetsManager.getProjectFacet(JST_WEBFRAGMENT_MODULE);
is = is || (faceted != null && faceted.hasProjectFacet(facet));
}
} catch (CoreException e) {
Logger.logException(e);
}
return is;
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacet in project liferay-ide by liferay.
the class LiferayProjectImportDataModelProvider method init.
@Override
public void init() {
super.init();
// set the project facets to get the runtime target dropdown to only show liferay runtimes
IFacetedProjectWorkingCopy facetedProject = getFacetedProjectWorkingCopy();
facetedProject.setSelectedPreset(IPluginFacetConstants.LIFERAY_PORTLET_PRESET);
Set<IProjectFacet> fixedFacets = new HashSet<>();
fixedFacets.add(ProjectFacetsManager.getProjectFacet(IPluginFacetConstants.LIFERAY_EXT_FACET_ID));
facetedProject.setFixedProjectFacets(Collections.unmodifiableSet(fixedFacets));
ProjectUtil.setDefaultRuntime(getDataModel());
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacet 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();
}
use of org.eclipse.wst.common.project.facet.core.IProjectFacet in project liferay-ide by liferay.
the class SDKPluginFacetUtil method configureProjectAsSDKProject.
public static void configureProjectAsSDKProject(IFacetedProjectWorkingCopy fpjwc, String pluginType, String sdkLocation, ProjectRecord projectRecord) throws CoreException {
IFacetedProjectTemplate template = getLiferayTemplateForProject(pluginType);
IPreset preset = getLiferayPresetForProject(pluginType);
if (preset == null) {
throw new CoreException(ProjectCore.createErrorStatus(NLS.bind(Msgs.noFacetPreset, fpjwc.getProjectName())));
}
IRuntime primaryRuntime = fpjwc.getPrimaryRuntime();
if (primaryRuntime != null) {
fpjwc.removeTargetedRuntime(primaryRuntime);
}
Set<IProjectFacetVersion> currentProjectFacetVersions = fpjwc.getProjectFacets();
Set<IProjectFacet> requiredFacets = template.getFixedProjectFacets();
for (IProjectFacet requiredFacet : requiredFacets) {
boolean hasRequiredFacet = false;
for (IProjectFacetVersion currentFacetVersion : currentProjectFacetVersions) {
if (currentFacetVersion.getProjectFacet().equals(requiredFacet)) {
// TODO how to check the bundle support status?
boolean requiredVersion = _isRequiredVersion(currentFacetVersion);
if (requiredVersion) {
hasRequiredFacet = true;
} else {
fpjwc.removeProjectFacet(currentFacetVersion);
}
break;
}
}
if (!hasRequiredFacet) {
IProjectFacetVersion requiredFacetVersion = _getRequiredFacetVersionFromPreset(requiredFacet, preset);
if (requiredFacetVersion != null) {
fpjwc.addProjectFacet(requiredFacetVersion);
if (ProjectUtil.isJavaFacet(requiredFacetVersion)) {
configureJavaFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset, projectRecord);
} else if (ProjectUtil.isDynamicWebFacet(requiredFacetVersion)) {
configureWebFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset);
}
}
} else {
if (ProjectUtil.isJavaFacet(requiredFacet)) {
configureJavaFacet(fpjwc, requiredFacet, preset, projectRecord);
} else if (ProjectUtil.isDynamicWebFacet(requiredFacet)) {
configureWebFacet(fpjwc, requiredFacet, preset);
}
}
}
}
Aggregations