Search in sources :

Example 16 with IProjectFacetVersion

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

the class DataModelFacetCreationWizardPage method handlePrimaryFacetVersionSelectedEvent.

protected void handlePrimaryFacetVersionSelectedEvent() {
    final IProjectFacetVersion fv = getPrimaryFacetVersion();
    if (fv != null) {
        String presetID = null;
        IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
        if (runtime != null) {
            if (runtime.getRuntimeComponents().size() > 0) {
                IRuntimeComponent runtimeComponent = runtime.getRuntimeComponents().get(0);
                String facetRuntimeTypeID = runtimeComponent.getRuntimeComponentType().getId();
                String facetRuntimeVersion = runtimeComponent.getRuntimeComponentVersion().getVersionString();
                String facetID = fv.getProjectFacet().getId();
                String facetVersion = fv.getVersionString();
                presetID = RuntimePresetMappingRegistry.INSTANCE.getPresetID(facetRuntimeTypeID, facetRuntimeVersion, facetID, facetVersion);
            }
        }
        if (presetID == null) {
            final Set<IProjectFacetVersion> facets = getFacetConfiguration(fv);
            this.fpjwc.setProjectFacets(facets);
        } else {
            // setting the facets prior to setting the preset is to let the dynamic presets adjust
            final Set<IProjectFacetVersion> facets = getFacetConfiguration(fv);
            this.fpjwc.setProjectFacets(facets);
            this.fpjwc.setSelectedPreset(presetID);
        }
    }
}
Also used : IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IRuntimeComponent(org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 17 with IProjectFacetVersion

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

the class DataModelFacetCreationWizardPage method createPrimaryFacetComposite.

protected void createPrimaryFacetComposite(Composite top) {
    primaryProjectFacet = ProjectFacetsManager.getProjectFacet(getModuleTypeID());
    if (primaryProjectFacet.getVersions().size() <= 1) {
        // facet version to choose from (e.g. utility and static web)
        return;
    }
    final Group group = new Group(top, SWT.NONE);
    group.setLayoutData(gdhfill());
    group.setLayout(new GridLayout(1, false));
    group.setText(getPrimaryFacetCompositeLabel());
    primaryVersionCombo = new Combo(group, SWT.BORDER | SWT.READ_ONLY);
    primaryVersionCombo.setLayoutData(gdhfill());
    updatePrimaryVersions();
    primaryVersionCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            handlePrimaryFacetVersionSelectedEvent();
        }
    });
    IFacetedProjectListener fpjwcListenerForPrimaryFacetCombo = new IFacetedProjectListener() {

        @Override
        public void handleEvent(IFacetedProjectEvent event) {
            if (event.getType() == IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED) {
                // this block is to update the combo when the underlying facet version changes
                IProjectFacetsChangedEvent actionEvent = (IProjectFacetsChangedEvent) event;
                Set<IProjectFacetVersion> changedVersions = actionEvent.getFacetsWithChangedVersions();
                boolean foundComboVersion = false;
                for (Iterator<IProjectFacetVersion> iterator = changedVersions.iterator(); iterator.hasNext() && !foundComboVersion; ) {
                    IProjectFacetVersion next = iterator.next();
                    if (next.getProjectFacet().equals(primaryProjectFacet)) {
                        foundComboVersion = true;
                        final IProjectFacetVersion selectedVersion = next;
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                String selectedText = primaryVersionCombo.getItem(primaryVersionCombo.getSelectionIndex());
                                if (!selectedText.equals(selectedVersion.getVersionString())) {
                                    String[] items = primaryVersionCombo.getItems();
                                    int selectedVersionIndex = -1;
                                    for (int i = 0; i < items.length && selectedVersionIndex == -1; i++) {
                                        if (items[i].equals(selectedVersion.getVersionString())) {
                                            selectedVersionIndex = i;
                                            primaryVersionCombo.select(selectedVersionIndex);
                                        }
                                    }
                                }
                            }
                        });
                    }
                }
            } else if (event.getType() == IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED) {
                // this block updates the items in the combo when the runtime changes
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        updatePrimaryVersions();
                    }
                });
            }
        }
    };
    this.facetedProjectListeners.add(fpjwcListenerForPrimaryFacetCombo);
    fpjwc.addListener(fpjwcListenerForPrimaryFacetCombo, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED, IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED);
}
Also used : IFacetedProjectListener(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener) NewProjectGroup(org.eclipse.wst.common.frameworks.internal.ui.NewProjectGroup) WorkingSetGroup(org.eclipse.ui.dialogs.WorkingSetGroup) Group(org.eclipse.swt.widgets.Group) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IProjectFacetsChangedEvent(org.eclipse.wst.common.project.facet.core.events.IProjectFacetsChangedEvent) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) IFacetedProjectEvent(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 18 with IProjectFacetVersion

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

the class DataModelFacetCreationWizardPage method updatePrimaryVersions.

protected void updatePrimaryVersions() {
    IProjectFacetVersion selectedVersion = fpjwc.getProjectFacetVersion(primaryProjectFacet);
    SortedSet<IProjectFacetVersion> initialVersions = fpjwc.getAvailableVersions(primaryProjectFacet);
    String[] items = new String[initialVersions.size()];
    int i = 0;
    int selectedVersionIndex = -1;
    for (Iterator<IProjectFacetVersion> iterator = initialVersions.iterator(); iterator.hasNext(); i++) {
        items[i] = iterator.next().getVersionString();
        if (selectedVersionIndex == -1 && items[i].equals(selectedVersion.getVersionString())) {
            selectedVersionIndex = i;
        }
    }
    primaryVersionCombo.clearSelection();
    primaryVersionCombo.setItems(items);
    primaryVersionCombo.select(selectedVersionIndex);
}
Also used : IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)

Example 19 with IProjectFacetVersion

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

the class SDKPluginFacetUtil method configureProjectAsSDKProject.

public static void configureProjectAsSDKProject(IFacetedProjectWorkingCopy fpjwc, String pluginType, String sdkLocation, ProjectRecord projectRecord) throws CoreException {
    IFacetedProjectTemplate template = getLiferayTemplateForProject(pluginType);
    IPreset preset = getLiferayPresetForProject(pluginType);
    if (preset == null) {
        throw new CoreException(ProjectCore.createErrorStatus(NLS.bind(Msgs.noFacetPreset, fpjwc.getProjectName())));
    }
    IRuntime primaryRuntime = fpjwc.getPrimaryRuntime();
    if (primaryRuntime != null) {
        fpjwc.removeTargetedRuntime(primaryRuntime);
    }
    Set<IProjectFacetVersion> currentProjectFacetVersions = fpjwc.getProjectFacets();
    Set<IProjectFacet> requiredFacets = template.getFixedProjectFacets();
    for (IProjectFacet requiredFacet : requiredFacets) {
        boolean hasRequiredFacet = false;
        for (IProjectFacetVersion currentFacetVersion : currentProjectFacetVersions) {
            if (currentFacetVersion.getProjectFacet().equals(requiredFacet)) {
                // TODO how to check the bundle support status?
                boolean requiredVersion = _isRequiredVersion(currentFacetVersion);
                if (requiredVersion) {
                    hasRequiredFacet = true;
                } else {
                    fpjwc.removeProjectFacet(currentFacetVersion);
                }
                break;
            }
        }
        if (!hasRequiredFacet) {
            IProjectFacetVersion requiredFacetVersion = _getRequiredFacetVersionFromPreset(requiredFacet, preset);
            if (requiredFacetVersion != null) {
                fpjwc.addProjectFacet(requiredFacetVersion);
                if (ProjectUtil.isJavaFacet(requiredFacetVersion)) {
                    configureJavaFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset, projectRecord);
                } else if (ProjectUtil.isDynamicWebFacet(requiredFacetVersion)) {
                    configureWebFacet(fpjwc, requiredFacetVersion.getProjectFacet(), preset);
                }
            }
        } else {
            if (ProjectUtil.isJavaFacet(requiredFacet)) {
                configureJavaFacet(fpjwc, requiredFacet, preset, projectRecord);
            } else if (ProjectUtil.isDynamicWebFacet(requiredFacet)) {
                configureWebFacet(fpjwc, requiredFacet, preset);
            }
        }
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IFacetedProjectTemplate(org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate) IPreset(org.eclipse.wst.common.project.facet.core.IPreset) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 20 with IProjectFacetVersion

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

the class ValidProjectChecker method checkValidProjectTypes.

public void checkValidProjectTypes() {
    IProject[] projects = CoreUtil.getAllProjects();
    boolean hasValidProjectTypes = false;
    boolean hasJsfFacet = false;
    for (IProject project : projects) {
        if (ProjectUtil.isLiferayFacetedProject(project)) {
            Set<IProjectFacetVersion> facets = ProjectUtil.getFacetedProject(project).getProjectFacets();
            if ((validProjectTypes != null) && (facets != null)) {
                String[] validTypes = validProjectTypes.split(StringPool.COMMA);
                for (String validProjectType : validTypes) {
                    for (IProjectFacetVersion facet : facets) {
                        String id = facet.getProjectFacet().getId();
                        if (jsfPortlet && id.equals("jst.jsf")) {
                            hasJsfFacet = true;
                        }
                        if (id.startsWith("liferay.") && id.equals("liferay." + validProjectType)) {
                            hasValidProjectTypes = true;
                        }
                    }
                }
            }
        }
    }
    if (jsfPortlet) {
        hasValidProjectTypes = hasJsfFacet && hasValidProjectTypes;
    }
    if (!hasValidProjectTypes) {
        final Shell activeShell = Display.getDefault().getActiveShell();
        Boolean openNewLiferayProjectWizard = MessageDialog.openQuestion(activeShell, NLS.bind(Msgs.newElement, wizardName), NLS.bind(Msgs.noSuitableLiferayProjects, wizardName));
        if (openNewLiferayProjectWizard) {
            final Action defaultAction = NewPluginProjectDropDownAction.getPluginProjectAction();
            if (defaultAction != null) {
                defaultAction.run();
                checkValidProjectTypes();
            }
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Action(org.eclipse.jface.action.Action) NewPluginProjectDropDownAction(com.liferay.ide.project.ui.action.NewPluginProjectDropDownAction) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IProject(org.eclipse.core.resources.IProject)

Aggregations

IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)22 IProjectFacet (org.eclipse.wst.common.project.facet.core.IProjectFacet)10 CoreException (org.eclipse.core.runtime.CoreException)7 IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)5 IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)5 HashSet (java.util.HashSet)4 IPreset (org.eclipse.wst.common.project.facet.core.IPreset)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)3 Action (org.eclipse.wst.common.project.facet.core.IFacetedProject.Action)3 Iterator (java.util.Iterator)2 IProject (org.eclipse.core.resources.IProject)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 ILibraryProvider (org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider)2 LibraryInstallDelegate (org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate)2 IRuntime (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)2 ModifyFacetedProjectWizard (org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard)2 MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)1 ContainerType (com.centurylink.mdw.plugin.project.model.ServerSettings.ContainerType)1