Mercurial > projects > dwt-addons
annotate dwtx/jface/viewers/ITreeSelection.d @ 70:46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 22 May 2008 01:36:46 +0200 |
parents | b6c35faf97c8 |
children |
rev | line source |
---|---|
10 | 1 /******************************************************************************* |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
2 * Copyright (c) 2005, 2007 IBM Corporation and others. |
10 | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.viewers.ITreeSelection; | |
14 | |
15 import dwtx.jface.viewers.IStructuredSelection; | |
16 import dwtx.jface.viewers.TreePath; | |
17 | |
18 import dwt.dwthelper.utils; | |
19 | |
20 /** | |
21 * A selection containing tree paths. | |
70
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
22 * <p> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
23 * It is recommended that clients do not implement this interface but instead |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
24 * use the standard implementation of this interface, {@link TreeSelection}. |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
25 * <code>TreeSelection</code> adds API for getting the {@link IElementComparer} |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
26 * of a selection (if available). This is important for clients who want to |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
27 * create a slightly modified tree selection based on an existing tree selection. |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
28 * The recommended coding pattern in this case is as follows: |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
29 * <pre> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
30 * ITreeSelection selection = (ITreeSelection)treeViewer.getSelection(); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
31 * TreePath[] paths = selection.getPaths(); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
32 * IElementComparer comparer = null; |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
33 * if (selection instanceof TreeSelection) { |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
34 * comparer = ((TreeSelection)selection).getElementComparer(); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
35 * } |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
36 * TreePath[] modifiedPaths = ... // modify as required |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
37 * TreeSelection modifiedSelection = new TreeSelection(modifiedPaths, comparer); |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
38 * </pre> |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
39 * See bugs 135818 and 133375 for details. |
46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
40 * </p> |
10 | 41 * |
42 * @since 3.2 | |
43 * | |
44 */ | |
45 public interface ITreeSelection : IStructuredSelection { | |
46 | |
47 /** | |
48 * Returns the paths in this selection | |
49 * | |
50 * @return the paths in this selection | |
51 */ | |
52 public TreePath[] getPaths(); | |
53 | |
54 /** | |
55 * Returns the paths in this selection whose last segment is equal | |
56 * to the given element | |
57 * | |
58 * @param element the element to get the tree paths for | |
59 * | |
60 * @return the array of tree paths | |
61 */ | |
62 public TreePath[] getPathsFor(Object element); | |
63 | |
64 } |