use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class NewLiferayPluginProjectOpMethods method getPossibleProfileIds.
public static Set<String> getPossibleProfileIds(NewLiferayPluginProjectOp op, boolean includeNewProfiles) {
String activeProfilesValue = op.getActiveProfilesValue().content();
Path currentLocation = op.getLocation().content();
File param = currentLocation != null ? currentLocation.toFile() : null;
NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content(true);
List<String> systemProfileIds = provider.getData("profileIds", String.class, param);
ElementList<NewLiferayProfile> newLiferayProfiles = op.getNewLiferayProfiles();
Set<String> possibleProfileIds = new HashSet<>();
if (!CoreUtil.isNullOrEmpty(activeProfilesValue)) {
String[] vals = activeProfilesValue.split(",");
if (ListUtil.isNotEmpty(vals)) {
for (String val : vals) {
if (!possibleProfileIds.contains(val) && !val.contains(StringPool.SPACE)) {
possibleProfileIds.add(val);
}
}
}
}
if (ListUtil.isNotEmpty(systemProfileIds)) {
for (Object systemProfileId : systemProfileIds) {
if (systemProfileId != null) {
String val = systemProfileId.toString();
if (!possibleProfileIds.contains(val) && !val.contains(StringPool.SPACE)) {
possibleProfileIds.add(val);
}
}
}
}
if (includeNewProfiles) {
for (NewLiferayProfile newLiferayProfile : newLiferayProfiles) {
String newId = newLiferayProfile.getId().content();
if (!CoreUtil.isNullOrEmpty(newId) && !possibleProfileIds.contains(newId) && !newId.contains(StringPool.SPACE)) {
possibleProfileIds.add(newId);
}
}
}
return possibleProfileIds;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class NewLiferayPluginProjectOpMethods method updateLocation.
public static void updateLocation(NewLiferayPluginProjectOp op, Path baseLocation) {
String projectName = getProjectNameWithSuffix(op);
if (baseLocation == null) {
return;
}
String lastSegment = baseLocation.lastSegment();
if ((baseLocation != null) && (baseLocation.segmentCount() > 0)) {
if (lastSegment.equals(projectName)) {
return;
}
}
Path newLocation = baseLocation.append(projectName);
op.setLocation(newLocation);
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class NewLiferayPluginProjectOpMethods method supportsTypePlugin.
public static boolean supportsTypePlugin(NewLiferayPluginProjectOp op, String type) {
boolean retval = false;
NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content(true);
if (provider.getShortName().equals("maven") && (type.equals("web") || type.equals("theme"))) {
return true;
} else {
SDK sdk = null;
try {
sdk = SDKUtil.getWorkspaceSDK();
} catch (CoreException ce) {
}
if (sdk == null) {
Path sdkLocation = op.getSdkLocation().content();
if (sdkLocation != null) {
sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
}
}
if (sdk == null) {
return true;
}
Version version = new Version(sdk.getVersion());
boolean greaterThan700 = false;
if (CoreUtil.compareVersions(version, ILiferayConstants.V700) >= 0) {
greaterThan700 = true;
}
if ((greaterThan700 && "web".equals(type)) || ("theme".equals(type))) {
retval = true;
}
if (greaterThan700 && "ext".equals(type)) {
IPath extFolder = sdk.getLocation().append("ext");
File buildXml = extFolder.append("build.xml").toFile();
if (FileUtil.exists(extFolder) && FileUtil.exists(buildXml)) {
return true;
}
} else if (!greaterThan700 && "ext".equals(type)) {
return true;
}
}
return retval;
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class NewLiferayPluginProjectOpMethods method updateLocation.
public static void updateLocation(NewLiferayPluginProjectOp op) {
String currentProjectName = op.getProjectName().content();
if (currentProjectName == null) {
return;
}
boolean useDefaultLocation = op.getUseDefaultLocation().content(true);
NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content(true);
String providerShortName = provider.getShortName();
if (useDefaultLocation) {
Path newLocationBase = null;
if (providerShortName.equals("ant")) {
SDK sdk = null;
try {
sdk = SDKUtil.getWorkspaceSDK();
if (sdk != null) {
IStatus sdkStatus = sdk.validate();
if (!sdkStatus.isOK()) {
sdk = null;
}
}
} catch (CoreException ce) {
}
if (sdk == null) {
if (op.getSdkLocation() != null) {
Path sdkPath = op.getSdkLocation().content();
if (sdkPath != null) {
IPath sdkLocation = PathBridge.create(sdkPath);
sdk = SDKUtil.createSDKFromLocation(sdkLocation);
}
}
}
if (sdk != null) {
Path sdkLocation = PathBridge.create(sdk.getLocation());
switch(op.getPluginType().content(true)) {
case portlet:
case servicebuilder:
newLocationBase = sdkLocation.append("portlets");
break;
case ext:
newLocationBase = sdkLocation.append("ext");
break;
case hook:
newLocationBase = sdkLocation.append("hooks");
break;
case layouttpl:
newLocationBase = sdkLocation.append("layouttpl");
break;
case theme:
newLocationBase = sdkLocation.append("themes");
break;
case web:
newLocationBase = sdkLocation.append("webs");
break;
}
} else {
return;
}
} else {
newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRoot().getLocation());
}
if (newLocationBase != null) {
updateLocation(op, newLocationBase);
}
}
}
use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.
the class ParentSDKProjectImportOpMethods method execute.
public static final Status execute(ParentSDKProjectImportOp op, ProgressMonitor pm) {
IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
monitor.beginTask("Importing Liferay parent sdk project...", 100);
Status retval = Status.createOkStatus();
Path sdkLocation = op.getSdkLocation().content();
if ((sdkLocation == null) || sdkLocation.isEmpty()) {
return Status.createErrorStatus("SDK folder cannot be empty");
}
SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
try {
SDKUtil.openAsProject(sdk, monitor);
} catch (CoreException ce) {
retval = StatusBridge.create(ProjectCore.createErrorStatus(ce));
}
return retval;
}
Aggregations