KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 JavaDoc 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 JavaDoc 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