use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.
the class PortletFrameworkValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
NewLiferayPluginProjectOp op = _op();
ILiferayProjectProvider projectProvider = op.getProjectProvider().content();
IPortletFramework portletFramework = op.getPortletFramework().content();
if (!portletFramework.supports(projectProvider)) {
return Status.createErrorStatus("Selected portlet framework is not supported with " + projectProvider.getDisplayName());
}
try {
if ("ant".equals(projectProvider.getShortName())) {
SDK sdk = SDKUtil.getWorkspaceSDK();
if (sdk != null) {
Version requiredVersion = new Version(portletFramework.getRequiredSDKVersion());
Version sdkVersion = new Version(sdk.getVersion());
if (CoreUtil.compareVersions(requiredVersion, sdkVersion) > 0) {
retval = Status.createErrorStatus("Selected portlet framework requires SDK version at least " + requiredVersion);
}
}
}
} catch (CoreException ce) {
}
return retval;
}
use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.
the class PortletFrameworkValueImageService method provide.
@Override
public ImageData provide(String value) {
ImageData data = null;
IPortletFramework framework = ProjectCore.getPortletFramework(value);
if (framework != null) {
String name = framework.getShortName();
Result<ImageData> result = ImageData.readFromClassLoader(framework.getClass(), "images/" + name + ".png");
data = result.optional();
}
return data;
}
use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.
the class SDKLocationValidationService method compute.
@Override
protected Status compute() {
NewLiferayPluginProjectOp op = _op();
NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content();
if (!provider.getShortName().equals("ant")) {
return Status.createOkStatus();
}
int countPossibleWorkspaceSDKProjects = SDKUtil.countPossibleWorkspaceSDKProjects();
if (countPossibleWorkspaceSDKProjects > 1) {
return StatusBridge.create(ProjectCore.createErrorStatus("This workspace has more than one SDK."));
}
Path sdkLocation = op.getSdkLocation().content(true);
if ((sdkLocation == null) || sdkLocation.isEmpty()) {
return StatusBridge.create(ProjectCore.createErrorStatus("This sdk location is empty."));
}
SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
if (sdk != null) {
IStatus status = sdk.validate(true);
if (!status.isOK()) {
return StatusBridge.create(status);
}
} else {
return StatusBridge.create(ProjectCore.createErrorStatus("This sdk location is not correct."));
}
Path projectLocation = op.getLocation().content();
String projectName = op.getProjectName().content();
IPath projectPath = PathBridge.create(projectLocation);
if (FileUtil.exists(projectPath)) {
return StatusBridge.create(ProjectCore.createErrorStatus("Project(" + projectName + ") is existed in sdk folder, please set new project name."));
}
PluginType pluginType = op.getPluginType().content();
if (pluginType.equals(PluginType.web) && !supportsTypePlugin(op, "web")) {
StringBuilder sb = new StringBuilder();
sb.append("The selected Plugins SDK does not support creating new web type plugins. ");
sb.append("");
sb.append("Please configure version 7.0 or greater.");
return Status.createErrorStatus(sb.toString());
} else if (pluginType.equals(PluginType.theme) && !supportsTypePlugin(op, "theme")) {
StringBuilder sb = new StringBuilder();
sb.append("The selected Plugins SDK does not support creating theme type plugins. ");
sb.append("");
sb.append("Please configure version 6.2 or less or using gulp way.");
return Status.createErrorStatus(sb.toString());
} else if (pluginType.equals(PluginType.portlet)) {
IPortletFramework portletFramework = op.getPortletFramework().content();
Version requiredVersion = new Version(portletFramework.getRequiredSDKVersion());
Version sdkVersion = new Version(sdk.getVersion());
if (CoreUtil.compareVersions(requiredVersion, sdkVersion) > 0) {
StringBuilder sb = new StringBuilder();
sb.append("Selected portlet framework requires SDK version at least ");
sb.append("");
sb.append(requiredVersion);
return Status.createErrorStatus(sb.toString());
}
} else if (pluginType.equals(PluginType.ext) && !supportsTypePlugin(op, "ext")) {
StringBuilder sb = new StringBuilder();
sb.append("The selected Plugins SDK does not support creating ext type plugins. ");
sb.append("");
sb.append("Please try to confirm whether sdk has ext folder.");
return Status.createErrorStatus(sb.toString());
}
return Status.createOkStatus();
}
use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.
the class NewLiferayPluginProjectOpMethods method getFrameworkName.
public static String getFrameworkName(NewLiferayPluginProjectOp op) {
IPortletFramework portletFramework = op.getPortletFramework().content();
String frameworkName = portletFramework.getShortName();
if (portletFramework.isRequiresAdvanced()) {
IPortletFramework framework = op.getPortletFrameworkAdvanced().content();
frameworkName = framework.getShortName();
}
return frameworkName;
}
use of com.liferay.ide.project.core.IPortletFramework in project liferay-ide by liferay.
the class ProjectImportUtil method createSDKPluginProject.
/**
* @param dataModel
* @param pluginBinaryRecord
* @param liferaySDK
* @return
* @throws IOException
*/
public static ProjectRecord createSDKPluginProject(BridgedRuntime bridgedRuntime, BinaryProjectRecord pluginBinaryRecord, SDK liferaySDK) throws IOException {
ProjectRecord projectRecord = null;
if (!pluginBinaryRecord.isConflicts()) {
String displayName = pluginBinaryRecord.getDisplayName();
File binaryFile = pluginBinaryRecord.getBinaryFile();
IPath projectPath = null;
IPath sdkPluginProjectFolder = liferaySDK.getLocation();
// IDE-110 IDE-648
String webappRootFolder = null;
IProgressMonitor npm = new NullProgressMonitor();
ArrayList<String> arguments = new ArrayList<>();
arguments.add(displayName);
arguments.add(displayName);
if (pluginBinaryRecord.isHook()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.HOOK_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "hook", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.HOOK_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isPortlet()) {
IPortletFramework[] portletFrameworks = ProjectCore.getPortletFrameworks();
String portletFrameworkName = null;
for (int i = 0; i < portletFrameworks.length; i++) {
IPortletFramework portletFramework = portletFrameworks[i];
if (portletFramework.isDefault() && !portletFramework.isAdvanced()) {
portletFrameworkName = portletFramework.getShortName();
break;
}
}
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.PORTLET_PLUGIN_PROJECT_FOLDER);
arguments.add(portletFrameworkName);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "portlet", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.PORTLET_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isTheme()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.THEME_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "theme", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.THEME_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isLayoutTpl()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.LAYOUTTPL_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "layouttpl", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.LAYOUTTPL_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isExt()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.EXT_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "ext", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.EXT_PLUGIN_SDK_CONFIG_FOLDER;
} else if (pluginBinaryRecord.isWeb()) {
sdkPluginProjectFolder = sdkPluginProjectFolder.append(ISDKConstants.WEB_PLUGIN_PROJECT_FOLDER);
try {
projectPath = liferaySDK.createNewProject(displayName, arguments, "web", sdkPluginProjectFolder.toOSString(), npm);
} catch (CoreException ce) {
ProjectCore.logError(ce);
}
webappRootFolder = IPluginFacetConstants.WEB_PLUGIN_SDK_CONFIG_FOLDER;
}
// Extract the contents
File webappRoot = new File(projectPath.toFile(), webappRootFolder);
ZipUtil.unzip(binaryFile, webappRoot);
// IDE-569 check to see if the project already has .project
File projectFile = new File(projectPath.toFile(), ".project");
if (FileUtil.exists(projectFile)) {
projectRecord = new ProjectRecord(projectFile);
} else {
projectRecord = new ProjectRecord(projectPath.toFile());
}
}
return projectRecord;
}
Aggregations