Skip to content

Package: EmfFormsPreferences

EmfFormsPreferences

nameinstructionbranchcomplexitylinemethod
getNode()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isSegmentTooling()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setSegmentTooling(boolean)
M: 21 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 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: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.spi.ide.preferences;
15:
16: import org.eclipse.core.runtime.preferences.IEclipsePreferences;
17: import org.eclipse.core.runtime.preferences.InstanceScope;
18: import org.eclipse.emfforms.internal.ide.preferences.Activator;
19: import org.eclipse.emfforms.spi.common.report.AbstractReport;
20: import org.osgi.service.prefs.BackingStoreException;
21:
22: /**
23: * Utility class providing access to EMF Forms's eclipse preferences.
24: *
25: * @author Lucas Koehler
26: *
27: */
28: public final class EmfFormsPreferences {
29:
30:         /** Default value of the segment tooling preference. */
31:         public static final boolean SEGMENT_TOOLING_DEFAULT = false;
32:
33:         private static final String SEGMENT_TOOLING = "segmentTooling";
34:
35:         private EmfFormsPreferences() {
36:                 // hide constructor
37:         }
38:
39:         /**
40:          * Returns whether segment IDE tooling is enabled.
41:          *
42:          * @return <code>true</code> if segment tooling is enabled
43:          */
44:         public static boolean isSegmentTooling() {
45:                 return getNode().getBoolean(SEGMENT_TOOLING, SEGMENT_TOOLING_DEFAULT);
46:         }
47:
48:         /**
49:          * Set whether segment IDE tooling is enabled.
50:          *
51:          * @param segmentTooling <code>true</code> if segment tooling is enabled
52:          */
53:         public static void setSegmentTooling(boolean segmentTooling) {
54:                 final IEclipsePreferences node = getNode();
55:                 node.putBoolean(SEGMENT_TOOLING, segmentTooling);
56:                 try {
57:                         node.flush();
58:                         node.sync();
59:                 } catch (final BackingStoreException ex) {
60:                         Activator.getDefault().getReportService()
61:                                 .report(new AbstractReport(ex, "Could not sync EMFForms Preferences."));
62:                 }
63:         }
64:
65:         private static IEclipsePreferences getNode() {
66:                 return InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
67:         }
68: }