1 11 package org.eclipse.pde.internal.ui.correction; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.osgi.util.NLS; 15 import org.eclipse.pde.core.plugin.IPluginModelBase; 16 import org.eclipse.pde.core.plugin.PluginRegistry; 17 import org.eclipse.pde.internal.core.ibundle.IManifestHeader; 18 import org.eclipse.pde.internal.core.text.bundle.BundleModel; 19 import org.eclipse.pde.internal.ui.PDEUIMessages; 20 import org.eclipse.pde.internal.ui.editor.plugin.JavaAttributeValue; 21 import org.eclipse.pde.internal.ui.util.PDEJavaHelperUI; 22 import org.eclipse.pde.internal.ui.util.TextUtil; 23 24 public class CreateManifestClassResolution extends AbstractManifestMarkerResolution { 25 26 private String fHeader; 27 28 public CreateManifestClassResolution(int type, String headerName) { 29 super(type); 30 fHeader = headerName; 31 } 32 33 protected void createChange(BundleModel model) { 34 IManifestHeader header = model.getBundle().getManifestHeader(fHeader); 35 36 String name = TextUtil.trimNonAlphaChars(header.getValue()).replace('$', '.'); 37 IProject project = model.getUnderlyingResource().getProject(); 38 39 IPluginModelBase modelBase = PluginRegistry.findModel(project); 40 if (modelBase == null) 41 return; 42 43 JavaAttributeValue value = new JavaAttributeValue(project, modelBase, null, name); 44 name = PDEJavaHelperUI.createClass(name, project, value, true); 45 if (name != null && !name.equals(header.getValue())) 46 header.setValue(name); 47 } 48 49 public String getLabel() { 50 return NLS.bind(PDEUIMessages.CreateManifestClassResolution_label, fHeader); 51 } 52 53 } 54 | Popular Tags |