use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class BinaryProjectsImportOperation method execute.
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
String sdkLocation = model.getStringProperty(ISDKProjectsImportDataModelProperties.SDK_LOCATION);
IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
Object[] projects = (Object[]) model.getProperty(ISDKProjectsImportDataModelProperties.SELECTED_PROJECTS);
BridgedRuntime bridgedRuntime = (BridgedRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
WorkspaceJob job = new WorkspaceJob(Msgs.importingBinaryProjectPlugins) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
if (projects == null) {
return Status.OK_STATUS;
}
SDKManager sdkManager = SDKManager.getInstance();
SDK liferaySDK = sdkManager.getSDK(new Path(sdkLocation));
Object[] seleBinaryRecords = (Object[]) projects;
monitor.beginTask(Msgs.creatingSDKProjects, seleBinaryRecords.length);
ProjectRecord[] projectRecords = new ProjectRecord[seleBinaryRecords.length];
for (int i = 0; i < seleBinaryRecords.length; i++) {
BinaryProjectRecord pluginBinaryRecord = (BinaryProjectRecord) seleBinaryRecords[i];
try {
monitor.subTask(Msgs.creatingPlugin + pluginBinaryRecord.getLiferayPluginName());
projectRecords[i] = ProjectImportUtil.createSDKPluginProject(bridgedRuntime, pluginBinaryRecord, liferaySDK);
monitor.worked(1);
} catch (IOException ioe) {
throw new CoreException(ProjectCore.createErrorStatus("Error creating project.", ioe));
}
}
monitor.done();
ProjectImportUtil.createWorkspaceProjects(projectRecords, runtime, sdkLocation, monitor);
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return Status.OK_STATUS;
}
use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class CleanAppServerAction method run.
public void run(IAction action) {
try {
if (!(fSelection instanceof IStructuredSelection)) {
return;
}
Object elem = ((IStructuredSelection) fSelection).toArray()[0];
if (!(elem instanceof IProject)) {
return;
}
IProject project = (IProject) elem;
SDK sdk = SDKUtil.getSDK(project);
if (sdk == null) {
return;
}
IStatus status = sdk.validate();
if (!status.isOK()) {
MessageDialog.openError(null, Msgs.cleanAppServer, status.getChildren()[0].getMessage());
return;
}
Map<String, Object> sdkProperties = sdk.getBuildProperties();
String bundleZipLocation = (String) sdkProperties.get("app.server.zip.name");
status = validate(project, bundleZipLocation);
if (status.isOK()) {
cleanAppServer(project, bundleZipLocation);
} else {
MessageDialog.openError(null, Msgs.cleanAppServer, status.getMessage());
return;
}
} catch (Exception ex) {
ProjectUI.logError(ex);
}
}
use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class ServerStartup method importGlobalSDKs.
private void importGlobalSDKs(File sdksFile) {
try {
final SDKManager manager = SDKManager.getInstance();
final IMemento sdksMemento = XMLMemento.loadMemento(new FileInputStream(sdksFile));
if (sdksMemento != null) {
final IMemento[] sdks = sdksMemento.getChildren("sdk");
if (ListUtil.isNotEmpty(sdks)) {
for (IMemento sdkMemento : sdks) {
final SDK newSDK = createSDKfromMemento(sdkMemento);
if (newSDK != null) {
final SDK existingSDK = manager.getSDK(newSDK.getName());
if (existingSDK == null) {
manager.addSDK(newSDK);
}
}
}
}
}
} catch (FileNotFoundException e) {
}
}
use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class SDKImportValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
ParentSDKProjectImportOp op = _op();
try {
SDK sdk = SDKUtil.getWorkspaceSDK();
if (sdk != null) {
return StatusBridge.create(ProjectCore.createErrorStatus(" This workspace already has another sdk."));
}
Path currentProjectLocation = op.getSdkLocation().content(true);
if ((currentProjectLocation != null) && !currentProjectLocation.isEmpty()) {
sdk = SDKUtil.createSDKFromLocation(PathBridge.create(currentProjectLocation));
if (sdk != null) {
IStatus sdkStatus = sdk.validate(true);
if (!sdkStatus.isOK()) {
retval = StatusBridge.create(ProjectCore.createWarningStatus(sdkStatus.getChildren()[0].getMessage()));
}
} else {
retval = StatusBridge.create(ProjectCore.createErrorStatus("This parent sdk project path is invalid."));
}
}
} catch (CoreException ce) {
}
return retval;
}
use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class SDKImportVersionDerivedValueService method compute.
@Override
protected String compute() {
String retVal = null;
SDKProjectsImportOp op = _op();
Value<Path> sdkLocation = op.getSdkLocation();
if ((sdkLocation != null) && (sdkLocation.content() != null) && !sdkLocation.content().isEmpty()) {
Path sdkPath = sdkLocation.content();
IStatus status = ProjectImportUtil.validateSDKPath(sdkLocation.content().toPortableString());
if (status.isOK()) {
SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkPath));
retVal = sdk.getVersion();
}
}
return retVal;
}
Aggregations