Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 334675
Collapse All | Expand All

(-)src/org/eclipse/jface/viewers/CellLabelProvider.java (+6 lines)
Lines 231-236 Link Here
231
	 * @since 1.1
231
	 * @since 1.1
232
	 */
232
	 */
233
	protected void initialize(ColumnViewer viewer, ViewerColumn column) {
233
	protected void initialize(ColumnViewer viewer, ViewerColumn column) {
234
        // RAP: [if] Cell tooltips support
235
        CellToolTipProvider.attach( viewer, this );
236
        // RAPEND: [if]
234
	}
237
	}
235
238
236
	/**
239
	/**
Lines 248-253 Link Here
248
	 */
251
	 */
249
	public void dispose(ColumnViewer viewer, ViewerColumn column) {
252
	public void dispose(ColumnViewer viewer, ViewerColumn column) {
250
		dispose();
253
		dispose();
254
        // RAP: [if] Cell tooltips support
255
        CellToolTipProvider.attach( viewer, null );
256
        // RAPEND: [if]
251
	}
257
	}
252
	
258
	
253
}
259
}
(-)src/org/eclipse/jface/viewers/CellToolTipProvider.java (-19 / +31 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009, 2010 EclipseSource and others. All rights reserved.
2
 * Copyright (c) 2009, 2011 EclipseSource and others. All rights reserved.
3
 * This program and the accompanying materials are made available under the
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
Lines 9-51 Link Here
9
 ******************************************************************************/
9
 ******************************************************************************/
10
package org.eclipse.jface.viewers;
10
package org.eclipse.jface.viewers;
11
11
12
import org.eclipse.swt.internal.widgets.ICellToolTipAdapter;
12
import org.eclipse.swt.internal.widgets.ITableAdapter;
13
import org.eclipse.swt.internal.widgets.ITableAdapter;
13
import org.eclipse.swt.internal.widgets.ICellToolTipProvider;
14
import org.eclipse.swt.internal.widgets.ICellToolTipProvider;
15
import org.eclipse.swt.internal.widgets.ITreeAdapter;
16
import org.eclipse.swt.widgets.Item;
14
import org.eclipse.swt.widgets.Table;
17
import org.eclipse.swt.widgets.Table;
18
import org.eclipse.swt.widgets.Tree;
15
19
16
/**
20
/**
17
 * Support for table tool-tips in RAP
21
 * Support for table/tree tool-tips in RAP
18
 */
22
 */
19
final class CellToolTipProvider implements ICellToolTipProvider {
23
final class CellToolTipProvider implements ICellToolTipProvider {
20
  private TableViewer viewer;
24
  private ColumnViewer viewer;
21
25
22
  CellToolTipProvider( final TableViewer viewer ) {
26
  CellToolTipProvider( final ColumnViewer viewer ) {
23
    this.viewer = viewer;
27
    this.viewer = viewer;
24
  }
28
  }
25
29
26
  static void attach( final TableViewer tableViewer,
30
  static void attach( final ColumnViewer viewer,
27
                      final IBaseLabelProvider labelProvider )
31
                      final CellLabelProvider labelProvider )
28
  {
32
  {
29
    Table table = tableViewer.getTable();
33
    ICellToolTipAdapter adapter = getAdapter( viewer );
30
    Object adapter = table.getAdapter( ITableAdapter.class );
34
    if( labelProvider != null ) {
31
    ITableAdapter tableAdapter = ( ITableAdapter )adapter;
35
      CellToolTipProvider provider = new CellToolTipProvider( viewer );
32
    if( labelProvider instanceof CellLabelProvider ) {
36
      adapter.setCellToolTipProvider( provider );
33
      CellToolTipProvider provider = new CellToolTipProvider( tableViewer );
34
      tableAdapter.setCellToolTipProvider( provider );
35
    } else {
37
    } else {
36
      tableAdapter.setCellToolTipProvider( null );
38
      adapter.setCellToolTipProvider( null );
37
    }
39
    }
38
  }
40
  }
39
41
40
  public void getToolTipText( final int itemIndex, final int columnIndex ) {
42
  private static ICellToolTipAdapter getAdapter( final ColumnViewer viewer ) {
41
    Table table = viewer.getTable();
43
    ICellToolTipAdapter result = null;
42
    Object element =  table.getItem( itemIndex ).getData();
44
    if( viewer instanceof TableViewer ) {
45
      Table table = ( ( TableViewer )viewer ).getTable();
46
      result = ( ICellToolTipAdapter )table.getAdapter( ITableAdapter.class );
47
    } else if( viewer instanceof TreeViewer ) {
48
      Tree tree = ( ( TreeViewer )viewer ).getTree();
49
      result = ( ICellToolTipAdapter )tree.getAdapter( ITreeAdapter.class );
50
    }
51
    return result;
52
  }
53
54
  public void getToolTipText( final Item item, final int columnIndex ) {
55
    Object element =  item.getData();
43
    ViewerColumn column = viewer.getViewerColumn( columnIndex );
56
    ViewerColumn column = viewer.getViewerColumn( columnIndex );
44
    CellLabelProvider labelProvider = column.getLabelProvider();
57
    CellLabelProvider labelProvider = column.getLabelProvider();
45
    String text = labelProvider.getToolTipText( element );
58
    String text = labelProvider.getToolTipText( element );
46
    Object adapter = table.getAdapter( ITableAdapter.class );
59
    ICellToolTipAdapter adapter = getAdapter( viewer );
47
    ITableAdapter tableAdapter = ( ITableAdapter )adapter;
60
    adapter.setToolTipText( text );
48
    tableAdapter.setToolTipText( text );
49
  }
61
  }
50
62
51
}
63
}
(-)src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java (-8 / +7 lines)
Lines 22-28 Link Here
22
//import org.eclipse.swt.graphics.Point;
22
//import org.eclipse.swt.graphics.Point;
23
//import org.eclipse.swt.widgets.Composite;
23
//import org.eclipse.swt.widgets.Composite;
24
//import org.eclipse.swt.widgets.Event;
24
//import org.eclipse.swt.widgets.Event;
25
import org.eclipse.swt.widgets.Table;
25
import org.eclipse.swt.internal.widgets.ICellToolTipProvider;
26
26
27
/**
27
/**
28
 * The ColumnViewerTooltipSupport is the class that provides tool tips for
28
 * The ColumnViewerTooltipSupport is the class that provides tool tips for
Lines 31-37 Link Here
31
 * @since 1.3
31
 * @since 1.3
32
 *
32
 *
33
 */
33
 */
34
// RAP [rh] RAP provides tooltip support only for the table widget
34
// RAP [rh] RAP provides tooltip support for the table and tree widgets
35
//     In addition RAP cannot reuse the DefaultToolTip and ToolTip as these  
35
//     In addition RAP cannot reuse the DefaultToolTip and ToolTip as these  
36
//     classes make heavy use of mouse events 
36
//     classes make heavy use of mouse events 
37
public class ColumnViewerToolTipSupport 
37
public class ColumnViewerToolTipSupport 
Lines 77-88 Link Here
77
	 * @param viewer
77
	 * @param viewer
78
	 *            the viewer the support is attached to
78
	 *            the viewer the support is attached to
79
	 */
79
	 */
80
//	public static void enableFor(ColumnViewer viewer) {
80
    public static void enableFor(ColumnViewer viewer) {
81
//		new ColumnViewerToolTipSupport(viewer, ToolTip.NO_RECREATE, false);
81
//      new ColumnViewerToolTipSupport(viewer, ToolTip.NO_RECREATE, false);
82
//	}
82
        viewer.getControl().setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP,
83
public static void enableFor(AbstractTableViewer viewer) {
83
                                     Boolean.TRUE );
84
  viewer.getControl().setData( Table.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
84
    }
85
}
86
85
87
// RAP [rh] ToolTip style not supported 
86
// RAP [rh] ToolTip style not supported 
88
//	/**
87
//	/**
(-)src/org/eclipse/jface/viewers/TableViewerColumn.java (-6 lines)
Lines 87-96 Link Here
87
		return column;
87
		return column;
88
	}
88
	}
89
89
90
// RAP: [if] Table cell tooltips support
91
	public void setLabelProvider( final CellLabelProvider labelProvider ) {
92
      super.setLabelProvider( labelProvider );
93
      CellToolTipProvider.attach( ( TableViewer )getViewer(), labelProvider );
94
    }
95
// RAPEND: [if]
96
}
90
}
(-)src/org/eclipse/swt/internal/widgets/ICellToolTipAdapter.java (+20 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 EclipseSource and others. All rights reserved.
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
6
 *
7
 * Contributors:
8
 *   EclipseSource - initial API and implementation
9
 ******************************************************************************/
10
package org.eclipse.swt.internal.widgets;
11
12
public interface ICellToolTipAdapter {
13
14
  ICellToolTipProvider getCellToolTipProvider();
15
  void setCellToolTipProvider( ICellToolTipProvider provider );
16
17
  String getToolTipText();
18
  void setToolTipText( String toolTipText );
19
20
}
(-)src/org/eclipse/swt/internal/widgets/ICellToolTipProvider.java (-2 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 EclipseSource and others. All rights reserved.
2
 * Copyright (c) 2009, 2011 EclipseSource and others. All rights reserved.
3
 * This program and the accompanying materials are made available under the
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
Lines 9-17 Link Here
9
 ******************************************************************************/
9
 ******************************************************************************/
10
package org.eclipse.swt.internal.widgets;
10
package org.eclipse.swt.internal.widgets;
11
11
12
import org.eclipse.swt.widgets.Item;
13
12
14
13
public interface ICellToolTipProvider {
15
public interface ICellToolTipProvider {
14
16
15
  void getToolTipText( int itemIndex, int columnIndex );
17
  public static final String ENABLE_CELL_TOOLTIP
18
    = ICellToolTipProvider.class.getName() + "#enableCellToolTip";
19
20
  void getToolTipText( Item item, int columnIndex );
16
21
17
}
22
}
(-)src/org/eclipse/swt/internal/widgets/ITableAdapter.java (-8 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2009 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2007, 2011 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 14-20 Link Here
14
import org.eclipse.swt.widgets.TableColumn;
14
import org.eclipse.swt.widgets.TableColumn;
15
import org.eclipse.swt.widgets.TableItem;
15
import org.eclipse.swt.widgets.TableItem;
16
16
17
public interface ITableAdapter {
17
public interface ITableAdapter extends ICellToolTipAdapter {
18
18
19
  int getCheckWidth();
19
  int getCheckWidth();
20
  int getItemImageWidth( int columnIndex );
20
  int getItemImageWidth( int columnIndex );
Lines 40-49 Link Here
40
  boolean hasVScrollBar();
40
  boolean hasVScrollBar();
41
41
42
  TableItem getMeasureItem();
42
  TableItem getMeasureItem();
43
44
  ICellToolTipProvider getCellToolTipProvider();
45
  void setCellToolTipProvider( ICellToolTipProvider provider );
46
47
  String getToolTipText();
48
  void setToolTipText( String toolTipText );
49
}
43
}
(-)src/org/eclipse/swt/internal/widgets/ITreeAdapter.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2011 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 15-21 Link Here
15
import org.eclipse.swt.graphics.Rectangle;
15
import org.eclipse.swt.graphics.Rectangle;
16
import org.eclipse.swt.widgets.*;
16
import org.eclipse.swt.widgets.*;
17
17
18
public interface ITreeAdapter {
18
public interface ITreeAdapter extends ICellToolTipAdapter {
19
19
20
  void setScrollLeft( final int left );
20
  void setScrollLeft( final int left );
21
  int getScrollLeft();
21
  int getScrollLeft();
(-)src/org/eclipse/swt/widgets/Table.java (-10 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2011 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 243-257 Link Here
243
  public static final String ALWAYS_HIDE_SELECTION
243
  public static final String ALWAYS_HIDE_SELECTION
244
    = Table.class.getName() + "#alwaysHideSelection";
244
    = Table.class.getName() + "#alwaysHideSelection";
245
245
246
  /**
247
   * <strong>IMPORTANT:</strong> This field is <em>not</em> part of the SWT
248
   * public API. It is marked public only so that it can be shared
249
   * within the packages provided by SWT. It should never be accessed from
250
   * application code.
251
   */
252
  public static final String ENABLE_CELL_TOOLTIP
253
    = Table.class.getName() + "#enableCellToolTip";
254
255
  private static final int GRID_WIDTH = 1;
246
  private static final int GRID_WIDTH = 1;
256
247
257
  private static final int[] EMPTY_SELECTION = new int[ 0 ];
248
  private static final int[] EMPTY_SELECTION = new int[ 0 ];
(-)src/org/eclipse/swt/widgets/Tree.java (-1 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2011 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 155-160 Link Here
155
  }
155
  }
156
  private final class InternalTreeAdapter implements ITreeAdapter {
156
  private final class InternalTreeAdapter implements ITreeAdapter {
157
157
158
    private String toolTipText;
159
    private ICellToolTipProvider provider;
160
158
    public void setScrollLeft( final int left ) {
161
    public void setScrollLeft( final int left ) {
159
      Tree.this.scrollLeft = left;
162
      Tree.this.scrollLeft = left;
160
    }
163
    }
Lines 232-237 Link Here
232
      return Tree.this.getColumn( index ).getLeft();
235
      return Tree.this.getColumn( index ).getLeft();
233
    }
236
    }
234
237
238
    public ICellToolTipProvider getCellToolTipProvider() {
239
      return provider;
240
    }
241
242
    public void setCellToolTipProvider( final ICellToolTipProvider provider ) {
243
      this.provider = provider;
244
    }
245
246
    public String getToolTipText() {
247
      return toolTipText;
248
    }
249
250
    public void setToolTipText( final String toolTipText ) {
251
      this.toolTipText = toolTipText;
252
    }
253
235
  }
254
  }
236
255
237
  private static final class ResizeListener extends ControlAdapter {
256
  private static final class ResizeListener extends ControlAdapter {
(-)js/org/eclipse/rwt/widgets/Tree.js (-1 / +62 lines)
Lines 71-76 Link Here
71
    this.add( this._clientArea );
71
    this.add( this._clientArea );
72
    this.add( this._horzScrollBar );
72
    this.add( this._horzScrollBar );
73
    this.add( this._vertScrollBar );
73
    this.add( this._vertScrollBar );
74
    // Cell tooltip
75
    this._cellToolTip = null;
74
    // Configure:
76
    // Configure:
75
    this.setCursor( "default" );
77
    this.setCursor( "default" );
76
    this.setOverflow( "hidden" );
78
    this.setOverflow( "hidden" );
Lines 102-107 Link Here
102
    this._hoverItem = null;
104
    this._hoverItem = null;
103
    this._hoverElement = null;
105
    this._hoverElement = null;
104
    this._resizeLine = null;
106
    this._resizeLine = null;
107
    if( this._cellToolTip ) {
108
      this._cellToolTip.destroy();
109
      this._cellToolTip = null;
110
    }
105
  },
111
  },
106
112
107
  members : {
113
  members : {
Lines 448-454 Link Here
448
    getColumnCount : function() {
454
    getColumnCount : function() {
449
      return Math.max( 1, this._columnCount );
455
      return Math.max( 1, this._columnCount );
450
    },
456
    },
451
    
457
458
    getColumns : function() {
459
      return this._columnArea.getChildren().slice( 1 );
460
    },
461
452
    getRootItem : function() {
462
    getRootItem : function() {
453
      return this._rootItem;
463
      return this._rootItem;
454
    },
464
    },
Lines 1653-1658 Link Here
1653
    
1663
    
1654
    _isDragSource : function() {
1664
    _isDragSource : function() {
1655
      return this.hasEventListeners( "dragstart" ); 
1665
      return this.hasEventListeners( "dragstart" ); 
1666
    },
1667
    
1668
    ////////////////////////
1669
    // Cell tooltip handling
1670
1671
    setEnableCellToolTip : function( value ) {
1672
      if( value ) {
1673
        var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
1674
        var id = widgetManager.findIdByWidget( this );
1675
        this._cellToolTip = new org.eclipse.swt.widgets.TableCellToolTip( id );
1676
        this._clientArea.addEventListener( "mousemove",
1677
                                           this._onClientAreaMouseMove,
1678
                                           this );
1679
        this._clientArea.setToolTip( this._cellToolTip );
1680
      } else {
1681
        this._clientArea.removeEventListener( "mousemove",
1682
                                              this._onClientAreaMouseMove,
1683
                                              this );
1684
        this._clientArea.setToolTip( null );
1685
        this._cellToolTip.destroy();
1686
        this._cellToolTip = null;
1687
      }
1688
    },
1689
1690
    _onClientAreaMouseMove : function( evt ) {
1691
      if( this._cellToolTip != null ) {
1692
        var pageX = evt.getPageX();
1693
        var pageY = evt.getPageY();
1694
        if( this._hoverItem ) {
1695
          var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
1696
          var itemId = widgetManager.findIdByWidget( this._hoverItem );
1697
          var columnIndex = -1;
1698
          var columns = this.getColumns();
1699
          var element = this._clientArea.getElement();
1700
          var leftOffset = qx.bom.element.Location.getLeft( element );
1701
          for( var i = 0; columnIndex == -1 && i < columns.length; i++ ) {
1702
            var pageLeft = leftOffset + this._itemLeft[ i ];
1703
            if( pageX >= pageLeft && pageX < pageLeft + this._itemWidth[ i ] ) {
1704
              columnIndex = i;
1705
            }
1706
          }        
1707
          this._cellToolTip.setCell( itemId, columnIndex );
1708
        }
1709
      }
1710
    },
1711
1712
    /** Only called by server-side */
1713
    setCellToolTipText : function( text ) {
1714
      if( this._cellToolTip != null ) {
1715
        this._cellToolTip.setText( text );
1716
      }
1656
    }
1717
    }
1657
    
1718
    
1658
  }
1719
  }
(-)js/org/eclipse/swt/widgets/Table.js (-22 / +36 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2007, 2011 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 160-171 Link Here
160
    this.add( this._clientArea );
160
    this.add( this._clientArea );
161
    // Cell tooltip
161
    // Cell tooltip
162
    this._cellToolTip = null;
162
    this._cellToolTip = null;
163
    if( qx.lang.String.contains( style, "enableCellToolTip" ) ) {
164
      this._cellToolTip = new org.eclipse.swt.widgets.TableCellToolTip();
165
      this._cellToolTip.setTableId( id );
166
      this._clientArea.addEventListener( "mousemove", this._onClientAreaMouseMove, this );
167
      this._clientArea.setToolTip( this._cellToolTip );
168
    }
169
    // Disable scrolling (see bug 279460)
163
    // Disable scrolling (see bug 279460)
170
    qx.ui.core.Widget.disableScrolling( this );
164
    qx.ui.core.Widget.disableScrolling( this );
171
    // Fix for bug Bug 297202
165
    // Fix for bug Bug 297202
Lines 228-234 Link Here
228
      this._clientArea = null;
222
      this._clientArea = null;
229
    }
223
    }
230
    if( this._cellToolTip ) {
224
    if( this._cellToolTip ) {
231
      this._cellToolTip.dispose();
225
      this._cellToolTip.destroy();
232
      this._cellToolTip = null;
226
      this._cellToolTip = null;
233
    }
227
    }
234
    if( this._columnArea ) {
228
    if( this._columnArea ) {
Lines 1730-1755 Link Here
1730
    ////////////////////////
1724
    ////////////////////////
1731
    // Cell tooltip handling
1725
    // Cell tooltip handling
1732
1726
1727
    setEnableCellToolTip : function( value ) {
1728
      if( value ) {
1729
        var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
1730
        var id = widgetManager.findIdByWidget( this );
1731
        this._cellToolTip = new org.eclipse.swt.widgets.TableCellToolTip( id );
1732
        this._clientArea.addEventListener( "mousemove",
1733
                                           this._onClientAreaMouseMove,
1734
                                           this );
1735
        this._clientArea.setToolTip( this._cellToolTip );
1736
      } else {
1737
        this._clientArea.removeEventListener( "mousemove",
1738
                                              this._onClientAreaMouseMove,
1739
                                              this );
1740
        this._clientArea.setToolTip( null );
1741
        this._cellToolTip.destroy();
1742
        this._cellToolTip = null;
1743
      }
1744
    },
1745
1733
    _onClientAreaMouseMove : function( evt ) {
1746
    _onClientAreaMouseMove : function( evt ) {
1734
      if( this._cellToolTip != null ) {
1747
      if( this._cellToolTip != null ) {
1735
        var pageX = evt.getPageX();
1748
        var pageX = evt.getPageX();
1736
        var pageY = evt.getPageY();
1749
        var pageY = evt.getPageY();
1737
        var row = this._getRowAtPoint( pageX, pageY );
1750
        var row = this._getRowAtPoint( pageX, pageY );
1738
        var rowIndex = this._rows.indexOf( row );
1751
        var itemIndex = row.getItemIndex();
1739
        var itemIndex = this._getItemIndexFromRowIndex( rowIndex );
1752
        if( itemIndex != -1 ) {
1740
        var columnIndex = -1;
1753
	        var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
1741
        var columns = this.getColumns();
1754
	        var itemId = widgetManager.findIdByWidget( this._items[ itemIndex ] );
1742
        for( var i = 0; columnIndex == -1 && i < columns.length; i++ ) {
1755
	        var columnIndex = -1;
1743
          var element = this._clientArea.getElement();
1756
	        var columns = this.getColumns();
1744
          var pageLeft = qx.bom.element.Location.getLeft( element )
1757
	        var element = this._clientArea.getElement();
1745
                       + this._itemLeft[ i ];
1758
	        var leftOffset = qx.bom.element.Location.getLeft( element );
1746
          if(    pageX >= pageLeft
1759
	        for( var i = 0; columnIndex == -1 && i < columns.length; i++ ) {
1747
              && pageX < pageLeft + this._itemWidth[ i ] )
1760
	          var pageLeft = leftOffset + this._itemLeft[ i ];
1748
          {
1761
	          if( pageX >= pageLeft && pageX < pageLeft + this._itemWidth[ i ] ) {
1749
            columnIndex = i;
1762
	            columnIndex = i;
1750
          }
1763
	          }
1764
	        }        
1765
	        this._cellToolTip.setCell( itemId, columnIndex );
1751
        }
1766
        }
1752
        this._cellToolTip.setCell( itemIndex, columnIndex );
1753
      }
1767
      }
1754
    },
1768
    },
1755
1769
(-)js/org/eclipse/swt/widgets/TableCellToolTip.js (-15 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 EclipseSource and others. All rights reserved.
2
 * Copyright (c) 2009, 2011 EclipseSource and others. All rights reserved.
3
 * This program and the accompanying materials are made available under the
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
Lines 12-21 Link Here
12
  extend : qx.ui.popup.ToolTip,
12
  extend : qx.ui.popup.ToolTip,
13
  include : org.eclipse.rwt.FadeAnimationMixin,
13
  include : org.eclipse.rwt.FadeAnimationMixin,
14
14
15
  construct : function() {
15
  construct : function( controlId ) {
16
    this.base( arguments );
16
    this.base( arguments );
17
    this._tableId = -1;
17
    this._controlId = controlId;
18
    this._itemIndex = -1;
18
    this._itemId = null;
19
    this._columnIndex = -1;
19
    this._columnIndex = -1;
20
  },
20
  },
21
21
Lines 37-53 Link Here
37
      }
37
      }
38
    },
38
    },
39
39
40
    setTableId : function( tableId ) {
40
    setCell : function( itemId, columnIndex ) {
41
      this._tableId = tableId;
41
      if( this._itemId != itemId || this._columnIndex != columnIndex ) {
42
    },
42
        this._itemId = itemId;
43
44
    setCell : function( itemIndex, columnIndex ) {
45
      if( this._itemIndex != itemIndex || this._columnIndex != columnIndex ) {
46
        this._itemIndex = itemIndex;
47
        this._columnIndex = columnIndex;
43
        this._columnIndex = columnIndex;
48
        this.hide();
44
        this.hide();
49
        if(   !this._showTimer.getEnabled()
45
        if(   !this._showTimer.getEnabled()
50
            && itemIndex != -1
46
            && itemId != null
51
            && columnIndex != -1 )
47
            && columnIndex != -1 )
52
        {
48
        {
53
          this._showTimer.start();
49
          this._showTimer.start();
Lines 56-66 Link Here
56
    },
52
    },
57
53
58
    _requestCellToolTipText : function() {
54
    _requestCellToolTipText : function() {
59
      if( this._itemIndex != -1 && this._columnIndex != -1 ) {
55
      if( this._itemId != null && this._columnIndex != -1 ) {
60
        var req = org.eclipse.swt.Request.getInstance();
56
        var req = org.eclipse.swt.Request.getInstance();
61
        req.addEvent( "org.eclipse.swt.events.cellToolTipTextRequested",
57
        req.addEvent( "org.eclipse.swt.events.cellToolTipTextRequested",
62
                      this._tableId );
58
                      this._controlId );
63
        var cell = this._itemIndex + "," + this._columnIndex;
59
        var cell = this._itemId + "," + this._columnIndex;
64
        req.addParameter( "org.eclipse.swt.events.cellToolTipTextRequested.cell",
60
        req.addParameter( "org.eclipse.swt.events.cellToolTipTextRequested.cell",
65
                          cell );
61
                          cell );
66
        req.send();
62
        req.send();
(-)src/org/eclipse/rwt/internal/lifecycle/JSConst.java (-3 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2011 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 13-20 Link Here
13
13
14
import org.eclipse.rwt.lifecycle.JSVar;
14
import org.eclipse.rwt.lifecycle.JSVar;
15
15
16
17
18
/**
16
/**
19
 * Commonly used request parameter names and JavaScript names.
17
 * Commonly used request parameter names and JavaScript names.
20
 */
18
 */
Lines 61-66 Link Here
61
  public static final String EVENT_MENU_DETECT
59
  public static final String EVENT_MENU_DETECT
62
    = "org.eclipse.swt.events.menuDetect";
60
    = "org.eclipse.swt.events.menuDetect";
63
61
62
  // Request cell tooltip text event
63
  public static final String EVENT_CELL_TOOLTIP_REQUESTED
64
    = "org.eclipse.swt.events.cellToolTipTextRequested";
64
65
65
  // Parameter names that specify further event details
66
  // Parameter names that specify further event details
66
  public static final String EVENT_WIDGET_SELECTED_DETAIL
67
  public static final String EVENT_WIDGET_SELECTED_DETAIL
Lines 114-119 Link Here
114
  public static final String EVENT_MENU_DETECT_Y
115
  public static final String EVENT_MENU_DETECT_Y
115
    = "org.eclipse.swt.events.menuDetect.y";
116
    = "org.eclipse.swt.events.menuDetect.y";
116
117
118
  // Request cell tooltip text event details
119
  public static final String EVENT_CELL_TOOLTIP_DETAILS
120
    = "org.eclipse.swt.events.cellToolTipTextRequested.cell";
121
117
  // Indicates that a shell was closed on the client side. The parameter
122
  // Indicates that a shell was closed on the client side. The parameter
118
  // value holds the id of the shell that was closed.
123
  // value holds the id of the shell that was closed.
119
  public static final String EVENT_SHELL_CLOSED
124
  public static final String EVENT_SHELL_CLOSED
(-)src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java (-39 / +70 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2011 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 22-41 Link Here
22
import org.eclipse.swt.events.SelectionEvent;
22
import org.eclipse.swt.events.SelectionEvent;
23
import org.eclipse.swt.graphics.Rectangle;
23
import org.eclipse.swt.graphics.Rectangle;
24
import org.eclipse.swt.internal.events.EventLCAUtil;
24
import org.eclipse.swt.internal.events.EventLCAUtil;
25
import org.eclipse.swt.internal.widgets.ITableAdapter;
25
import org.eclipse.swt.internal.widgets.*;
26
import org.eclipse.swt.internal.widgets.ICellToolTipProvider;
27
import org.eclipse.swt.widgets.*;
26
import org.eclipse.swt.widgets.*;
28
27
29
28
30
public final class TableLCA extends AbstractWidgetLCA {
29
public final class TableLCA extends AbstractWidgetLCA {
31
30
32
  // Request cell tooltip text event
33
  static final String EVENT_CELL_TOOLTIP_REQUESTED
34
    = "org.eclipse.swt.events.cellToolTipTextRequested";
35
  // Parameter names that specify further event details
36
  static final String EVENT_CELL_TOOLTIP_DETAILS
37
    = "org.eclipse.swt.events.cellToolTipTextRequested.cell";
38
39
  // Property names to preserve values
31
  // Property names to preserve values
40
  static final String PROP_HEADER_HEIGHT = "headerHeight";
32
  static final String PROP_HEADER_HEIGHT = "headerHeight";
41
  static final String PROP_HEADER_VISIBLE = "headerVisible";
33
  static final String PROP_HEADER_VISIBLE = "headerVisible";
Lines 51-56 Link Here
51
  static final String PROP_LEFT_OFFSET = "leftOffset";
43
  static final String PROP_LEFT_OFFSET = "leftOffset";
52
  static final String PROP_SCROLLBARS_SELECTION_LISTENER
44
  static final String PROP_SCROLLBARS_SELECTION_LISTENER
53
    = "scrollBarsSelectionListeners";
45
    = "scrollBarsSelectionListeners";
46
  static final String PROP_ENABLE_CELL_TOOLTIP
47
    = "enableCellToolTip";
54
48
55
  private static final Integer DEFAULT_TOP_INDEX = new Integer( 0 );
49
  private static final Integer DEFAULT_TOP_INDEX = new Integer( 0 );
56
  private static final Integer DEFAULT_ITEM_COUNT = new Integer( 0 );
50
  private static final Integer DEFAULT_ITEM_COUNT = new Integer( 0 );
Lines 100-105 Link Here
100
    adapter.preserve( PROP_LEFT_OFFSET, getLeftOffset( table ) );
94
    adapter.preserve( PROP_LEFT_OFFSET, getLeftOffset( table ) );
101
    adapter.preserve( PROP_SCROLLBARS_SELECTION_LISTENER,
95
    adapter.preserve( PROP_SCROLLBARS_SELECTION_LISTENER,
102
                      hasScrollBarsSelectionListener( table ) );
96
                      hasScrollBarsSelectionListener( table ) );
97
    adapter.preserve( PROP_ENABLE_CELL_TOOLTIP,
98
                      isCellToolTipEnabled( table ) );
103
  }
99
  }
104
100
105
  public void readData( final Widget widget ) {
101
  public void readData( final Widget widget ) {
Lines 127-135 Link Here
127
    if( ( table.getStyle() & SWT.MULTI ) != 0 ) {
123
    if( ( table.getStyle() & SWT.MULTI ) != 0 ) {
128
      style += "|multi";
124
      style += "|multi";
129
    }
125
    }
130
    if( Boolean.TRUE.equals( table.getData( Table.ENABLE_CELL_TOOLTIP ) ) ) {
131
      style += "|enableCellToolTip";
132
    }
133
    if( ( table.getStyle() & SWT.HIDE_SELECTION ) != 0 ) {
126
    if( ( table.getStyle() & SWT.HIDE_SELECTION ) != 0 ) {
134
      style += "|hideSelection";
127
      style += "|hideSelection";
135
    }
128
    }
Lines 159-164 Link Here
159
    writeAlwaysHideSelection( table );
152
    writeAlwaysHideSelection( table );
160
    writeScrollBarsVisible( table );
153
    writeScrollBarsVisible( table );
161
    writeLeftOffset( table );
154
    writeLeftOffset( table );
155
    writeEnableCellToolTip( table );
162
    writeCellToolTipText( table );
156
    writeCellToolTipText( table );
163
    WidgetLCAUtil.writeCustomVariant( table );
157
    WidgetLCAUtil.writeCustomVariant( table );
164
  }
158
  }
Lines 311-340 Link Here
311
    return result;
305
    return result;
312
  }
306
  }
313
307
314
  private static void readCellToolTipTextRequested( final Table table ) {
315
    Object adapter = table.getAdapter( ITableAdapter.class );
316
    ITableAdapter tableAdapter = ( ITableAdapter )adapter;
317
    tableAdapter.setToolTipText( null );
318
    String event = EVENT_CELL_TOOLTIP_REQUESTED;
319
    if( WidgetLCAUtil.wasEventSent( table, event ) ) {
320
      ICellToolTipProvider provider = tableAdapter.getCellToolTipProvider();
321
      if( provider != null ) {
322
        HttpServletRequest request = ContextProvider.getRequest();
323
        String cell = request.getParameter( EVENT_CELL_TOOLTIP_DETAILS );
324
        String[] indices = cell.split( "," );
325
        int itemIndex = Integer.parseInt( indices[ 0 ] );
326
        int columnIndex = Integer.parseInt( indices[ 1 ] );
327
        // Bug 321119: Sometimes the client can request tooltips for already
328
        //             disposed cells.
329
        if(    itemIndex < table.getItemCount()
330
            && ( columnIndex == 0 || columnIndex < table.getColumnCount() ) )
331
        {
332
          provider.getToolTipText( itemIndex, columnIndex );
333
        }
334
      }
335
    }
336
  }
337
338
  ///////////////////////////////////////////
308
  ///////////////////////////////////////////
339
  // Helping methods to write JavaScript code
309
  // Helping methods to write JavaScript code
340
310
Lines 464-481 Link Here
464
    writer.set( PROP_LEFT_OFFSET, "leftOffset", newValue, DEFAULT_LEFT_OFFSET );
434
    writer.set( PROP_LEFT_OFFSET, "leftOffset", newValue, DEFAULT_LEFT_OFFSET );
465
  }
435
  }
466
436
467
  private void writeCellToolTipText( final Table table ) throws IOException {
437
  ////////////////
438
  // Cell tooltips
439
440
  private static Boolean isCellToolTipEnabled( final Table table ) {
441
    Boolean result = Boolean.FALSE;
442
    Object data = table.getData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP );
443
    if( Boolean.TRUE.equals( data ) ) {
444
      result = Boolean.TRUE;
445
    }
446
    return result;
447
  }
448
449
  private static void writeEnableCellToolTip( final Table table )
450
    throws IOException
451
  {
452
    JSWriter writer = JSWriter.getWriterFor( table );
453
    Boolean newValue = isCellToolTipEnabled( table );
454
    Boolean defValue = Boolean.FALSE;
455
    String prop = PROP_ENABLE_CELL_TOOLTIP;
456
    writer.set( prop, "enableCellToolTip", newValue, defValue );
457
  }
458
459
  private static void readCellToolTipTextRequested( final Table table ) {
460
    Object adapter = table.getAdapter( ITableAdapter.class );
461
    ITableAdapter tableAdapter = ( ITableAdapter )adapter;
462
    tableAdapter.setToolTipText( null );
463
    String event = JSConst.EVENT_CELL_TOOLTIP_REQUESTED;
464
    if( WidgetLCAUtil.wasEventSent( table, event ) ) {
465
      ICellToolTipProvider provider = tableAdapter.getCellToolTipProvider();
466
      if( provider != null ) {
467
        HttpServletRequest request = ContextProvider.getRequest();
468
        String cell = request.getParameter( JSConst.EVENT_CELL_TOOLTIP_DETAILS );
469
        String[] details = cell.split( "," );
470
        String itemId = details[ 0 ];
471
        int columnIndex = Integer.parseInt( details[ 1 ] );
472
        TableItem item = getItemById( table, itemId );
473
        // Bug 321119: Sometimes the client can request tooltips for already
474
        //             disposed cells.
475
        if(    item != null
476
            && ( columnIndex == 0 || columnIndex < table.getColumnCount() ) )
477
        {
478
          provider.getToolTipText( item, columnIndex );
479
        }
480
      }
481
    }
482
  }
483
484
  private static void writeCellToolTipText( final Table table )
485
    throws IOException
486
  {
468
    Object adapter = table.getAdapter( ITableAdapter.class );
487
    Object adapter = table.getAdapter( ITableAdapter.class );
469
    ITableAdapter tableAdapter = ( ITableAdapter )adapter;
488
    ITableAdapter tableAdapter = ( ITableAdapter )adapter;
470
    String text = tableAdapter.getToolTipText();
489
    String text = tableAdapter.getToolTipText();
471
    if( text != null ) {
490
    if( text != null ) {
472
      JSWriter writer = JSWriter.getWriterFor( table );
491
      JSWriter writer = JSWriter.getWriterFor( table );
473
      text = WidgetLCAUtil.escapeText( text, false );
492
      text = WidgetLCAUtil.escapeText( text, false );
474
      text = WidgetLCAUtil.replaceNewLines( text, "<br>" );
493
      text = WidgetLCAUtil.replaceNewLines( text, "<br/>" );
475
      writer.call( "setCellToolTipText", new String[]{ text } );
494
      writer.call( "setCellToolTipText", new String[]{ text } );
476
    }
495
    }
477
  }
496
  }
478
497
498
  private static TableItem getItemById( final Table table, final String itemId )
499
  {
500
    TableItem result = null;
501
    TableItem[] items = table.getItems();
502
    for( int i = 0; i < items.length && result == null; i++ ) {
503
      if( WidgetUtil.getId( items[ i ] ).equals( itemId ) ) {
504
        result = items[ i ];
505
      }
506
    }
507
    return result;
508
  }
509
479
  //////////////////
510
  //////////////////
480
  // Helping methods
511
  // Helping methods
481
512
(-)src/org/eclipse/swt/internal/widgets/treekit/TreeLCA.java (-2 / +82 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2011 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 22-28 Link Here
22
import org.eclipse.swt.events.*;
22
import org.eclipse.swt.events.*;
23
import org.eclipse.swt.graphics.Rectangle;
23
import org.eclipse.swt.graphics.Rectangle;
24
import org.eclipse.swt.internal.events.EventLCAUtil;
24
import org.eclipse.swt.internal.events.EventLCAUtil;
25
import org.eclipse.swt.internal.widgets.ITreeAdapter;
25
import org.eclipse.swt.internal.widgets.*;
26
import org.eclipse.swt.widgets.*;
26
import org.eclipse.swt.widgets.*;
27
27
28
public final class TreeLCA extends AbstractWidgetLCA {
28
public final class TreeLCA extends AbstractWidgetLCA {
Lines 42-47 Link Here
42
  static final String PROP_LINES_VISIBLE = "linesVisible";
42
  static final String PROP_LINES_VISIBLE = "linesVisible";
43
  static final String PROP_SCROLLBARS_SELECTION_LISTENER
43
  static final String PROP_SCROLLBARS_SELECTION_LISTENER
44
    = "scrollBarsSelectionListeners";
44
    = "scrollBarsSelectionListeners";
45
  static final String PROP_ENABLE_CELL_TOOLTIP
46
    = "enableCellToolTip";
45
47
46
  private static final Integer DEFAULT_SCROLL_LEFT = new Integer( 0 );
48
  private static final Integer DEFAULT_SCROLL_LEFT = new Integer( 0 );
47
49
Lines 67-72 Link Here
67
    adapter.preserve( PROP_HAS_V_SCROLL_BAR, hasVScrollBar( tree ) );
69
    adapter.preserve( PROP_HAS_V_SCROLL_BAR, hasVScrollBar( tree ) );
68
    adapter.preserve( PROP_SCROLLBARS_SELECTION_LISTENER,
70
    adapter.preserve( PROP_SCROLLBARS_SELECTION_LISTENER,
69
                      hasScrollBarsSelectionListener( tree ) );
71
                      hasScrollBarsSelectionListener( tree ) );
72
    adapter.preserve( PROP_ENABLE_CELL_TOOLTIP,
73
                      isCellToolTipEnabled( tree ) );
70
    WidgetLCAUtil.preserveCustomVariant( tree );
74
    WidgetLCAUtil.preserveCustomVariant( tree );
71
  }
75
  }
72
76
Lines 77-82 Link Here
77
    readTopItemIndex( tree );
81
    readTopItemIndex( tree );
78
    processWidgetSelectedEvent( tree );
82
    processWidgetSelectedEvent( tree );
79
    processWidgetDefaultSelectedEvent( tree );
83
    processWidgetDefaultSelectedEvent( tree );
84
    readCellToolTipTextRequested( tree );
80
    ControlLCAUtil.processMouseEvents( tree );
85
    ControlLCAUtil.processMouseEvents( tree );
81
    ControlLCAUtil.processKeyEvents( tree );
86
    ControlLCAUtil.processKeyEvents( tree );
82
    ControlLCAUtil.processMenuDetect( tree );
87
    ControlLCAUtil.processMenuDetect( tree );
Lines 132-137 Link Here
132
    writeHeaderHeight( tree );
137
    writeHeaderHeight( tree );
133
    writeHeaderVisible( tree );
138
    writeHeaderVisible( tree );
134
    writeScrollLeft( tree );
139
    writeScrollLeft( tree );
140
    writeEnableCellToolTip( tree );
141
    writeCellToolTipText( tree );
135
    WidgetLCAUtil.writeCustomVariant( tree );
142
    WidgetLCAUtil.writeCustomVariant( tree );
136
  }
143
  }
137
144
Lines 366-371 Link Here
366
    }
373
    }
367
  }
374
  }
368
375
376
  ////////////////
377
  // Cell tooltips
378
379
  private static Boolean isCellToolTipEnabled( final Tree tree ) {
380
    Boolean result = Boolean.FALSE;
381
    Object data = tree.getData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP );
382
    if( Boolean.TRUE.equals( data ) ) {
383
      result = Boolean.TRUE;
384
    }
385
    return result;
386
  }
387
388
  private static void writeEnableCellToolTip( final Tree tree )
389
    throws IOException
390
  {
391
    JSWriter writer = JSWriter.getWriterFor( tree );
392
    Boolean newValue = isCellToolTipEnabled( tree );
393
    Boolean defValue = Boolean.FALSE;
394
    String prop = PROP_ENABLE_CELL_TOOLTIP;
395
    writer.set( prop, "enableCellToolTip", newValue, defValue );
396
  }
397
398
  private static void readCellToolTipTextRequested( final Tree tree ) {
399
    Object adapter = tree.getAdapter( ITreeAdapter.class );
400
    ITreeAdapter treeAdapter = ( ITreeAdapter )adapter;
401
    treeAdapter.setToolTipText( null );
402
    String event = JSConst.EVENT_CELL_TOOLTIP_REQUESTED;
403
    if( WidgetLCAUtil.wasEventSent( tree, event ) ) {
404
      ICellToolTipProvider provider = treeAdapter.getCellToolTipProvider();
405
      if( provider != null ) {
406
        HttpServletRequest request = ContextProvider.getRequest();
407
        String cell = request.getParameter( JSConst.EVENT_CELL_TOOLTIP_DETAILS );
408
        String[] details = cell.split( "," );
409
        String itemId = details[ 0 ];
410
        int columnIndex = Integer.parseInt( details[ 1 ] );
411
        TreeItem item = getItemById( tree.getItems(), itemId );
412
        if(    item != null
413
            && ( columnIndex == 0 || columnIndex < tree.getColumnCount() ) )
414
        {
415
          provider.getToolTipText( item, columnIndex );
416
        }
417
      }
418
    }
419
  }
420
421
  private static void writeCellToolTipText( final Tree tree )
422
    throws IOException
423
  {
424
    Object adapter = tree.getAdapter( ITreeAdapter.class );
425
    ITreeAdapter treeAdapter = ( ITreeAdapter )adapter;
426
    String text = treeAdapter.getToolTipText();
427
    if( text != null ) {
428
      JSWriter writer = JSWriter.getWriterFor( tree );
429
      text = WidgetLCAUtil.escapeText( text, false );
430
      text = WidgetLCAUtil.replaceNewLines( text, "<br/>" );
431
      writer.call( "setCellToolTipText", new String[]{ text } );
432
    }
433
  }
434
435
  private static TreeItem getItemById( final TreeItem[] items,
436
                                       final String itemId )
437
  {
438
    TreeItem result = null;
439
    for( int i = 0; i < items.length && result == null; i++ ) {
440
      if( WidgetUtil.getId( items[ i ] ).equals( itemId ) ) {
441
        result = items[ i ];
442
      } else if( items[ i ].getExpanded() ) {
443
        result = getItemById( items[ i ].getItems(), itemId );
444
      }
445
    }
446
    return result;
447
  }
448
369
  //////////////////
449
  //////////////////
370
  // Helping methods
450
  // Helping methods
371
451
(-)js/org/eclipse/rwt/test/tests/TableTest.js (-2 / +31 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 EclipseSource and others. All rights reserved.
2
 * Copyright (c) 2010, 2011 EclipseSource and others. All rights reserved.
3
 * This program and the accompanying materials are made available under the
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
Lines 114-121 Link Here
114
      table.destroy();
114
      table.destroy();
115
    },
115
    },
116
116
117
    testEnableCellToolTip : function() {
118
      var table = this._createDefaultTable();
119
      assertNull( table._cellToolTip );
120
      assertNull( table._clientArea.getToolTip() );
121
      table.setEnableCellToolTip( true );
122
      assertNotNull( table._cellToolTip );
123
      assertNotNull( table._clientArea.getToolTip() );
124
      table.setEnableCellToolTip( false );
125
      assertNull( table._cellToolTip );
126
      assertNull( table._clientArea.getToolTip() );
127
      table.destroy();
128
    },
129
130
    testRequestCellToolTipText : function() {
131
      var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
132
      var table = this._createDefaultTable();
133
      var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
134
      widgetManager.add( table, "w3", true );
135
      table.setEnableCellToolTip( true );
136
      testUtil.prepareTimerUse();
137
      testUtil.initRequestLog();      
138
      table._cellToolTip.setCell( "w45", 5 );
139
      testUtil.forceInterval( table._cellToolTip._showTimer );
140
      var msg = testUtil.getMessage();
141
      var param1 = "org.eclipse.swt.events.cellToolTipTextRequested=w3";
142
      var param2 = "org.eclipse.swt.events.cellToolTipTextRequested.cell=w45%2C5";
143
      assertTrue( msg.indexOf( param1 ) != -1 );
144
      assertTrue( msg.indexOf( param2 ) != -1 );
145
      table.destroy();
146
    },
117
147
118
    
119
    /////////
148
    /////////
120
    // Helper
149
    // Helper
121
    
150
    
(-)js/org/eclipse/rwt/test/tests/TreeTest.js (-1 / +31 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2010 EclipseSource and others. All rights reserved.
2
 * Copyright (c) 2010, 2011 EclipseSource and others. All rights reserved.
3
 * This program and the accompanying materials are made available under the
3
 * This program and the accompanying materials are made available under the
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
4
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
5
 * and is available at http://www.eclipse.org/legal/epl-v10.html
Lines 3167-3172 Link Here
3167
      tree.destroy();
3167
      tree.destroy();
3168
    },
3168
    },
3169
3169
3170
    testEnableCellToolTip : function() {
3171
      var tree = this._createDefaultTree();
3172
      assertNull( tree._cellToolTip );
3173
      assertNull( tree._clientArea.getToolTip() );
3174
      tree.setEnableCellToolTip( true );
3175
      assertNotNull( tree._cellToolTip );
3176
      assertNotNull( tree._clientArea.getToolTip() );
3177
      tree.setEnableCellToolTip( false );
3178
      assertNull( tree._cellToolTip );
3179
      assertNull( tree._clientArea.getToolTip() );
3180
      tree.destroy();
3181
    },
3182
3183
    testRequestCellToolTipText : function() {
3184
      var testUtil = org.eclipse.rwt.test.fixture.TestUtil;
3185
      var tree = this._createDefaultTree();
3186
      var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
3187
      widgetManager.add( tree, "w3", true );
3188
      tree.setEnableCellToolTip( true );
3189
      testUtil.prepareTimerUse();
3190
      testUtil.initRequestLog();      
3191
      tree._cellToolTip.setCell( "w45", 5 );
3192
      testUtil.forceInterval( tree._cellToolTip._showTimer );
3193
      var msg = testUtil.getMessage();
3194
      var param1 = "org.eclipse.swt.events.cellToolTipTextRequested=w3";
3195
      var param2 = "org.eclipse.swt.events.cellToolTipTextRequested.cell=w45%2C5";
3196
      assertTrue( msg.indexOf( param1 ) != -1 );
3197
      assertTrue( msg.indexOf( param2 ) != -1 );
3198
      tree.destroy();
3199
    },
3170
3200
3171
    /////////
3201
    /////////
3172
    // helper
3202
    // helper
(-)src/org/eclipse/swt/internal/widgets/tablekit/TableLCA_Test.java (-21 / +68 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2011 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 275-280 Link Here
275
    Fixture.clearPreserved();
275
    Fixture.clearPreserved();
276
  }
276
  }
277
277
278
  public void testPreserveEnableCellToolTip() {
279
    Table table = new Table( shell, SWT.BORDER );
280
    Fixture.markInitialized( display );
281
    Fixture.preserveWidgets();
282
    IWidgetAdapter adapter = WidgetUtil.getAdapter( table );
283
    Boolean preserved
284
      = ( Boolean )adapter.getPreserved( TableLCA.PROP_ENABLE_CELL_TOOLTIP );
285
    assertEquals( Boolean.FALSE, preserved );
286
    Fixture.clearPreserved();
287
    table.setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
288
    Fixture.preserveWidgets();
289
    adapter = WidgetUtil.getAdapter( table );
290
    preserved
291
      = ( Boolean )adapter.getPreserved( TableLCA.PROP_ENABLE_CELL_TOOLTIP );
292
    assertEquals( Boolean.TRUE, preserved );
293
    Fixture.clearPreserved();
294
  }
295
278
  public void testSetDataEvent() {
296
  public void testSetDataEvent() {
279
    final StringBuffer log = new StringBuffer();
297
    final StringBuffer log = new StringBuffer();
280
    final Table table = new Table( shell, SWT.VIRTUAL );
298
    final Table table = new Table( shell, SWT.VIRTUAL );
Lines 816-832 Link Here
816
    assertEquals( 0, table.getTopIndex() );
834
    assertEquals( 0, table.getTopIndex() );
817
  }
835
  }
818
836
837
  public void testWriteEnableCellToolTip() throws IOException {
838
    Table table = new Table( shell, SWT.NONE );
839
    createTableItems( table, 5 );
840
    Fixture.fakeNewRequest();
841
    table.setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
842
    TableLCA tableLCA = new TableLCA();
843
    tableLCA.renderChanges( table );
844
    String markup = Fixture.getAllMarkup();
845
    String expected = "w.setEnableCellToolTip( true )";
846
    assertTrue( markup.indexOf( expected ) != -1 );
847
  }
848
819
  public void testGetCellToolTipText() {
849
  public void testGetCellToolTipText() {
820
    Table table = new Table( shell, SWT.NONE );
850
    Table table = new Table( shell, SWT.NONE );
821
    createTableItems( table, 5 );
851
    createTableItems( table, 5 );
822
    Object adapter = table.getAdapter( ITableAdapter.class );
852
    Object adapter = table.getAdapter( ITableAdapter.class );
823
    final ITableAdapter tableAdapter = ( ITableAdapter )adapter;
853
    final ITableAdapter tableAdapter = ( ITableAdapter )adapter;
824
    tableAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
854
    tableAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
825
      public void getToolTipText( final int itemIndex,
855
      public void getToolTipText( final Item item,
826
                                  final int columnIndex )
856
                                  final int columnIndex )
827
      {
857
      {
828
        String text = "[" + itemIndex + "," + columnIndex + "]";
858
        StringBuffer buffer = new StringBuffer();
829
        tableAdapter.setToolTipText( text );
859
        buffer.append( "[" );
860
        buffer.append( WidgetUtil.getId( item ) );
861
        buffer.append( "," );
862
        buffer.append( columnIndex );
863
        buffer.append( "]" );
864
        tableAdapter.setToolTipText( buffer.toString() );
830
      }
865
      }
831
    } );
866
    } );
832
    Fixture.fakeNewRequest();
867
    Fixture.fakeNewRequest();
Lines 834-842 Link Here
834
    String markup = Fixture.getAllMarkup();
869
    String markup = Fixture.getAllMarkup();
835
    String expected = "w.setCellToolTipText(";
870
    String expected = "w.setCellToolTipText(";
836
    assertTrue( markup.indexOf( expected ) == -1 );
871
    assertTrue( markup.indexOf( expected ) == -1 );
837
    processCellToolTipRequest( table, 2, 0 );
872
    String itemId = WidgetUtil.getId( table.getItem( 2 ) );
873
    processCellToolTipRequest( table, itemId, 0 );
838
    markup = Fixture.getAllMarkup();
874
    markup = Fixture.getAllMarkup();
839
    expected = "w.setCellToolTipText( \"[2,0]\" );";
875
    expected = "w.setCellToolTipText( \"[" + itemId + ",0]\" );";
840
    assertTrue( markup.indexOf( expected ) != -1 );
876
    assertTrue( markup.indexOf( expected ) != -1 );
841
  }
877
  }
842
878
Lines 848-872 Link Here
848
      = ( ITableAdapter )table.getAdapter( ITableAdapter.class );
884
      = ( ITableAdapter )table.getAdapter( ITableAdapter.class );
849
    tableAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
885
    tableAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
850
886
851
      public void getToolTipText( final int itemIndex, final int columnIndex ) {
887
      public void getToolTipText( final Item item, final int columnIndex ) {
852
        log.append( "[" + itemIndex + "," + columnIndex + "]" );
888
        StringBuffer buffer = new StringBuffer();
889
        buffer.append( "[" );
890
        buffer.append( WidgetUtil.getId( item ) );
891
        buffer.append( "," );
892
        buffer.append( columnIndex );
893
        buffer.append( "]" );
894
        log.append( buffer.toString() );
853
      }
895
      }
854
    } );
896
    } );
855
    processCellToolTipRequest( table, 0, 0 );
897
    String itemId = WidgetUtil.getId( table.getItem( 0 ) );
856
    assertEquals( "[0,0]", log.toString() );
898
    processCellToolTipRequest( table, itemId, 0 );
899
    String expected = "[" + itemId + ",0]";
900
    assertEquals( expected, log.toString() );
857
    log.setLength( 0 );
901
    log.setLength( 0 );
858
    processCellToolTipRequest( table, 2, 0 );
902
    itemId = WidgetUtil.getId( table.getItem( 2 ) );
859
    assertEquals( "[2,0]", log.toString() );
903
    processCellToolTipRequest( table, itemId, 0 );
904
    expected = "[" + itemId + ",0]";
905
    assertEquals( expected, log.toString() );
860
    log.setLength( 0 );
906
    log.setLength( 0 );
861
    processCellToolTipRequest( table, 3, 0 );
907
    processCellToolTipRequest( table, "xyz", 0 );
862
    assertEquals( "", log.toString() );
908
    assertEquals( "", log.toString() );
863
    processCellToolTipRequest( table, 2, 1 );
909
    processCellToolTipRequest( table, itemId, 1 );
864
    assertEquals( "", log.toString() );
910
    assertEquals( "", log.toString() );
865
    createTableColumns( table, 2 );
911
    createTableColumns( table, 2 );
866
    processCellToolTipRequest( table, 2, 1 );
912
    processCellToolTipRequest( table, itemId, 1 );
867
    assertEquals( "[2,1]", log.toString() );
913
    expected = "[" + itemId + ",1]";
914
    assertEquals( expected, log.toString() );
868
    log.setLength( 0 );
915
    log.setLength( 0 );
869
    processCellToolTipRequest( table, 2, 2 );
916
    processCellToolTipRequest( table, itemId, 2 );
870
    assertEquals( "", log.toString() );
917
    assertEquals( "", log.toString() );
871
  }
918
  }
872
919
Lines 921-936 Link Here
921
  }
968
  }
922
969
923
  private static void processCellToolTipRequest( final Table table,
970
  private static void processCellToolTipRequest( final Table table,
924
                                                 final int item,
971
                                                 final String itemId,
925
                                                 final int column )
972
                                                 final int column )
926
  {
973
  {
927
    Fixture.fakeNewRequest();
974
    Fixture.fakeNewRequest();
928
    String displayId = DisplayUtil.getId( table.getDisplay() );
975
    String displayId = DisplayUtil.getId( table.getDisplay() );
929
    Fixture.fakeRequestParam( RequestParams.UIROOT, displayId );
976
    Fixture.fakeRequestParam( RequestParams.UIROOT, displayId );
930
    String tableId = WidgetUtil.getId( table );
977
    String tableId = WidgetUtil.getId( table );
931
    Fixture.fakeRequestParam( TableLCA.EVENT_CELL_TOOLTIP_REQUESTED, tableId );
978
    Fixture.fakeRequestParam( JSConst.EVENT_CELL_TOOLTIP_REQUESTED, tableId );
932
    String cellString = item + "," + column;
979
    String cellString = itemId + "," + column;
933
    Fixture.fakeRequestParam( TableLCA.EVENT_CELL_TOOLTIP_DETAILS, cellString );
980
    Fixture.fakeRequestParam( JSConst.EVENT_CELL_TOOLTIP_DETAILS, cellString );
934
    Fixture.executeLifeCycleFromServerThread();
981
    Fixture.executeLifeCycleFromServerThread();
935
  }
982
  }
936
983
(-)src/org/eclipse/swt/internal/widgets/treekit/TreeLCA_Test.java (-3 / +163 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
2
 * Copyright (c) 2002, 2011 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 27-34 Link Here
27
import org.eclipse.swt.graphics.*;
27
import org.eclipse.swt.graphics.*;
28
import org.eclipse.swt.internal.events.ActivateAdapter;
28
import org.eclipse.swt.internal.events.ActivateAdapter;
29
import org.eclipse.swt.internal.events.ActivateEvent;
29
import org.eclipse.swt.internal.events.ActivateEvent;
30
import org.eclipse.swt.internal.widgets.ITreeAdapter;
30
import org.eclipse.swt.internal.widgets.*;
31
import org.eclipse.swt.internal.widgets.Props;
32
import org.eclipse.swt.internal.widgets.treekit.TreeLCA.ItemMetrics;
31
import org.eclipse.swt.internal.widgets.treekit.TreeLCA.ItemMetrics;
33
import org.eclipse.swt.layout.FillLayout;
32
import org.eclipse.swt.layout.FillLayout;
34
import org.eclipse.swt.widgets.*;
33
import org.eclipse.swt.widgets.*;
Lines 530-535 Link Here
530
    hasListeners = ( Boolean )adapter.getPreserved( Props.ACTIVATE_LISTENER );
529
    hasListeners = ( Boolean )adapter.getPreserved( Props.ACTIVATE_LISTENER );
531
    assertEquals( Boolean.TRUE, hasListeners );
530
    assertEquals( Boolean.TRUE, hasListeners );
532
  }
531
  }
532
  
533
  public void testPreserveEnableCellToolTip() {
534
    Tree tree = new Tree( shell, SWT.BORDER );
535
    Fixture.markInitialized( display );
536
    Fixture.preserveWidgets();
537
    IWidgetAdapter adapter = WidgetUtil.getAdapter( tree );
538
    Boolean preserved
539
      = ( Boolean )adapter.getPreserved( TreeLCA.PROP_ENABLE_CELL_TOOLTIP );
540
    assertEquals( Boolean.FALSE, preserved );
541
    Fixture.clearPreserved();
542
    tree.setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
543
    Fixture.preserveWidgets();
544
    adapter = WidgetUtil.getAdapter( tree );
545
    preserved
546
      = ( Boolean )adapter.getPreserved( TreeLCA.PROP_ENABLE_CELL_TOOLTIP );
547
    assertEquals( Boolean.TRUE, preserved );
548
    Fixture.clearPreserved();
549
  }
533
550
534
  public void testSelectionEvent() {
551
  public void testSelectionEvent() {
535
    final StringBuffer log = new StringBuffer();
552
    final StringBuffer log = new StringBuffer();
Lines 672-677 Link Here
672
    String expected = "w.setHasScrollBarsSelectionListener( true );";
689
    String expected = "w.setHasScrollBarsSelectionListener( true );";
673
    assertTrue( markup.indexOf( expected ) != -1 );
690
    assertTrue( markup.indexOf( expected ) != -1 );
674
  }
691
  }
692
  
693
  public void testWriteEnableCellToolTip() throws IOException {
694
    Tree tree = new Tree( shell, SWT.NONE );
695
    createTreeItems( tree, 5 );
696
    Fixture.fakeNewRequest();
697
    tree.setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
698
    TreeLCA treeLCA = new TreeLCA();
699
    treeLCA.renderChanges( tree );
700
    String markup = Fixture.getAllMarkup();
701
    String expected = "w.setEnableCellToolTip( true )";
702
    assertTrue( markup.indexOf( expected ) != -1 );
703
  }
704
705
  public void testGetCellToolTipText() {
706
    Tree tree = new Tree( shell, SWT.NONE );
707
    createTreeItems( tree, 5 );
708
    Object adapter = tree.getAdapter( ITreeAdapter.class );
709
    final ITreeAdapter treeAdapter = ( ITreeAdapter )adapter;
710
    treeAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
711
      public void getToolTipText( final Item item,
712
                                  final int columnIndex )
713
      {
714
        StringBuffer buffer = new StringBuffer();
715
        buffer.append( "[" );
716
        buffer.append( WidgetUtil.getId( item ) );
717
        buffer.append( "," );
718
        buffer.append( columnIndex );
719
        buffer.append( "]" );
720
        treeAdapter.setToolTipText( buffer.toString() );
721
      }
722
    } );
723
    Fixture.fakeNewRequest();
724
    Fixture.executeLifeCycleFromServerThread();
725
    String markup = Fixture.getAllMarkup();
726
    String expected = "w.setCellToolTipText(";
727
    assertTrue( markup.indexOf( expected ) == -1 );
728
    String itemId = WidgetUtil.getId( tree.getItem( 2 ) );
729
    processCellToolTipRequest( tree, itemId, 0 );
730
    markup = Fixture.getAllMarkup();
731
    expected = "w.setCellToolTipText( \"[" + itemId + ",0]\" );";
732
    assertTrue( markup.indexOf( expected ) != -1 );
733
  }
734
  
735
  public void testGetCellToolTipTextForSubitems() {
736
    Tree tree = new Tree( shell, SWT.NONE );
737
    createTreeItems( tree, 5 );
738
    Object adapter = tree.getAdapter( ITreeAdapter.class );
739
    final ITreeAdapter treeAdapter = ( ITreeAdapter )adapter;
740
    treeAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
741
      public void getToolTipText( final Item item,
742
                                  final int columnIndex )
743
      {
744
        StringBuffer buffer = new StringBuffer();
745
        buffer.append( "[" );
746
        buffer.append( WidgetUtil.getId( item ) );
747
        buffer.append( "," );
748
        buffer.append( columnIndex );
749
        buffer.append( "]" );
750
        treeAdapter.setToolTipText( buffer.toString() );
751
      }
752
    } );
753
    Fixture.fakeNewRequest();
754
    Fixture.executeLifeCycleFromServerThread();
755
    String markup = Fixture.getAllMarkup();
756
    String expected = "w.setCellToolTipText(";
757
    assertTrue( markup.indexOf( expected ) == -1 );
758
    String itemId = WidgetUtil.getId( tree.getItem( 2 ).getItem( 1 ) );
759
    processCellToolTipRequest( tree, itemId, 0 );
760
    markup = Fixture.getAllMarkup();
761
    expected = "w.setCellToolTipText( \"[" + itemId + ",0]\" );";
762
    assertTrue( markup.indexOf( expected ) != -1 );
763
  }
764
765
  public void testCellTooltipRequestForMissingCells() {
766
    Tree tree = new Tree( shell, SWT.NONE );
767
    createTreeItems( tree, 3 );
768
    final StringBuffer log = new StringBuffer();
769
    final ITreeAdapter treeAdapter
770
      = ( ITreeAdapter )tree.getAdapter( ITreeAdapter.class );
771
    treeAdapter.setCellToolTipProvider( new ICellToolTipProvider() {
772
773
      public void getToolTipText( final Item item, final int columnIndex ) {
774
        StringBuffer buffer = new StringBuffer();
775
        buffer.append( "[" );
776
        buffer.append( WidgetUtil.getId( item ) );
777
        buffer.append( "," );
778
        buffer.append( columnIndex );
779
        buffer.append( "]" );
780
        log.append( buffer.toString() );
781
      }
782
    } );
783
    String itemId = WidgetUtil.getId( tree.getItem( 0 ) );
784
    processCellToolTipRequest( tree, itemId, 0 );
785
    String expected = "[" + itemId + ",0]";
786
    assertEquals( expected, log.toString() );
787
    log.setLength( 0 );
788
    itemId = WidgetUtil.getId( tree.getItem( 2 ) );
789
    processCellToolTipRequest( tree, itemId, 0 );
790
    expected = "[" + itemId + ",0]";
791
    assertEquals( expected, log.toString() );
792
    log.setLength( 0 );
793
    processCellToolTipRequest( tree, "xyz", 0 );
794
    assertEquals( "", log.toString() );
795
    processCellToolTipRequest( tree, itemId, 1 );
796
    assertEquals( "", log.toString() );
797
    createTreeColumns( tree, 2 );
798
    processCellToolTipRequest( tree, itemId, 1 );
799
    expected = "[" + itemId + ",1]";
800
    assertEquals( expected, log.toString() );
801
    log.setLength( 0 );
802
    processCellToolTipRequest( tree, itemId, 2 );
803
    assertEquals( "", log.toString() );
804
  }
805
  
806
  private static void createTreeColumns( final Tree tree, final int count ) {
807
    for( int i = 0; i < count; i++ ) {
808
      new TreeColumn( tree, SWT.NONE );
809
    }
810
  }
811
812
  private static void createTreeItems( final Tree tree, final int count ) {
813
    for( int i = 0; i < count; i++ ) {
814
      TreeItem item = new TreeItem( tree, SWT.NONE );      
815
      for( int j = 0; j < count; j++ ) {
816
        new TreeItem( item, SWT.NONE );
817
      }
818
      item.setExpanded( true );
819
    }
820
  }
821
822
  private static void processCellToolTipRequest( final Tree tree,
823
                                                 final String itemId,
824
                                                 final int column )
825
  {
826
    Fixture.fakeNewRequest();
827
    String displayId = DisplayUtil.getId( tree.getDisplay() );
828
    Fixture.fakeRequestParam( RequestParams.UIROOT, displayId );
829
    String treeId = WidgetUtil.getId( tree );
830
    Fixture.fakeRequestParam( JSConst.EVENT_CELL_TOOLTIP_REQUESTED, treeId );
831
    String cellString = itemId + "," + column;
832
    Fixture.fakeRequestParam( JSConst.EVENT_CELL_TOOLTIP_DETAILS, cellString );
833
    Fixture.executeLifeCycleFromServerThread();
834
  }
675
835
676
  // TODO [tb] : Test for fake redraw calls checkAllData
836
  // TODO [tb] : Test for fake redraw calls checkAllData
677
837

Return to bug 334675