Search in sources :

Example 1 with BridgedRuntime

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

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

the class SDKProjectsImportDataModelProvider method validate.

@Override
public IStatus validate(String name) {
    if (SDK_LOCATION.equals(name)) {
        String sdkLocation = getStringProperty(SDK_LOCATION);
        if (SDKUtil.isValidSDKLocation(sdkLocation)) {
            return Status.OK_STATUS;
        } else {
            return ProjectCore.createErrorStatus(Msgs.invalidPluginSDKLocation);
        }
    } else if (SDK_VERSION.equals(name)) {
        String sdkVersion = getStringProperty(SDK_VERSION);
        if (SDKUtil.isValidSDKVersion(sdkVersion, SDKManager.getLeastValidVersion())) {
            Object runtime = getProperty(FACET_RUNTIME);
            if (_compareSDKRuntimeVersion(sdkVersion, runtime)) {
                return Status.OK_STATUS;
            } else {
                return ProjectCore.createWarningStatus(Msgs.versionUnequal);
            }
        } else {
            return ProjectCore.createErrorStatus(Msgs.invalidPluginSDKVersion + SDKManager.getLeastValidVersion());
        }
    } else if (SELECTED_PROJECTS.equals(name)) {
        Object val = getProperty(SELECTED_PROJECTS);
        if (val instanceof Object[]) {
            Object[] selectedProjects = (Object[]) val;
            if (selectedProjects.length >= 1) {
                for (Object project : selectedProjects) {
                    if (project instanceof BinaryProjectRecord) {
                        BinaryProjectRecord binaryProject = (BinaryProjectRecord) project;
                        Version sdkVersion = new Version(getStringProperty(SDK_VERSION));
                        if (binaryProject.isWeb() && (CoreUtil.compareVersions(sdkVersion, ILiferayConstants.V700) < 0)) {
                            return ProjectCore.createErrorStatus(Msgs.unableSupportWebPluginType);
                        }
                    }
                }
                return Status.OK_STATUS;
            }
        }
        return createSelectedProjectsErrorStatus();
    } else if (FACET_RUNTIME.equals(name)) {
        Object runtime = getProperty(FACET_RUNTIME);
        if (!(runtime instanceof BridgedRuntime)) {
            return ProjectCore.createErrorStatus(Msgs.selectValidLiferayRuntime);
        } else {
            String sdkVersion = getStringProperty(SDK_VERSION);
            if (_compareSDKRuntimeVersion(sdkVersion, runtime)) {
                return Status.OK_STATUS;
            } else {
                return ProjectCore.createWarningStatus(Msgs.versionUnequal);
            }
        }
    } else if (FACET_PROJECT_NAME.equals(name)) {
        return Status.OK_STATUS;
    }
    return super.validate(name);
}
Also used : Version(org.osgi.framework.Version) BridgedRuntime(org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime)

Example 3 with BridgedRuntime

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

the class LiferayProjectImportDataModelProvider method validate.

@Override
public IStatus validate(String name) {
    if (PROJECT_LOCATION.equals(name)) {
        String projectLocation = getStringProperty(PROJECT_LOCATION);
        ProjectRecord record = ProjectUtil.getProjectRecordForDir(projectLocation);
        if (record != null) {
            String projectName = record.getProjectName();
            IProject existingProject = CoreUtil.getWorkspaceRoot().getProject(projectName);
            if (FileUtil.exists(existingProject)) {
                return ProjectCore.createErrorStatus(Msgs.projectNameExists);
            }
            File projectDir = record.getProjectLocation().toFile();
            // go up to the SDK level
            SDK sdk = SDKUtil.getSDKFromProjectDir(projectDir);
            if (sdk != null) {
                return Status.OK_STATUS;
            } else {
                return ProjectCore.createErrorStatus(Msgs.projectNotLocated);
            }
        }
        return ProjectCore.createErrorStatus(Msgs.invalidProjectLocation);
    } else if (SDK_VERSION.equals(name)) {
        IStatus locationStatus = validate(PROJECT_LOCATION);
        if (locationStatus.isOK()) {
            Version version = new Version(getStringProperty(SDK_VERSION));
            if (CoreUtil.compareVersions(version, SDKManager.getLeastValidVersion()) >= 0) {
                return Status.OK_STATUS;
            } else {
                return ProjectCore.createErrorStatus(Msgs.invalidPluginSDKVersion + SDKManager.getLeastValidVersion());
            }
        } else {
            return locationStatus;
        }
    } else if (PLUGIN_TYPE.equals(name)) {
        if (ProjectUtil.isLiferayPluginType(getStringProperty(PLUGIN_TYPE))) {
            return Status.OK_STATUS;
        } else {
            return ProjectCore.createErrorStatus(Msgs.invalidLiferayPluginType);
        }
    } else if (FACET_RUNTIME.equals(name)) {
        Object runtime = getProperty(FACET_RUNTIME);
        if (!(runtime instanceof BridgedRuntime)) {
            return ProjectCore.createErrorStatus(Msgs.validLiferayRuntimeSelected);
        } else {
            return Status.OK_STATUS;
        }
    } else if (FACET_PROJECT_NAME.equals(name)) {
        return Status.OK_STATUS;
    }
    return super.validate(name);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Version(org.osgi.framework.Version) BridgedRuntime(org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime) SDK(com.liferay.ide.sdk.core.SDK) File(java.io.File) IProject(org.eclipse.core.resources.IProject)

Example 4 with BridgedRuntime

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

the class PluginsSDKProjectRuntimeValidator method validate.

public void validate(IFacetedProject fproj) throws CoreException {
    IProject project = fproj.getProject();
    if (!ProjectUtil.isLiferayFacetedProject(project)) {
        return;
    }
    _clearMarkers(project);
    if (SDKUtil.isSDKProject(fproj.getProject())) {
        IJavaProject javaProject = JavaCore.create(project);
        for (IClasspathEntry entry : javaProject.getRawClasspath()) {
            String segment = entry.getPath().segment(0);
            if ((entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) && segment.equals(SDKClasspathContainer.ID)) {
                return;
            }
        }
        if (fproj.getPrimaryRuntime() == null) {
            _setMarker(project, ProjectCore.LIFERAY_PROJECT_MARKER_TYPE, IMarker.SEVERITY_ERROR, MSG_PRIMARY_RUNTIME_NOT_SET, LOCATION_TARGETED_RUNTIMES, ID_PRIMARY_RUNTIME_NOT_SET);
        } else {
            if (!ServerUtil.isLiferayRuntime((BridgedRuntime) fproj.getPrimaryRuntime())) {
                _setMarker(project, ProjectCore.LIFERAY_PROJECT_MARKER_TYPE, IMarker.SEVERITY_ERROR, MSG_PRIMARY_RUNTIME_NOT_LIFERAY_RUNTIME, LOCATION_TARGETED_RUNTIMES, ID_PRIMARY_RUNTIME_NOT_LIFERAY_RUNTIME);
            }
        }
    } else if (!ProjectUtil.isMavenProject(project)) {
        _setMarker(project, ProjectCore.LIFERAY_PROJECT_MARKER_TYPE, IMarker.SEVERITY_ERROR, Msgs.pluginSDKNotSet, LOCATION_TARGETED_SDK, ID_PLUGINS_SDK_NOT_SET);
    }
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) BridgedRuntime(org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime) IProject(org.eclipse.core.resources.IProject)

Example 5 with BridgedRuntime

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

the class PluginFacetProjectCreationDataModelProvider method init.

@Override
public void init() {
    super.init();
    getDataModel().setProperty(LIFERAY_USE_SDK_LOCATION, true);
    DataModelPropertyDescriptor[] validDescriptors = getDataModel().getValidPropertyDescriptors(FACET_RUNTIME);
    for (DataModelPropertyDescriptor desc : validDescriptors) {
        Object runtime = desc.getPropertyValue();
        if (runtime instanceof BridgedRuntime && ServerUtil.isLiferayRuntime((BridgedRuntime) runtime)) {
            getDataModel().setProperty(FACET_RUNTIME, runtime);
            break;
        }
    }
    ProjectCore.getPortletFrameworks();
}
Also used : BridgedRuntime(org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime) DataModelPropertyDescriptor(org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor)

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