Search in sources :

Example 31 with IFacetedProject

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

the class LiferayTomcatUtil method canAddModule.

public static IStatus canAddModule(IModule module, IServer currentServer) {
    IProject project = module.getProject();
    if (project != null) {
        IFacetedProject facetedProject = ProjectUtil.getFacetedProject(project);
        if (facetedProject != null) {
            IProjectFacet liferayFacet = ProjectUtil.getLiferayFacet(facetedProject);
            if (liferayFacet != null) {
                String facetId = liferayFacet.getId();
                IRuntime runtime = null;
                try {
                    runtime = ServerUtil.getRuntime(project);
                } catch (CoreException e) {
                }
                if (runtime != null) {
                    IPluginPublisher pluginPublisher = LiferayServerCore.getPluginPublisher(facetId, runtime.getRuntimeType().getId());
                    if (pluginPublisher != null) {
                        IStatus status = pluginPublisher.canPublishModule(currentServer, module);
                        if (!status.isOK()) {
                            return status;
                        }
                    }
                }
            }
        }
    }
    return Status.OK_STATUS;
}
Also used : IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) IPluginPublisher(com.liferay.ide.server.core.IPluginPublisher) IProject(org.eclipse.core.resources.IProject) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 32 with IFacetedProject

use of org.eclipse.wst.common.project.facet.core.IFacetedProject in project mdw-designer by CenturyLinkCloud.

the class ConvertProjectAction method run.

@SuppressWarnings("restriction")
public void run(IAction action) {
    if (selection != null) {
        Object element = selection.getFirstElement();
        try {
            IProject project = (element instanceof IJavaProject) ? ((IJavaProject) element).getProject() : (IProject) element;
            IFacetedProject facetedProject = ProjectFacetsManager.create(project);
            if (facetedProject == null) {
                org.eclipse.wst.common.project.facet.ui.internal.ConvertProjectToFacetedFormRunnable.runInProgressDialog(shell, project);
                facetedProject = ProjectFacetsManager.create(project);
            }
            IFacetedProjectWorkingCopy workingCopy = org.eclipse.wst.common.project.facet.ui.internal.SharedWorkingCopyManager.getWorkingCopy(facetedProject);
            workingCopy.addProjectFacet(ProjectFacetsManager.getProjectFacet("mdw.workflow").getDefaultVersion());
            if (!facetedProject.hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.ear")) && !facetedProject.hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.web")) && !facetedProject.hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.utility"))) {
                workingCopy.addProjectFacet(ProjectFacetsManager.getProjectFacet("jst.utility").getDefaultVersion());
            }
            PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(shell, element, FACETS_PROP_PAGE_ID, null, null, PreferencesUtil.OPTION_NONE);
            if (dialog != null) {
                dialog.open();
            }
        } catch (Exception ex) {
            PluginMessages.uiError(shell, ex, "Convert Workflow Project");
        }
    }
}
Also used : IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IJavaProject(org.eclipse.jdt.core.IJavaProject) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy) IProject(org.eclipse.core.resources.IProject)

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