|
51 | 51 | import org.eclipse.pde.internal.core.text.bundle.ExecutionEnvironment;
|
52 | 52 | import org.eclipse.pde.internal.core.text.bundle.PDEManifestElement;
|
53 | 53 | import org.eclipse.pde.internal.core.text.bundle.RequiredExecutionEnvironmentHeader;
|
| 54 | +import org.eclipse.pde.internal.core.util.ManifestUtils; |
54 | 55 | import org.eclipse.pde.internal.ui.IHelpContextIds;
|
55 | 56 | import org.eclipse.pde.internal.ui.PDEPlugin;
|
56 | 57 | import org.eclipse.pde.internal.ui.PDEPluginImages;
|
|
79 | 80 | import org.eclipse.ui.forms.widgets.Section;
|
80 | 81 | import org.eclipse.ui.forms.widgets.TableWrapData;
|
81 | 82 | import org.osgi.framework.Constants;
|
| 83 | +import org.osgi.resource.Resource; |
82 | 84 |
|
83 | 85 | public class ExecutionEnvironmentSection extends TableSection {
|
84 | 86 |
|
@@ -139,13 +141,10 @@ protected void createClient(Section section, FormToolkit toolkit) {
|
139 | 141 | createViewerPartControl(container, SWT.FULL_SELECTION | SWT.MULTI, 2, toolkit);
|
140 | 142 | fEETable = tablePart.getTableViewer();
|
141 | 143 | fEETable.setContentProvider((IStructuredContentProvider) inputElement -> {
|
142 |
| - if (inputElement instanceof IBundleModel model) { |
143 |
| - IBundle bundle = model.getBundle(); |
144 |
| - @SuppressWarnings("deprecation") |
145 |
| - IManifestHeader header = bundle.getManifestHeader(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT); |
146 |
| - if (header instanceof RequiredExecutionEnvironmentHeader breeHeader) { |
147 |
| - return breeHeader.getEnvironments(); |
148 |
| - } |
| 144 | + IPluginModelBase model = getPluginModel(); |
| 145 | + if (model != null) { |
| 146 | + Resource bundle = model.getBundleDescription(); |
| 147 | + return ManifestUtils.getRequiredExecutionEnvironments(bundle).toArray(String[]::new); |
149 | 148 | }
|
150 | 149 | return new Object[0];
|
151 | 150 | });
|
@@ -331,14 +330,19 @@ private String getLineDelimiter() {
|
331 | 330 | }
|
332 | 331 |
|
333 | 332 | private IExecutionEnvironment[] getEnvironments() {
|
334 |
| - RequiredExecutionEnvironmentHeader header = getHeader(); |
335 | 333 | IExecutionEnvironmentsManager eeManager = JavaRuntime.getExecutionEnvironmentsManager();
|
336 | 334 | IExecutionEnvironment[] envs = eeManager.getExecutionEnvironments();
|
337 |
| - if (header == null) { |
338 |
| - return envs; |
| 335 | + IPluginModelBase model = getPluginModel(); |
| 336 | + if (model != null) { |
| 337 | + List<IExecutionEnvironment> requiredEEs = ManifestUtils |
| 338 | + .getRequiredExecutionEnvironments(model.getBundleDescription()) // |
| 339 | + .map(eeManager::getEnvironment).toList(); |
| 340 | + if (!requiredEEs.isEmpty()) { |
| 341 | + return Arrays.stream(envs).filter(ee -> !requiredEEs.contains(ee)) |
| 342 | + .toArray(IExecutionEnvironment[]::new); |
| 343 | + } |
339 | 344 | }
|
340 |
| - List<IExecutionEnvironment> ees = header.getElementNames().stream().map(eeManager::getEnvironment).toList(); |
341 |
| - return Arrays.stream(envs).filter(ee -> !ees.contains(ee)).toArray(IExecutionEnvironment[]::new); |
| 345 | + return envs; |
342 | 346 | }
|
343 | 347 |
|
344 | 348 | @Override
|
@@ -404,11 +408,13 @@ protected RequiredExecutionEnvironmentHeader getHeader() {
|
404 | 408 | }
|
405 | 409 |
|
406 | 410 | protected boolean isFragment() {
|
| 411 | + IPluginModelBase model = getPluginModel(); |
| 412 | + return model != null && model.isFragmentModel(); |
| 413 | + } |
| 414 | + |
| 415 | + private IPluginModelBase getPluginModel() { |
407 | 416 | InputContextManager manager = getPage().getPDEEditor().getContextManager();
|
408 |
| - if (manager.getAggregateModel() instanceof IPluginModelBase model) { |
409 |
| - return model.isFragmentModel(); |
410 |
| - } |
411 |
| - return false; |
| 417 | + return manager.getAggregateModel() instanceof IPluginModelBase model ? model : null; |
412 | 418 | }
|
413 | 419 |
|
414 | 420 | @Override
|
|
0 commit comments