1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.editor.xmlEditor.commands;
13
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.gef.commands.CompoundCommand;
16 import sk.baka.xml.gene.ExportException;
17 import sk.uniba.euromath.EuroMath;
18 import sk.uniba.euromath.document.XMLAccess;
19
20 /***
21 * Compound command for wraping document modifiing commands.
22 *
23 * @author Tomáš Studva 2.12.2005
24 */
25 public class DocumentModifyCompoundCommand extends CompoundCommand {
26 /***
27 * XmlAccess instance.
28 */
29 private final XMLAccess xmlAccess;
30
31 /***
32 * Constructs an empty CompoundCommand
33 *
34 * @since 2.0
35 * @param xmlAccess
36 * document instance
37 */
38 public DocumentModifyCompoundCommand(XMLAccess xmlAccess) {
39 super();
40 this.xmlAccess = xmlAccess;
41 }
42
43 /***
44 * Constructs an empty CompoundCommand with the specified label.
45 *
46 * @param label
47 * the label for the Command
48 * @param xmlAccess
49 * document instance
50 */
51 public DocumentModifyCompoundCommand(XMLAccess xmlAccess, String label) {
52 super(label);
53 this.xmlAccess = xmlAccess;
54 }
55
56 /***
57 * Wraps holded commands execution with start,end modify.
58 */
59 @Override
60 public void execute() {
61 getXmlAccess().getModifier().startModify();
62 super.execute();
63 try {
64 getXmlAccess().getModifier().endModify();
65 } catch (ExportException e) {
66 EuroMath.log(IStatus.ERROR, 0, "",e);
67 }
68 }
69
70 /***
71 * @return Returns the xmlAccess.
72 */
73 protected XMLAccess getXmlAccess() {
74 return this.xmlAccess;
75 }
76 }