1 /*******************************************************************************
2  *  Copyright (c) 2005, 2019 IBM Corporation and others.
3  *
4  *  This program and the accompanying materials
5  *  are made available under the terms of the Eclipse Public License 2.0
6  *  which accompanies this distribution, and is available at
7  *  https://www.eclipse.org/legal/epl-2.0/
8  *
9  *  SPDX-License-Identifier: EPL-2.0
10  *
11  *  Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.pde.internal.ui.correction;
15 
16 import org.eclipse.core.resources.IMarker;
17 import org.eclipse.pde.internal.core.ibundle.IBundle;
18 import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
19 import org.eclipse.pde.internal.core.text.bundle.*;
20 import org.eclipse.pde.internal.ui.PDEUIMessages;
21 import org.osgi.framework.Constants;
22 
23 public class UnsupportedSingletonDirectiveResolution extends AbstractManifestMarkerResolution {
24 
UnsupportedSingletonDirectiveResolution(int type, IMarker marker)25 	public UnsupportedSingletonDirectiveResolution(int type, IMarker marker) {
26 		super(type, marker);
27 	}
28 
29 	@Override
getDescription()30 	public String getDescription() {
31 		return PDEUIMessages.RevertUnsupportSingletonResolution_desc;
32 	}
33 
34 	@Override
getLabel()35 	public String getLabel() {
36 		return PDEUIMessages.RevertUnsupportSingletonResolution_desc;
37 	}
38 
39 	@Override
createChange(BundleModel model)40 	protected void createChange(BundleModel model) {
41 		IBundle bundle = model.getBundle();
42 		if (bundle instanceof Bundle) {
43 			Bundle bun = (Bundle) bundle;
44 			IManifestHeader header = bun.getManifestHeader(Constants.BUNDLE_SYMBOLICNAME);
45 			if (header instanceof BundleSymbolicNameHeader) {
46 				((BundleSymbolicNameHeader) header).fixUnsupportedDirective();
47 			}
48 		}
49 	}
50 }
51