View | Details | Raw Unified | Return to bug 284885 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/launching/launcher/BundleLauncherHelper.java (-52 / +124 lines)
Lines 62-127 Link Here
62
				}
62
				}
63
				return map;
63
				return map;
64
			}
64
			}
65
		}
66
65
67
		if (configuration.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, true)) {
66
			if (configuration.getAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, true)) {
68
			//TODO
67
				//TODO
69
			FeatureModelManager featureModelMgr = new FeatureModelManager();
68
				String value = configuration.getAttribute(IPDELauncherConstants.SELECTED_FEATURES, ""); //$NON-NLS-1$
70
			ExternalFeatureModelManager extFeatureModelMgr = new ExternalFeatureModelManager();
69
				String defaultLocation = configuration.getAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, LOCATION_WORKSPACE);
71
70
				String defaultPluginResolution = configuration.getAttribute(IPDELauncherConstants.FEATURE_PLUGIN_RESOLUTION, LOCATION_WORKSPACE);
72
			IFeatureModel[] workspaceModels = featureModelMgr.getWorkspaceModels();
71
73
			HashMap wrkspcFeaturesMap = new HashMap();
72
				HashMap featureLocationMap = new HashMap();
74
			for (int i = 0; i < workspaceModels.length; i++) {
73
				HashMap featurePluginResolutionMap = new HashMap();
75
				wrkspcFeaturesMap.put(workspaceModels[i].getFeature().getId(), workspaceModels[i].getFeature());
74
				if (value.length() != 0) {
76
			}
75
					String[] features = value.split(";"); //$NON-NLS-1$
77
76
					if (features != null && features.length > 0) {
78
			extFeatureModelMgr.startup();
77
						for (int i = 0; i < features.length; i++) {
79
			IFeatureModel[] externalModels = extFeatureModelMgr.getModels();
78
							String[] attributes = features[i].split(":"); //$NON-NLS-1$
80
			HashMap extrnlFeaturesMap = new HashMap();
79
							String id = attributes[0];
81
			for (int i = 0; i < externalModels.length; i++) {
80
							featureLocationMap.put(id, attributes[1]);
82
				extrnlFeaturesMap.put(externalModels[i].getFeature().getId(), externalModels[i].getFeature());
81
							featurePluginResolutionMap.put(id, attributes[2]);
83
			}
82
						}
84
			extFeatureModelMgr.shutdown();
83
					}
85
86
			HashMap featureVersionMap = new HashMap();
87
			HashMap featureLocationMap = new HashMap();
88
			HashMap pluginResolutionMap = new HashMap();
89
			getFeatureMaps(configuration, featureVersionMap, featureLocationMap, pluginResolutionMap);
90
			String defaultLocation = configuration.getAttribute(IPDELauncherConstants.FEATURE_DEFAULT_LOCATION, LOCATION_WORKSPACE);
91
			PluginModelManager pluginModelMgr = new PluginModelManager();
92
			for (Iterator iterator = featureLocationMap.keySet().iterator(); iterator.hasNext();) {
93
				String id = (String) iterator.next();
94
				String location = (String) featureLocationMap.get(id);
95
				IFeature feature = null;
96
				if (LOCATION_DEFAULT.equalsIgnoreCase(location)) {
97
					location = defaultLocation;
98
				}
99
				if (LOCATION_WORKSPACE.equalsIgnoreCase(location)) {
100
					feature = (IFeature) wrkspcFeaturesMap.get(id);
101
				} else if (LOCATION_EXTERNAL.equalsIgnoreCase(location)) {
102
					feature = (IFeature) extrnlFeaturesMap.get(id);
103
				}
84
				}
104
				if (feature == null || !feature.getVersion().equalsIgnoreCase((String) featureVersionMap.get(id)))
85
105
					continue;
86
				HashMap workspaceFeatureMap = new HashMap();
106
				IFeaturePlugin[] featurePlugins = feature.getPlugins();
87
				HashMap externalFeatureMap = new HashMap();
107
				for (int i = 0; i < featurePlugins.length; i++) {
88
108
					IPluginModelBase model = pluginModelMgr.findModel(featurePlugins[i].getId());
89
				FeatureModelManager fmm = new FeatureModelManager();
109
					if (model == null)
90
				IFeatureModel[] workspaceFeatureModels = fmm.getWorkspaceModels();
91
				for (int i = 0; i < workspaceFeatureModels.length; i++) {
92
					String id = workspaceFeatureModels[i].getFeature().getId();
93
					workspaceFeatureMap.put(id, workspaceFeatureModels[i]);
94
				}
95
				fmm.shutdown();
96
97
				ExternalFeatureModelManager efmm = new ExternalFeatureModelManager();
98
				efmm.startup();
99
				IFeatureModel[] externalFeatureModels = efmm.getModels();
100
				for (int i = 0; i < externalFeatureModels.length; i++) {
101
					String id = externalFeatureModels[i].getFeature().getId();
102
					externalFeatureMap.put(id, externalFeatureModels[i]);
103
				}
104
				efmm.shutdown();
105
106
				PluginModelManager pluginModelMgr = new PluginModelManager();
107
				for (Iterator iterator = featureLocationMap.keySet().iterator(); iterator.hasNext();) {
108
					String id = (String) iterator.next();
109
					String location = (String) featureLocationMap.get(id);
110
					IFeatureModel featureModel = null;
111
					if (LOCATION_DEFAULT.equalsIgnoreCase(location)) {
112
						location = defaultLocation;
113
					}
114
					if (LOCATION_WORKSPACE.equalsIgnoreCase(location)) {
115
						featureModel = (IFeatureModel) workspaceFeatureMap.get(id);
116
					} else if (LOCATION_EXTERNAL.equalsIgnoreCase(location)) {
117
						featureModel = (IFeatureModel) externalFeatureMap.get(id);
118
					}
119
					if (featureModel == null) {
110
						continue;
120
						continue;
111
					addBundleToMap(map, model, "default:default"); //$NON-NLS-1$
121
					}
112
				}
122
					IFeaturePlugin[] featurePlugins = featureModel.getFeature().getPlugins();
113
				IFeatureImport[] featureImports = feature.getImports();
123
					String pluginResolution = (String) featurePluginResolutionMap.get(id);
114
				for (int i = 0; i < featureImports.length; i++) {
124
					if (LOCATION_DEFAULT.equalsIgnoreCase(pluginResolution)) {
115
					if (featureImports[i].getType() == IFeatureImport.PLUGIN) {
125
						pluginResolution = defaultPluginResolution;
116
						IPluginModelBase model = pluginModelMgr.findModel(featureImports[i].getId());
126
					}
117
						if (model == null)
127
128
					for (int i = 0; i < featurePlugins.length; i++) {
129
						ModelEntry modelEntry = pluginModelMgr.findEntry(featurePlugins[i].getId());
130
						if (modelEntry == null) {
131
							continue;
132
						}
133
						IPluginModelBase model = null;
134
						if (LOCATION_WORKSPACE.equalsIgnoreCase(pluginResolution)) {
135
							model = getBestCandidateModel(modelEntry.getWorkspaceModels());
136
						} else if (LOCATION_EXTERNAL.equalsIgnoreCase(pluginResolution)) {
137
							model = getBestCandidateModel(modelEntry.getExternalModels());
138
						}
139
						if (model == null || map.containsKey(model))
118
							continue;
140
							continue;
119
						addBundleToMap(map, model, "default:default"); //$NON-NLS-1$
141
						addBundleToMap(map, model, "default:default"); //$NON-NLS-1$
120
					}
142
					}
143
144
					IFeatureImport[] featureImports = featureModel.getFeature().getImports();
145
					for (int i = 0; i < featureImports.length; i++) {
146
						if (featureImports[i].getType() == IFeatureImport.PLUGIN) {
147
							ModelEntry modelEntry = pluginModelMgr.findEntry(featureImports[i].getId());
148
							if (modelEntry == null) {
149
								continue;
150
							}
151
							IPluginModelBase model = null;
152
							if (LOCATION_WORKSPACE.equalsIgnoreCase(pluginResolution)) {
153
								model = getBestCandidateModel(modelEntry.getWorkspaceModels());
154
							} else if (LOCATION_EXTERNAL.equalsIgnoreCase(pluginResolution)) {
155
								model = getBestCandidateModel(modelEntry.getExternalModels());
156
							}
157
158
							if (model == null || map.containsKey(model))
159
								continue;
160
							addBundleToMap(map, model, "default:default"); //$NON-NLS-1$
161
						}
162
					}
121
				}
163
				}
122
			}
123
164
124
			return map;
165
				return map;
166
			}
125
		}
167
		}
126
168
127
		String workspace = osgi == false ? IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.WORKSPACE_BUNDLES;
169
		String workspace = osgi == false ? IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS : IPDELauncherConstants.WORKSPACE_BUNDLES;
Lines 131-136 Link Here
131
		return map;
173
		return map;
132
	}
174
	}
133
175
176
	private static IPluginModelBase getBestCandidateModel(IPluginModelBase[] models) {
177
		IPluginModelBase model = null;
178
		for (int i = 0; i < models.length; i++) {
179
			if (models[i].getBundleDescription() == null)
180
				continue;
181
182
			if (model == null) {
183
				model = models[i];
184
				continue;
185
			}
186
187
			if (!model.isEnabled() && models[i].isEnabled()) {
188
				model = models[i];
189
				continue;
190
			}
191
192
			BundleDescription current = model.getBundleDescription();
193
			BundleDescription candidate = models[i].getBundleDescription();
194
			if (!current.isResolved() && candidate.isResolved()) {
195
				model = models[i];
196
				continue;
197
			}
198
199
			if (current.getVersion().compareTo(candidate.getVersion()) < 0) {
200
				model = models[i];
201
			}
202
		}
203
		return model;
204
	}
205
134
	public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
206
	public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration, boolean osgi) throws CoreException {
135
		Map map = getMergedBundleMap(configuration, osgi);
207
		Map map = getMergedBundleMap(configuration, osgi);
136
		return (IPluginModelBase[]) map.keySet().toArray(new IPluginModelBase[map.size()]);
208
		return (IPluginModelBase[]) map.keySet().toArray(new IPluginModelBase[map.size()]);
(-)src/org/eclipse/pde/internal/ui/launcher/FeatureBlock.java (-18 / +31 lines)
Lines 181-202 Link Here
181
				}
181
				}
182
182
183
			} else if (PROPERTY_RESOLUTION.equalsIgnoreCase(property)) {
183
			} else if (PROPERTY_RESOLUTION.equalsIgnoreCase(property)) {
184
				return true;
184
				return fTree.getChecked(id);
185
			}
185
			}
186
			return false;
186
			return false;
187
		}
187
		}
188
188
189
		public Object getValue(Object id, String property) {
189
		public Object getValue(Object id, String property) {
190
			if (PROPERTY_LOCATION.equalsIgnoreCase(property) || PROPERTY_RESOLUTION.equalsIgnoreCase(property)) {
190
			String location = ""; //$NON-NLS-1$
191
				String location = fModelProvider.getLocation((String) id);
191
			if (PROPERTY_LOCATION.equalsIgnoreCase(property)) {
192
192
				location = fModelProvider.getLocation((String) id);
193
				if (LOCATION_DEFAULT.equalsIgnoreCase(location)) {
193
			} else if (PROPERTY_RESOLUTION.equalsIgnoreCase(property)) {
194
					return new Integer(0);
194
				location = fModelProvider.getPluginResolution(location);
195
				} else if (LOCATION_WORKSPACE.equalsIgnoreCase(location)) {
195
			}
196
					return new Integer(1);
196
			if (LOCATION_DEFAULT.equalsIgnoreCase(location)) {
197
				} else if (LOCATION_EXTERNAL.equalsIgnoreCase(location)) {
197
				return new Integer(0);
198
					return new Integer(2);
198
			} else if (LOCATION_WORKSPACE.equalsIgnoreCase(location)) {
199
				}
199
				return new Integer(1);
200
			} else if (LOCATION_EXTERNAL.equalsIgnoreCase(location)) {
201
				return new Integer(2);
200
			}
202
			}
201
203
202
			return new Integer(0);
204
			return new Integer(0);
Lines 389-395 Link Here
389
		});
391
		});
390
392
391
		String[] items = new String[] {PDEUIMessages.FeatureBlock_default, PDEUIMessages.FeatureBlock_workspaceBefore, PDEUIMessages.FeatureBlock_externalBefore};
393
		String[] items = new String[] {PDEUIMessages.FeatureBlock_default, PDEUIMessages.FeatureBlock_workspaceBefore, PDEUIMessages.FeatureBlock_externalBefore};
392
		fTree.setCellEditors(new CellEditor[] {null, null, new ComboBoxCellEditor(fTree.getTree(), items), new ComboBoxCellEditor(fTree.getTree(), items)});
394
		ComboBoxCellEditor cellEditor = new ComboBoxCellEditor(fTree.getTree(), items);
395
		cellEditor.getControl().pack();
396
		fTree.setCellEditors(new CellEditor[] {null, null, cellEditor, cellEditor});
393
		fTree.setColumnProperties(new String[] {null, null, PROPERTY_LOCATION, PROPERTY_RESOLUTION});
397
		fTree.setColumnProperties(new String[] {null, null, PROPERTY_LOCATION, PROPERTY_RESOLUTION});
394
		fTree.setCellModifier(new LocationCellModifier());
398
		fTree.setCellModifier(new LocationCellModifier());
395
		fTree.addDoubleClickListener(new IDoubleClickListener() {
399
		fTree.addDoubleClickListener(new IDoubleClickListener() {
Lines 398-406 Link Here
398
				if (selection == null || !(selection instanceof IStructuredSelection)) {
402
				if (selection == null || !(selection instanceof IStructuredSelection)) {
399
					return;
403
					return;
400
				}
404
				}
401
				fTree.editElement(((IStructuredSelection) selection).getFirstElement(), 2);
405
				Object element = ((IStructuredSelection) selection).getFirstElement();
406
				if (fTree.getChecked(element) == true) {
407
					fTree.editElement(element, COLUMN_FEATURE_LOCATION);
408
				} else {
409
					fTree.setChecked(element, true);
410
				}
402
			}
411
			}
403
		});
412
		});
413
		fTree.setAllChecked(true);
404
414
405
		/*		TreeViewerColumn tvc = new TreeViewerColumn(fTree, column3);
415
		/*		TreeViewerColumn tvc = new TreeViewerColumn(fTree, column3);
406
				tvc.setLabelProvider(new CellLabelProvider() {
416
				tvc.setLabelProvider(new CellLabelProvider() {
Lines 485-498 Link Here
485
		}
495
		}
486
496
487
		fLaunchConfig = config;
497
		fLaunchConfig = config;
498
		fModelProvider.init(fModelProvider.getDefaultFeatureLocation());
488
		ArrayList selectedFeatureList = fModelProvider.parseConfig(config);
499
		ArrayList selectedFeatureList = fModelProvider.parseConfig(config);
500
489
		fDefaultFeatureLocationCombo.setText(getLocationText(fModelProvider.getDefaultFeatureLocation()));
501
		fDefaultFeatureLocationCombo.setText(getLocationText(fModelProvider.getDefaultFeatureLocation()));
490
		fDefaultPluginResolutionCombo.setText(getLocationText(fModelProvider.getDefaultPluginResolution()));
502
		fDefaultPluginResolutionCombo.setText(getLocationText(fModelProvider.getDefaultPluginResolution()));
491
		fModelProvider.init(fModelProvider.getDefaultFeatureLocation());
503
		if (selectedFeatureList.size() > 0) {
492
504
			fTree.setAllChecked(false);
493
		for (int index = 0; index < selectedFeatureList.size(); index++) {
505
			for (int index = 0; index < selectedFeatureList.size(); index++) {
494
			String id = (String) selectedFeatureList.get(index);
506
				String id = (String) selectedFeatureList.get(index);
495
			fTree.setChecked(id, true);
507
				fTree.setChecked(id, true);
508
			}
496
		}
509
		}
497
510
498
		// If the workspace plug-in state has changed (project closed, etc.) the launch config needs to be updated without making the tab dirty
511
		// If the workspace plug-in state has changed (project closed, etc.) the launch config needs to be updated without making the tab dirty

Return to bug 284885