### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.launching Index: src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java,v retrieving revision 1.4 diff -u -r1.4 BundleLauncherHelper.java --- src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java 16 Feb 2010 13:10:27 -0000 1.4 +++ src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java 19 Feb 2010 18:47:10 -0000 @@ -374,13 +374,11 @@ wc.doSave(); } - public static String writeFeatureEntry(String id, String version, String location, String resolution) { + public static String writeFeatureEntry(String id, String location, String resolution) { StringBuffer buffer = new StringBuffer(); buffer.append(id); buffer.append(':'); - buffer.append(version); - buffer.append(':'); buffer.append(location); buffer.append(':'); buffer.append(resolution); #P org.eclipse.pde.ui Index: src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java,v retrieving revision 1.3 diff -u -r1.3 FeatureBlock.java --- src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java 16 Feb 2010 22:24:15 -0000 1.3 +++ src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java 19 Feb 2010 18:47:13 -0000 @@ -10,16 +10,16 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.launcher; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.viewers.*; import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.internal.core.*; +import org.eclipse.pde.internal.core.PDEPreferencesManager; import org.eclipse.pde.internal.core.ifeature.*; -import org.eclipse.pde.internal.core.util.VersionUtil; import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper; import org.eclipse.pde.internal.ui.*; import org.eclipse.pde.internal.ui.shared.CachedCheckboxTreeViewer; @@ -31,12 +31,10 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; -import org.osgi.framework.Version; public class FeatureBlock { @@ -46,17 +44,16 @@ } public String getColumnText(Object obj, int index) { + String id = (String) obj; switch (index) { case COLUMN_FEATURE_NAME : - return super.getObjectText((IFeatureModel) fFeatureModelMap.get(obj), false); + return super.getObjectText(fModelProvider.getFeatureModel(id), false); case COLUMN_FEATURE_VERSION : - return (String) fFeatureVersionMap.get(obj); + return fModelProvider.getVersion(id); case COLUMN_FEATURE_LOCATION : - String featureLocation = (String) fFeatureLocationMap.get(obj); - return getLocationText(featureLocation); + return getLocationText(fModelProvider.getLocation(id)); case COLUMN_PLUGIN_RESOLUTION : - String pluginResolution = (String) fPluginResolutionMap.get(obj); - return getLocationText(pluginResolution); + return getLocationText(fModelProvider.getPluginResolution(id)); default : return ""; //$NON-NLS-1$ } @@ -76,7 +73,7 @@ } else if (source == fDefaultsButton) { handleRestoreDefaults(); } else if (source == fDefaultFeatureLocationCombo) { - handleDefaultChange(); + handleDefaultLocationChange(); } else if (source instanceof TreeColumn) { handleColumn((TreeColumn) source, 0); } @@ -90,7 +87,7 @@ for (int i = 0; i < featureModelIDs.length; i++) { requiredFeatureList.add(featureModelIDs[i]); - getFeatureDependencies((IFeatureModel) fFeatureModelMap.get(featureModelIDs[i]), requiredFeatureList); + getFeatureDependencies(fModelProvider.getFeatureModel((String) featureModelIDs[i]), requiredFeatureList); } fTree.setCheckedElements(requiredFeatureList.toArray()); } @@ -112,9 +109,8 @@ } private void addFeature(ArrayList requiredFeatureList, String id) { - IFeatureModel model; if (!requiredFeatureList.contains(id)) { - model = (IFeatureModel) fFeatureModelMap.get(id); + IFeatureModel model = fModelProvider.getFeatureModel(id); if (model != null) { requiredFeatureList.add(id); getFeatureDependencies(model, requiredFeatureList); @@ -145,7 +141,7 @@ private void handleRestoreDefaults() { fDefaultFeatureLocationCombo.setText(getLocationText(LOCATION_WORKSPACE)); fDefaultPluginResolutionCombo.setText(getLocationText(LOCATION_WORKSPACE)); - fTree.setInput(getFeatures(LOCATION_WORKSPACE)); + fModelProvider.init(LOCATION_WORKSPACE); fTree.refresh(true); } @@ -154,33 +150,26 @@ updateCounter(); } - private void handleDefaultChange() { + private void handleDefaultLocationChange() { String defaultLocation = getLocationConstant(fDefaultFeatureLocationCombo.getText()); - for (Iterator iterator = fFeatureModelMap.keySet().iterator(); iterator.hasNext();) { - String id = (String) iterator.next(); - String location = (String) fFeatureLocationMap.get(id); + fModelProvider.setDefaultFeatureLocation(defaultLocation); + String[] idArray = fModelProvider.getIDArray(); + for (int i = 0; i < idArray.length; ++i) { + String id = idArray[i]; + String location = fModelProvider.getLocation(id); if (LOCATION_DEFAULT.equalsIgnoreCase(location)) { - IFeatureModel model = null; - if (LOCATION_WORKSPACE.equalsIgnoreCase(defaultLocation)) { - model = (IFeatureModel) fWorkspaceFeatureMap.get(id); - } else { - model = (IFeatureModel) fExternalFeatureMap.get(id); - } - if (model != null) { - fFeatureModelMap.put(id, model); - fFeatureVersionMap.put(id, model.getFeature().getVersion()); - fTree.refresh(id, true); - } + fModelProvider.setModelFromLocation(id, location); + fTree.refresh(id, true); } } } } - private class LocationCellModifier implements ICellModifier { + class LocationCellModifier implements ICellModifier { public boolean canModify(Object id, String property) { if (PROPERTY_LOCATION.equalsIgnoreCase(property)) { - if (fWorkspaceFeatureMap.containsKey(id) && fExternalFeatureMap.containsKey(id)) { + if (fModelProvider.isCommon((String) id)) { return fTree.getChecked(id); } @@ -192,7 +181,7 @@ public Object getValue(Object id, String property) { if (PROPERTY_LOCATION.equalsIgnoreCase(property) || PROPERTY_RESOLUTION.equalsIgnoreCase(property)) { - String location = (String) fFeatureLocationMap.get(id); + String location = fModelProvider.getLocation((String) id); if (LOCATION_DEFAULT.equalsIgnoreCase(location)) { return new Integer(0); @@ -210,33 +199,21 @@ String id = (String) ((TreeItem) item).getData(); int comboIndex = ((Integer) value).intValue(); String location = null; - HashMap map = null; switch (comboIndex) { case 0 : location = LOCATION_DEFAULT; - if (LOCATION_WORKSPACE.equalsIgnoreCase(getLocationConstant(fDefaultFeatureLocationCombo.getText()))) { - map = fWorkspaceFeatureMap; - } else { - map = fExternalFeatureMap; - } break; case 1 : location = LOCATION_WORKSPACE; - map = fWorkspaceFeatureMap; break; case 2 : location = LOCATION_EXTERNAL; - map = fExternalFeatureMap; } if (PROPERTY_LOCATION.equalsIgnoreCase(property)) { - fFeatureLocationMap.put(id, location); - IFeatureModel newModel = (IFeatureModel) map.get(id); - fFeatureVersionMap.put(id, newModel.getFeature().getVersion()); - fFeatureModelMap.put(id, newModel); + fModelProvider.setModelFromLocation(id, location); } else if (PROPERTY_RESOLUTION.equalsIgnoreCase(property)) { - fPluginResolutionMap.put(id, location); - + fModelProvider.setPluginResolution(id, location); } else { return; // nothing to do } @@ -293,6 +270,8 @@ } + private FeatureLaunchModelProvider fModelProvider; + private static final int COLUMN_FEATURE_NAME = 0; private static final int COLUMN_FEATURE_VERSION = 1; private static final int COLUMN_FEATURE_LOCATION = 2; @@ -315,13 +294,6 @@ private Combo fDefaultFeatureLocationCombo; private Combo fDefaultPluginResolutionCombo; - private HashMap fExternalFeatureMap; - private HashMap fFeatureLocationMap; - private HashMap fPluginResolutionMap; - private HashMap fWorkspaceFeatureMap; - private HashMap fFeatureVersionMap; - private HashMap fFeatureModelMap; - private ILaunchConfiguration fLaunchConfig; private Listener fListener; private AbstractLauncherTab fTab; @@ -330,6 +302,7 @@ public FeatureBlock(PluginsTab pluginsTab) { Assert.isNotNull(pluginsTab); fTab = pluginsTab; + fModelProvider = new FeatureLaunchModelProvider(); } public void createControl(Composite parent, int span, int indent) { @@ -348,6 +321,7 @@ fDefaultFeatureLocationCombo = SWTFactory.createCombo(defaultsCombo, SWT.READ_ONLY | SWT.BORDER, 1, GridData.HORIZONTAL_ALIGN_BEGINNING, new String[] {PDEUIMessages.FeatureBlock_workspaceBefore, PDEUIMessages.FeatureBlock_externalBefore}); label = SWTFactory.createLabel(defaultsCombo, PDEUIMessages.FeatureBlock_defaultPluginResolution, 1); + label.setLayoutData(gd); fDefaultPluginResolutionCombo = SWTFactory.createCombo(defaultsCombo, SWT.READ_ONLY | SWT.BORDER, 1, GridData.HORIZONTAL_ALIGN_BEGINNING, new String[] {PDEUIMessages.FeatureBlock_workspaceBefore, PDEUIMessages.FeatureBlock_externalBefore}); fDefaultFeatureLocationCombo.addSelectionListener(fListener); @@ -395,19 +369,12 @@ fTree.getTree().setHeaderVisible(true); fTree.setLabelProvider(new FeatureTreeLabelProvider()); fTree.setContentProvider(contentProvider); - fTree.setInput(getFeatures(LOCATION_WORKSPACE)); + fTree.setInput(fModelProvider.getIDArray()); fTree.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { String id = (String) event.getElement(); if (event.getChecked() == false) { - fFeatureLocationMap.put(id, LOCATION_DEFAULT); - fPluginResolutionMap.put(id, LOCATION_DEFAULT); - IFeatureModel model = (IFeatureModel) fWorkspaceFeatureMap.get(id); - if (model == null) { - model = (IFeatureModel) fExternalFeatureMap.get(id); - } - fFeatureModelMap.put(id, model); - fFeatureVersionMap.put(id, model.getFeature().getVersion()); + fModelProvider.setModelFromLocation(id, LOCATION_DEFAULT); } fTree.refresh(id, true); fTab.updateLaunchConfigurationDialog(); @@ -428,22 +395,22 @@ } }); - TreeViewerColumn tvc = new TreeViewerColumn(fTree, column3); - tvc.setLabelProvider(new CellLabelProvider() { - public void update(ViewerCell cell) { - String id = (String) cell.getElement(); - Display display = fTree.getTree().getDisplay(); - Color gray = display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW); - Color white = display.getSystemColor(SWT.COLOR_WHITE); - if (fWorkspaceFeatureMap.containsKey(id) && fExternalFeatureMap.containsKey(id) && fTree.getChecked(id)) { - cell.setBackground(white); - } else { - cell.setBackground(gray); - } - FeatureTreeLabelProvider provider = (FeatureTreeLabelProvider) fTree.getLabelProvider(); - cell.setText(provider.getColumnText(id, COLUMN_FEATURE_LOCATION)); - } - }); + /* TreeViewerColumn tvc = new TreeViewerColumn(fTree, column3); + tvc.setLabelProvider(new CellLabelProvider() { + public void update(ViewerCell cell) { + String id = (String) cell.getElement(); + Display display = fTree.getTree().getDisplay(); + Color gray = display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW); + Color white = display.getSystemColor(SWT.COLOR_WHITE); + if (fModelProvider.isCommon(id) && fTree.getChecked(id)) { + cell.setBackground(white); + } else { + cell.setBackground(gray); + } + FeatureTreeLabelProvider provider = (FeatureTreeLabelProvider) fTree.getLabelProvider(); + cell.setText(provider.getColumnText(id, COLUMN_FEATURE_LOCATION)); + } + });*/ } private void createButtonContainer(Composite parent, int vOffset) { @@ -460,7 +427,7 @@ fAddRequiredFeaturesButton = createButton(composite, PDEUIMessages.FeatureBlock_addRequiredFeatues, SWT.PUSH); fDefaultsButton = createButton(composite, PDEUIMessages.AdvancedLauncherTab_defaults, SWT.PUSH); - fCounter = new Label(composite, SWT.NONE); + fCounter = new Label(parent, SWT.NONE); fCounter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END)); updateCounter(); } @@ -474,43 +441,10 @@ return button; } - private Object getFeatures(String defaultLocation) { - FeatureModelManager fmm = new FeatureModelManager(); - - fWorkspaceFeatureMap = new HashMap(); - fExternalFeatureMap = new HashMap(); - fFeatureLocationMap = new HashMap(); - fPluginResolutionMap = new HashMap(); - fFeatureVersionMap = new HashMap(); - fFeatureModelMap = new HashMap(); - - IFeatureModel[] workspaceModels = fmm.getWorkspaceModels(); - for (int i = 0; i < workspaceModels.length; i++) { - String id = workspaceModels[i].getFeature().getId(); - fWorkspaceFeatureMap.put(id, workspaceModels[i]); - fFeatureLocationMap.put(id, LOCATION_DEFAULT); - fPluginResolutionMap.put(id, LOCATION_DEFAULT); - fFeatureVersionMap.put(id, workspaceModels[i].getFeature().getVersion()); - fFeatureModelMap.put(id, workspaceModels[i]); - } - fmm.shutdown(); - - ExternalFeatureModelManager efmm = new ExternalFeatureModelManager(); - efmm.startup(); - IFeatureModel[] externalModels = efmm.getModels(); - for (int i = 0; i < externalModels.length; i++) { - String id = externalModels[i].getFeature().getId(); - fExternalFeatureMap.put(id, externalModels[i]); - if (LOCATION_EXTERNAL.equalsIgnoreCase(defaultLocation) || (LOCATION_WORKSPACE.equalsIgnoreCase(defaultLocation) && !fWorkspaceFeatureMap.containsKey(id))) { - fFeatureLocationMap.put(id, LOCATION_DEFAULT); - fPluginResolutionMap.put(id, LOCATION_DEFAULT); - fFeatureVersionMap.put(id, externalModels[i].getFeature().getVersion()); - fFeatureModelMap.put(id, externalModels[i]); - } - } - efmm.shutdown(); - return fFeatureModelMap.keySet().toArray(new String[fFeatureModelMap.size()]); - } + /* private Object getFeatures(String defaultLocation) { + fModelProvider = new FeatureLaunchModelProvider(); + return fModelProvider.getIDArray(); + }*/ private String getLocationConstant(String value) { if (PDEUIMessages.FeatureBlock_workspaceBefore.equalsIgnoreCase(value)) { @@ -532,23 +466,6 @@ return ""; //$NON-NLS-1$ } - private IFeatureModel getFeatureModel(String id) { - String version = (String) fFeatureVersionMap.get(id); - Version featureVersion = Version.parseVersion(version); - IFeatureModel model = (IFeatureModel) fExternalFeatureMap.get(id); - Version modelVersion = Version.parseVersion(model.getFeature().getVersion()); - if (VersionUtil.isEquivalentTo(featureVersion, modelVersion)) { - return model; - } - - model = (IFeatureModel) fWorkspaceFeatureMap.get(id); - modelVersion = Version.parseVersion(model.getFeature().getVersion()); - if (VersionUtil.isEquivalentTo(featureVersion, modelVersion)) { - return model; - } - return null; - } - public void initialize() throws CoreException { initializeFrom(fLaunchConfig); } @@ -560,17 +477,13 @@ } fLaunchConfig = config; - String defaultLocation = config.getAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, LOCATION_WORKSPACE); - fDefaultFeatureLocationCombo.setText(getLocationText(defaultLocation)); - String pluginResolution = config.getAttribute(IPDELauncherConstants.FEATURE_PLUGIN_RESOLUTION, LOCATION_WORKSPACE); - fDefaultPluginResolutionCombo.setText(getLocationText(pluginResolution)); - fTree.setInput(getFeatures(defaultLocation)); - - ArrayList selectedFeatureList = BundleLauncherHelper.getFeatureMaps(config, fFeatureVersionMap, fFeatureLocationMap, fPluginResolutionMap); + ArrayList selectedFeatureList = fModelProvider.parseConfig(config); + fDefaultFeatureLocationCombo.setText(getLocationText(fModelProvider.getDefaultFeatureLocation())); + fDefaultPluginResolutionCombo.setText(getLocationText(fModelProvider.getDefaultPluginResolution())); + fModelProvider.init(fModelProvider.getDefaultFeatureLocation()); for (int index = 0; index < selectedFeatureList.size(); index++) { String id = (String) selectedFeatureList.get(index); - fFeatureModelMap.put(id, getFeatureModel(id)); fTree.setChecked(id, true); } @@ -603,17 +516,16 @@ Arrays.sort(selectedFeatureModels); // So that Tab is not marked dirty due to Sorting changes for (int i = 0; i < selectedFeatureModels.length; i++) { String id = (String) selectedFeatureModels[i]; - String location = (String) fFeatureLocationMap.get(id); - String resolution = (String) fPluginResolutionMap.get(id); - String version = (String) fFeatureVersionMap.get(id); - String value = BundleLauncherHelper.writeFeatureEntry(id, version, location, resolution); + String location = fModelProvider.getLocation(id); + String resolution = fModelProvider.getPluginResolution(id); + + String value = BundleLauncherHelper.writeFeatureEntry(id, location, resolution); featuresEntry.append(value); } } config.setAttribute(IPDELauncherConstants.SELECTED_FEATURES, featuresEntry.length() == 0 ? (String) null : featuresEntry.toString()); config.setAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, getLocationConstant(fDefaultFeatureLocationCombo.getText())); config.setAttribute(IPDELauncherConstants.FEATURE_PLUGIN_RESOLUTION, getLocationConstant(fDefaultPluginResolutionCombo.getText())); - } private void saveSortOrder() { @@ -634,7 +546,7 @@ private void updateCounter() { if (fCounter != null) { int checked = fTree.getCheckedElements().length; - int total = fFeatureLocationMap.keySet().size(); + int total = fModelProvider.size(); fCounter.setText(NLS.bind(PDEUIMessages.AbstractPluginBlock_counter, new Integer(checked), new Integer(total))); } } Index: src/org/eclipse/pde/internal/ui/launcher/FeatureLaunchModelProvider.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/FeatureLaunchModelProvider.java diff -N src/org/eclipse/pde/internal/ui/launcher/FeatureLaunchModelProvider.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/launcher/FeatureLaunchModelProvider.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2010 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.launcher; + +import java.util.ArrayList; +import java.util.HashMap; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.pde.internal.core.ExternalFeatureModelManager; +import org.eclipse.pde.internal.core.FeatureModelManager; +import org.eclipse.pde.internal.core.ifeature.IFeatureModel; +import org.eclipse.pde.launching.IPDELauncherConstants; + +public class FeatureLaunchModelProvider { + + private static final String LOCATION_DEFAULT = "Default"; //$NON-NLS-1$ + private static final String LOCATION_EXTERNAL = "External"; //$NON-NLS-1$ + private static final String LOCATION_WORKSPACE = "Workspace"; //$NON-NLS-1$ + + private class FeatureLaunchModel { + public IFeatureModel FeatureModel; + public String Location; + public String PluginResolution; + + public FeatureLaunchModel(IFeatureModel model) { + FeatureModel = model; + Location = LOCATION_DEFAULT; + PluginResolution = LOCATION_DEFAULT; + } + + public String getVersion() { + return FeatureModel.getFeature().getVersion(); + } + + } + + private HashMap fFeatureModels; + private HashMap fWorkspaceFeatureMap; + private HashMap fExternalFeatureMap; + private String fDefaultFeatureLocation; + private String fDefaultPluginResolution; + + public FeatureLaunchModelProvider() { + fFeatureModels = new HashMap(); + fWorkspaceFeatureMap = new HashMap(); + fExternalFeatureMap = new HashMap(); + fDefaultFeatureLocation = LOCATION_WORKSPACE; + fDefaultPluginResolution = LOCATION_WORKSPACE; + + init(LOCATION_WORKSPACE); + } + + public void init(String defaultLocation) { + FeatureModelManager fmm = new FeatureModelManager(); + IFeatureModel[] workspaceModels = fmm.getWorkspaceModels(); + for (int i = 0; i < workspaceModels.length; i++) { + String id = workspaceModels[i].getFeature().getId(); + fWorkspaceFeatureMap.put(id, workspaceModels[i]); + put(id, workspaceModels[i]); + } + fmm.shutdown(); + + ExternalFeatureModelManager efmm = new ExternalFeatureModelManager(); + efmm.startup(); + IFeatureModel[] externalModels = efmm.getModels(); + for (int i = 0; i < externalModels.length; i++) { + String id = externalModels[i].getFeature().getId(); + fExternalFeatureMap.put(id, externalModels[i]); + if (LOCATION_EXTERNAL.equalsIgnoreCase(defaultLocation) || (LOCATION_WORKSPACE.equalsIgnoreCase(defaultLocation) && !fWorkspaceFeatureMap.containsKey(id))) { + put(id, externalModels[i]); + } + } + efmm.shutdown(); + } + + private void put(String id, IFeatureModel model) { + fFeatureModels.put(id, new FeatureLaunchModel(model)); + } + + public int size() { + return fFeatureModels.size(); + } + + public boolean isCommon(String id) { + if (fWorkspaceFeatureMap.containsKey(id) && fExternalFeatureMap.containsKey(id)) { + return true; + } + return false; + } + + public String getVersion(String id) { + FeatureLaunchModel model = (FeatureLaunchModel) fFeatureModels.get(id); + if (model != null) + return model.getVersion(); + return null; + } + + public String getLocation(String id) { + FeatureLaunchModel model = (FeatureLaunchModel) fFeatureModels.get(id); + if (model != null) + return model.Location; + return null; + } + + public String getPluginResolution(String id) { + FeatureLaunchModel model = (FeatureLaunchModel) fFeatureModels.get(id); + if (model != null) + return model.PluginResolution; + return null; + } + + public String[] getIDArray() { + return (String[]) fFeatureModels.keySet().toArray(new String[size()]); + } + + public IFeatureModel getFeatureModel(String id) { + FeatureLaunchModel model = getFeatureLaunchModel(id); + if (model != null) + return model.FeatureModel; + return null; + } + + private FeatureLaunchModel getFeatureLaunchModel(String id) { + return (FeatureLaunchModel) fFeatureModels.get(id); + } + + public void setModel(String id, IFeatureModel featureModel) { + FeatureLaunchModel model = getFeatureLaunchModel(id); + if (model != null) + model.FeatureModel = featureModel; + } + + public void setLocation(String id, String location) { + FeatureLaunchModel model = getFeatureLaunchModel(id); + if (model != null) + model.Location = location; + } + + public void setModelFromLocation(String id, String location) { + HashMap map = null; + String modelLocation = location; + if (LOCATION_DEFAULT.equalsIgnoreCase(location)) { + location = fDefaultFeatureLocation; + } + if (LOCATION_WORKSPACE.equalsIgnoreCase(location)) { + map = fWorkspaceFeatureMap; + } else if (LOCATION_EXTERNAL.equalsIgnoreCase(location)) { + map = fExternalFeatureMap; + } + + if (map != null) { + IFeatureModel model = (IFeatureModel) map.get(id); + if (model != null) { + setModel(id, model); + setLocation(id, modelLocation); + } + } + } + + public void setPluginResolution(String id, String location) { + FeatureLaunchModel model = getFeatureLaunchModel(id); + if (model != null) + model.PluginResolution = location; + } + + public String getDefaultFeatureLocation() { + return fDefaultFeatureLocation; + } + + public void setDefaultFeatureLocation(String location) { + if (LOCATION_WORKSPACE.equalsIgnoreCase(location) || LOCATION_EXTERNAL.equalsIgnoreCase(location)) { + fDefaultFeatureLocation = location; + } + } + + public String getDefaultPluginResolution() { + return fDefaultPluginResolution; + } + + public void setDefaultPluginResolution(String location) { + if (LOCATION_WORKSPACE.equalsIgnoreCase(location) || LOCATION_EXTERNAL.equalsIgnoreCase(location)) { + fDefaultPluginResolution = location; + } + } + + public ArrayList parseConfig(ILaunchConfiguration config) throws CoreException { + ArrayList selectedFeatureList = new ArrayList(); + String value = config.getAttribute(IPDELauncherConstants.SELECTED_FEATURES, ""); //$NON-NLS-1$ + setDefaultFeatureLocation(config.getAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, LOCATION_WORKSPACE)); + setDefaultPluginResolution(config.getAttribute(IPDELauncherConstants.FEATURE_PLUGIN_RESOLUTION, LOCATION_WORKSPACE)); + + if (value.length() != 0) { + String[] features = value.split(";"); //$NON-NLS-1$ + if (features != null && features.length > 0) { + for (int i = 0; i < features.length; i++) { + String[] attributes = features[i].split(":"); //$NON-NLS-1$ + String id = attributes[0]; + selectedFeatureList.add(id); + setModelFromLocation(id, attributes[1]); + setPluginResolution(id, attributes[2]); + } + } + } + return selectedFeatureList; + } +}