use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.
the class PluginFacetProjectCreationDataModelProvider method setupPortletFramework.
protected void setupPortletFramework(IPortletFramework portletFramework) {
IPortletFramework[] portletFrameworks = ProjectCore.getPortletFrameworks();
for (IPortletFramework framework : portletFrameworks) {
if (!framework.equals(portletFramework)) {
IProjectFacet[] facets = framework.getFacets();
for (IProjectFacet facet : facets) {
removeFacet(getFacetedProjectWorkingCopy(), facet);
}
}
}
portletFramework.configureNewProject(getDataModel(), getFacetedProjectWorkingCopy());
}
use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.
the class ArchetypeDefaultValueService method compute.
@Override
protected String compute() {
NewLiferayPluginProjectOp op = _op();
PluginType pluginType = op.getPluginType().content();
String frameworkType = null;
if (pluginType.equals(PluginType.portlet)) {
IPortletFramework portletFramework = op.getPortletFramework().content();
if (portletFramework.isRequiresAdvanced()) {
IPortletFramework framework = op.getPortletFrameworkAdvanced().content();
frameworkType = framework.getShortName();
} else {
frameworkType = portletFramework.getShortName();
}
} else {
frameworkType = pluginType.name();
}
frameworkType = frameworkType.replaceAll("_", "-");
NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
return provider.getData("archetypeGAV", String.class, frameworkType).get(0);
}
use of com.liferay.ide.project.core.IPortletFramework 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 com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.
the class PluginFacetProjectCreationDataModelProvider method propertySet.
@Override
public boolean propertySet(final String propertyName, final Object propertyValue) {
String portletFrameworkId = getStringProperty(PORTLET_FRAMEWORK_ID);
IPortletFramework portletFramework = ProjectCore.getPortletFramework(portletFrameworkId);
if (FACET_PROJECT_NAME.equals(propertyName) || LIFERAY_SDK_NAME.equals(propertyName) || LIFERAY_USE_WORKSPACE_LOCATION.equals(propertyName) || LIFERAY_USE_CUSTOM_LOCATION.equals(propertyName)) {
updateProjectLocation();
} else if (DISPLAY_NAME.equals(propertyName)) {
String displayName = ProjectUtil.removePluginSuffix(propertyValue.toString());
return super.propertySet(DISPLAY_NAME, displayName);
} else if (PORTLET_FRAMEWORK_ID.equals(propertyName) && (portletFramework != null)) {
setupPortletFramework(portletFramework);
}
return super.propertySet(propertyName, propertyValue);
}
use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.
the class PortletFrameworkPossibleValuesService method initPossibleValuesService.
@Override
protected void initPossibleValuesService() {
super.initPossibleValuesService();
_possibleValues = new ArrayList<>();
for (IPortletFramework portletFramework : ProjectCore.getPortletFrameworks()) {
if (shouldAdd(portletFramework)) {
_possibleValues.add(portletFramework.getShortName());
}
}
}
Aggregations