use of org.eclipse.sapphire.modeling.Path 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 org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class NewLiferayPluginProjectOpMethods method execute.
public static final Status execute(NewLiferayPluginProjectOp op, ProgressMonitor pm) {
IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
monitor.beginTask("Creating Liferay plugin project (this process may take several minutes)", 100);
Status retval = null;
try {
NewLiferayProjectProvider<NewLiferayPluginProjectOp> projectProvider = op.getProjectProvider().content(true);
// IDE-1306 If the user types too quickly all the model changes may not have propagated
Path projectLocation = op.getLocation().content();
updateLocation(op, projectLocation);
IStatus status = projectProvider.createNewProject(op, monitor);
if (status.isOK()) {
_updateProjectPrefs(op);
_removeSampleCodeAndFiles(op);
op.setImportProjectStatus(true);
}
retval = StatusBridge.create(status);
} catch (Exception e) {
String msg = "Error creating Liferay plugin project.";
ProjectCore.logError(msg, e);
return Status.createErrorStatus(msg + " Please see Eclipse error log for more details.", e);
}
return retval;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class FragmentProjectNameListener method updateLocation.
public static void updateLocation(NewModuleFragmentOp op) {
String currentProjectName = op.getProjectName().content(true);
if ((currentProjectName == null) || CoreUtil.isNullOrEmpty(currentProjectName.trim())) {
return;
}
boolean useDefaultLocation = op.getUseDefaultLocation().content(true);
if (useDefaultLocation) {
Path newLocationBase = null;
boolean hasLiferayWorkspace = false;
boolean hasGradleWorkspace = false;
boolean hasMavenWorkspace = false;
try {
hasLiferayWorkspace = LiferayWorkspaceUtil.hasWorkspace();
hasGradleWorkspace = LiferayWorkspaceUtil.hasGradleWorkspace();
hasMavenWorkspace = LiferayWorkspaceUtil.hasMavenWorkspace();
} catch (Exception e) {
ProjectCore.logError("Failed to check LiferayWorkspace project.");
}
if (!hasLiferayWorkspace) {
newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRoot().getLocation());
} else {
boolean gradleModule = false;
boolean mavenModule = false;
ILiferayProjectProvider iProvider = op.getProjectProvider().content();
if (iProvider != null) {
String shortName = iProvider.getShortName();
if (!CoreUtil.empty(shortName) && shortName.startsWith("gradle")) {
gradleModule = true;
} else {
mavenModule = true;
}
}
if ((gradleModule && hasGradleWorkspace) || (mavenModule && hasMavenWorkspace)) {
IProject liferayWorkspaceProject = LiferayWorkspaceUtil.getWorkspaceProject();
if (FileUtil.exists(liferayWorkspaceProject)) {
String folder = LiferayWorkspaceUtil.getModulesDir(liferayWorkspaceProject);
if (folder != null) {
IPath appendPath = liferayWorkspaceProject.getLocation().append(folder);
newLocationBase = PathBridge.create(appendPath);
}
}
} else {
newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRoot().getLocation());
}
}
if (newLocationBase != null) {
op.setLocation(newLocationBase);
}
}
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class ModuleProjectArtifactVersionDefaultValueService method compute.
@Override
protected String compute() {
String data = null;
NewLiferayModuleProjectOp op = _op();
Path location = op.getLocation().content();
if (location != null) {
String parentProjectLocation = location.toOSString();
IPath parentProjectOsPath = org.eclipse.core.runtime.Path.fromOSString(parentProjectLocation);
String projectName = op.getProjectName().content();
data = NewLiferayModuleProjectOpMethods.getMavenParentPomVersion(op, projectName, parentProjectOsPath);
}
if (data == null) {
data = "1.0.0-SNAPSHOT";
}
return data;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class ModuleProjectGroupIdDefaultValueService method compute.
@Override
protected String compute() {
NewLiferayModuleProjectOp op = _op();
String groupId = null;
Path location = op.getLocation().content();
if (location != null) {
String parentProjectLocation = location.toOSString();
IPath parentProjectOsPath = org.eclipse.core.runtime.Path.fromOSString(parentProjectLocation);
String projectName = op.getProjectName().content();
groupId = NewLiferayModuleProjectOpMethods.getMavenParentPomGroupId(op, projectName, parentProjectOsPath);
}
if (groupId == null) {
groupId = _getDefaultMavenGroupId();
if (CoreUtil.isNullOrEmpty(groupId)) {
groupId = op.getPackageName().content();
}
}
return groupId;
}
Aggregations