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.Element;
16 import sk.baka.xml.gene.ExportException;
17 import sk.baka.xml.gene.ExportException;
18 import sk.uniba.euromath.editor.xmlEditor.actions.lang.Messages;
19
20 /***
21 * Action to add new attribute to element.
22 *
23 * @author Tomáš Studva 19.12.2005
24 */
25 public class AddAttributeWizardAction extends NodeManipulateAction {
26
27 /***
28 * Id.
29 */
30 public static final String id = AddAttributeWizardAction.class
31 .toString();
32
33 /***
34 * Constructor.
35 */
36 public AddAttributeWizardAction() {
37 this(null);
38 }
39
40 /***
41 * Constructor. Creates action to add attribute to selected element.
42 *
43 * @param part
44 * associated workbench part
45 */
46 public AddAttributeWizardAction(IWorkbenchPart part) {
47 super(part);
48 setId(id);
49 setText(Messages.getString("AddAttributeWizardAction.Text"));
50 }
51
52 /***
53 * Constructor. Creates action to add attribute to element e.
54 *
55 * @param e
56 * element for attribute addition
57 * @param part
58 * associated workbench part
59 */
60 public AddAttributeWizardAction(Element e, IWorkbenchPart part) {
61 super(e, part);
62 setId(id + e.toString());
63 setText(Messages.getString("AddAttributeWizardAction.Text"));
64 }
65
66 @Override
67 protected boolean calculateEnabled() {
68 return super.calculateEnabled()
69 && (getNode() instanceof Element);
70 }
71
72
73
74
75
76
77 @Override
78 public void run() {
79 try {
80 getModifyHelper()
81 .insertNewAttribute(
82 getWorkbenchPart()
83 .getSite()
84 .getShell(),
85 (Element) getNode());
86 } catch (ExportException ex) {
87 handleExportException(ex);
88 }
89 }
90 }