Skip to content

Package: TreeMasterDetailSelectionManipulatorHelper

TreeMasterDetailSelectionManipulatorHelper

nameinstructionbranchcomplexitylinemethod
checkInitState()
M: 24 C: 24
50%
M: 2 C: 4
67%
M: 2 C: 2
50%
M: 5 C: 8
62%
M: 0 C: 1
100%
manipulateSelection(Object)
M: 4 C: 5
56%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 3
75%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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: * Eugen - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.treemasterdetail.ui.swt.internal;
15:
16: import org.eclipse.core.runtime.CoreException;
17: import org.eclipse.core.runtime.IConfigurationElement;
18: import org.eclipse.core.runtime.IExtensionRegistry;
19: import org.eclipse.core.runtime.IStatus;
20: import org.eclipse.core.runtime.Platform;
21: import org.eclipse.core.runtime.Status;
22: import org.eclipse.emf.ecp.view.internal.treemasterdetail.ui.swt.Activator;
23:
24: /**
25: * Helper Class for manipulating a selection.
26: *
27: * @author Eugen Neufeld
28: * @since 1.5
29: *
30: */
31: public final class TreeMasterDetailSelectionManipulatorHelper {
32:
33:         private static TreeMasterDetailSelectionManipulator manipulator;
34:         private static boolean initialized;
35:
36:         private TreeMasterDetailSelectionManipulatorHelper() {
37:         }
38:
39:         /**
40:          * Manipulate the selection using the manipulateSelection ExtensionPoint.
41:          *
42:          * @param object The Object to manipulate
43:          * @return the manipulated Object
44:          */
45:         public static Object manipulateSelection(Object object) {
46:                 checkInitState();
47:•                if (manipulator != null) {
48:                         return manipulator.manipulateSelection(object);
49:                 }
50:                 return object;
51:         }
52:
53:         private static synchronized void checkInitState() {
54:•                if (!initialized) {
55:                         final IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
56:•                        if (extensionRegistry == null) {
57:                                 return;
58:                         }
59:                         final IConfigurationElement[] controls = extensionRegistry
60:                                 .getConfigurationElementsFor("org.eclipse.emf.ecp.view.treemasterdetail.ui.swt.selectionManipulator"); //$NON-NLS-1$
61:•                        for (final IConfigurationElement e : controls) {
62:                                 try {
63:                                         manipulator = (TreeMasterDetailSelectionManipulator) e.createExecutableExtension("class"); //$NON-NLS-1$
64:                                 } catch (final CoreException e1) {
65:                                         Activator.getDefault().getLog()
66:                                                 .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e1.getMessage(), e1));
67:                                 }
68:                         }
69:                         initialized = true;
70:                 }
71:         }
72: }