1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.editor.xmlEditor.actions;
13
14 import org.eclipse.ui.IWorkbenchPart;
15 import org.w3c.dom.Attr;
16 import org.w3c.dom.Node;
17
18 import sk.baka.xml.gene.ExportException;
19 import sk.uniba.euromath.editor.xmlEditor.actions.lang.Messages;
20
21 /***
22 * Action to modify node of any type. Node to modify is gained from contructor
23 * or from selsction(action is enabled if only one node is selected).
24 *
25 * @author Tomáš Studva 9.12.2005
26 */
27 public class ModifyNodeAction extends NodeManipulateAction {
28
29 /***
30 * Default id of action.
31 */
32 public static final String id = ModifyNodeAction.class.toString();
33
34 /***
35 * Constructor.
36 */
37 public ModifyNodeAction() {
38 this(null);
39 }
40
41 /***
42 * Constructor. Creates action to modify node of any type from
43 * selection.
44 *
45 * @param part
46 * associated workbench part
47 */
48 ModifyNodeAction(IWorkbenchPart part) {
49 super(part, NodeManipulateAction.SINGLE, false);
50 setId(id);
51 setText(Messages.getString("ModifyNodeAction.Text"));
52 }
53
54 /***
55 * Constructor. Creates action to modify node.
56 *
57 * @param node
58 * node to modify.
59 * @param part
60 */
61 public ModifyNodeAction(Node node, IWorkbenchPart part) {
62 super(node, part);
63 setId(id + node.toString());
64 setText(Messages.getString("ModifyNodeAction.Text"));
65 }
66
67 /***
68 * Tries to modify node.
69 */
70 @Override
71 public void run() {
72
73 switch (getNode().getNodeType()) {
74 case Node.ELEMENT_NODE:
75 break;
76 case Node.ATTRIBUTE_NODE:
77 try {
78 getModifyHelper().modifyAttribute(getShell(),
79 (Attr) getNode());
80 } catch (ExportException e) {
81 handleExportException(e);
82 }
83 break;
84 case Node.TEXT_NODE:
85 try {
86 getModifyHelper().modifyTextNode(getShell(),
87 getNode());
88 } catch (ExportException e) {
89 handleExportException(e);
90 }
91 break;
92 case Node.CDATA_SECTION_NODE:
93 break;
94 case Node.COMMENT_NODE:
95 break;
96 case Node.ENTITY_NODE:
97 break;
98 case Node.ENTITY_REFERENCE_NODE:
99 break;
100 case Node.PROCESSING_INSTRUCTION_NODE:
101 break;
102 }
103 }
104 }