Search in sources :

Example 6 with IRuntime

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

the class NewProjectDataModelFacetWizard method createPageControls.

@Override
public void createPageControls(Composite container) {
    super.createPageControls(container);
    final IPreset preset = this.template.getInitialPreset();
    final IRuntime runtime = (IRuntime) model.getProperty(FACET_RUNTIME);
    if (preset == null) {
        // If no preset is specified, select the runtime and it's default
        // facets.
        setRuntimeAndDefaultFacets(runtime);
    } else {
        // If preset is specified, select the runtime only if supports all
        // of the facets included in the preset.
        getFacetedProjectWorkingCopy().setSelectedPreset(preset.getId());
        boolean supports = false;
        if (runtime != null) {
            supports = true;
            for (Iterator itr = preset.getProjectFacets().iterator(); itr.hasNext(); ) {
                final IProjectFacetVersion fv = (IProjectFacetVersion) itr.next();
                if (!runtime.supports(fv)) {
                    supports = false;
                    break;
                }
            }
        }
        if (supports) {
            getFacetedProjectWorkingCopy().setTargetedRuntimes(Collections.singleton(runtime));
        } else {
            model.setProperty(FACET_RUNTIME, null);
        }
    }
    synchRuntimes();
}
Also used : IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IPreset(org.eclipse.wst.common.project.facet.core.IPreset) Iterator(java.util.Iterator) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 7 with IRuntime

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

the class DataModelFacetCreationWizardPage method restoreRuntimeSettings.

public static void restoreRuntimeSettings(IDialogSettings settings, IDataModel model) {
    if (settings != null) {
        if (!model.isPropertySet(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)) {
            boolean runtimeSet = false;
            String[] mruRuntimeArray = settings.getArray(MRU_RUNTIME_STORE);
            DataModelPropertyDescriptor[] descriptors = model.getValidPropertyDescriptors(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
            List mruRuntimes = new ArrayList();
            if (mruRuntimeArray == null) {
                List defRuntimes = ProductManager.getDefaultRuntimes();
                for (Iterator iter = defRuntimes.iterator(); iter.hasNext(); ) mruRuntimes.add(((IRuntime) iter.next()).getName());
            } else {
                mruRuntimes.addAll(Arrays.asList(mruRuntimeArray));
            }
            if (!mruRuntimes.isEmpty()) {
                for (int i = 0; i < mruRuntimes.size() && !runtimeSet; i++) {
                    for (int j = 0; j < descriptors.length - 1 && !runtimeSet; j++) {
                        if (mruRuntimes.get(i).equals(((IRuntime) descriptors[j].getPropertyValue()).getName())) {
                            model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[j].getPropertyValue());
                            runtimeSet = true;
                        }
                    }
                    if (!runtimeSet && mruRuntimes.get(i).equals(NULL_RUNTIME)) {
                        model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[descriptors.length - 1].getPropertyValue());
                        runtimeSet = true;
                    }
                }
            }
            if (!runtimeSet && descriptors.length > 0) {
                model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[0].getPropertyValue());
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) DataModelPropertyDescriptor(org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 8 with IRuntime

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

the class ProductManager method getMatchingRuntime.

private static IRuntime getMatchingRuntime(String defaultProductRuntimeProperty, Set<IRuntime> runtimes) {
    String defaultProductRuntimeKey = getProperty(defaultProductRuntimeProperty);
    if (defaultProductRuntimeKey == null || defaultProductRuntimeKey.length() == 0) {
        return null;
    }
    // The defaultProductRuntimeKey needs to be in the following format
    // <facet runtime id>:<facet version>.
    int seperatorIndex = defaultProductRuntimeKey.indexOf(RUNTIME_SEPARATOR);
    if (seperatorIndex < 0 && seperatorIndex < defaultProductRuntimeKey.length()) {
        // Consider throwing an exception here.
        // $NON-NLS-1$
        WSTWebPlugin.logError("Invalid default product runtime id.  It should follow the format <facet runtime id>:<facet version>.  Id processed: " + defaultProductRuntimeKey);
        return null;
    }
    String defaultRuntimeID = defaultProductRuntimeKey.substring(0, seperatorIndex);
    String defaultFacetVersion = defaultProductRuntimeKey.substring(seperatorIndex + 1);
    for (Iterator<IRuntime> runtimeIt = runtimes.iterator(); runtimeIt.hasNext(); ) {
        IRuntime runtime = runtimeIt.next();
        List<IRuntimeComponent> runtimeComps = runtime.getRuntimeComponents();
        if (!runtimeComps.isEmpty()) {
            for (Iterator<IRuntimeComponent> compsIter = runtimeComps.iterator(); compsIter.hasNext(); ) {
                IRuntimeComponent runtimeComp = compsIter.next();
                if (defaultRuntimeID.equals(runtimeComp.getRuntimeComponentType().getId()) && (defaultFacetVersion.equals(runtimeComp.getRuntimeComponentVersion().getVersionString()))) {
                    return runtime;
                }
            }
        }
    }
    // No matches found.
    return null;
}
Also used : IRuntimeComponent(org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 9 with IRuntime

use of org.eclipse.wst.common.project.facet.core.runtime.IRuntime 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 10 with IRuntime

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

the class DataModelFacetCreationWizardPage method saveRuntimeSettings.

public static void saveRuntimeSettings(IDialogSettings settings, IDataModel model) {
    if (settings != null) {
        String[] mruRuntimeArray = settings.getArray(MRU_RUNTIME_STORE);
        List mruRuntimes = new ArrayList();
        if (mruRuntimeArray != null)
            mruRuntimes.addAll(Arrays.asList(mruRuntimeArray));
        IRuntime runtime = (IRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
        String runtimeName = runtime == null ? NULL_RUNTIME : runtime.getName();
        if (mruRuntimes.contains(runtimeName)) {
            mruRuntimes.remove(runtimeName);
        }
        mruRuntimes.add(0, runtimeName);
        while (mruRuntimes.size() > 5) {
            mruRuntimes.remove(5);
        }
        mruRuntimeArray = new String[mruRuntimes.size()];
        for (int i = 0; i < mruRuntimeArray.length; i++) {
            mruRuntimeArray[i] = (String) mruRuntimes.get(i);
        }
        settings.put(MRU_RUNTIME_STORE, mruRuntimeArray);
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Aggregations

IRuntime (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)13 CoreException (org.eclipse.core.runtime.CoreException)4 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)3 SDK (com.liferay.ide.sdk.core.SDK)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 IProject (org.eclipse.core.resources.IProject)2 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Path (org.eclipse.core.runtime.Path)2 IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)2 IPreset (org.eclipse.wst.common.project.facet.core.IPreset)2 IRuntimeComponent (org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent)2 SDKManager (com.liferay.ide.sdk.core.SDKManager)1 File (java.io.File)1 IOException (java.io.IOException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IPath (org.eclipse.core.runtime.IPath)1