Search in sources :

Example 1 with IFacetedProject

use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project sling by apache.

the class ConfigurationHelper method convertToLaunchpadProject.

public static void convertToLaunchpadProject(IProject project, IPath modelsDirectoryPath) throws CoreException {
    IProjectFacet facet = ProjectFacetsManager.getProjectFacet("sling.launchpad");
    IFacetedProject fp2 = ProjectFacetsManager.create(project, true, null);
    fp2.installProjectFacet(facet.getLatestVersion(), null, null);
    project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    if (modelsDirectoryPath != null) {
        ProjectUtil.setProvisioningModelPath(project, modelsDirectoryPath);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Example 2 with IFacetedProject

use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project sling by apache.

the class ConfigurationHelper method convertToBundleProject.

public static void convertToBundleProject(IProject aBundleProject) throws CoreException {
    IProjectFacet slingContentFacet = ProjectFacetsManager.getProjectFacet("sling.bundle");
    IFacetedProject fp2 = ProjectFacetsManager.create(aBundleProject, true, null);
    fp2.installProjectFacet(slingContentFacet.getLatestVersion(), null, null);
    aBundleProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Example 3 with IFacetedProject

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

the class LiferayProjectPropertyPage method performOk.

@Override
public boolean performOk() {
    final IProject proj = getProject();
    if (SDKUtil.isSDKProject(proj)) {
        if (_runtimeCombo != null) {
            final String selectedRuntimeName = this._runtimeCombo.getText();
            if (!CoreUtil.isNullOrEmpty(selectedRuntimeName)) {
                final org.eclipse.wst.common.project.facet.core.runtime.IRuntime runtime = RuntimeManager.getRuntime(selectedRuntimeName);
                if (runtime != null) {
                    final IFacetedProject fProject = ProjectUtil.getFacetedProject(getProject());
                    final org.eclipse.wst.common.project.facet.core.runtime.IRuntime primaryRuntime = fProject.getPrimaryRuntime();
                    if (!runtime.equals(primaryRuntime)) {
                        Job job = new WorkspaceJob("Setting targeted runtime for project.") {

                            @Override
                            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                                IStatus retval = Status.OK_STATUS;
                                try {
                                    fProject.setTargetedRuntimes(Collections.singleton(runtime), monitor);
                                    fProject.setPrimaryRuntime(runtime, monitor);
                                } catch (Exception e) {
                                    retval = ProjectUI.createErrorStatus("Could not set targeted runtime", e);
                                }
                                return retval;
                            }
                        };
                        job.schedule();
                    }
                } else {
                    return false;
                }
            }
        }
        final String sdkName = this._sdkLabel.getText();
        if (!CoreUtil.isNullOrEmpty(sdkName)) {
            try {
                final IEclipsePreferences prefs = new ProjectScope(getProject()).getNode(SDKCorePlugin.PLUGIN_ID);
                prefs.put(SDKCorePlugin.PREF_KEY_SDK_NAME, sdkName);
                prefs.flush();
            } catch (BackingStoreException bse) {
                ProjectCore.logError("Unable to persist sdk name to project " + getProject(), bse);
            }
        }
    }
    return true;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IStatus(org.eclipse.core.runtime.IStatus) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) BackingStoreException(org.osgi.service.prefs.BackingStoreException) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) BackingStoreException(org.osgi.service.prefs.BackingStoreException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Job(org.eclipse.core.runtime.jobs.Job)

Example 4 with IFacetedProject

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

the class LiferayProjectPropertyPage method getFacetedProject.

protected IFacetedProject getFacetedProject() {
    IFacetedProject retval = null;
    IProject project = getProject();
    if (project != null) {
        retval = ProjectUtil.getFacetedProject(project);
    }
    return retval;
}
Also used : IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IProject(org.eclipse.core.resources.IProject)

Example 5 with IFacetedProject

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

Aggregations

IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)32 CoreException (org.eclipse.core.runtime.CoreException)20 IProjectFacet (org.eclipse.wst.common.project.facet.core.IProjectFacet)17 IProject (org.eclipse.core.resources.IProject)16 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IStatus (org.eclipse.core.runtime.IStatus)6 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)5 IRuntime (org.eclipse.wst.server.core.IRuntime)5 IWorkspace (org.eclipse.core.resources.IWorkspace)4 IPath (org.eclipse.core.runtime.IPath)4 IFile (org.eclipse.core.resources.IFile)3 Path (org.eclipse.core.runtime.Path)3 IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)3 FacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy)3 PluginClasspathContainerInitializer (com.liferay.ide.project.core.PluginClasspathContainerInitializer)2 IPluginPublisher (com.liferay.ide.server.core.IPluginPublisher)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Status (org.eclipse.core.runtime.Status)2