Search in sources :

Example 1 with SDKManager

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;
}
Also used : Path(org.eclipse.core.runtime.Path) SDKManager(com.liferay.ide.sdk.core.SDKManager) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IOException(java.io.IOException) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) BridgedRuntime(org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime) SDK(com.liferay.ide.sdk.core.SDK)

Example 2 with SDKManager

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) {
    }
}
Also used : SDKManager(com.liferay.ide.sdk.core.SDKManager) FileNotFoundException(java.io.FileNotFoundException) SDK(com.liferay.ide.sdk.core.SDK) IMemento(org.eclipse.wst.server.core.internal.IMemento) FileInputStream(java.io.FileInputStream)

Example 3 with SDKManager

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);
}
Also used : Path(org.eclipse.core.runtime.Path) SDKManager(com.liferay.ide.sdk.core.SDKManager) BridgedRuntime(org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime) SDK(com.liferay.ide.sdk.core.SDK) ExecutionException(org.eclipse.core.commands.ExecutionException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

SDK (com.liferay.ide.sdk.core.SDK)3 SDKManager (com.liferay.ide.sdk.core.SDKManager)3 Path (org.eclipse.core.runtime.Path)2 BridgedRuntime (org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IRuntime (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)1 IMemento (org.eclipse.wst.server.core.internal.IMemento)1