blob: 57ad87c879f487dcf38b4f5e5fcb49a27ea31238 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*******************************************************************************
* Copyright (c) 2005, 2015 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.correction;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.core.text.bundle.*;
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.osgi.framework.Constants;
public class OptionalRequireBundleResolution extends AbstractManifestMarkerResolution {
private String fBundleId;
public OptionalRequireBundleResolution(int type, String bundleId) {
super(type);
fBundleId = bundleId;
}
@Override
protected void createChange(BundleModel model) {
Bundle bundle = (Bundle) model.getBundle();
RequireBundleHeader header = (RequireBundleHeader) bundle.getManifestHeader(Constants.REQUIRE_BUNDLE);
if (header != null) {
RequireBundleObject[] required = header.getRequiredBundles();
for (int i = 0; i < required.length; i++) {
if (fBundleId.equals(required[i].getId()))
required[i].setOptional(true);
}
}
}
@Override
public String getDescription() {
return NLS.bind(PDEUIMessages.OptionalRequireBundleResolution_description, fBundleId);
}
@Override
public String getLabel() {
return NLS.bind(PDEUIMessages.OptionalRequireBundleResolution_label, fBundleId);
}
}
|