### 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.5 diff -u -r1.5 BundleLauncherHelper.java --- src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java 19 Feb 2010 19:43:16 -0000 1.5 +++ src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java 19 Feb 2010 22:37:29 -0000 @@ -62,66 +62,108 @@ } return map; } - } - if (configuration.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, true)) { - //TODO - FeatureModelManager featureModelMgr = new FeatureModelManager(); - ExternalFeatureModelManager extFeatureModelMgr = new ExternalFeatureModelManager(); - - IFeatureModel[] workspaceModels = featureModelMgr.getWorkspaceModels(); - HashMap wrkspcFeaturesMap = new HashMap(); - for (int i = 0; i < workspaceModels.length; i++) { - wrkspcFeaturesMap.put(workspaceModels[i].getFeature().getId(), workspaceModels[i].getFeature()); - } - - extFeatureModelMgr.startup(); - IFeatureModel[] externalModels = extFeatureModelMgr.getModels(); - HashMap extrnlFeaturesMap = new HashMap(); - for (int i = 0; i < externalModels.length; i++) { - extrnlFeaturesMap.put(externalModels[i].getFeature().getId(), externalModels[i].getFeature()); - } - extFeatureModelMgr.shutdown(); - - HashMap featureVersionMap = new HashMap(); - HashMap featureLocationMap = new HashMap(); - HashMap pluginResolutionMap = new HashMap(); - getFeatureMaps(configuration, featureVersionMap, featureLocationMap, pluginResolutionMap); - String defaultLocation = configuration.getAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, LOCATION_WORKSPACE); - PluginModelManager pluginModelMgr = new PluginModelManager(); - for (Iterator iterator = featureLocationMap.keySet().iterator(); iterator.hasNext();) { - String id = (String) iterator.next(); - String location = (String) featureLocationMap.get(id); - IFeature feature = null; - if (LOCATION_DEFAULT.equalsIgnoreCase(location)) { - location = defaultLocation; - } - if (LOCATION_WORKSPACE.equalsIgnoreCase(location)) { - feature = (IFeature) wrkspcFeaturesMap.get(id); - } else if (LOCATION_EXTERNAL.equalsIgnoreCase(location)) { - feature = (IFeature) extrnlFeaturesMap.get(id); + if (configuration.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, true)) { + //TODO + String value = configuration.getAttribute(IPDELauncherConstants.SELECTED_FEATURES, ""); //$NON-NLS-1$ + String defaultLocation = configuration.getAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, LOCATION_WORKSPACE); + String defaultPluginResolution = configuration.getAttribute(IPDELauncherConstants.FEATURE_PLUGIN_RESOLUTION, LOCATION_WORKSPACE); + + HashMap featureLocationMap = new HashMap(); + HashMap featurePluginResolutionMap = new HashMap(); + 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]; + featureLocationMap.put(id, attributes[1]); + featurePluginResolutionMap.put(id, attributes[2]); + } + } } - if (feature == null || !feature.getVersion().equalsIgnoreCase((String) featureVersionMap.get(id))) - continue; - IFeaturePlugin[] featurePlugins = feature.getPlugins(); - for (int i = 0; i < featurePlugins.length; i++) { - IPluginModelBase model = pluginModelMgr.findModel(featurePlugins[i].getId()); - if (model == null) + + HashMap workspaceFeatureMap = new HashMap(); + HashMap externalFeatureMap = new HashMap(); + + FeatureModelManager fmm = new FeatureModelManager(); + IFeatureModel[] workspaceFeatureModels = fmm.getWorkspaceModels(); + for (int i = 0; i < workspaceFeatureModels.length; i++) { + String id = workspaceFeatureModels[i].getFeature().getId(); + workspaceFeatureMap.put(id, workspaceFeatureModels[i]); + } + fmm.shutdown(); + + ExternalFeatureModelManager efmm = new ExternalFeatureModelManager(); + efmm.startup(); + IFeatureModel[] externalFeatureModels = efmm.getModels(); + for (int i = 0; i < externalFeatureModels.length; i++) { + String id = externalFeatureModels[i].getFeature().getId(); + externalFeatureMap.put(id, externalFeatureModels[i]); + } + efmm.shutdown(); + + PluginModelManager pluginModelMgr = new PluginModelManager(); + for (Iterator iterator = featureLocationMap.keySet().iterator(); iterator.hasNext();) { + String id = (String) iterator.next(); + String location = (String) featureLocationMap.get(id); + IFeatureModel featureModel = null; + if (LOCATION_DEFAULT.equalsIgnoreCase(location)) { + location = defaultLocation; + } + if (LOCATION_WORKSPACE.equalsIgnoreCase(location)) { + featureModel = (IFeatureModel) workspaceFeatureMap.get(id); + } else if (LOCATION_EXTERNAL.equalsIgnoreCase(location)) { + featureModel = (IFeatureModel) externalFeatureMap.get(id); + } + if (featureModel == null) { continue; - addBundleToMap(map, model, "default:default"); //$NON-NLS-1$ - } - IFeatureImport[] featureImports = feature.getImports(); - for (int i = 0; i < featureImports.length; i++) { - if (featureImports[i].getType() == IFeatureImport.PLUGIN) { - IPluginModelBase model = pluginModelMgr.findModel(featureImports[i].getId()); - if (model == null) + } + IFeaturePlugin[] featurePlugins = featureModel.getFeature().getPlugins(); + String pluginResolution = (String) featurePluginResolutionMap.get(id); + if (LOCATION_DEFAULT.equalsIgnoreCase(pluginResolution)) { + pluginResolution = defaultPluginResolution; + } + + for (int i = 0; i < featurePlugins.length; i++) { + ModelEntry modelEntry = pluginModelMgr.findEntry(featurePlugins[i].getId()); + if (modelEntry == null) { + continue; + } + IPluginModelBase model = null; + if (LOCATION_WORKSPACE.equalsIgnoreCase(pluginResolution)) { + model = getBestCandidateModel(modelEntry.getWorkspaceModels()); + } else if (LOCATION_EXTERNAL.equalsIgnoreCase(pluginResolution)) { + model = getBestCandidateModel(modelEntry.getExternalModels()); + } + if (model == null || map.containsKey(model)) continue; addBundleToMap(map, model, "default:default"); //$NON-NLS-1$ } + + IFeatureImport[] featureImports = featureModel.getFeature().getImports(); + for (int i = 0; i < featureImports.length; i++) { + if (featureImports[i].getType() == IFeatureImport.PLUGIN) { + ModelEntry modelEntry = pluginModelMgr.findEntry(featureImports[i].getId()); + if (modelEntry == null) { + continue; + } + IPluginModelBase model = null; + if (LOCATION_WORKSPACE.equalsIgnoreCase(pluginResolution)) { + model = getBestCandidateModel(modelEntry.getWorkspaceModels()); + } else if (LOCATION_EXTERNAL.equalsIgnoreCase(pluginResolution)) { + model = getBestCandidateModel(modelEntry.getExternalModels()); + } + + if (model == null || map.containsKey(model)) + continue; + addBundleToMap(map, model, "default:default"); //$NON-NLS-1$ + } + } } - } - return map; + return map; + } } String workspace = osgi == false ? IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.WORKSPACE_BUNDLES; @@ -131,6 +173,36 @@ return map; } + private static IPluginModelBase getBestCandidateModel(IPluginModelBase[] models) { + IPluginModelBase model = null; + for (int i = 0; i < models.length; i++) { + if (models[i].getBundleDescription() == null) + continue; + + if (model == null) { + model = models[i]; + continue; + } + + if (!model.isEnabled() && models[i].isEnabled()) { + model = models[i]; + continue; + } + + BundleDescription current = model.getBundleDescription(); + BundleDescription candidate = models[i].getBundleDescription(); + if (!current.isResolved() && candidate.isResolved()) { + model = models[i]; + continue; + } + + if (current.getVersion().compareTo(candidate.getVersion()) < 0) { + model = models[i]; + } + } + return model; + } + public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration, boolean osgi) throws CoreException { Map map = getMergedBundleMap(configuration, osgi); return (IPluginModelBase[]) map.keySet().toArray(new IPluginModelBase[map.size()]); #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.4 diff -u -r1.4 FeatureBlock.java --- src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java 19 Feb 2010 19:26:23 -0000 1.4 +++ src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java 19 Feb 2010 22:37:32 -0000 @@ -181,22 +181,24 @@ } } else if (PROPERTY_RESOLUTION.equalsIgnoreCase(property)) { - return true; + return fTree.getChecked(id); } return false; } public Object getValue(Object id, String property) { - if (PROPERTY_LOCATION.equalsIgnoreCase(property) || PROPERTY_RESOLUTION.equalsIgnoreCase(property)) { - String location = fModelProvider.getLocation((String) id); - - if (LOCATION_DEFAULT.equalsIgnoreCase(location)) { - return new Integer(0); - } else if (LOCATION_WORKSPACE.equalsIgnoreCase(location)) { - return new Integer(1); - } else if (LOCATION_EXTERNAL.equalsIgnoreCase(location)) { - return new Integer(2); - } + String location = ""; //$NON-NLS-1$ + if (PROPERTY_LOCATION.equalsIgnoreCase(property)) { + location = fModelProvider.getLocation((String) id); + } else if (PROPERTY_RESOLUTION.equalsIgnoreCase(property)) { + location = fModelProvider.getPluginResolution(location); + } + if (LOCATION_DEFAULT.equalsIgnoreCase(location)) { + return new Integer(0); + } else if (LOCATION_WORKSPACE.equalsIgnoreCase(location)) { + return new Integer(1); + } else if (LOCATION_EXTERNAL.equalsIgnoreCase(location)) { + return new Integer(2); } return new Integer(0); @@ -389,7 +391,9 @@ }); String[] items = new String[] {PDEUIMessages.FeatureBlock_default, PDEUIMessages.FeatureBlock_workspaceBefore, PDEUIMessages.FeatureBlock_externalBefore}; - fTree.setCellEditors(new CellEditor[] {null, null, new ComboBoxCellEditor(fTree.getTree(), items), new ComboBoxCellEditor(fTree.getTree(), items)}); + ComboBoxCellEditor cellEditor = new ComboBoxCellEditor(fTree.getTree(), items); + cellEditor.getControl().pack(); + fTree.setCellEditors(new CellEditor[] {null, null, cellEditor, cellEditor}); fTree.setColumnProperties(new String[] {null, null, PROPERTY_LOCATION, PROPERTY_RESOLUTION}); fTree.setCellModifier(new LocationCellModifier()); fTree.addDoubleClickListener(new IDoubleClickListener() { @@ -398,9 +402,15 @@ if (selection == null || !(selection instanceof IStructuredSelection)) { return; } - fTree.editElement(((IStructuredSelection) selection).getFirstElement(), 2); + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (fTree.getChecked(element) == true) { + fTree.editElement(element, COLUMN_FEATURE_LOCATION); + } else { + fTree.setChecked(element, true); + } } }); + fTree.setAllChecked(true); /* TreeViewerColumn tvc = new TreeViewerColumn(fTree, column3); tvc.setLabelProvider(new CellLabelProvider() { @@ -485,14 +495,17 @@ } fLaunchConfig = config; + fModelProvider.init(fModelProvider.getDefaultFeatureLocation()); 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); - fTree.setChecked(id, true); + if (selectedFeatureList.size() > 0) { + fTree.setAllChecked(false); + for (int index = 0; index < selectedFeatureList.size(); index++) { + String id = (String) selectedFeatureList.get(index); + fTree.setChecked(id, true); + } } // If the workspace plug-in state has changed (project closed, etc.) the launch config needs to be updated without making the tab dirty