1 11 package org.eclipse.pde.internal.ui.correction; 12 13 import org.eclipse.core.resources.IMarker; 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.pde.core.plugin.IPluginModelBase; 17 import org.eclipse.pde.core.plugin.IPluginObject; 18 import org.eclipse.pde.core.plugin.IPluginParent; 19 import org.eclipse.pde.internal.core.text.plugin.PluginAttribute; 20 import org.eclipse.pde.internal.core.text.plugin.PluginBaseNode; 21 import org.eclipse.pde.internal.ui.PDEUIMessages; 22 23 public class RemoveNodeXMLResolution extends AbstractXMLMarkerResolution { 24 25 public RemoveNodeXMLResolution(int resolutionType, IMarker marker) { 26 super(resolutionType, marker); 27 } 28 29 protected void createChange(IPluginModelBase model) { 30 Object node = findNode(model); 31 if (!(node instanceof IPluginObject)) 32 return; 33 try { 34 IPluginObject pluginObject = (IPluginObject)node; 35 IPluginObject parent = pluginObject.getParent(); 36 if (parent instanceof IPluginParent) 37 ((IPluginParent)parent).remove(pluginObject); 38 else if (parent instanceof PluginBaseNode) 39 ((PluginBaseNode)parent).remove(pluginObject); 40 else if (pluginObject instanceof PluginAttribute) { 41 PluginAttribute attr = (PluginAttribute)pluginObject; 42 attr.getEnclosingElement().setXMLAttribute(attr.getName(), null); 43 } 44 45 } catch (CoreException e) { 46 } 47 } 48 49 public String getLabel() { 50 if (isAttrNode()) 51 return NLS.bind(PDEUIMessages.RemoveNodeXMLResolution_attrLabel, getNameOfNode()); 52 return NLS.bind(PDEUIMessages.RemoveNodeXMLResolution_label, getNameOfNode()); 53 } 54 55 } 56 | Popular Tags |