Search in sources :

Example 1 with IRuntime

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

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

the class SDKProjectConvertOperation method convertExistingProject.

protected IProject convertExistingProject(ProjectRecord record, IProgressMonitor monitor) throws CoreException {
    String projectName = record.getProjectName();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IProject project = workspace.getRoot().getProject(projectName);
    if (record.description == null) {
        // error case
        record.description = workspace.newProjectDescription(projectName);
        IPath locationPath = new Path(record.projectSystemFile.getAbsolutePath());
        if (Platform.getLocation().isPrefixOf(locationPath)) {
            record.description.setLocation(null);
        } else {
            record.description.setLocation(locationPath);
        }
    } else {
        record.description.setName(projectName);
    }
    monitor.beginTask(Msgs.importingProject, 100);
    project.open(IResource.FORCE, CoreUtil.newSubMonitor(monitor, 70));
    IFacetedProject fProject = ProjectFacetsManager.create(project, true, monitor);
    FacetedProjectWorkingCopy fpwc = new FacetedProjectWorkingCopy(fProject);
    String sdkLocation = getDataModel().getStringProperty(SDK_LOCATION);
    IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
    String pluginType = ProjectUtil.guessPluginType(fpwc);
    SDKPluginFacetUtil.configureProjectAsRuntimeProject(fpwc, runtime, pluginType, sdkLocation, record);
    fpwc.commitChanges(monitor);
    monitor.done();
    return project;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IPath(org.eclipse.core.runtime.IPath) IWorkspace(org.eclipse.core.resources.IWorkspace) FacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy) IProject(org.eclipse.core.resources.IProject) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 3 with IRuntime

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

the class SDKProjectsImportOperation 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);
    WorkspaceJob workspaceJob = new WorkspaceJob(Msgs.creatingSDKProjects) {

        @Override
        public IStatus runInWorkspace(IProgressMonitor monitor) {
            try {
                ProjectImportUtil.createWorkspaceProjects(projects, runtime, sdkLocation, monitor);
            } catch (Exception ex) {
                return ProjectCore.createErrorStatus(ex);
            }
            return Status.OK_STATUS;
        }
    };
    workspaceJob.setUser(true);
    workspaceJob.schedule();
    return Status.OK_STATUS;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) ExecutionException(org.eclipse.core.commands.ExecutionException) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 4 with IRuntime

use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project webtools.sourceediting by eclipse.

the class ProductManager method getDefaultRuntimes.

@SuppressWarnings("unchecked")
public static List<IRuntime> getDefaultRuntimes() {
    List<IRuntime> theRuntimes = null;
    Set<IRuntime> runtimes = RuntimeManager.getRuntimes();
    if (!runtimes.isEmpty()) {
        IRuntime defaultRuntime = null;
        // First check if defaults are defined
        for (int i = 0; i < DEFAULT_RUNTIME_KEYS.length; i++) {
            defaultRuntime = getMatchingRuntime(DEFAULT_RUNTIME_KEYS[i], runtimes);
            if (defaultRuntime != null) {
                if (theRuntimes == null) {
                    theRuntimes = new ArrayList<>(DEFAULT_RUNTIME_KEYS.length);
                }
                theRuntimes.add(defaultRuntime);
            }
        }
    }
    if (theRuntimes == null) {
        theRuntimes = Collections.EMPTY_LIST;
    }
    return theRuntimes;
}
Also used : IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 5 with IRuntime

use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime in project webtools.sourceediting by eclipse.

the class NewProjectDataModelFacetWizard method synchRuntimes.

protected void synchRuntimes() {
    final Boolean[] suppressBackEvents = { Boolean.FALSE };
    model.addListener(new IDataModelListener() {

        @Override
        public void propertyChanged(DataModelEvent event) {
            if (IDataModel.VALUE_CHG == event.getFlag() || IDataModel.DEFAULT_CHG == event.getFlag()) {
                if (FACET_RUNTIME.equals(event.getPropertyName())) {
                    if (!suppressBackEvents[0].booleanValue()) {
                        IRuntime runtime = (IRuntime) event.getProperty();
                        setRuntimeAndDefaultFacets(runtime);
                    }
                }
            }
        }
    });
    getFacetedProjectWorkingCopy().addListener(new IFacetedProjectListener() {

        @Override
        public void handleEvent(final IFacetedProjectEvent event) {
            suppressBackEvents[0] = Boolean.TRUE;
            model.setProperty(FACET_RUNTIME, getFacetedProjectWorkingCopy().getPrimaryRuntime());
            suppressBackEvents[0] = Boolean.FALSE;
        }
    }, IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED);
}
Also used : IFacetedProjectListener(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener) IDataModelListener(org.eclipse.wst.common.frameworks.datamodel.IDataModelListener) IFacetedProjectEvent(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent) DataModelEvent(org.eclipse.wst.common.frameworks.datamodel.DataModelEvent) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Aggregations

IRuntime (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)13 CoreException (org.eclipse.core.runtime.CoreException)4 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)3 SDK (com.liferay.ide.sdk.core.SDK)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 IProject (org.eclipse.core.resources.IProject)2 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Path (org.eclipse.core.runtime.Path)2 IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)2 IPreset (org.eclipse.wst.common.project.facet.core.IPreset)2 IRuntimeComponent (org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent)2 SDKManager (com.liferay.ide.sdk.core.SDKManager)1 File (java.io.File)1 IOException (java.io.IOException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IPath (org.eclipse.core.runtime.IPath)1