KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > correction > OptionalRequireBundleResolution


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.correction;
12
13 import org.eclipse.osgi.util.NLS;
14 import org.eclipse.pde.internal.core.text.bundle.Bundle;
15 import org.eclipse.pde.internal.core.text.bundle.BundleModel;
16 import org.eclipse.pde.internal.core.text.bundle.RequireBundleHeader;
17 import org.eclipse.pde.internal.core.text.bundle.RequireBundleObject;
18 import org.eclipse.pde.internal.ui.PDEUIMessages;
19 import org.osgi.framework.Constants;
20
21 public class OptionalRequireBundleResolution extends
22         AbstractManifestMarkerResolution {
23     
24     private String JavaDoc fBundleId;
25
26     public OptionalRequireBundleResolution(int type, String JavaDoc bundleId) {
27         super(type);
28         fBundleId = bundleId;
29     }
30
31     protected void createChange(BundleModel model) {
32         Bundle bundle = (Bundle)model.getBundle();
33         RequireBundleHeader header = (RequireBundleHeader)bundle.getManifestHeader(Constants.REQUIRE_BUNDLE);
34         if (header != null) {
35             RequireBundleObject[] required = header.getRequiredBundles();
36             for (int i = 0; i < required.length; i++) {
37                 if (fBundleId.equals(required[i].getId()))
38                     required[i].setOptional(true);
39             }
40         }
41     }
42
43     public String JavaDoc getDescription() {
44         return NLS.bind(PDEUIMessages.OptionalRequireBundleResolution_description, fBundleId);
45     }
46
47     public String JavaDoc getLabel() {
48         return NLS.bind(PDEUIMessages.OptionalRequireBundleResolution_label, fBundleId);
49     }
50
51 }
52
Popular Tags