use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class SDKImportProjectsOpMethods method execute.
public static final Status execute(SDKProjectsImportOp op, ProgressMonitor pm) {
IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
monitor.beginTask("Importing Liferay plugin projects...", 100);
Status retval = Status.createOkStatus();
Path projectLocation = op.getSdkLocation().content();
if ((projectLocation == null) || projectLocation.isEmpty()) {
return Status.createErrorStatus("Project cannot be empty");
}
Job job = new WorkspaceJob("Importing Liferay projects...") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
MultiStatusBuilder statusBuilder = new MultiStatusBuilder(ProjectCore.PLUGIN_ID);
ElementList<ProjectNamedItem> projectItems = op.getSelectedProjects();
for (NamedItem projectNamedItem : projectItems) {
try {
if (projectNamedItem instanceof ProjectNamedItem) {
String projectPath = ((ProjectNamedItem) projectNamedItem).getLocation().content();
String projectLocation = new Path(projectPath).toPortableString();
ProjectImportUtil.importProject(PathBridge.create(new Path(projectLocation)), new NullProgressMonitor(), null);
}
} catch (Exception e) {
statusBuilder.add(StatusBridge.create(Status.createErrorStatus(e.getMessage())));
}
}
return statusBuilder.retval();
}
};
job.schedule();
return retval;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class ArtifactVersionDefaultValueService method compute.
@Override
protected String compute() {
String data = null;
NewLiferayPluginProjectOp 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 = NewLiferayPluginProjectOpMethods.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 GroupIdDefaultValueService method compute.
@Override
protected String compute() {
String groupId = null;
NewLiferayPluginProjectOp 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();
groupId = NewLiferayPluginProjectOpMethods.getMavenParentPomGroupId(op, projectName, parentProjectOsPath);
}
if (groupId == null) {
groupId = _getDefaultMavenGroupId();
if (CoreUtil.isNullOrEmpty(groupId)) {
groupId = "com.example.plugins";
}
}
return groupId;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class JSFModuleProjectNameListener method updateLocation.
public static void updateLocation(NewLiferayJSFModuleProjectOp op) {
String currentProjectName = op.getProjectName().content(true);
Path newLocationBase = null;
if ((currentProjectName == null) || CoreUtil.isNullOrEmpty(currentProjectName.trim())) {
return;
}
boolean useDefaultLocation = op.getUseDefaultLocation().content(true);
if (useDefaultLocation) {
newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRoot().getLocation());
} else {
Path currentProjectLocation = op.getLocation().content(true);
boolean hasLiferayWorkspace = false;
if (currentProjectLocation != null) {
hasLiferayWorkspace = LiferayWorkspaceUtil.isValidWorkspaceLocation(currentProjectLocation.toOSString());
}
if (hasLiferayWorkspace) {
File workspaceDir = LiferayWorkspaceUtil.getWorkspaceDir(currentProjectLocation.toFile());
if (FileUtil.notExists(workspaceDir)) {
return;
}
String[] folders = LiferayWorkspaceUtil.getLiferayWorkspaceProjectWarsDirs(workspaceDir.getAbsolutePath());
if (folders != null) {
boolean appendWarFolder = false;
IPath projectLocation = PathBridge.create(currentProjectLocation);
for (String folder : folders) {
if (projectLocation.lastSegment().endsWith(folder)) {
appendWarFolder = true;
break;
}
}
if (appendWarFolder == true) {
newLocationBase = PathBridge.create(projectLocation);
} else {
newLocationBase = PathBridge.create(projectLocation.append(folders[0]));
}
} 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 SdkLocationValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
int countPossibleWorkspaceSDKProjects = SDKUtil.countPossibleWorkspaceSDKProjects();
if (countPossibleWorkspaceSDKProjects > 1) {
return StatusBridge.create(ProjectCore.createErrorStatus("This workspace has more than one SDK. "));
}
Value<Path> sdkLocationValue = _op().getSdkLocation();
Path sdkLocation = sdkLocationValue.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"));
}
return retval;
}
Aggregations