Search in sources :

Example 6 with IFacetedProjectWorkingCopy

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

the class NewProjectDataModelFacetWizard method setRuntimeAndDefaultFacets.

protected void setRuntimeAndDefaultFacets(final IRuntime runtime) {
    final IFacetedProjectWorkingCopy dm = getFacetedProjectWorkingCopy();
    dm.setTargetedRuntimes(Collections.<IRuntime>emptySet());
    if (runtime != null) {
        final Set<IProjectFacetVersion> minFacets = new HashSet<IProjectFacetVersion>();
        try {
            for (IProjectFacet f : dm.getFixedProjectFacets()) {
                minFacets.add(f.getLatestSupportedVersion(runtime));
            }
        } catch (CoreException e) {
            throw new RuntimeException(e);
        }
        dm.setProjectFacets(minFacets);
        dm.setTargetedRuntimes(Collections.singleton(runtime));
    }
    dm.setSelectedPreset(FacetedProjectFramework.DEFAULT_CONFIGURATION_PRESET_ID);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) 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)

Example 7 with IFacetedProjectWorkingCopy

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

the class DataModelFacetCreationWizardPage method createPresetPanel.

protected void createPresetPanel(Composite top) {
    final IFacetedProjectWorkingCopy workingCopy = ((ModifyFacetedProjectWizard) getWizard()).getFacetedProjectWorkingCopy();
    final IFilter<IPreset> filter = new AbstractFilter<IPreset>() {

        {
            IFacetedProjectListener fpjwcListenerForPreset = new IFacetedProjectListener() {

                @Override
                public void handleEvent(final IFacetedProjectEvent event) {
                    handleProjectFacetsChangedEvent((IProjectFacetsChangedEvent) event);
                }
            };
            facetedProjectListeners.add(fpjwcListenerForPreset);
            workingCopy.addListener(fpjwcListenerForPreset, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED);
        }

        @Override
        public boolean check(final IPreset preset) {
            final IProjectFacetVersion primaryFacetVersion = getPrimaryFacetVersion();
            return preset.getProjectFacets().contains(primaryFacetVersion);
        }

        private void handleProjectFacetsChangedEvent(final IProjectFacetsChangedEvent event) {
            for (IProjectFacetVersion fv : event.getFacetsWithChangedVersions()) {
                if (fv.getProjectFacet() == getPrimaryFacet()) {
                    final IFilterEvent<IPreset> filterEvent = new FilterEvent<IPreset>(this, IFilterEvent.Type.FILTER_CHANGED);
                    notifyListeners(filterEvent);
                }
            }
        }
    };
    final PresetSelectionPanel ppanel = new PresetSelectionPanel(top, workingCopy, filter);
    ppanel.setLayoutData(gdhfill());
}
Also used : IFacetedProjectListener(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener) FilterEvent(org.eclipse.wst.common.project.facet.core.util.FilterEvent) AbstractFilter(org.eclipse.wst.common.project.facet.core.util.AbstractFilter) IFacetedProjectEvent(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) ModifyFacetedProjectWizard(org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard) IProjectFacetsChangedEvent(org.eclipse.wst.common.project.facet.core.events.IProjectFacetsChangedEvent) PresetSelectionPanel(org.eclipse.wst.common.project.facet.ui.PresetSelectionPanel) IPreset(org.eclipse.wst.common.project.facet.core.IPreset) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)

Example 8 with IFacetedProjectWorkingCopy

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

the class ServerSettingsPage method initValues.

public void initValues() {
    configurator = ServerConfigurator.Factory.create(getServerSettings());
    ContainerType type = ServerSettings.getContainerTypeFromClass(this.getClass().getSimpleName());
    if (type != null) {
        String prevServerHome = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_HOME);
        if (prevServerHome.length() > 0)
            getServerSettings().setHome(prevServerHome);
        if (getServerSettings().getHome() != null)
            serverHomeTextField.setText(getServerSettings().getHome());
        if (getServerSettings().isServiceMix())
            getServerSettings().setContainerVersion("4.4.1");
        if (getServerSettings().isFuse())
            getServerSettings().setContainerVersion("6.1.0");
        String prevJdkHome = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_JDK_HOME);
        if (prevJdkHome.length() > 0)
            getServerSettings().setJdkHome(prevJdkHome);
        if (getServerSettings().getJdkHome() != null)
            jdkHomeTextField.setText(getServerSettings().getJdkHome());
        String prevServerHost = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_HOST);
        if (prevServerHost.length() > 0 && getProject().isRemote())
            getServerSettings().setHost(prevServerHost);
        else
            getServerSettings().setHost(ServerSettings.DEFAULT_HOST);
        serverHostTextField.setText(getServerSettings().getHost());
        String prevServerPort = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_PORT);
        if (prevServerPort.length() > 0 && getProject().isRemote()) {
            try {
                getServerSettings().setPort(Integer.parseInt(prevServerPort));
            } catch (NumberFormatException ex) {
                MdwPlugin.setStringPref(type + "-" + ProjectPersist.MDW_SERVER_PORT, String.valueOf(getDefaultServerPort()));
            }
        } else {
            getServerSettings().setPort(getDefaultServerPort());
        }
        serverPortTextField.setText(String.valueOf(getServerSettings().getPort()));
        String prevServerUser = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_USER);
        if (prevServerUser.length() > 0)
            getServerSettings().setUser(prevServerUser);
        else
            getServerSettings().setUser(getDefaultServerUser());
        serverUserTextField.setText(getServerSettings().getUser());
    }
    if (!getProject().checkRequiredVersion(5, 0)) {
        IProjectFacetVersion pfv = ProjectFacetsManager.getProjectFacet("mdw.workflow").getVersion("1.1");
        IFacetedProjectWorkingCopy wc = ((ModifyFacetedProjectWizard) getWizard()).getFacetedProjectWorkingCopy();
        wc.changeProjectFacetVersion(pfv);
    }
}
Also used : IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) ContainerType(com.centurylink.mdw.plugin.project.model.ServerSettings.ContainerType) ModifyFacetedProjectWizard(org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)

Example 9 with IFacetedProjectWorkingCopy

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

the class ConvertJob method runInWorkspace.

public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
    try {
        IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(JSDT_FACET);
        IFacetedProject facetedProject = ProjectFacetsManager.create(fProject);
        if (facetedProject != null && fProject.isAccessible()) {
            if (fInstall) {
                IProjectFacetVersion latestVersion = projectFacet.getLatestVersion();
                facetedProject.installProjectFacet(latestVersion, null, monitor);
            }
            if (fUseExplicitWorkingCopy) {
                IFacetedProjectWorkingCopy copy = facetedProject.createWorkingCopy();
                Set fixed = new HashSet(facetedProject.getFixedProjectFacets());
                fixed.add(projectFacet);
                copy.setFixedProjectFacets(fixed);
                copy.commitChanges(new NullProgressMonitor());
                copy.dispose();
            } else {
                Set fixed = new HashSet(facetedProject.getFixedProjectFacets());
                if (!fixed.contains(projectFacet)) {
                    fixed.add(projectFacet);
                    facetedProject.setFixedProjectFacets(fixed);
                }
            }
        }
    } catch (IllegalArgumentException e) {
    // unknown facet ID, bad installation configuration?
    } catch (Exception e) {
        Logger.logException(e);
    }
    return Status.OK_STATUS;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) Set(java.util.Set) HashSet(java.util.HashSet) 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) CoreException(org.eclipse.core.runtime.CoreException) HashSet(java.util.HashSet)

Example 10 with IFacetedProjectWorkingCopy

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

the class LiferayProjectImportDataModelProvider 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();
    facetedProject.setSelectedPreset(IPluginFacetConstants.LIFERAY_PORTLET_PRESET);
    Set<IProjectFacet> fixedFacets = new HashSet<>();
    fixedFacets.add(ProjectFacetsManager.getProjectFacet(IPluginFacetConstants.LIFERAY_EXT_FACET_ID));
    facetedProject.setFixedProjectFacets(Collections.unmodifiableSet(fixedFacets));
    ProjectUtil.setDefaultRuntime(getDataModel());
}
Also used : IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy) HashSet(java.util.HashSet)

Aggregations

IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)12 HashSet (java.util.HashSet)5 CoreException (org.eclipse.core.runtime.CoreException)5 IProjectFacet (org.eclipse.wst.common.project.facet.core.IProjectFacet)5 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)5 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)2 PluginFacetProjectCreationDataModelProvider (com.liferay.ide.project.core.facet.PluginFacetProjectCreationDataModelProvider)2 PluginType (com.liferay.ide.project.core.model.PluginType)2 ArrayList (java.util.ArrayList)2 IResource (org.eclipse.core.resources.IResource)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)2 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)2 IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)2 ModifyFacetedProjectWizard (org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard)2 ContainerType (com.centurylink.mdw.plugin.project.model.ServerSettings.ContainerType)1 SDK (com.liferay.ide.sdk.core.SDK)1 File (java.io.File)1