tableTree.addTreeListener( new TreeListener( ) {  public void treeCollapsed( TreeEvent e ) { if ( e.item instanceof TreeItem ) { TreeItem item = (TreeItem) e.item; if ( viewer.getInput( ) != null && viewer.getInput( ) instanceof GroupElementHandle ) { GroupElementHandle handle = (GroupElementHandle) viewer.getInput( ); Object obj = handle.getElements( ).get( 0 ); if ( obj instanceof DesignElementHandle ) { ViewsMemento element = (ViewsMemento) viewerMemento.getChild( PropertyMementoUtil.getElementType( (DesignElementHandle) obj ) ); if ( element != null ) { MementoElement[] path = createItemPath( item ); PropertyMementoUtil.removeNode( element, path ); } } } viewer.getTree( ).setSelection( item ); saveSelection( item ); } }  public void treeExpanded( TreeEvent e ) { if ( e.item instanceof TreeItem ) { TreeItem item = (TreeItem) e.item; if ( viewer.getInput( ) != null && viewer.getInput( ) instanceof GroupElementHandle ) { GroupElementHandle handle = (GroupElementHandle) viewer.getInput( ); Object obj = handle.getElements( ).get( 0 ); if ( obj instanceof DesignElementHandle ) { ViewsMemento element = (ViewsMemento) viewerMemento.getChild( PropertyMementoUtil.getElementType( (DesignElementHandle) obj ) ); if ( element != null ) { MementoElement[] path = createItemPath( item ); PropertyMementoUtil.addNode( element, path ); } } } viewer.getTree( ).setSelection( item ); saveSelection( item ); }  }  } );
	private void hookControl( )	{		// Handle selections in the TableTree		// Part1: Double click only (allow traversal via keyboard without		// activation		tableTree.addSelectionListener( new SelectionAdapter( ) {			public void widgetDefaultSelected( SelectionEvent e )			{				handleSelect( (TreeItem) e.item );			}		} );		// Part2: handle single click activation of cell editor		tableTree.addMouseListener( new MouseAdapter( ) {			public void mouseDown( MouseEvent event )			{				// only activate if there is a cell editor				Point pt = new Point( event.x, event.y );				TreeItem item = tableTree.getItem( pt );				if ( item != null )				{					handleSelect( item );				}			}		} );		tableTree.addKeyListener( new KeyAdapter( ) {			public void keyReleased( KeyEvent e )			{				if ( e.character == SWT.ESC )					deactivateCellEditor( );				else if ( e.keyCode == SWT.F5 )				{					// Refresh the table when F5 pressed					// The following will simulate a reselect					viewer.setInput( viewer.getInput( ) );				}			}		} );	}