Skip to content

Package: ECPViewEditorTreeSelectionDialog

ECPViewEditorTreeSelectionDialog

nameinstructionbranchcomplexitylinemethod
ECPViewEditorTreeSelectionDialog(Shell, ILabelProvider, ITreeContentProvider)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getTreePath()
M: 0 C: 20
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 5
100%
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 Neufeld - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.internal.editor.controls;
15:
16: import org.eclipse.jface.viewers.ILabelProvider;
17: import org.eclipse.jface.viewers.ITreeContentProvider;
18: import org.eclipse.jface.viewers.TreePath;
19: import org.eclipse.jface.viewers.TreeSelection;
20: import org.eclipse.swt.widgets.Shell;
21: import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
22:
23: /**
24: * ElementTreeSelectionDialog which also stores the selection along the tree.
25: *
26: * @author Eugen Neufeld
27: *
28: */
29: public class ECPViewEditorTreeSelectionDialog extends ElementTreeSelectionDialog {
30:         private TreePath treePath;
31:
32:         /**
33:          * Default constructor.
34:          *
35:          * @param parent the {@link Shell} for creating the dialog
36:          * @param labelProvider the {@link ILabelProvider} for the tree
37:          * @param contentProvider the {@link ITreeContentProvider} for the tree
38:          */
39:         public ECPViewEditorTreeSelectionDialog(Shell parent, ILabelProvider labelProvider,
40:                 ITreeContentProvider contentProvider) {
41:                 super(parent, labelProvider, contentProvider);
42:         }
43:
44:         /**
45:          * Returns the {@link TreePath} from the tree viewer.
46:          *
47:          * @return the path
48:          */
49:         public TreePath getTreePath() {
50:•                if (getTreeViewer() != null) {
51:                         final TreeSelection selection = (TreeSelection) getTreeViewer().getSelection();
52:•                        if (!selection.isEmpty()) {
53:                                 treePath = selection.getPaths()[0];
54:                         }
55:                 }
56:                 return treePath;
57:         }
58: }