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