Search in sources :

Example 11 with SDK

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;
}
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 12 with SDK

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);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SDK(com.liferay.ide.sdk.core.SDK) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 13 with SDK

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) {
    }
}
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 14 with SDK

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) ParentSDKProjectImportOp(com.liferay.ide.project.core.model.ParentSDKProjectImportOp) SDK(com.liferay.ide.sdk.core.SDK)

Example 15 with SDK

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;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) SDKProjectsImportOp(com.liferay.ide.project.core.model.SDKProjectsImportOp) SDK(com.liferay.ide.sdk.core.SDK)

Aggregations

SDK (com.liferay.ide.sdk.core.SDK)75 IPath (org.eclipse.core.runtime.IPath)41 CoreException (org.eclipse.core.runtime.CoreException)29 IStatus (org.eclipse.core.runtime.IStatus)26 IProject (org.eclipse.core.resources.IProject)24 Path (org.eclipse.sapphire.modeling.Path)16 File (java.io.File)15 IFile (org.eclipse.core.resources.IFile)14 Path (org.eclipse.core.runtime.Path)14 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 Version (org.osgi.framework.Version)11 IOException (java.io.IOException)9 Status (org.eclipse.sapphire.modeling.Status)9 IFolder (org.eclipse.core.resources.IFolder)7 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 IWebProject (com.liferay.ide.core.IWebProject)4 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)4 PluginType (com.liferay.ide.project.core.model.PluginType)4