Skip to content

Package: ECPCommand

ECPCommand

nameinstructionbranchcomplexitylinemethod
ECPCommand(EObject, EditingDomain)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
doExecute()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
run(boolean)
M: 21 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Edgar Mueller - initial API and implementation
13: * Eugen Neufeld - refactor
14: *
15: *******************************************************************************/
16:
17: package org.eclipse.emf.ecp.editor.internal.e3;
18:
19: import org.eclipse.emf.ecore.EObject;
20: import org.eclipse.emf.edit.command.ChangeCommand;
21: import org.eclipse.emf.edit.domain.EditingDomain;
22:
23: // TODO: possibily remove this class
24: /**
25: * Command capable of recording changes on a model element.
26: *
27: * @author emueller
28: */
29: public abstract class ECPCommand extends ChangeCommand {
30:
31:         private final EditingDomain domain;
32:
33:         private RuntimeException runtimeException;
34:
35:         /**
36:          * Constructor.
37:          *
38:          * @param eObject
39:          * the model element whose changes one is interested in
40:          * @param domain the {@link EditingDomain} to use
41:          */
42:         public ECPCommand(EObject eObject, EditingDomain domain) {
43:                 super(eObject);
44:                 this.domain = domain;
45:         }
46:
47:         /**
48:          * {@inheritDoc}
49:          *
50:          * @see org.eclipse.emf.edit.ChangeCommand#doExecute()
51:          */
52:         @Override
53:         protected final void doExecute() {
54:                 try {
55:                         doRun();
56:                         // BEGIN SUPRESS CATCH EXCEPTION
57:                 } catch (final RuntimeException e) {
58:                         // END SUPRESS CATCH EXCEPTION
59:                         runtimeException = e;
60:                         throw e;
61:                 }
62:         }
63:
64:         /**
65:          * The actual action that is being executed.
66:          */
67:         protected abstract void doRun();
68:
69:         /**
70:          * Executes the command.
71:          *
72:          * @param ignoreExceptions
73:          * true if any thrown exception in the execution of the command should be ignored.
74:          */
75:         public void run(boolean ignoreExceptions) {
76:                 runtimeException = null;
77:
78:                 // EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(eObject);
79:•                if (domain == null) {
80:                         return;
81:                 }
82:                 domain.getCommandStack().execute(this);
83:
84:•                if (!ignoreExceptions && runtimeException != null) {
85:                         throw runtimeException;
86:                 }
87:         }
88:
89: }