Changeset 2001
- Timestamp:
- 03/13/08 13:36:12
(8 months ago)
- Author:
- apatel
- Message:
removed double click behavior that I had added. Need to think more on the correct/consitent behavior of that view.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1949 |
r2001 |
|
| 27 | 27 | import org.eclipse.gef.editparts.AbstractTreeEditPart; |
|---|
| 28 | 28 | import org.eclipse.gef.editpolicies.RootComponentEditPolicy; |
|---|
| | 29 | import org.eclipse.gef.requests.SelectionRequest; |
|---|
| 29 | 30 | import org.eclipse.gef.tools.SelectEditPartTracker; |
|---|
| | 31 | import org.eclipse.gef.ui.parts.TreeViewer; |
|---|
| 30 | 32 | import org.eclipse.jface.viewers.ILabelDecorator; |
|---|
| 31 | 33 | import org.eclipse.swt.graphics.Image; |
|---|
| | 34 | import org.eclipse.swt.graphics.Point; |
|---|
| | 35 | import org.eclipse.swt.widgets.Tree; |
|---|
| | 36 | import org.eclipse.swt.widgets.TreeItem; |
|---|
| 32 | 37 | import org.eclipse.ui.IContributorResourceAdapter; |
|---|
| 33 | 38 | import org.eclipse.ui.IWorkbenchPage; |
|---|
| … | … | |
| 230 | 235 | public void performRequest (Request request) |
|---|
| 231 | 236 | { |
|---|
| 232 | | // Object o = request.getType (); |
|---|
| 233 | 237 | if (request.getType ().equals (REQ_OPEN)) |
|---|
| 234 | 238 | { |
|---|
| 235 | 239 | IResource res = getCastedModel (); |
|---|
| 236 | | |
|---|
| 237 | 240 | if (res instanceof IFolder || res instanceof IProject) |
|---|
| 238 | 241 | { |
|---|
| 239 | | //TODO: expand/collapse |
|---|
| 240 | | // some findings |
|---|
| 241 | | // setModel must be called to set appropriate resource |
|---|
| 242 | | // it is never called so getCastedModel always return workspace. |
|---|
| 243 | | // I think once we configure that properly it should work fine. |
|---|
| 244 | | // TreeViewer viewer = (TreeViewer) getViewer (); |
|---|
| 245 | | // viewer. |
|---|
| 246 | | |
|---|
| 247 | | /* |
|---|
| 248 | | IStructuredSelection selection = (IStructuredSelection) event.getSelection(); |
|---|
| 249 | | Object element = selection.getFirstElement(); |
|---|
| 250 | | |
|---|
| 251 | | TreeViewer viewer = getViewer(); |
|---|
| 252 | | if (viewer.isExpandable(element)) |
|---|
| 253 | | { |
|---|
| 254 | | viewer.setExpandedState(element, !viewer.getExpandedState(element)); |
|---|
| 255 | | } |
|---|
| 256 | | */ |
|---|
| 257 | | |
|---|
| | 242 | TreeItem item = (TreeItem)getWidget (); |
|---|
| | 243 | item.setExpanded (!item.getExpanded ()); |
|---|
| 258 | 244 | } |
|---|
| 259 | 245 | else if (res instanceof IFile) |
|---|
| … | … | |
| 268 | 254 | { |
|---|
| 269 | 255 | } |
|---|
| 270 | | |
|---|
| 271 | 256 | return; |
|---|
| 272 | 257 | } |
|---|
| r2000 |
r2001 |
|
| 32 | 32 | { |
|---|
| 33 | 33 | |
|---|
| 34 | | private final MouseListener mListner = new MouseListener() |
|---|
| 35 | | { |
|---|
| 36 | | /** |
|---|
| 37 | | * TODO::arp::there has to be a better way, it works for now |
|---|
| 38 | | */ |
|---|
| 39 | | public void mouseDoubleClick (MouseEvent e) |
|---|
| 40 | | { |
|---|
| 41 | | Object source = e.getSource (); |
|---|
| 42 | | if( source instanceof Tree) |
|---|
| 43 | | { |
|---|
| 44 | | TreeItem [] items = ((Tree)source).getSelection (); |
|---|
| 45 | | if( items == null || items.length != 1) |
|---|
| 46 | | return; |
|---|
| 47 | | items[0].setExpanded (!items[0].getExpanded ()); |
|---|
| 48 | | } |
|---|
| 49 | | } |
|---|
| 50 | | |
|---|
| 51 | | public void mouseDown (MouseEvent e) |
|---|
| 52 | | { |
|---|
| 53 | | } |
|---|
| 54 | | public void mouseUp (MouseEvent e) |
|---|
| 55 | | { |
|---|
| 56 | | } |
|---|
| 57 | | }; |
|---|
| | 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 | // }; |
|---|
| 58 | 59 | |
|---|
| 59 | 60 | public PolicyTreeViewer () |
|---|
| … | … | |
| 96 | 97 | { |
|---|
| 97 | 98 | super.hookControl (); |
|---|
| 98 | | getControl ().addMouseListener (mListner); |
|---|
| | 99 | // getControl ().addMouseListener (mListner); |
|---|
| 99 | 100 | } |
|---|
| 100 | 101 | |
|---|
| 101 | 102 | protected void unhookControl () |
|---|
| 102 | 103 | { |
|---|
| 103 | | if(getControl () != null ) |
|---|
| 104 | | getControl ().removeMouseListener (mListner); |
|---|
| | 104 | // if(getControl () != null ) |
|---|
| | 105 | // getControl ().removeMouseListener (mListner); |
|---|
| 105 | 106 | super.unhookControl (); |
|---|
| 106 | 107 | } |
|---|
Download in other formats:
* Generating other formats may take time.