Search in sources :

Example 6 with BridgedRuntime

use of org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime 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)

Example 7 with BridgedRuntime

use of org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime in project liferay-ide by liferay.

the class SDKProjectsImportDataModelProvider method _compareSDKRuntimeVersion.

private boolean _compareSDKRuntimeVersion(String sdkVersion, Object runtime) {
    if ((sdkVersion == null) && !(runtime instanceof BridgedRuntime)) {
        return false;
    }
    try {
        Version liferaySdkVersion = new Version(sdkVersion);
        String runtimeVersion = ServerUtil.getLiferayRuntime((BridgedRuntime) runtime).getPortalVersion();
        Version liferayRuntimeVersion = new Version(runtimeVersion);
        if ((liferaySdkVersion.getMajor() == liferayRuntimeVersion.getMajor()) && (liferaySdkVersion.getMinor() == liferayRuntimeVersion.getMinor())) {
            return true;
        }
        return false;
    } catch (Exception e) {
        LiferayCore.logError("invalid sdk or runtime version ", e);
        return false;
    }
}
Also used : Version(org.osgi.framework.Version) BridgedRuntime(org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime)

Aggregations

BridgedRuntime (org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime)7 SDK (com.liferay.ide.sdk.core.SDK)3 Version (org.osgi.framework.Version)3 SDKManager (com.liferay.ide.sdk.core.SDKManager)2 IProject (org.eclipse.core.resources.IProject)2 Path (org.eclipse.core.runtime.Path)2 File (java.io.File)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 IStatus (org.eclipse.core.runtime.IStatus)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 DataModelPropertyDescriptor (org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor)1 IRuntime (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)1