Changeset 1999
- Timestamp:
- 03/13/08 11:57:20
(8 months ago)
- Author:
- apatel
- Message:
Upon double click of mouse, Collapse/Expand items in the viewer.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1825 |
r1999 |
|
| 4 | 4 | |*| Author: Brandon Whalen <bwhalen@tresys.com> |
|---|
| 5 | 5 | |*| David Sugar <dsugar@tresys.com> |
|---|
| | 6 | |*| Anand Patel <apatel@tresys.com> |
|---|
| 6 | 7 | |*| |
|---|
| 7 | | |*| Version: @version@ |
|---|
| | 8 | |*| |
|---|
| | 9 | |*| $Rev$ |
|---|
| | 10 | |*| $Date$ |
|---|
| 8 | 11 | \*/ |
|---|
| 9 | 12 | |
|---|
| … | … | |
| 16 | 19 | import org.eclipse.core.resources.IWorkspaceRoot; |
|---|
| 17 | 20 | import org.eclipse.gef.EditPart; |
|---|
| | 21 | import org.eclipse.gef.KeyHandler; |
|---|
| 18 | 22 | import org.eclipse.gef.ui.parts.TreeViewer; |
|---|
| 19 | 23 | import org.eclipse.jface.viewers.ISelection; |
|---|
| 20 | 24 | import org.eclipse.jface.viewers.StructuredSelection; |
|---|
| | 25 | import org.eclipse.swt.events.MouseEvent; |
|---|
| | 26 | import org.eclipse.swt.events.MouseListener; |
|---|
| | 27 | import org.eclipse.swt.widgets.Control; |
|---|
| | 28 | import org.eclipse.swt.widgets.Tree; |
|---|
| | 29 | import org.eclipse.swt.widgets.TreeItem; |
|---|
| 21 | 30 | |
|---|
| 22 | 31 | public class PolicyTreeViewer |
|---|
| 23 | 32 | extends TreeViewer |
|---|
| 24 | 33 | { |
|---|
| 25 | | |
|---|
| | 34 | |
|---|
| | 35 | private final MouseListener mListner = new MouseListener() |
|---|
| | 36 | { |
|---|
| | 37 | /** |
|---|
| | 38 | * TODO::arp::there has to be a better way, it works for now |
|---|
| | 39 | */ |
|---|
| | 40 | public void mouseDoubleClick (MouseEvent e) |
|---|
| | 41 | { |
|---|
| | 42 | Object source = e.getSource (); |
|---|
| | 43 | if( source instanceof Tree) |
|---|
| | 44 | { |
|---|
| | 45 | TreeItem [] items = ((Tree)source).getSelection (); |
|---|
| | 46 | if( items == null || items.length != 1) |
|---|
| | 47 | return; |
|---|
| | 48 | items[0].setExpanded (!items[0].getExpanded ()); |
|---|
| | 49 | } |
|---|
| | 50 | } |
|---|
| | 51 | |
|---|
| | 52 | public void mouseDown (MouseEvent e) |
|---|
| | 53 | { |
|---|
| | 54 | } |
|---|
| | 55 | public void mouseUp (MouseEvent e) |
|---|
| | 56 | { |
|---|
| | 57 | } |
|---|
| | 58 | }; |
|---|
| | 59 | |
|---|
| | 60 | public PolicyTreeViewer () |
|---|
| | 61 | { |
|---|
| | 62 | super (); |
|---|
| | 63 | } |
|---|
| | 64 | |
|---|
| 26 | 65 | /* |
|---|
| 27 | 66 | * make sure that IWorkspaceRoot is not part of the selection |
|---|
| … | … | |
| 54 | 93 | return tmpSelection; |
|---|
| 55 | 94 | } |
|---|
| | 95 | |
|---|
| | 96 | protected void hookControl () |
|---|
| | 97 | { |
|---|
| | 98 | super.hookControl (); |
|---|
| | 99 | getControl ().addMouseListener (mListner); |
|---|
| | 100 | } |
|---|
| | 101 | |
|---|
| | 102 | protected void unhookControl () |
|---|
| | 103 | { |
|---|
| | 104 | if(getControl () != null ) |
|---|
| | 105 | getControl ().removeMouseListener (mListner); |
|---|
| | 106 | super.unhookControl (); |
|---|
| | 107 | } |
|---|
| | 108 | |
|---|
| | 109 | public KeyHandler getKeyHandler () |
|---|
| | 110 | { |
|---|
| | 111 | return super.getKeyHandler (); |
|---|
| | 112 | } |
|---|
| | 113 | |
|---|
| 56 | 114 | } |
|---|
Download in other formats:
* Generating other formats may take time.