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()]); |