|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2007, 2008 Innoopract Informationssysteme GmbH. |
2 |
* Copyright (c) 2007, 2009 Innoopract Informationssysteme GmbH. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 7-12
Link Here
|
| 7 |
* |
7 |
* |
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* Innoopract Informationssysteme GmbH - initial API and implementation |
9 |
* Innoopract Informationssysteme GmbH - initial API and implementation |
|
|
10 |
* EclipseSource - ongoing development |
| 10 |
******************************************************************************/ |
11 |
******************************************************************************/ |
| 11 |
|
12 |
|
| 12 |
/** |
13 |
/** |
|
Lines 57-63
Link Here
|
| 57 |
this._tree.addEventListener( "contextmenu", this._onContextMenu, this ); |
58 |
this._tree.addEventListener( "contextmenu", this._onContextMenu, this ); |
| 58 |
this._tree.addEventListener( "focus", this._onFocusIn, this ); |
59 |
this._tree.addEventListener( "focus", this._onFocusIn, this ); |
| 59 |
this._tree.addEventListener( "blur", this._onFocusOut, this ); |
60 |
this._tree.addEventListener( "blur", this._onFocusOut, this ); |
| 60 |
this._tree.addEventListener( "appear", this._updateLayout, this ); |
61 |
this._tree.addEventListener( "appear", this._updateLayout, this ); |
|
|
62 |
this._tree.addEventListener( "keydown", this._onKeyDown, this ); |
| 61 |
// TODO [rst] Find out why this is not the default appearance |
63 |
// TODO [rst] Find out why this is not the default appearance |
| 62 |
this._tree.setAppearance( "tree" ); |
64 |
this._tree.setAppearance( "tree" ); |
| 63 |
|
65 |
|
|
Lines 107-112
Link Here
|
| 107 |
this._tree.removeEventListener( "focus", this._onFocusIn, this ); |
109 |
this._tree.removeEventListener( "focus", this._onFocusIn, this ); |
| 108 |
this._tree.removeEventListener( "blur", this._onFocusOut, this ); |
110 |
this._tree.removeEventListener( "blur", this._onFocusOut, this ); |
| 109 |
this._tree.removeEventListener( "appear", this._updateLayout, this ); |
111 |
this._tree.removeEventListener( "appear", this._updateLayout, this ); |
|
|
112 |
this._tree.removeEventListener( "keydown", this._onKeyDown, this ); |
| 110 |
this._tree.removeEventListener( "changeElement", this._onTreeElementChange, this._tree ); |
113 |
this._tree.removeEventListener( "changeElement", this._onTreeElementChange, this._tree ); |
| 111 |
this._tree.dispose(); |
114 |
this._tree.dispose(); |
| 112 |
this._tree = null; |
115 |
this._tree = null; |
|
Lines 430-435
Link Here
|
| 430 |
|
433 |
|
| 431 |
///////////////// |
434 |
///////////////// |
| 432 |
// Event Listener |
435 |
// Event Listener |
|
|
436 |
_onKeyDown : function( evt ) { |
| 437 |
switch( evt.getKeyIdentifier() ) { |
| 438 |
case "Enter": |
| 439 |
var item = this._tree.getManager().getLeadItem(); |
| 440 |
var selection = this._getSelectionIndices(); |
| 441 |
if( selection != "" ) { |
| 442 |
this._sendWidgetDefaultSelected( item ); |
| 443 |
} |
| 444 |
break; |
| 445 |
} |
| 446 |
}, |
| 447 |
|
| 448 |
_sendWidgetDefaultSelected : function( item ) { |
| 449 |
if( !org_eclipse_rap_rwt_EventUtil_suspend ) { |
| 450 |
if( this._selectionListeners ) { |
| 451 |
var wm = org.eclipse.swt.WidgetManager.getInstance(); |
| 452 |
var id = wm.findIdByWidget( this ); |
| 453 |
var itemId = wm.findIdByWidget( item ); |
| 454 |
var req = org.eclipse.swt.Request.getInstance(); |
| 455 |
var eventName = "org.eclipse.swt.events.widgetDefaultSelected"; |
| 456 |
req.addEvent( eventName, id ); |
| 457 |
req.addParameter( eventName + ".item", itemId ); |
| 458 |
req.send(); |
| 459 |
} |
| 460 |
} |
| 461 |
}, |
| 433 |
|
462 |
|
| 434 |
_onChangeSelection : function( evt ) { |
463 |
_onChangeSelection : function( evt ) { |
| 435 |
this._updateSelectedItemState(); |
464 |
this._updateSelectedItemState(); |
|
Lines 445-452
Link Here
|
| 445 |
// When first visible item is selected and arrow up is pressed the root |
474 |
// When first visible item is selected and arrow up is pressed the root |
| 446 |
// item ( == this ) is selected which results in an invisible selection. |
475 |
// item ( == this ) is selected which results in an invisible selection. |
| 447 |
if( item == this ) { |
476 |
if( item == this ) { |
| 448 |
this._tree.getFirstVisibleChildOfFolder().setSelected( true ); |
477 |
this._tree.getFirstVisibleChildOfFolder().setSelected( true ); |
| 449 |
this._tree.setSelected( false ); |
478 |
this._tree.setSelected( false ); |
| 450 |
} else { |
479 |
} else { |
| 451 |
if ( this._selectionListeners ) { |
480 |
if ( this._selectionListeners ) { |
| 452 |
this._suspendClicks(); |
481 |
this._suspendClicks(); |
|
Lines 546-564
Link Here
|
| 546 |
* Handle double click on tree item |
575 |
* Handle double click on tree item |
| 547 |
* called by org.eclipse.swt.widgets.TreeItem |
576 |
* called by org.eclipse.swt.widgets.TreeItem |
| 548 |
*/ |
577 |
*/ |
| 549 |
_notifyItemDblClick : function(item) { |
578 |
_notifyItemDblClick : function( item ) { |
| 550 |
if( !org_eclipse_rap_rwt_EventUtil_suspend ) { |
579 |
this._sendWidgetDefaultSelected( item ); |
| 551 |
if( this._selectionListeners ) { |
|
|
| 552 |
var wm = org.eclipse.swt.WidgetManager.getInstance(); |
| 553 |
var id = wm.findIdByWidget( this ); |
| 554 |
var itemId = wm.findIdByWidget( item ); |
| 555 |
var req = org.eclipse.swt.Request.getInstance(); |
| 556 |
var eventName = "org.eclipse.swt.events.widgetDefaultSelected"; |
| 557 |
req.addEvent( eventName, id ); |
| 558 |
req.addParameter( eventName + ".item", itemId ); |
| 559 |
req.send(); |
| 560 |
} |
| 561 |
} |
| 562 |
}, |
580 |
}, |
| 563 |
|
581 |
|
| 564 |
/* |
582 |
/* |