use of com.liferay.ide.sdk.core.SDKManager 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.SDKManager 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.SDKManager in project liferay-ide by liferay.
the class BinaryProjectImportOperation method execute.
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
Object selectedProjects = getDataModel().getProperty(ISDKProjectsImportDataModelProperties.SELECTED_PROJECTS);
BridgedRuntime bridgedRuntime = (BridgedRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
String sdkLocation = model.getStringProperty(ISDKProjectsImportDataModelProperties.SDK_LOCATION);
if (selectedProjects == null) {
return super.execute(monitor, info);
}
SDKManager sdkManager = SDKManager.getInstance();
SDK liferaySDK = sdkManager.getSDK(new Path(sdkLocation));
Object[] seleBinaryRecords = (Object[]) selectedProjects;
ProjectRecord[] projectRecords = new ProjectRecord[1];
BinaryProjectRecord pluginBinaryRecord = (BinaryProjectRecord) seleBinaryRecords[0];
try {
projectRecords[0] = ProjectImportUtil.createSDKPluginProject(bridgedRuntime, pluginBinaryRecord, liferaySDK);
} catch (Exception e) {
throw new ExecutionException("Error while importing Binary:" + pluginBinaryRecord.getBinaryName(), e);
}
getDataModel().setProperty(SELECTED_PROJECTS, projectRecords);
return super.execute(monitor, info);
}
Aggregations