Search in sources :

Example 1 with IProjectFacet

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

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

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

the class JSFPortletFramework method configureNewProject.

@Override
public IStatus configureNewProject(IDataModel dataModel, IFacetedProjectWorkingCopy facetedProject) {
    IProjectFacetVersion jsfFacetVersion = getJSFProjectFacet(facetedProject);
    IProjectFacet jsfFacet = PortletCore.JSF_FACET;
    if (jsfFacetVersion == null) {
        jsfFacetVersion = jsfFacet.getVersion(JSF_FACET_SUPPORTED_VERSION);
        facetedProject.addProjectFacet(jsfFacetVersion);
    }
    Action action = facetedProject.getProjectFacetAction(jsfFacet);
    IDataModel jsfFacetDataModel = (IDataModel) action.getConfig();
    // TODO IDE-648 IDE-110
    jsfFacetDataModel.setProperty(SERVLET_URL_PATTERNS, null);
    jsfFacetDataModel.setProperty(WEBCONTENT_DIR, ISDKConstants.DEFAULT_DOCROOT_FOLDER);
    LibraryInstallDelegate libraryInstallDelegate = (LibraryInstallDelegate) jsfFacetDataModel.getProperty(LIBRARY_PROVIDER_DELEGATE);
    List<ILibraryProvider> providers = libraryInstallDelegate.getLibraryProviders();
    ILibraryProvider noOpProvider = null;
    for (ILibraryProvider provider : providers) {
        if (provider.getId().equals("jsf-no-op-library-provider")) {
            noOpProvider = provider;
            break;
        }
    }
    if (noOpProvider != null) {
        libraryInstallDelegate.setLibraryProvider(noOpProvider);
    }
    return Status.OK_STATUS;
}
Also used : Action(org.eclipse.wst.common.project.facet.core.IFacetedProject.Action) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) LibraryInstallDelegate(org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate) ILibraryProvider(org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel)

Example 4 with IProjectFacet

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

the class LiferayProjectPropertyPage method createInfoGroup.

protected void createInfoGroup(final Composite parent) {
    new Label(parent, SWT.LEFT).setText(Msgs.liferayPluginTypeLabel);
    final Text pluginTypeLabel = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
    pluginTypeLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
    final IProjectFacet liferayFacet = ProjectUtil.getLiferayFacet(getFacetedProject());
    if (liferayFacet != null) {
        pluginTypeLabel.setText(liferayFacet.getLabel());
    }
    final IProject proj = getProject();
    if ((proj != null) && ProjectUtil.isLiferayFacetedProject(proj)) {
        try {
            if (!ProjectUtil.isMavenProject(proj)) {
                final SDK projectSdk = SDKUtil.getSDK(getProject());
                new Label(parent, SWT.LEFT).setText(Msgs.liferaySdkLabel);
                _sdkLabel = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
                if (projectSdk != null) {
                    _sdkLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
                    _sdkLabel.setText(projectSdk.getName());
                } else {
                    _sdkLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
                    _sdkLabel.setText("");
                    final Hyperlink link = new Hyperlink(parent, SWT.NULL);
                    link.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
                    link.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE));
                    link.setUnderlined(true);
                    link.setText(Msgs.changeliferaySdk);
                    link.addHyperlinkListener(new HyperlinkAdapter() {

                        public void linkActivated(HyperlinkEvent e) {
                            String dialogId = new String("com.liferay.ide.project.ui.dialog.SelectPluginsSDKDialog");
                            final LiferayPluginSDKOp op = (LiferayPluginSDKOp) (LiferayPluginSDKOp.TYPE.instantiate().initialize());
                            DefinitionLoader sdefLoader = DefinitionLoader.context(getClass()).sdef(dialogId);
                            final Reference<DialogDef> dialogRef = sdefLoader.dialog("ConfigureLiferaySDK");
                            final SapphireDialog dialog = new SapphireDialog(UIUtil.getActiveShell(), op, dialogRef);
                            dialog.setBlockOnOpen(true);
                            final int result = dialog.open();
                            if (result != SapphireDialog.CANCEL) {
                                _sdkLabel.setText(op.getPluginsSDKName().content());
                            }
                        }
                    });
                }
                if (CoreUtil.compareVersions(new Version(projectSdk.getVersion()), ILiferayConstants.V700) < 0) {
                    new Label(parent, SWT.LEFT).setText(Msgs.liferayRuntimeLabel);
                    _runtimeCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
                    _runtimeCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
                    String currentRuntimeName = null;
                    try {
                        ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(getProject());
                        if (liferayRuntime != null) {
                            currentRuntimeName = liferayRuntime.getRuntime().getName();
                        }
                    } catch (Exception e) {
                        ProjectUI.logError("Could not determine liferay runtime", e);
                    }
                    List<String> runtimeNames = new ArrayList<>();
                    int selectionIndex = -1;
                    for (IRuntime runtime : ServerCore.getRuntimes()) {
                        if (ServerUtil.isLiferayRuntime(runtime) && FileUtil.exists(runtime.getLocation()) && (LiferayServerCore.newPortalBundle(runtime.getLocation()) == null)) {
                            runtimeNames.add(runtime.getName());
                            if (runtime.getName().equals(currentRuntimeName)) {
                                selectionIndex = runtimeNames.size() - 1;
                            }
                        }
                    }
                    if (ListUtil.isEmpty(runtimeNames)) {
                        runtimeNames.add("No Liferay runtimes available.");
                    }
                    _runtimeCombo.setItems(runtimeNames.toArray(new String[0]));
                    if (selectionIndex > -1) {
                        _runtimeCombo.select(selectionIndex);
                    }
                }
            }
        } catch (Exception e) {
            ProjectUI.logError("Could not determine whether its a maven project ", e);
        }
    }
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Reference(org.eclipse.sapphire.ui.def.DefinitionLoader.Reference) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) LiferayPluginSDKOp(com.liferay.ide.project.core.model.LiferayPluginSDKOp) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) BackingStoreException(org.osgi.service.prefs.BackingStoreException) IRuntime(org.eclipse.wst.server.core.IRuntime) Version(org.osgi.framework.Version) DefinitionLoader(org.eclipse.sapphire.ui.def.DefinitionLoader) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) GridData(org.eclipse.swt.layout.GridData) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) SDK(com.liferay.ide.sdk.core.SDK) SapphireDialog(org.eclipse.sapphire.ui.forms.swt.SapphireDialog) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 5 with IProjectFacet

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

the class SDKProjectConvertDataModelProvider method init.

@Override
public void init() {
    super.init();
    // set the project facets to get the runtime target dropdown to only show liferay runtimes
    IFacetedProjectWorkingCopy facetedProject = getFacetedProjectWorkingCopy();
    Set<IProjectFacetVersion> facets = ProjectUtil.getFacetsForPreset(IPluginFacetConstants.LIFERAY_PORTLET_PRESET);
    Set<IProjectFacet> fixedFacets = new HashSet<>();
    for (IProjectFacetVersion pfv : facets) {
        fixedFacets.add(pfv.getProjectFacet());
    }
    facetedProject.setFixedProjectFacets(Collections.unmodifiableSet(fixedFacets));
}
Also used : IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy) HashSet(java.util.HashSet)

Aggregations

IProjectFacet (org.eclipse.wst.common.project.facet.core.IProjectFacet)28 IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)17 CoreException (org.eclipse.core.runtime.CoreException)14 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 HashSet (java.util.HashSet)6 IProject (org.eclipse.core.resources.IProject)6 IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)5 IStatus (org.eclipse.core.runtime.IStatus)3 Action (org.eclipse.wst.common.project.facet.core.IFacetedProject.Action)3 IPluginPublisher (com.liferay.ide.server.core.IPluginPublisher)2 ArrayList (java.util.ArrayList)2 IFile (org.eclipse.core.resources.IFile)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ILibraryProvider (org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider)2 LibraryInstallDelegate (org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate)2 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)2 IRuntime (org.eclipse.wst.server.core.IRuntime)2 MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)1 VcsRepository (com.centurylink.mdw.plugin.project.model.VcsRepository)1