Skip to content

Package: DefaultRealm

DefaultRealm

nameinstructionbranchcomplexitylinemethod
DefaultRealm()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
asyncExec(Runnable)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
dispose()
M: 0 C: 8
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
isCurrent()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
syncExec(Runnable)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 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: * http://wiki.eclipse.org/JFace_Data_Binding/Realm
13: * Lucas Koehler - initial API and implementation
14: ******************************************************************************/
15: package org.eclipse.emfforms.internal.core.services.databinding;
16:
17: import org.eclipse.core.databinding.observable.Realm;
18:
19: /**
20: * Simple realm implementation that will set itself as default when constructed. Invoke {@link #dispose()} to remove the
21: * realm from being the default. Does not support asyncExec(...).
22: *
23: * @see <a href="http://wiki.eclipse.org/JFace_Data_Binding/Realm">http://wiki.eclipse.org/JFace_Data_Binding/Realm</a>
24: * @author Lucas Koehler
25: */
26: public class DefaultRealm extends Realm {
27:         private final Realm previousRealm;
28:
29:         /**
30:          * Create a new instance of {@link DefaultRealm}.
31:          */
32:         public DefaultRealm() {
33:                 previousRealm = super.setDefault(this);
34:         }
35:
36:         /**
37:          * @return always returns true
38:          */
39:         @Override
40:         public boolean isCurrent() {
41:                 return true;
42:         }
43:
44:         @Override
45:         protected void syncExec(Runnable runnable) {
46:                 runnable.run();
47:         }
48:
49:         /**
50:          * @throws UnsupportedOperationException
51:          */
52:         @Override
53:         public void asyncExec(Runnable runnable) {
54:                 throw new UnsupportedOperationException("asyncExec is unsupported"); //$NON-NLS-1$
55:         }
56:
57:         /**
58:          * Removes the realm from being the current and sets the previous realm to the default.
59:          */
60:         public void dispose() {
61:•                if (getDefault() == this) {
62:                         setDefault(previousRealm);
63:                 }
64:         }
65: }