use of org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy in project liferay-ide by liferay.
the class LayoutTplPluginFacetInstall method removeUnneededClasspathEntries.
protected void removeUnneededClasspathEntries() {
IFacetedProjectWorkingCopy facetedProject = getFacetedProject();
IJavaProject javaProject = JavaCore.create(facetedProject.getProject());
try {
IClasspathEntry[] existingClasspath = javaProject.getRawClasspath();
List<IClasspathEntry> newClasspath = new ArrayList<>();
for (IClasspathEntry entry : existingClasspath) {
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
continue;
} else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
String path = entry.getPath().toPortableString();
if (path.contains("org.eclipse.jdt.launching.JRE_CONTAINER") || path.contains("org.eclipse.jst.j2ee.internal.web.container") || path.contains("org.eclipse.jst.j2ee.internal.module.container")) {
continue;
}
}
newClasspath.add(entry);
}
javaProject.setRawClasspath(newClasspath.toArray(new IClasspathEntry[0]), null);
IResource sourceFolder = javaProject.getProject().findMember(IPluginFacetConstants.PORTLET_PLUGIN_SDK_SOURCE_FOLDER);
if (FileUtil.exists(sourceFolder)) {
sourceFolder.delete(true, null);
}
} catch (Exception e) {
}
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy in project liferay-ide by liferay.
the class SDKProjectConvertDataModelProvider 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();
Set<IProjectFacetVersion> facets = ProjectUtil.getFacetsForPreset(IPluginFacetConstants.LIFERAY_PORTLET_PRESET);
Set<IProjectFacet> fixedFacets = new HashSet<>();
for (IProjectFacetVersion pfv : facets) {
fixedFacets.add(pfv.getProjectFacet());
}
facetedProject.setFixedProjectFacets(Collections.unmodifiableSet(fixedFacets));
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy in project liferay-ide by liferay.
the class SDKProjectsImportDataModelProvider 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.IFacetedProjectWorkingCopy in project liferay-ide by liferay.
the class ProjectUtil method createNewSDKProject.
public static IProject createNewSDKProject(ProjectRecord projectRecord, IPath sdkLocation, IProgressMonitor monitor, NewLiferayPluginProjectOp op) throws CoreException {
IDataModel newProjectDataModel = DataModelFactory.createDataModel(new PluginFacetProjectCreationDataModelProvider());
// we are importing so set flag to not create anything
newProjectDataModel.setBooleanProperty(IPluginProjectDataModelProperties.CREATE_PROJECT_OPERATION, false);
IDataModel nestedModel = newProjectDataModel.getNestedModel(IPluginProjectDataModelProperties.NESTED_PROJECT_DM);
// using sdk location
nestedModel.setBooleanProperty(IPluginProjectDataModelProperties.USE_DEFAULT_LOCATION, true);
newProjectDataModel.setBooleanProperty(IPluginProjectDataModelProperties.LIFERAY_USE_SDK_LOCATION, false);
newProjectDataModel.setBooleanProperty(IPluginProjectDataModelProperties.LIFERAY_USE_WORKSPACE_LOCATION, true);
setGenerateDD(newProjectDataModel, false);
IPath webXmlPath = projectRecord.getProjectLocation().append(ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/web.xml");
File webXmlFile = webXmlPath.toFile();
if (projectRecord.getProjectName().endsWith(ISDKConstants.PORTLET_PLUGIN_PROJECT_SUFFIX)) {
newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_PORTLET, true);
if (FileUtil.notExists(webXmlFile)) {
createDefaultWebXml(webXmlFile, projectRecord.getProjectName());
}
} else if (projectRecord.getProjectName().endsWith(ISDKConstants.HOOK_PLUGIN_PROJECT_SUFFIX)) {
newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_HOOK, true);
if (FileUtil.notExists(webXmlFile)) {
createDefaultWebXml(webXmlFile, projectRecord.getProjectName());
}
} else if (projectRecord.getProjectName().endsWith(ISDKConstants.EXT_PLUGIN_PROJECT_SUFFIX)) {
Path path = new Path(ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/ext-web/docroot/WEB-INF/web.xml");
webXmlPath = webXmlPath.removeLastSegments(3).append(path);
webXmlFile = webXmlPath.toFile();
newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_EXT, true);
if (FileUtil.notExists(webXmlFile)) {
createDefaultWebXml(webXmlPath.toFile(), projectRecord.getProjectName());
}
} else if (projectRecord.getProjectName().endsWith(ISDKConstants.LAYOUTTPL_PLUGIN_PROJECT_SUFFIX)) {
newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_LAYOUTTPL, true);
} else if (projectRecord.getProjectName().endsWith(ISDKConstants.THEME_PLUGIN_PROJECT_SUFFIX)) {
newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_THEME, true);
} else if (projectRecord.getProjectName().endsWith(ISDKConstants.WEB_PLUGIN_PROJECT_SUFFIX)) {
newProjectDataModel.setProperty(IPluginProjectDataModelProperties.PLUGIN_TYPE_WEB, true);
}
IFacetedProjectWorkingCopy fpwc = (IFacetedProjectWorkingCopy) newProjectDataModel.getProperty(IFacetProjectCreationDataModelProperties.FACETED_PROJECT_WORKING_COPY);
fpwc.setProjectName(projectRecord.getProjectName());
IPath projectLocation = projectRecord.getProjectLocation();
String projectDirName = projectLocation.lastSegment();
// for now always set a project location (so it can be used by facet install methods) may be unset later
fpwc.setProjectLocation(projectRecord.getProjectLocation());
String pluginType = null;
if (op != null) {
PluginType type = op.getPluginType().content();
pluginType = type.name();
if (PluginType.theme.name().equals(pluginType)) {
newProjectDataModel.setProperty(IPluginProjectDataModelProperties.THEME_PARENT, op.getThemeParent().content(true));
newProjectDataModel.setProperty(IPluginProjectDataModelProperties.THEME_TEMPLATE_FRAMEWORK, op.getThemeFramework().content(true));
}
} else {
pluginType = guessPluginType(fpwc);
}
SDKPluginFacetUtil.configureProjectAsSDKProject(fpwc, pluginType, sdkLocation.toPortableString(), projectRecord);
if ((op != null) && PluginType.portlet.name().equals(pluginType)) {
IPortletFramework portletFramework = op.getPortletFramework().content(true);
portletFramework.configureNewProject(newProjectDataModel, fpwc);
}
// if project is located in natural workspace location then don't need to set a project location
IPath rootLocation = CoreUtil.getWorkspaceRoot().getLocation();
if (rootLocation.append(projectDirName).equals(projectLocation)) {
fpwc.setProjectLocation(null);
}
fpwc.commitChanges(monitor);
CoreUtil.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
SDK sdk = SDKUtil.createSDKFromLocation(sdkLocation);
SDKUtil.openAsProject(sdk);
}
}, monitor);
return fpwc.getProject();
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy in project liferay-ide by liferay.
the class ThemePluginFacetInstall method removeUnneededClasspathEntries.
protected void removeUnneededClasspathEntries() {
IFacetedProjectWorkingCopy facetedProject = getFacetedProject();
IJavaProject javaProject = JavaCore.create(facetedProject.getProject());
try {
IClasspathEntry[] existingClasspath = javaProject.getRawClasspath();
List<IClasspathEntry> newClasspath = new ArrayList<>();
for (IClasspathEntry entry : existingClasspath) {
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
continue;
} else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
String path = entry.getPath().toPortableString();
if (path.contains("org.eclipse.jdt.launching.JRE_CONTAINER") || path.contains("org.eclipse.jst.j2ee.internal.web.container") || path.contains("org.eclipse.jst.j2ee.internal.module.container")) {
continue;
}
}
newClasspath.add(entry);
}
javaProject.setRawClasspath(newClasspath.toArray(new IClasspathEntry[0]), null);
IResource sourceFolder = javaProject.getProject().findMember(IPluginFacetConstants.PORTLET_PLUGIN_SDK_SOURCE_FOLDER);
if (sourceFolder.exists()) {
sourceFolder.delete(true, null);
}
} catch (Exception e) {
}
}
Aggregations