Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Sternberg2011-01-27 23:11:31 +0000
committerRalf Sternberg2011-01-27 23:11:31 +0000
commitdd51781684222a2ce376bef33e668e2c7dee8f3a (patch)
treeab54e6d37a9b1d88817ee943790cc163266a44a6 /bundles
parentbeeb86723c16a05459d9aa6c0008a307da004a0c (diff)
downloadorg.eclipse.rap-dd51781684222a2ce376bef33e668e2c7dee8f3a.tar.gz
org.eclipse.rap-dd51781684222a2ce376bef33e668e2c7dee8f3a.tar.xz
org.eclipse.rap-dd51781684222a2ce376bef33e668e2c7dee8f3a.zip
Applied patch for bug 334675: Provide tooltip support for TreeViewer
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334675
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java6
-rw-r--r--bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellToolTipProvider.java54
-rwxr-xr-xbundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java15
-rwxr-xr-xbundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/TableViewerColumn.java6
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/widgets/Tree.js63
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/Table.js58
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/TableCellToolTip.js26
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/rwt/internal/lifecycle/JSConst.java11
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java109
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA.java84
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ICellToolTipAdapter.java20
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ICellToolTipProvider.java9
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITableAdapter.java10
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITreeAdapter.java4
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Table.java11
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Tree.java21
16 files changed, 368 insertions, 139 deletions
diff --git a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java
index 716d65cd9b..575c00f8b2 100755
--- a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java
+++ b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java
@@ -231,6 +231,9 @@ public abstract class CellLabelProvider extends BaseLabelProvider {
* @since 1.1
*/
protected void initialize(ColumnViewer viewer, ViewerColumn column) {
+ // RAP: [if] Cell tooltips support
+ CellToolTipProvider.attach( viewer, this );
+ // RAPEND: [if]
}
/**
@@ -248,6 +251,9 @@ public abstract class CellLabelProvider extends BaseLabelProvider {
*/
public void dispose(ColumnViewer viewer, ViewerColumn column) {
dispose();
+ // RAP: [if] Cell tooltips support
+ CellToolTipProvider.attach( viewer, null );
+ // RAPEND: [if]
}
}
diff --git a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellToolTipProvider.java b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellToolTipProvider.java
index 2de0f18868..93ab801887 100644
--- a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellToolTipProvider.java
+++ b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/CellToolTipProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 EclipseSource and others. All rights reserved.
+ * Copyright (c) 2009, 2011 EclipseSource and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -9,43 +9,57 @@
******************************************************************************/
package org.eclipse.jface.viewers;
+import org.eclipse.swt.internal.widgets.ICellToolTipAdapter;
import org.eclipse.swt.internal.widgets.ITableAdapter;
import org.eclipse.swt.internal.widgets.ICellToolTipProvider;
+import org.eclipse.swt.internal.widgets.ITreeAdapter;
+import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Tree;
/**
- * Support for table tool-tips in RAP
+ * Support for table/tree tool-tips in RAP
*/
final class CellToolTipProvider implements ICellToolTipProvider {
- private TableViewer viewer;
+ private ColumnViewer viewer;
- CellToolTipProvider( final TableViewer viewer ) {
+ CellToolTipProvider( final ColumnViewer viewer ) {
this.viewer = viewer;
}
- static void attach( final TableViewer tableViewer,
- final IBaseLabelProvider labelProvider )
+ static void attach( final ColumnViewer viewer,
+ final CellLabelProvider labelProvider )
{
- Table table = tableViewer.getTable();
- Object adapter = table.getAdapter( ITableAdapter.class );
- ITableAdapter tableAdapter = ( ITableAdapter )adapter;
- if( labelProvider instanceof CellLabelProvider ) {
- CellToolTipProvider provider = new CellToolTipProvider( tableViewer );
- tableAdapter.setCellToolTipProvider( provider );
+ ICellToolTipAdapter adapter = getAdapter( viewer );
+ if( labelProvider != null ) {
+ CellToolTipProvider provider = new CellToolTipProvider( viewer );
+ adapter.setCellToolTipProvider( provider );
} else {
- tableAdapter.setCellToolTipProvider( null );
+ adapter.setCellToolTipProvider( null );
}
}
- public void getToolTipText( final int itemIndex, final int columnIndex ) {
- Table table = viewer.getTable();
- Object element = table.getItem( itemIndex ).getData();
+ private static ICellToolTipAdapter getAdapter( final ColumnViewer viewer ) {
+ ICellToolTipAdapter result = null;
+ if( viewer instanceof TableViewer ) {
+ Table table = ( ( TableViewer )viewer ).getTable();
+ result = ( ICellToolTipAdapter )table.getAdapter( ITableAdapter.class );
+ } else if( viewer instanceof TreeViewer ) {
+ Tree tree = ( ( TreeViewer )viewer ).getTree();
+ result = ( ICellToolTipAdapter )tree.getAdapter( ITreeAdapter.class );
+ }
+ return result;
+ }
+
+ public void getToolTipText( final Item item, final int columnIndex ) {
+ Object element = item.getData();
ViewerColumn column = viewer.getViewerColumn( columnIndex );
CellLabelProvider labelProvider = column.getLabelProvider();
- String text = labelProvider.getToolTipText( element );
- Object adapter = table.getAdapter( ITableAdapter.class );
- ITableAdapter tableAdapter = ( ITableAdapter )adapter;
- tableAdapter.setToolTipText( text );
+ if( labelProvider != null ) {
+ String text = labelProvider.getToolTipText( element );
+ ICellToolTipAdapter adapter = getAdapter( viewer );
+ adapter.setToolTipText( text );
+ }
}
}
diff --git a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java
index 0a9059ebfe..22e582c7cf 100755
--- a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java
+++ b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java
@@ -22,7 +22,7 @@ package org.eclipse.jface.viewers;
//import org.eclipse.swt.graphics.Point;
//import org.eclipse.swt.widgets.Composite;
//import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.internal.widgets.ICellToolTipProvider;
/**
* The ColumnViewerTooltipSupport is the class that provides tool tips for
@@ -31,7 +31,7 @@ import org.eclipse.swt.widgets.Table;
* @since 1.3
*
*/
-// RAP [rh] RAP provides tooltip support only for the table widget
+// RAP [rh] RAP provides tooltip support for the table and tree widgets
// In addition RAP cannot reuse the DefaultToolTip and ToolTip as these
// classes make heavy use of mouse events
public class ColumnViewerToolTipSupport
@@ -77,12 +77,11 @@ public class ColumnViewerToolTipSupport
* @param viewer
* the viewer the support is attached to
*/
-// public static void enableFor(ColumnViewer viewer) {
-// new ColumnViewerToolTipSupport(viewer, ToolTip.NO_RECREATE, false);
-// }
-public static void enableFor(AbstractTableViewer viewer) {
- viewer.getControl().setData( Table.ENABLE_CELL_TOOLTIP, Boolean.TRUE );
-}
+ public static void enableFor(ColumnViewer viewer) {
+// new ColumnViewerToolTipSupport(viewer, dis, false);
+ viewer.getControl().setData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP,
+ Boolean.TRUE );
+ }
// RAP [rh] ToolTip style not supported
// /**
diff --git a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/TableViewerColumn.java b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/TableViewerColumn.java
index 67169c5ef2..0b7d0a38ed 100755
--- a/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/TableViewerColumn.java
+++ b/bundles/org.eclipse.rap.jface/src/org/eclipse/jface/viewers/TableViewerColumn.java
@@ -87,10 +87,4 @@ public final class TableViewerColumn extends ViewerColumn {
return column;
}
-// RAP: [if] Table cell tooltips support
- public void setLabelProvider( final CellLabelProvider labelProvider ) {
- super.setLabelProvider( labelProvider );
- CellToolTipProvider.attach( ( TableViewer )getViewer(), labelProvider );
- }
-// RAPEND: [if]
}
diff --git a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/widgets/Tree.js b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/widgets/Tree.js
index a14002b7bf..06067c95ab 100644
--- a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/widgets/Tree.js
+++ b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/rwt/widgets/Tree.js
@@ -71,6 +71,8 @@ qx.Class.define( "org.eclipse.rwt.widgets.Tree", {
this.add( this._clientArea );
this.add( this._horzScrollBar );
this.add( this._vertScrollBar );
+ // Cell tooltip
+ this._cellToolTip = null;
// Configure:
this.setCursor( "default" );
this.setOverflow( "hidden" );
@@ -102,6 +104,10 @@ qx.Class.define( "org.eclipse.rwt.widgets.Tree", {
this._hoverItem = null;
this._hoverElement = null;
this._resizeLine = null;
+ if( this._cellToolTip ) {
+ this._cellToolTip.destroy();
+ this._cellToolTip = null;
+ }
},
members : {
@@ -448,7 +454,11 @@ qx.Class.define( "org.eclipse.rwt.widgets.Tree", {
getColumnCount : function() {
return Math.max( 1, this._columnCount );
},
-
+
+ getColumns : function() {
+ return this._columnArea.getChildren().slice( 1 );
+ },
+
getRootItem : function() {
return this._rootItem;
},
@@ -1653,6 +1663,57 @@ qx.Class.define( "org.eclipse.rwt.widgets.Tree", {
_isDragSource : function() {
return this.hasEventListeners( "dragstart" );
+ },
+
+ ////////////////////////
+ // Cell tooltip handling
+
+ setEnableCellToolTip : function( value ) {
+ if( value ) {
+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
+ var id = widgetManager.findIdByWidget( this );
+ this._cellToolTip = new org.eclipse.swt.widgets.TableCellToolTip( id );
+ this._clientArea.addEventListener( "mousemove",
+ this._onClientAreaMouseMove,
+ this );
+ this._clientArea.setToolTip( this._cellToolTip );
+ } else {
+ this._clientArea.removeEventListener( "mousemove",
+ this._onClientAreaMouseMove,
+ this );
+ this._clientArea.setToolTip( null );
+ this._cellToolTip.destroy();
+ this._cellToolTip = null;
+ }
+ },
+
+ _onClientAreaMouseMove : function( evt ) {
+ if( this._cellToolTip != null ) {
+ var pageX = evt.getPageX();
+ var pageY = evt.getPageY();
+ if( this._hoverItem ) {
+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
+ var itemId = widgetManager.findIdByWidget( this._hoverItem );
+ var columnIndex = -1;
+ var columns = this.getColumns();
+ var element = this._clientArea.getElement();
+ var leftOffset = qx.bom.element.Location.getLeft( element );
+ for( var i = 0; columnIndex == -1 && i < columns.length; i++ ) {
+ var pageLeft = leftOffset + this._itemLeft[ i ];
+ if( pageX >= pageLeft && pageX < pageLeft + this._itemWidth[ i ] ) {
+ columnIndex = i;
+ }
+ }
+ this._cellToolTip.setCell( itemId, columnIndex );
+ }
+ }
+ },
+
+ /** Only called by server-side */
+ setCellToolTipText : function( text ) {
+ if( this._cellToolTip != null ) {
+ this._cellToolTip.setText( text );
+ }
}
}
diff --git a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/Table.js b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/Table.js
index 52de2b5c1f..6107bf56ce 100644
--- a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/Table.js
+++ b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/Table.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2007, 2011 Innoopract Informationssysteme GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -160,12 +160,6 @@ qx.Class.define( "org.eclipse.swt.widgets.Table", {
this.add( this._clientArea );
// Cell tooltip
this._cellToolTip = null;
- if( qx.lang.String.contains( style, "enableCellToolTip" ) ) {
- this._cellToolTip = new org.eclipse.swt.widgets.TableCellToolTip();
- this._cellToolTip.setTableId( id );
- this._clientArea.addEventListener( "mousemove", this._onClientAreaMouseMove, this );
- this._clientArea.setToolTip( this._cellToolTip );
- }
// Disable scrolling (see bug 279460)
qx.ui.core.Widget.disableScrolling( this );
// Fix for bug Bug 297202
@@ -228,7 +222,7 @@ qx.Class.define( "org.eclipse.swt.widgets.Table", {
this._clientArea = null;
}
if( this._cellToolTip ) {
- this._cellToolTip.dispose();
+ this._cellToolTip.destroy();
this._cellToolTip = null;
}
if( this._columnArea ) {
@@ -1730,26 +1724,46 @@ qx.Class.define( "org.eclipse.swt.widgets.Table", {
////////////////////////
// Cell tooltip handling
+ setEnableCellToolTip : function( value ) {
+ if( value ) {
+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
+ var id = widgetManager.findIdByWidget( this );
+ this._cellToolTip = new org.eclipse.swt.widgets.TableCellToolTip( id );
+ this._clientArea.addEventListener( "mousemove",
+ this._onClientAreaMouseMove,
+ this );
+ this._clientArea.setToolTip( this._cellToolTip );
+ } else {
+ this._clientArea.removeEventListener( "mousemove",
+ this._onClientAreaMouseMove,
+ this );
+ this._clientArea.setToolTip( null );
+ this._cellToolTip.destroy();
+ this._cellToolTip = null;
+ }
+ },
+
_onClientAreaMouseMove : function( evt ) {
if( this._cellToolTip != null ) {
var pageX = evt.getPageX();
var pageY = evt.getPageY();
var row = this._getRowAtPoint( pageX, pageY );
- var rowIndex = this._rows.indexOf( row );
- var itemIndex = this._getItemIndexFromRowIndex( rowIndex );
- var columnIndex = -1;
- var columns = this.getColumns();
- for( var i = 0; columnIndex == -1 && i < columns.length; i++ ) {
- var element = this._clientArea.getElement();
- var pageLeft = qx.bom.element.Location.getLeft( element )
- + this._itemLeft[ i ];
- if( pageX >= pageLeft
- && pageX < pageLeft + this._itemWidth[ i ] )
- {
- columnIndex = i;
- }
+ var itemIndex = row.getItemIndex();
+ if( itemIndex != -1 ) {
+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
+ var itemId = widgetManager.findIdByWidget( this._items[ itemIndex ] );
+ var columnIndex = -1;
+ var columns = this.getColumns();
+ var element = this._clientArea.getElement();
+ var leftOffset = qx.bom.element.Location.getLeft( element );
+ for( var i = 0; columnIndex == -1 && i < columns.length; i++ ) {
+ var pageLeft = leftOffset + this._itemLeft[ i ];
+ if( pageX >= pageLeft && pageX < pageLeft + this._itemWidth[ i ] ) {
+ columnIndex = i;
+ }
+ }
+ this._cellToolTip.setCell( itemId, columnIndex );
}
- this._cellToolTip.setCell( itemIndex, columnIndex );
}
},
diff --git a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/TableCellToolTip.js b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/TableCellToolTip.js
index 748c16c955..ff76fae373 100644
--- a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/TableCellToolTip.js
+++ b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/TableCellToolTip.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 EclipseSource and others. All rights reserved.
+ * Copyright (c) 2009, 2011 EclipseSource and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -12,10 +12,10 @@ qx.Class.define( "org.eclipse.swt.widgets.TableCellToolTip", {
extend : qx.ui.popup.ToolTip,
include : org.eclipse.rwt.FadeAnimationMixin,
- construct : function() {
+ construct : function( controlId ) {
this.base( arguments );
- this._tableId = -1;
- this._itemIndex = -1;
+ this._controlId = controlId;
+ this._itemId = null;
this._columnIndex = -1;
},
@@ -37,17 +37,13 @@ qx.Class.define( "org.eclipse.swt.widgets.TableCellToolTip", {
}
},
- setTableId : function( tableId ) {
- this._tableId = tableId;
- },
-
- setCell : function( itemIndex, columnIndex ) {
- if( this._itemIndex != itemIndex || this._columnIndex != columnIndex ) {
- this._itemIndex = itemIndex;
+ setCell : function( itemId, columnIndex ) {
+ if( this._itemId != itemId || this._columnIndex != columnIndex ) {
+ this._itemId = itemId;
this._columnIndex = columnIndex;
this.hide();
if( !this._showTimer.getEnabled()
- && itemIndex != -1
+ && itemId != null
&& columnIndex != -1 )
{
this._showTimer.start();
@@ -56,11 +52,11 @@ qx.Class.define( "org.eclipse.swt.widgets.TableCellToolTip", {
},
_requestCellToolTipText : function() {
- if( this._itemIndex != -1 && this._columnIndex != -1 ) {
+ if( this._itemId != null && this._columnIndex != -1 ) {
var req = org.eclipse.swt.Request.getInstance();
req.addEvent( "org.eclipse.swt.events.cellToolTipTextRequested",
- this._tableId );
- var cell = this._itemIndex + "," + this._columnIndex;
+ this._controlId );
+ var cell = this._itemId + "," + this._columnIndex;
req.addParameter( "org.eclipse.swt.events.cellToolTipTextRequested.cell",
cell );
req.send();
diff --git a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/rwt/internal/lifecycle/JSConst.java b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/rwt/internal/lifecycle/JSConst.java
index edb406124a..7e09824cc7 100644
--- a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/rwt/internal/lifecycle/JSConst.java
+++ b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/rwt/internal/lifecycle/JSConst.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,8 +13,6 @@ package org.eclipse.rwt.internal.lifecycle;
import org.eclipse.rwt.lifecycle.JSVar;
-
-
/**
* Commonly used request parameter names and JavaScript names.
*/
@@ -61,6 +59,9 @@ public final class JSConst {
public static final String EVENT_MENU_DETECT
= "org.eclipse.swt.events.menuDetect";
+ // Request cell tooltip text event
+ public static final String EVENT_CELL_TOOLTIP_REQUESTED
+ = "org.eclipse.swt.events.cellToolTipTextRequested";
// Parameter names that specify further event details
public static final String EVENT_WIDGET_SELECTED_DETAIL
@@ -114,6 +115,10 @@ public final class JSConst {
public static final String EVENT_MENU_DETECT_Y
= "org.eclipse.swt.events.menuDetect.y";
+ // Request cell tooltip text event details
+ public static final String EVENT_CELL_TOOLTIP_DETAILS
+ = "org.eclipse.swt.events.cellToolTipTextRequested.cell";
+
// Indicates that a shell was closed on the client side. The parameter
// value holds the id of the shell that was closed.
public static final String EVENT_SHELL_CLOSED
diff --git a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java
index 62d7491b60..f4ee8040be 100644
--- a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java
+++ b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tablekit/TableLCA.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,20 +22,12 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.events.EventLCAUtil;
-import org.eclipse.swt.internal.widgets.ITableAdapter;
-import org.eclipse.swt.internal.widgets.ICellToolTipProvider;
+import org.eclipse.swt.internal.widgets.*;
import org.eclipse.swt.widgets.*;
public final class TableLCA extends AbstractWidgetLCA {
- // Request cell tooltip text event
- static final String EVENT_CELL_TOOLTIP_REQUESTED
- = "org.eclipse.swt.events.cellToolTipTextRequested";
- // Parameter names that specify further event details
- static final String EVENT_CELL_TOOLTIP_DETAILS
- = "org.eclipse.swt.events.cellToolTipTextRequested.cell";
-
// Property names to preserve values
static final String PROP_HEADER_HEIGHT = "headerHeight";
static final String PROP_HEADER_VISIBLE = "headerVisible";
@@ -51,6 +43,8 @@ public final class TableLCA extends AbstractWidgetLCA {
static final String PROP_LEFT_OFFSET = "leftOffset";
static final String PROP_SCROLLBARS_SELECTION_LISTENER
= "scrollBarsSelectionListeners";
+ static final String PROP_ENABLE_CELL_TOOLTIP
+ = "enableCellToolTip";
private static final Integer DEFAULT_TOP_INDEX = new Integer( 0 );
private static final Integer DEFAULT_ITEM_COUNT = new Integer( 0 );
@@ -100,6 +94,8 @@ public final class TableLCA extends AbstractWidgetLCA {
adapter.preserve( PROP_LEFT_OFFSET, getLeftOffset( table ) );
adapter.preserve( PROP_SCROLLBARS_SELECTION_LISTENER,
hasScrollBarsSelectionListener( table ) );
+ adapter.preserve( PROP_ENABLE_CELL_TOOLTIP,
+ isCellToolTipEnabled( table ) );
}
public void readData( final Widget widget ) {
@@ -127,9 +123,6 @@ public final class TableLCA extends AbstractWidgetLCA {
if( ( table.getStyle() & SWT.MULTI ) != 0 ) {
style += "|multi";
}
- if( Boolean.TRUE.equals( table.getData( Table.ENABLE_CELL_TOOLTIP ) ) ) {
- style += "|enableCellToolTip";
- }
if( ( table.getStyle() & SWT.HIDE_SELECTION ) != 0 ) {
style += "|hideSelection";
}
@@ -159,6 +152,7 @@ public final class TableLCA extends AbstractWidgetLCA {
writeAlwaysHideSelection( table );
writeScrollBarsVisible( table );
writeLeftOffset( table );
+ writeEnableCellToolTip( table );
writeCellToolTipText( table );
WidgetLCAUtil.writeCustomVariant( table );
}
@@ -311,30 +305,6 @@ public final class TableLCA extends AbstractWidgetLCA {
return result;
}
- private static void readCellToolTipTextRequested( final Table table ) {
- Object adapter = table.getAdapter( ITableAdapter.class );
- ITableAdapter tableAdapter = ( ITableAdapter )adapter;
- tableAdapter.setToolTipText( null );
- String event = EVENT_CELL_TOOLTIP_REQUESTED;
- if( WidgetLCAUtil.wasEventSent( table, event ) ) {
- ICellToolTipProvider provider = tableAdapter.getCellToolTipProvider();
- if( provider != null ) {
- HttpServletRequest request = ContextProvider.getRequest();
- String cell = request.getParameter( EVENT_CELL_TOOLTIP_DETAILS );
- String[] indices = cell.split( "," );
- int itemIndex = Integer.parseInt( indices[ 0 ] );
- int columnIndex = Integer.parseInt( indices[ 1 ] );
- // Bug 321119: Sometimes the client can request tooltips for already
- // disposed cells.
- if( itemIndex < table.getItemCount()
- && ( columnIndex == 0 || columnIndex < table.getColumnCount() ) )
- {
- provider.getToolTipText( itemIndex, columnIndex );
- }
- }
- }
- }
-
///////////////////////////////////////////
// Helping methods to write JavaScript code
@@ -464,18 +434,79 @@ public final class TableLCA extends AbstractWidgetLCA {
writer.set( PROP_LEFT_OFFSET, "leftOffset", newValue, DEFAULT_LEFT_OFFSET );
}
- private void writeCellToolTipText( final Table table ) throws IOException {
+ ////////////////
+ // Cell tooltips
+
+ private static Boolean isCellToolTipEnabled( final Table table ) {
+ Boolean result = Boolean.FALSE;
+ Object data = table.getData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP );
+ if( Boolean.TRUE.equals( data ) ) {
+ result = Boolean.TRUE;
+ }
+ return result;
+ }
+
+ private static void writeEnableCellToolTip( final Table table )
+ throws IOException
+ {
+ JSWriter writer = JSWriter.getWriterFor( table );
+ Boolean newValue = isCellToolTipEnabled( table );
+ Boolean defValue = Boolean.FALSE;
+ String prop = PROP_ENABLE_CELL_TOOLTIP;
+ writer.set( prop, "enableCellToolTip", newValue, defValue );
+ }
+
+ private static void readCellToolTipTextRequested( final Table table ) {
+ Object adapter = table.getAdapter( ITableAdapter.class );
+ ITableAdapter tableAdapter = ( ITableAdapter )adapter;
+ tableAdapter.setToolTipText( null );
+ String event = JSConst.EVENT_CELL_TOOLTIP_REQUESTED;
+ if( WidgetLCAUtil.wasEventSent( table, event ) ) {
+ ICellToolTipProvider provider = tableAdapter.getCellToolTipProvider();
+ if( provider != null ) {
+ HttpServletRequest request = ContextProvider.getRequest();
+ String cell = request.getParameter( JSConst.EVENT_CELL_TOOLTIP_DETAILS );
+ String[] details = cell.split( "," );
+ String itemId = details[ 0 ];
+ int columnIndex = Integer.parseInt( details[ 1 ] );
+ TableItem item = getItemById( table, itemId );
+ // Bug 321119: Sometimes the client can request tooltips for already
+ // disposed cells.
+ if( item != null
+ && ( columnIndex == 0 || columnIndex < table.getColumnCount() ) )
+ {
+ provider.getToolTipText( item, columnIndex );
+ }
+ }
+ }
+ }
+
+ private static void writeCellToolTipText( final Table table )
+ throws IOException
+ {
Object adapter = table.getAdapter( ITableAdapter.class );
ITableAdapter tableAdapter = ( ITableAdapter )adapter;
String text = tableAdapter.getToolTipText();
if( text != null ) {
JSWriter writer = JSWriter.getWriterFor( table );
text = WidgetLCAUtil.escapeText( text, false );
- text = WidgetLCAUtil.replaceNewLines( text, "<br>" );
+ text = WidgetLCAUtil.replaceNewLines( text, "<br/>" );
writer.call( "setCellToolTipText", new String[]{ text } );
}
}
+ private static TableItem getItemById( final Table table, final String itemId )
+ {
+ TableItem result = null;
+ TableItem[] items = table.getItems();
+ for( int i = 0; i < items.length && result == null; i++ ) {
+ if( WidgetUtil.getId( items[ i ] ).equals( itemId ) ) {
+ result = items[ i ];
+ }
+ }
+ return result;
+ }
+
//////////////////
// Helping methods
diff --git a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA.java b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA.java
index 734c702b78..8f9b7d63c6 100644
--- a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA.java
+++ b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/treekit/TreeLCA.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,7 +22,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.events.EventLCAUtil;
-import org.eclipse.swt.internal.widgets.ITreeAdapter;
+import org.eclipse.swt.internal.widgets.*;
import org.eclipse.swt.widgets.*;
public final class TreeLCA extends AbstractWidgetLCA {
@@ -42,6 +42,8 @@ public final class TreeLCA extends AbstractWidgetLCA {
static final String PROP_LINES_VISIBLE = "linesVisible";
static final String PROP_SCROLLBARS_SELECTION_LISTENER
= "scrollBarsSelectionListeners";
+ static final String PROP_ENABLE_CELL_TOOLTIP
+ = "enableCellToolTip";
private static final Integer DEFAULT_SCROLL_LEFT = new Integer( 0 );
@@ -67,6 +69,8 @@ public final class TreeLCA extends AbstractWidgetLCA {
adapter.preserve( PROP_HAS_V_SCROLL_BAR, hasVScrollBar( tree ) );
adapter.preserve( PROP_SCROLLBARS_SELECTION_LISTENER,
hasScrollBarsSelectionListener( tree ) );
+ adapter.preserve( PROP_ENABLE_CELL_TOOLTIP,
+ isCellToolTipEnabled( tree ) );
WidgetLCAUtil.preserveCustomVariant( tree );
}
@@ -77,6 +81,7 @@ public final class TreeLCA extends AbstractWidgetLCA {
readTopItemIndex( tree );
processWidgetSelectedEvent( tree );
processWidgetDefaultSelectedEvent( tree );
+ readCellToolTipTextRequested( tree );
ControlLCAUtil.processMouseEvents( tree );
ControlLCAUtil.processKeyEvents( tree );
ControlLCAUtil.processMenuDetect( tree );
@@ -132,6 +137,8 @@ public final class TreeLCA extends AbstractWidgetLCA {
writeHeaderHeight( tree );
writeHeaderVisible( tree );
writeScrollLeft( tree );
+ writeEnableCellToolTip( tree );
+ writeCellToolTipText( tree );
WidgetLCAUtil.writeCustomVariant( tree );
}
@@ -366,6 +373,79 @@ public final class TreeLCA extends AbstractWidgetLCA {
}
}
+ ////////////////
+ // Cell tooltips
+
+ private static Boolean isCellToolTipEnabled( final Tree tree ) {
+ Boolean result = Boolean.FALSE;
+ Object data = tree.getData( ICellToolTipProvider.ENABLE_CELL_TOOLTIP );
+ if( Boolean.TRUE.equals( data ) ) {
+ result = Boolean.TRUE;
+ }
+ return result;
+ }
+
+ private static void writeEnableCellToolTip( final Tree tree )
+ throws IOException
+ {
+ JSWriter writer = JSWriter.getWriterFor( tree );
+ Boolean newValue = isCellToolTipEnabled( tree );
+ Boolean defValue = Boolean.FALSE;
+ String prop = PROP_ENABLE_CELL_TOOLTIP;
+ writer.set( prop, "enableCellToolTip", newValue, defValue );
+ }
+
+ private static void readCellToolTipTextRequested( final Tree tree ) {
+ Object adapter = tree.getAdapter( ITreeAdapter.class );
+ ITreeAdapter treeAdapter = ( ITreeAdapter )adapter;
+ treeAdapter.setToolTipText( null );
+ String event = JSConst.EVENT_CELL_TOOLTIP_REQUESTED;
+ if( WidgetLCAUtil.wasEventSent( tree, event ) ) {
+ ICellToolTipProvider provider = treeAdapter.getCellToolTipProvider();
+ if( provider != null ) {
+ HttpServletRequest request = ContextProvider.getRequest();
+ String cell = request.getParameter( JSConst.EVENT_CELL_TOOLTIP_DETAILS );
+ String[] details = cell.split( "," );
+ String itemId = details[ 0 ];
+ int columnIndex = Integer.parseInt( details[ 1 ] );
+ TreeItem item = getItemById( tree.getItems(), itemId );
+ if( item != null
+ && ( columnIndex == 0 || columnIndex < tree.getColumnCount() ) )
+ {
+ provider.getToolTipText( item, columnIndex );
+ }
+ }
+ }
+ }
+
+ private static void writeCellToolTipText( final Tree tree )
+ throws IOException
+ {
+ Object adapter = tree.getAdapter( ITreeAdapter.class );
+ ITreeAdapter treeAdapter = ( ITreeAdapter )adapter;
+ String text = treeAdapter.getToolTipText();
+ if( text != null ) {
+ JSWriter writer = JSWriter.getWriterFor( tree );
+ text = WidgetLCAUtil.escapeText( text, false );
+ text = WidgetLCAUtil.replaceNewLines( text, "<br/>" );
+ writer.call( "setCellToolTipText", new String[]{ text } );
+ }
+ }
+
+ private static TreeItem getItemById( final TreeItem[] items,
+ final String itemId )
+ {
+ TreeItem result = null;
+ for( int i = 0; i < items.length && result == null; i++ ) {
+ if( WidgetUtil.getId( items[ i ] ).equals( itemId ) ) {
+ result = items[ i ];
+ } else if( items[ i ].getExpanded() ) {
+ result = getItemById( items[ i ].getItems(), itemId );
+ }
+ }
+ return result;
+ }
+
//////////////////
// Helping methods
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ICellToolTipAdapter.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ICellToolTipAdapter.java
new file mode 100644
index 0000000000..a98765df71
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ICellToolTipAdapter.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2011 EclipseSource and others. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.swt.internal.widgets;
+
+public interface ICellToolTipAdapter {
+
+ ICellToolTipProvider getCellToolTipProvider();
+ void setCellToolTipProvider( ICellToolTipProvider provider );
+
+ String getToolTipText();
+ void setToolTipText( String toolTipText );
+
+}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ICellToolTipProvider.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ICellToolTipProvider.java
index f04ecfbec9..fa0bcee757 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ICellToolTipProvider.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ICellToolTipProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 EclipseSource and others. All rights reserved.
+ * Copyright (c) 2009, 2011 EclipseSource and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -9,9 +9,14 @@
******************************************************************************/
package org.eclipse.swt.internal.widgets;
+import org.eclipse.swt.widgets.Item;
+
public interface ICellToolTipProvider {
- void getToolTipText( int itemIndex, int columnIndex );
+ public static final String ENABLE_CELL_TOOLTIP
+ = ICellToolTipProvider.class.getName() + "#enableCellToolTip";
+
+ void getToolTipText( Item item, int columnIndex );
}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITableAdapter.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITableAdapter.java
index a69f75ca65..6293e74cd0 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITableAdapter.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITableAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2007, 2011 Innoopract Informationssysteme GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,7 +14,7 @@ package org.eclipse.swt.internal.widgets;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
-public interface ITableAdapter {
+public interface ITableAdapter extends ICellToolTipAdapter {
int getCheckWidth();
int getItemImageWidth( int columnIndex );
@@ -40,10 +40,4 @@ public interface ITableAdapter {
boolean hasVScrollBar();
TableItem getMeasureItem();
-
- ICellToolTipProvider getCellToolTipProvider();
- void setCellToolTipProvider( ICellToolTipProvider provider );
-
- String getToolTipText();
- void setToolTipText( String toolTipText );
} \ No newline at end of file
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITreeAdapter.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITreeAdapter.java
index f88d67a688..859290d2f4 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITreeAdapter.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/ITreeAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,7 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.*;
-public interface ITreeAdapter {
+public interface ITreeAdapter extends ICellToolTipAdapter {
void setScrollLeft( final int left );
int getScrollLeft();
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Table.java
index 1c0ae251ab..305b32e6be 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Table.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -243,15 +243,6 @@ public class Table extends Composite {
public static final String ALWAYS_HIDE_SELECTION
= Table.class.getName() + "#alwaysHideSelection";
- /**
- * <strong>IMPORTANT:</strong> This field is <em>not</em> part of the SWT
- * public API. It is marked public only so that it can be shared
- * within the packages provided by SWT. It should never be accessed from
- * application code.
- */
- public static final String ENABLE_CELL_TOOLTIP
- = Table.class.getName() + "#enableCellToolTip";
-
private static final int GRID_WIDTH = 1;
private static final int[] EMPTY_SELECTION = new int[ 0 ];
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Tree.java
index 52694d4458..0da932705d 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Tree.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2010 Innoopract Informationssysteme GmbH.
+ * Copyright (c) 2002, 2011 Innoopract Informationssysteme GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -155,6 +155,9 @@ public class Tree extends Composite {
}
private final class InternalTreeAdapter implements ITreeAdapter {
+ private String toolTipText;
+ private ICellToolTipProvider provider;
+
public void setScrollLeft( final int left ) {
Tree.this.scrollLeft = left;
}
@@ -232,6 +235,22 @@ public class Tree extends Composite {
return Tree.this.getColumn( index ).getLeft();
}
+ public ICellToolTipProvider getCellToolTipProvider() {
+ return provider;
+ }
+
+ public void setCellToolTipProvider( final ICellToolTipProvider provider ) {
+ this.provider = provider;
+ }
+
+ public String getToolTipText() {
+ return toolTipText;
+ }
+
+ public void setToolTipText( final String toolTipText ) {
+ this.toolTipText = toolTipText;
+ }
+
}
private static final class ResizeListener extends ControlAdapter {

Back to the top