Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRüdiger Herrmann2011-01-24 10:37:38 +0000
committerRüdiger Herrmann2011-01-24 10:37:38 +0000
commitc819adf583bc04f1c51b9bcab667b96115235be3 (patch)
treeb83ee31f2928adb29808ecd3325d8b76c835fd7e /bundles
parent2031ea94bacb02d886a5f2701f2565103fa36f33 (diff)
downloadorg.eclipse.rap-c819adf583bc04f1c51b9bcab667b96115235be3.tar.gz
org.eclipse.rap-c819adf583bc04f1c51b9bcab667b96115235be3.tar.xz
org.eclipse.rap-c819adf583bc04f1c51b9bcab667b96115235be3.zip
RESOLVED 335112: ToolTip widget is missing
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ControlsDemo.java9
-rw-r--r--bundles/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ToolTipTab.java178
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/FontSizeCalculation.js2
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/theme/AppearancesBase.js59
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/ToolTip.js185
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/error.pngbin0 -> 1591 bytes
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/information.pngbin0 -> 2362 bytes
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/warning.pngbin0 -> 1692 bytes
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java4
-rw-r--r--bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTipLCA.java160
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/theme/ThemeManager.java7
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/SWT.java34
-rwxr-xr-xbundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/custom/ctabfolderkit/CTabFolder.theme.xml6
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IShellAdapter.java7
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IToolTipAdapter.java17
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor.java15
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTip.default.css47
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTip.theme.xml113
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Shell.java69
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ToolTip.java412
20 files changed, 1306 insertions, 18 deletions
diff --git a/bundles/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ControlsDemo.java b/bundles/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ControlsDemo.java
index a0d9c7b3d3..f036a9f645 100644
--- a/bundles/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ControlsDemo.java
+++ b/bundles/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ControlsDemo.java
@@ -86,16 +86,17 @@ public class ControlsDemo implements IEntryPoint {
new BrowserTab( topFolder ),
new ScaleTab( topFolder ),
new SliderTab( topFolder ),
+ new ProgressBarTab( topFolder ),
new ScrolledCompositeTab( topFolder ),
+ new ToolTipTab( topFolder ),
+ new DNDExampleTab( topFolder ),
new ContainmentTab( topFolder ),
new ZOrderTab( topFolder ),
new FocusTab( topFolder ),
- new ProgressBarTab( topFolder ),
- new ErrorHandlingTab( topFolder ),
- new NLSTab( topFolder ),
new VariantsTab( topFolder ),
new ControlDecoratorTab( topFolder ),
- new DNDExampleTab( topFolder )
+ new ErrorHandlingTab( topFolder ),
+ new NLSTab( topFolder ),
};
ensureMinTabHeight( topFolder );
tabs[ 0 ].createContents();
diff --git a/bundles/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ToolTipTab.java b/bundles/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ToolTipTab.java
new file mode 100644
index 0000000000..6ad5df49ed
--- /dev/null
+++ b/bundles/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ToolTipTab.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Rüdiger Herrmann and others. All rights reserved.
+ * 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:
+ * Rüdiger Herrmann - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.rap.demo.controls;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CTabFolder;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+
+public class ToolTipTab extends ExampleTab {
+
+ private ToolTip toolTip;
+ private boolean toolTipAutoHide;
+ private String toolTipText;
+ private String toolTipMessage;
+ private Point toolTipLocation;
+ private boolean toolTipSelectionListener;
+ private final SelectionListener selectionListener;
+
+ public ToolTipTab( final CTabFolder folder ) {
+ super( folder, "ToolTip" );
+ toolTipText = "";
+ toolTipMessage = "";
+ selectionListener = new SelectionAdapter() {
+ public void widgetSelected( final SelectionEvent event ) {
+ ToolTipTab.this.log( "" + event );
+ }
+ };
+ }
+
+ protected void createStyleControls( final Composite parent ) {
+ parent.setLayout( new GridLayout( 1, false ) );
+ createStyleButton( "BALLOON", SWT.BALLOON );
+ createStyleButton( "ICON_ERROR", SWT.ICON_ERROR );
+ createStyleButton( "ICON_INFORMATION", SWT.ICON_INFORMATION );
+ createStyleButton( "ICON_WARNING", SWT.ICON_WARNING );
+ createAutoHideButton();
+ createTextInput();
+ createMessageInput();
+ createLocationInput();
+ createSelectionListenerButton();
+ }
+
+ protected void createExampleControls( final Composite parent ) {
+ parent.setLayout( new GridLayout( 1, false ) );
+ Button button = new Button( parent, SWT.PUSH );
+ button.setText( "Show ToolTip" );
+ button.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected( SelectionEvent event ) {
+ if( toolTip != null ) {
+ toolTip.dispose();
+ }
+ toolTip = new ToolTip( parent.getShell(), getStyle() );
+ toolTip.setVisible( true );
+ toolTip.setAutoHide( toolTipAutoHide );
+ toolTip.setText( toolTipText );
+ toolTip.setMessage( toolTipMessage );
+ if( toolTipLocation != null ) {
+ toolTip.setLocation( toolTipLocation );
+ }
+ updateSelectionListener();
+ }
+ } );
+ }
+
+ private void createTextInput() {
+ Composite group = new Composite( styleComp, SWT.NONE );
+ group.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false ) );
+ group.setLayout( new GridLayout( 2, false ) );
+ new Label( group, SWT.NONE ).setText( "Text" );
+ Text text = new Text( group, SWT.BORDER );
+ text.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false ) );
+ text.addModifyListener( new ModifyListener() {
+ public void modifyText( ModifyEvent event ) {
+ Text text = ( Text )event.widget;
+ toolTipText = text.getText();
+ }
+ } );
+ }
+
+ private void createMessageInput() {
+ Composite group = new Composite( styleComp, SWT.NONE );
+ group.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false ) );
+ group.setLayout( new GridLayout( 2, false ) );
+ Label label = new Label( group, SWT.NONE );
+ label.setLayoutData( new GridData( SWT.FILL, SWT.TOP, false, false ) );
+ label.setText( "Message" );
+ Text text = new Text( group, SWT.BORDER | SWT.MULTI );
+ GridData gridData = new GridData( SWT.FILL, SWT.FILL, true, true );
+ gridData.heightHint = 150;
+ text.setLayoutData( gridData );
+ text.addModifyListener( new ModifyListener() {
+ public void modifyText( ModifyEvent event ) {
+ Text text = ( Text )event.widget;
+ toolTipMessage = text.getText();
+ }
+ } );
+ }
+
+ private void createLocationInput() {
+ Composite group = new Composite( styleComp, SWT.NONE );
+ group.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false ) );
+ group.setLayout( new GridLayout( 4, false ) );
+ new Label( group, SWT.NONE ).setText( "Location X" );
+ final Text textX = new Text( group, SWT.BORDER );
+ new Label( group, SWT.NONE ).setText( "Y" );
+ final Text textY = new Text( group, SWT.BORDER );
+ ModifyListener modifyListener = new ModifyListener() {
+ public void modifyText( ModifyEvent event ) {
+ int x = parseInt( textX.getText() );
+ int y = parseInt( textY.getText() );
+ if( x > 0 && y > 0 ) {
+ toolTipLocation = new Point( x, y );
+ } else {
+ toolTipLocation = null;
+ }
+ }
+ };
+ textX.addModifyListener( modifyListener );
+ textY.addModifyListener( modifyListener );
+ }
+
+ private void createAutoHideButton() {
+ Button button = new Button( styleComp, SWT.CHECK );
+ button.setText( "AutoHide" );
+ button.setSelection( toolTipAutoHide );
+ button.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected( final SelectionEvent event ) {
+ Button button = ( Button )event.widget;
+ toolTipAutoHide = button.getSelection();
+ }
+ } );
+ }
+
+ private void createSelectionListenerButton() {
+ Button button = new Button( styleComp, SWT.CHECK );
+ button.setText( "SelectionListener" );
+ button.setSelection( toolTipSelectionListener );
+ button.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected( final SelectionEvent event ) {
+ Button button = ( Button )event.widget;
+ toolTipSelectionListener = button.getSelection();
+ updateSelectionListener();
+ }
+ } );
+ }
+
+ private void updateSelectionListener() {
+ if( toolTip != null ) {
+ if( toolTipSelectionListener ) {
+ toolTip.addSelectionListener( selectionListener );
+ } else {
+ toolTip.removeSelectionListener( selectionListener );
+ }
+ }
+ }
+
+ private static int parseInt( final String text ) {
+ int result;
+ try {
+ result = Integer.parseInt( text );
+ } catch( NumberFormatException e ) {
+ result = -1;
+ }
+ return result;
+ }
+}
diff --git a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/FontSizeCalculation.js b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/FontSizeCalculation.js
index c73d9d13da..2bd6e5f50e 100644
--- a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/FontSizeCalculation.js
+++ b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/FontSizeCalculation.js
@@ -38,7 +38,6 @@ qx.Class.define( "org.eclipse.swt.FontSizeCalculation", {
_doMeasurement : function( item ) {
var lbl = org.eclipse.swt.FontSizeCalculation.MEASUREMENT_LABEL;
- var wm = org.eclipse.swt.WidgetManager.getInstance();
var measureNode = qx.ui.basic.Label._getMeasureNode();
// [if] Move the measure node to the left to prevent text split on
// small browser window - see bug 298798
@@ -49,6 +48,7 @@ qx.Class.define( "org.eclipse.swt.FontSizeCalculation", {
measureNode.style.width = "auto";
}
lbl.setText( item[ 1 ] );
+ var wm = org.eclipse.swt.WidgetManager.getInstance();
wm.setFont( lbl, item[ 2 ], item[ 3 ], item[ 4 ], item[ 5 ] );
var result = [ lbl._computePreferredInnerWidth(),
lbl._computePreferredInnerHeight() ];
diff --git a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/theme/AppearancesBase.js b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/theme/AppearancesBase.js
index a5b4107649..de9d04285b 100644
--- a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/theme/AppearancesBase.js
+++ b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/theme/AppearancesBase.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
@@ -8,9 +8,9 @@
* Contributors:
* Innoopract Informationssysteme GmbH - initial API and implementation
* EclipseSource - ongoing development
+ * Rüdiger Herrmann - bug 335112
******************************************************************************/
-
qx.Theme.define( "org.eclipse.swt.theme.AppearancesBase",
{
title : "Appearances Base Theme",
@@ -202,6 +202,61 @@ qx.Theme.define( "org.eclipse.swt.theme.AppearancesBase",
}
},
+ "tool-tip-widget" : {
+ include : "popup",
+
+ style : function( states ) {
+ var tv = new org.eclipse.swt.theme.ThemeValues( states );
+ var result = {};
+ result.width = "auto";
+ result.height = "auto";
+ result.minWidth = 36;
+ result.minHeight = 36;
+ result.cursor = tv.getCssCursor( "ToolTipWidget", "cursor" );
+ result.font = tv.getCssFont( "ToolTipWidget", "font" );
+ result.textColor = tv.getCssColor( "ToolTipWidget", "color" );
+ result.padding = tv.getCssBoxDimensions( "ToolTipWidget", "padding" ); result.border = tv.getCssBorder( "ToolTipWidget", "border" );
+ result.backgroundColor = tv.getCssColor( "ToolTipWidget", "background-color" );
+ result.backgroundImage = tv.getCssImage( "ToolTipWidget", "background-image" );
+ result.backgroundGradient = tv.getCssGradient( "ToolTipWidget", "background-image" );
+ result.animation = tv.getCssAnimation( "ToolTipWidget", "animation" );
+ result.opacity = tv.getCssFloat( "ToolTipWidget", "opacity" );
+ return result;
+ }
+ },
+
+ "tool-tip-widget-image" : {
+ include: "image",
+ style : function( states ) {
+ var tv = new org.eclipse.swt.theme.ThemeValues( states );
+ return {
+ source : tv.getCssImage( "ToolTipWidget-Image", "background-image" )
+ };
+ }
+ },
+
+ "tool-tip-widget-text" : {
+ style : function( states ) {
+ var tv = new org.eclipse.swt.theme.ThemeValues( states );
+ var result = {
+ font : tv.getCssFont( "ToolTipWidget-Text", "font" ),
+ textColor : tv.getCssColor( "ToolTipWidget-Text", "color" )
+ };
+ return result;
+ }
+ },
+
+ "tool-tip-widget-message" : {
+ style : function( states ) {
+ var tv = new org.eclipse.swt.theme.ThemeValues( states );
+ var result = {
+ font : tv.getCssFont( "ToolTipWidget-Message", "font" ),
+ textColor : tv.getCssColor( "ToolTipWidget-Message", "color" )
+ };
+ return result;
+ }
+ },
+
"iframe" : {
style : function( states ) {
return {
diff --git a/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/ToolTip.js b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/ToolTip.js
new file mode 100644
index 0000000000..0a09d0223d
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/ToolTip.js
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Rüdiger Herrmann 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:
+ * Rüdiger Herrmann - initial API and implementation
+ ******************************************************************************/
+
+qx.Class.define( "org.eclipse.swt.widgets.ToolTip", {
+ extend : qx.ui.popup.Popup,
+ include : org.eclipse.rwt.FadeAnimationMixin,
+
+ construct : function( style ) {
+ this.base( arguments );
+ this._style = style;
+ this.setAutoHide( false );
+ this.setDisplay( true );
+ this.setAppearance( "tool-tip-widget" );
+ var doc = qx.ui.core.ClientDocument.getInstance();
+ this.setMaxWidth( doc.getClientWidth() / 2 );
+ this.setMaxHeight( doc.getClientHeight() / 2 );
+ this.addToDocument();
+ this.addEventListener( "mousedown", this._onMouseDown, this );
+ this._hideAfterTimeout = false;
+ this._hasSelectionListener = false;
+ this._messageFont = this._getMessageFont();
+ this._contentArea = null;
+ this._textArea = null;
+ this._image = null;
+ this._text = null;
+ this._message = null;
+ this._createControls();
+ },
+
+ destruct : function() {
+ this.removeEventListener( "mousedown", this._onMouseDown, this );
+ this._contentArea.dispose();
+ this._textArea.dispose();
+ this._image.dispose();
+ this._text.dispose();
+ this._message.dispose();
+ this._messageFont = null;
+ },
+
+ members : {
+
+ setText : function( text ) {
+ this._text.setText( text );
+ if( this.getVisibility() ) {
+ this._update();
+ }
+ },
+
+ setMessage : function( message ) {
+ this._message.setText( message );
+ if( this.getVisibility() ) {
+ this._update();
+ }
+ },
+
+ setLocation : function( x, y ) {
+ this.setLeft( x );
+ this.setTop( y );
+ },
+
+ setHideAfterTimeout : function( value ) {
+ this._hideAfterTimeout = value;
+ },
+
+ setHasSelectionListener : function( value ) {
+ this._hasSelectionListener = value;
+ },
+
+ setVisible : function( visible ) {
+ this.setVisibility( visible );
+ if( visible ) {
+ this._update();
+ this.bringToFront();
+ if( this._hideAfterTimeout ) {
+ qx.client.Timer.once( this._hide, this, 5 * 1000 );
+ }
+ }
+ },
+
+ addState : function( state ) {
+ this.base( arguments, state );
+ this._image.addState( state );
+ },
+
+ removeState : function( state ) {
+ this.base( arguments, state );
+ this._image.removeState( state );
+ },
+
+ _createControls : function() {
+ this._contentArea = new qx.ui.layout.BoxLayout( "horizontal" );
+ this._contentArea.setWidth( "100%" );
+ this._contentArea.setHeight( "100%" );
+ this._contentArea.setSpacing( 5 );
+ this._contentArea.setParent( this );
+ this._image = new qx.ui.basic.Image();
+ this._image.setAppearance( "tool-tip-widget-image" );
+ this._image.setParent( this._contentArea );
+ this._textArea = new qx.ui.layout.BoxLayout( "vertical" );
+ this._textArea.setParent( this._contentArea );
+ this._textArea.setHeight( "100%" );
+ this._textArea.setSpacing( 5 );
+ this._text = new qx.ui.basic.Label();
+ this._text.setAppearance( "tool-tip-widget-text" );
+ this._text.setParent( this._textArea );
+ this._message = new qx.ui.basic.Label();
+ this._message.setAppearance( "tool-tip-widget-message" );
+ this._message.setHeight( "auto" );
+ this._message.setWrap( true );
+ this._message.setParent( this._textArea );
+ },
+
+ _update : function() {
+ var message = this._message.getText();
+ var textSize = this._getTextSize( this._text.getText(), -1 );
+ var messageSize = this._getTextSize( message, -1 );
+ var width = messageSize.x;
+ while( width > 0 && !this._matchesWidthToHeightRatio( messageSize ) ) {
+ width -= 10;
+ messageSize = this._getTextSize( message, width );
+ }
+ messageSize.x = this._max( messageSize.x, textSize.x );
+ this._message.setWidth( messageSize.x );
+ this._message.setHeight( messageSize.y );
+ },
+
+ _matchesWidthToHeightRatio : function( size ) {
+ return size.x / size.y <= 6;
+ },
+
+ _max : function( a, b ) {
+ return a > b ? a : b;
+ },
+
+ _getTextSize : function( text, width ) {
+ var data = new Array();
+ data[ 0 ] = "";
+ data[ 1 ] = text;
+ data[ 2 ] = this._messageFont.getFamily();
+ data[ 3 ] = this._messageFont.getSize();
+ data[ 4 ] = this._messageFont.getBold();
+ data[ 5 ] = this._messageFont.getItalic();
+ data[ 6 ] = width;
+ var textSize = org.eclipse.swt.FontSizeCalculation._doMeasurement( data );
+ return {
+ x : textSize[ 0 ],
+ y : textSize[ 1 ]
+ };
+ },
+
+ _onMouseDown : function( evt ) {
+ this._hide();
+ var id = this._getWidgetId();
+ var req = org.eclipse.swt.Request.getInstance();
+ req.addParameter( id + ".visible", false );
+ if( this._hasSelectionListener ) {
+ req.addEvent( "org.eclipse.swt.events.widgetSelected", id );
+ req.send();
+ }
+ },
+
+ _hide : function() {
+ this.setVisible( false );
+ qx.ui.core.Widget.flushGlobalQueues();
+ },
+
+ _getWidgetId : function() {
+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
+ return widgetManager.findIdByWidget( this );
+ },
+
+ _getMessageFont : function() {
+ var tv = new org.eclipse.swt.theme.ThemeValues( {} );
+ return tv.getCssFont( "ToolTipWidget-Message", "font" );
+ }
+
+ }
+} );
diff --git a/bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/error.png b/bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/error.png
new file mode 100644
index 0000000000..1de7a6fda0
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/error.png
Binary files differ
diff --git a/bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/information.png b/bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/information.png
new file mode 100644
index 0000000000..96642db7f0
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/information.png
Binary files differ
diff --git a/bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/warning.png b/bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/warning.png
new file mode 100644
index 0000000000..d83f3491e6
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt.q07/resources/resource/widget/rap/tooltip/warning.png
Binary files differ
diff --git a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java
index f5a9d695b9..cbabc15f67 100644
--- a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java
+++ b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java
@@ -8,6 +8,7 @@
* Contributors:
* Innoopract Informationssysteme GmbH - initial API and implementation
* EclipseSource - ongoing development
+ * Rüdiger Herrmann - bug 335112
******************************************************************************/
package org.eclipse.swt.internal.widgets.displaykit;
@@ -262,7 +263,8 @@ final class QooxdooResourcesUtil {
"org/eclipse/swt/widgets/Separator.js",
"org/eclipse/swt/theme/AppearancesBase.js",
"org/eclipse/rwt/widgets/ControlDecorator.js",
- "org/eclipse/rwt/MobileWebkitSupport.js"
+ "org/eclipse/rwt/MobileWebkitSupport.js",
+ "org/eclipse/swt/widgets/ToolTip.js"
};
private static final String[] WIDGET_IMAGES = new String[]{
diff --git a/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTipLCA.java b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTipLCA.java
new file mode 100644
index 0000000000..216bdd3942
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTipLCA.java
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Rüdiger Herrmann 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:
+ * Rüdiger Herrmann - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.swt.internal.widgets.tooltipkit;
+
+import java.io.IOException;
+
+import org.eclipse.rwt.lifecycle.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.internal.widgets.IToolTipAdapter;
+import org.eclipse.swt.widgets.*;
+
+public final class ToolTipLCA extends AbstractWidgetLCA {
+ static final String PROP_VISIBLE = "visible";
+ static final String PROP_AUTO_HIDE = "autoHide";
+ static final String PROP_TEXT = "text";
+ static final String PROP_MESSAGE = "message";
+ static final String PROP_LOCATION = "location";
+ static final String PROP_SELECTION_LISTENER = "selectionListener";
+
+ public void preserveValues( final Widget widget ) {
+ IWidgetAdapter adapter = WidgetUtil.getAdapter( widget );
+ ToolTip toolTip = ( ToolTip )widget;
+ adapter.preserve( PROP_VISIBLE, Boolean.valueOf( toolTip.isVisible() ) );
+ adapter.preserve( PROP_AUTO_HIDE,
+ Boolean.valueOf( toolTip.getAutoHide() ) );
+ adapter.preserve( PROP_TEXT, toolTip.getText() );
+ adapter.preserve( PROP_MESSAGE, toolTip.getMessage() );
+ adapter.preserve( PROP_LOCATION, getLocation( toolTip ) );
+ Boolean hasListener = hasSelectionListener( toolTip );
+ adapter.preserve( PROP_SELECTION_LISTENER, hasListener );
+ }
+
+ public void readData( final Widget widget ) {
+ ControlLCAUtil.processSelection( widget, null, false );
+ ToolTip toolTip = ( ToolTip )widget;
+ readVisible( toolTip );
+ }
+
+ public void renderInitialization( final Widget widget ) throws IOException {
+ ToolTip toolTip = ( ToolTip )widget;
+ JSWriter writer = JSWriter.getWriterFor( toolTip );
+ Object[] args = new Object[] { getImage( toolTip )};
+ writer.newWidget( "org.eclipse.swt.widgets.ToolTip", args );
+ WidgetLCAUtil.writeStyleFlag( toolTip, SWT.BALLOON, "BAlLOON" );
+ WidgetLCAUtil.writeStyleFlag( toolTip, SWT.ICON_ERROR, "ICON_ERROR" );
+ WidgetLCAUtil.writeStyleFlag( toolTip, SWT.ICON_WARNING, "ICON_WARNING" );
+ WidgetLCAUtil.writeStyleFlag( toolTip,
+ SWT.ICON_INFORMATION,
+ "ICON_INFORMATION" );
+ }
+
+ public void renderChanges( final Widget widget ) throws IOException {
+ ToolTip toolTip = ( ToolTip )widget;
+ WidgetLCAUtil.writeBackgroundGradient( widget );
+ WidgetLCAUtil.writeRoundedBorder( widget );
+ WidgetLCAUtil.writeCustomVariant( widget );
+ writeText( toolTip );
+ writeMessage( toolTip );
+ writeLocation( toolTip );
+ writeAutoHide( toolTip );
+ writeSelectionListener( toolTip );
+ // Order is relevant here: writeVisible must be called after all other
+ // properties are set
+ writeVisible( toolTip );
+ }
+
+ public void renderDispose( final Widget widget ) throws IOException {
+ JSWriter writer = JSWriter.getWriterFor( widget );
+ writer.dispose();
+ }
+
+ private static void readVisible( ToolTip toolTip ) {
+ String value = WidgetLCAUtil.readPropertyValue( toolTip, "visible" );
+ if( value != null ) {
+ toolTip.setVisible( Boolean.parseBoolean( value ) );
+ }
+ }
+
+ static void writeText( final ToolTip toolTip ) throws IOException {
+ JSWriter writer = JSWriter.getWriterFor( toolTip );
+ String text = WidgetLCAUtil.escapeText( toolTip.getText(), false );
+ writer.set( PROP_TEXT, "text", text, "" );
+ }
+
+ static void writeMessage( final ToolTip toolTip ) throws IOException {
+ JSWriter writer = JSWriter.getWriterFor( toolTip );
+ String message = WidgetLCAUtil.escapeText( toolTip.getMessage(), false );
+ message = WidgetLCAUtil.replaceNewLines( message, "<br/>" );
+ writer.set( PROP_MESSAGE, "message", message, "" );
+ }
+
+ private static void writeVisible( final ToolTip toolTip ) throws IOException {
+ JSWriter writer = JSWriter.getWriterFor( toolTip );
+ Boolean visible = Boolean.valueOf( toolTip.isVisible() );
+ writer.set( PROP_VISIBLE, "visible", visible, Boolean.FALSE );
+ }
+
+ private static void writeLocation( final ToolTip toolTip )
+ throws IOException
+ {
+ JSWriter writer = JSWriter.getWriterFor( toolTip );
+ Point location = getLocation( toolTip );
+ if( WidgetLCAUtil.hasChanged( toolTip, PROP_LOCATION, location ) ) {
+ Object[] args = new Object[] {
+ new Integer( location.x ),
+ new Integer( location.y )
+ };
+ writer.call( "setLocation", args );
+ }
+ }
+
+ private static void writeAutoHide( final ToolTip toolTip ) throws IOException
+ {
+ JSWriter writer = JSWriter.getWriterFor( toolTip );
+ Boolean autoHide = Boolean.valueOf( toolTip.getAutoHide() );
+ writer.set( PROP_AUTO_HIDE, "hideAfterTimeout", autoHide, Boolean.FALSE );
+ }
+
+ private static void writeSelectionListener( ToolTip toolTip )
+ throws IOException
+ {
+ JSWriter writer = JSWriter.getWriterFor( toolTip );
+ Boolean hasListener = hasSelectionListener( toolTip );
+ writer.set( PROP_SELECTION_LISTENER,
+ "hasSelectionListener",
+ hasListener,
+ Boolean.FALSE );
+ }
+
+ private static Boolean hasSelectionListener( ToolTip toolTip ) {
+ return Boolean.valueOf( SelectionEvent.hasListener( toolTip ) );
+ }
+
+ private static Point getLocation( final ToolTip toolTip ) {
+ Object adapter = toolTip.getAdapter( IToolTipAdapter.class );
+ IToolTipAdapter toolTipAdapter = ( IToolTipAdapter )adapter;
+ return toolTipAdapter.getLocation();
+ }
+
+ static String getImage( ToolTip toolTip ) {
+ String result = null;
+ if( ( toolTip.getStyle() & SWT.ICON_ERROR ) != 0 ) {
+ result = "error";
+ } if( ( toolTip.getStyle() & SWT.ICON_WARNING ) != 0 ) {
+ result = "warning";
+ } if( ( toolTip.getStyle() & SWT.ICON_INFORMATION ) != 0 ) {
+ result = "information";
+ }
+ return result;
+ }
+}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/theme/ThemeManager.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/theme/ThemeManager.java
index 9ee55c86bd..cc0fea1ac2 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/theme/ThemeManager.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/theme/ThemeManager.java
@@ -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
@@ -8,6 +8,7 @@
* Contributors:
* Innoopract Informationssysteme GmbH - initial API and implementation
* EclipseSource - ongoing development
+ * Rüdiger Herrmann - bug 335112
******************************************************************************/
package org.eclipse.rwt.internal.theme;
@@ -92,6 +93,7 @@ public final class ThemeManager {
org.eclipse.swt.widgets.ExpandBar.class,
org.eclipse.swt.widgets.Sash.class,
org.eclipse.swt.widgets.Slider.class,
+ org.eclipse.swt.widgets.ToolTip.class,
org.eclipse.swt.custom.CCombo.class,
org.eclipse.swt.custom.CLabel.class,
org.eclipse.swt.browser.Browser.class
@@ -382,7 +384,8 @@ public final class ThemeManager {
private boolean loadDefaultCss( final ThemeableWidget themeWidget,
final String pkgName,
- final String className ) throws IOException
+ final String className )
+ throws IOException
{
boolean result = false;
String resPkgName = pkgName.replace( '.', '/' );
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/SWT.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/SWT.java
index ab7dc1940c..d355a3bc47 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/SWT.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/SWT.java
@@ -797,6 +797,16 @@ public class SWT {
public static final int VERTICAL = 1 << 9;
/**
+ * Style constant for balloon behavior (value is 1&lt;&lt;12).
+ * <p><b>Used By:</b><ul>
+ * <li><code>ToolTip</code></li>
+ * </ul></p>
+ *
+ * @since 1.4
+ */
+ public static final int BALLOON = 1 << 12;
+
+ /**
* Style constant for vertical alignment or orientation behavior (value is 1).
* <p><b>Used By:</b><ul>
* <li><code>GridLayout</code> type</li>
@@ -1549,6 +1559,30 @@ public class SWT {
public static final int BORDER = 1 << 11;
/**
+ * Style constant indicating that the window manager should clip
+ * a widget's children with respect to its viewable area. (value is 1&lt;&lt;12).
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Control</code> and subclasses</li>
+ * </ul></p>
+ *
+ * @sicne 1.4
+ */
+ public static final int CLIP_CHILDREN = 1 << 12;
+
+ /**
+ * Style constant indicating that the window manager should clip
+ * a widget's siblings with respect to its viewable area. (value is 1&lt;&lt;13).
+ * <br>Note that this is a <em>HINT</em>.
+ * <p><b>Used By:</b><ul>
+ * <li><code>Control</code> and subclasses</li>
+ * </ul></p>
+ *
+ * @sicne 1.4
+ */
+ public static final int CLIP_SIBLINGS = 1 << 13;
+
+ /**
* Style constant for flat appearance. (value is 1&lt;&lt;23).
* <br>Note that this is a <em>HINT</em>.
* <p><b>Used By:</b><ul>
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/custom/ctabfolderkit/CTabFolder.theme.xml b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/custom/ctabfolderkit/CTabFolder.theme.xml
index 8ec818d3a9..80b0a932d8 100755
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/custom/ctabfolderkit/CTabFolder.theme.xml
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/custom/ctabfolderkit/CTabFolder.theme.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<!--
- Copyright (c) 2008, 2009 Innoopract Informationssysteme GmbH.
+ Copyright (c) 2008, 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
@@ -16,8 +16,8 @@
<element name="CTabFolder">
<description>
- RWT CTabFolder widgets.
- This widget is used to arrange views in the Workbench default presentation.
+ This widget implements the notebook user interface metaphor. It allows
+ the user to select a notebook page from set of pages.
</description>
<property name="border-color"
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IShellAdapter.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IShellAdapter.java
index 706ff70ccb..f40be366f0 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IShellAdapter.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IShellAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2007 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
@@ -7,12 +7,13 @@
*
* Contributors:
* Innoopract Informationssysteme GmbH - initial API and implementation
+ * Rüdiger Herrmann - bug 335112
******************************************************************************/
-
package org.eclipse.swt.internal.widgets;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.ToolTip;
public interface IShellAdapter {
@@ -23,4 +24,6 @@ public interface IShellAdapter {
Rectangle getMenuBounds();
void setBounds( Rectangle bounds );
+
+ ToolTip[] getToolTips();
}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IToolTipAdapter.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IToolTipAdapter.java
new file mode 100644
index 0000000000..1c910a8ea7
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IToolTipAdapter.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Rüdiger Herrmann 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:
+ * Rüdiger Herrmann - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.swt.internal.widgets;
+
+import org.eclipse.swt.graphics.Point;
+
+
+public interface IToolTipAdapter {
+ Point getLocation();
+}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor.java
index 51bff2a51e..c02abc6499 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/WidgetTreeVisitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2009 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
@@ -8,6 +8,7 @@
* Contributors:
* Innoopract Informationssysteme GmbH - initial API and implementation
* EclipseSource - ongoing development
+ * Rüdiger Herrmann - bug 335112
******************************************************************************/
package org.eclipse.swt.internal.widgets;
@@ -55,6 +56,7 @@ public class WidgetTreeVisitor {
for( int i = 0; i < children.length; i++ ) {
accept( children[ i ], visitor );
}
+ handleToolTips( root, visitor );
}
} else if( ItemHolder.isItemHolder( root ) ) {
if( visitor.visit( root ) ) {
@@ -130,4 +132,15 @@ public class WidgetTreeVisitor {
}
}
}
+
+ private static void handleToolTips( Widget root, WidgetTreeVisitor visitor ) {
+ Object adapter = root.getAdapter( IShellAdapter.class );
+ if( adapter != null ) {
+ IShellAdapter shellAdapter = ( IShellAdapter )adapter;
+ ToolTip[] toolTips = shellAdapter.getToolTips();
+ for( int i = 0; i < toolTips.length; i++ ) {
+ visitor.visit( toolTips[ i ] );
+ }
+ }
+ }
}
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTip.default.css b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTip.default.css
new file mode 100644
index 0000000000..9bc7cdd4ea
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTip.default.css
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Ruediger Herrmann and others. All rights reserved.
+ * 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:
+ * Ruediger Herrmann - initial API and implementation
+ ******************************************************************************/
+
+/* ToolTip default theme */
+
+ToolTipWidget {
+ cursor: default;
+ border: 1px solid #a4a4a4;
+ border-radius: 5px 5px 5px 5px;
+ padding: 3px 3px 3px 3px;
+ background-image: none;
+ opacity: 1;
+ color: #464a4e;
+ font: 12px Verdana, "Lucida Sans", Arial, Helvetica, sans-serif;
+ background-color: #fcfcfc;
+ animation: fadeIn 200ms linear, fadeOut 600ms ease-out;
+}
+
+ToolTipWidget-Image[ICON_ERROR] {
+ background-image: url( resource/widget/rap/tooltip/error.png );
+}
+
+ToolTipWidget-Image[ICON_INFORMATION] {
+ background-image: url( resource/widget/rap/tooltip/information.png );
+}
+
+ToolTipWidget-Image[ICON_WARNING] {
+ background-image: url( resource/widget/rap/tooltip/warning.png );
+}
+
+ToolTipWidget-Text {
+ color: #a7a6aa;
+ font: bold 14px Verdana, "Lucida Sans", Arial, Helvetica, sans-serif;
+}
+
+ToolTipWidget-Message {
+ color: #a7a6aa;
+ font: 12px Verdana, "Lucida Sans", Arial, Helvetica, sans-serif;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTip.theme.xml b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTip.theme.xml
new file mode 100644
index 0000000000..71521a3a14
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/tooltipkit/ToolTip.theme.xml
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<!--
+ Copyright (c) 2011 Rüdiger Herrmann and others. All rights reserved.
+ 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:
+ Rüdiger Herrmann - initial API and implementation
+ -->
+
+<theme>
+
+ <element name="ToolTipWidget">
+ <description>
+ ToolTip widgets represent popup windows that are used to inform or warn
+ the user
+ </description>
+
+ <style name="BALLOON"
+ description="Style constant for balloon behavior." />
+
+ <style name="ICON_ERROR"
+ description="The image used for ToolTips with style SWT#ICON_ERROR." />
+
+ <style name="ICON_INFORMATION"
+ description="The image used for ToolTips with style SWT#ICON_INFORMATION." />
+
+ <style name="ICON_WARNING"
+ description="The image used for ToolTips with style SWT#ICON_WARNING." />
+
+ <property name="font"
+ description="Text font for tooltips." />
+
+ <property name="color"
+ description="Text color" />
+
+ <property name="background-color"
+ description="Background color" />
+
+ <property name="cursor"
+ description="The cursor for the tooltip" />
+
+ <property name="background-image">
+ <description>
+ Background image or gradient for tooltip widget.
+ </description>
+ </property>
+
+ <property name="opacity"
+ description="The opacity of the tooltip widget. A value between 0 and 1." />
+
+ <property name="border"
+ description="Border for text tooltip widget." />
+
+ <property name="border-radius">
+ <description>
+ Border radius. The border radius has no effect if an enhanced border,
+ like "inset" or "outset" is used.
+ </description>
+ </property>
+
+ <property name="padding"
+ description="Padding for tooltip widget." />
+
+ <property name="animation">
+ <description>
+ Supports animations-types "fadeIn" and "fadeOut". Others are ignored.
+ </description>
+ </property>
+
+ <element name="ToolTipWidget-Image"
+ description="The image area.">
+
+ <style name="ICON_ERROR"
+ description="The image used for ToolTips with style SWT#ICON_ERROR." />
+
+ <style name="ICON_INFORMATION"
+ description="The image used for ToolTips with style SWT#ICON_INFORMATION." />
+
+ <style name="ICON_WARNING"
+ description="The image used for ToolTips with style SWT#ICON_WARNING." />
+
+ <property name="background-image"
+ description="The image URL" />
+
+ </element>
+
+ <element name="ToolTipWidget-Text"
+ description="The title text area.">
+
+ <property name="color"
+ description="Text message color" />
+
+ <property name="font"
+ description="Text font" />
+
+ </element>
+
+ <element name="ToolTipWidget-Message"
+ description="The message area.">
+
+ <property name="color"
+ description="Text message color" />
+
+ <property name="font"
+ description="Text font" />
+
+ </element>
+
+ </element>
+</theme>
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Shell.java
index 844fef0e87..16f9a094d7 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Shell.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
@@ -8,6 +8,7 @@
* Contributors:
* Innoopract Informationssysteme GmbH - initial API and implementation
* EclipseSource - ongoing development
+ * Rüdiger Herrmann - bug 335112
******************************************************************************/
package org.eclipse.swt.widgets;
@@ -15,7 +16,8 @@ import org.eclipse.rwt.internal.theme.IThemeAdapter;
import org.eclipse.rwt.lifecycle.ProcessActionRunner;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.*;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.ShellListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.events.ActivateEvent;
@@ -139,6 +141,7 @@ public class Shell extends Decorations {
private boolean modified;
private int minWidth;
private int minHeight;
+ private ToolTip[] toolTips;
private Shell( final Display display,
final Shell parent,
@@ -599,6 +602,9 @@ public class Shell extends Decorations {
public void setBounds( final Rectangle bounds ) {
Shell.this.setBounds( bounds, false );
}
+ public ToolTip[] getToolTips() {
+ return Shell.this.getToolTips();
+ }
};
}
result = shellAdapter;
@@ -1068,6 +1074,13 @@ public class Shell extends Decorations {
for( int i = 0; i < menus.length; i++ ) {
menus[ i ].dispose();
}
+ if( toolTips != null ) {
+ for( int i = 0; i < toolTips.length; i++ ) {
+ if( toolTips[ i ] != null ) {
+ toolTips[ i ].dispose();
+ }
+ }
+ }
}
void releaseParent() {
@@ -1364,6 +1377,58 @@ public class Shell extends Decorations {
checkWidget();
return ( mode & MODE_FULLSCREEN ) != 0;
}
+
+ ///////////////////
+ // ToolTips support
+
+ void createToolTip( ToolTip toolTip ) {
+ int id = 0;
+ if( toolTips == null ) {
+ toolTips = new ToolTip[ 4 ];
+ }
+ while( id < toolTips.length && toolTips[ id ] != null ) {
+ id++;
+ }
+ if( id == toolTips.length ) {
+ ToolTip[] newToolTips = new ToolTip[ toolTips.length + 4 ];
+ System.arraycopy( toolTips, 0, newToolTips, 0, toolTips.length );
+ toolTips = newToolTips;
+ }
+ toolTips[ id ] = toolTip;
+ }
+
+ void destroyToolTip( ToolTip toolTip ) {
+ boolean found = false;
+ for( int i = 0; !found && i < toolTips.length; i++ ) {
+ if( toolTips[ i ] == toolTip ) {
+ toolTips[ i ] = null;
+ found = true;
+ }
+ }
+ }
+
+ private ToolTip[] getToolTips() {
+ ToolTip[] result;
+ if( toolTips == null ) {
+ result = new ToolTip[ 0 ];
+ } else {
+ int count = 0;
+ for( int i = 0; i < toolTips.length; i++ ) {
+ if( toolTips[ i ] != null ) {
+ count++;
+ }
+ }
+ result = new ToolTip[ count ];
+ int index = 0;
+ for( int i = 0; i < toolTips.length; i++ ) {
+ if( toolTips[ i ] != null ) {
+ result[ index ] = toolTips[ i ];
+ index++;
+ }
+ }
+ }
+ return result;
+ }
///////////////////
// Widget overrides
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ToolTip.java
new file mode 100644
index 0000000000..4d53315847
--- /dev/null
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/ToolTip.java
@@ -0,0 +1,412 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Rüdiger Herrmann 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:
+ * Rüdiger Herrmann - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.internal.widgets.IToolTipAdapter;
+
+
+/**
+ * Instances of this class represent popup windows that are used
+ * to inform or warn the user.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BALLOON, ICON_ERROR, ICON_INFORMATION, ICON_WARNING</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION,
+ * and ICON_WARNING may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tooltips">Tool Tips snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 1.4
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ToolTip extends Widget {
+ private final Shell parent;
+ private boolean autoHide;
+ private boolean visible;
+ private String text;
+ private String message;
+ private int x;
+ private int y;
+ private IToolTipAdapter toolTipAdapter;
+
+ /**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BALLOON
+ * @see SWT#ICON_ERROR
+ * @see SWT#ICON_INFORMATION
+ * @see SWT#ICON_WARNING
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+ public ToolTip( final Shell parent, final int style ) {
+ super( parent, checkStyle( style ) );
+ this.parent = parent;
+ this.autoHide = true;
+ this.text = "";
+ this.message = "";
+ Point cursorLocation = display.getCursorLocation();
+ this.x = cursorLocation.x;
+ this.y = cursorLocation.y;
+ this.parent.createToolTip( this );
+ }
+
+ public Object getAdapter( Class adapter ) {
+ Object result;
+ if( adapter == IToolTipAdapter.class ) {
+ if( toolTipAdapter == null ) {
+ toolTipAdapter = new IToolTipAdapter() {
+ public Point getLocation() {
+ return new Point( ToolTip.this.x, ToolTip.this.y );
+ }
+ };
+ }
+ result = toolTipAdapter;
+ } else {
+ result = super.getAdapter( adapter );
+ }
+ return result;
+ }
+
+ /**
+ * Returns the receiver's parent, which must be a <code>Shell</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public Shell getParent() {
+ checkWidget();
+ return parent;
+ }
+
+ /**
+ * Returns <code>true</code> if the receiver is automatically
+ * hidden by the platform, and <code>false</code> otherwise.
+ *
+ * @return the receiver's auto hide state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+ public boolean getAutoHide() {
+ checkWidget();
+ return autoHide;
+ }
+
+ /**
+ * Makes the receiver hide automatically when <code>true</code>,
+ * and remain visible when <code>false</code>.
+ *
+ * @param autoHide the auto hide state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ * @see #setVisible
+ */
+ public void setAutoHide( final boolean autoHide ) {
+ checkWidget();
+ this.autoHide = autoHide;
+ }
+
+ /**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public boolean isVisible() {
+ checkWidget();
+ return visible;
+ }
+
+ /**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setVisible( final boolean visible ) {
+ checkWidget();
+ this.visible = visible;
+ }
+
+ /**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public String getText() {
+ checkWidget();
+ return text;
+ }
+
+ /**
+ * Sets the receiver's text.
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setText( final String text ) {
+ checkWidget();
+ if( text == null ) {
+ error( SWT.ERROR_NULL_ARGUMENT );
+ }
+ this.text = text;
+ }
+
+ /**
+ * Returns the receiver's message, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's message
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public String getMessage() {
+ checkWidget();
+ return message;
+ }
+
+ /**
+ * Sets the receiver's message.
+ *
+ * @param string the new message
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setMessage( final String message ) {
+ checkWidget();
+ if( message == null ) {
+ error( SWT.ERROR_NULL_ARGUMENT );
+ }
+ this.message = message;
+ }
+
+ /**
+ * Sets the location of the receiver, which must be a tooltip,
+ * to the point specified by the arguments which are relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p>
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setLocation( final int x, final int y ) {
+ checkWidget();
+ this.x = x;
+ this.y = y;
+ }
+
+ /**
+ * Sets the location of the receiver, which must be a tooltip,
+ * to the point specified by the argument which is relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p><p>
+ * Note that the platform window manager ultimately has control
+ * over the location of tooltips.
+ * </p>
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setLocation( final Point location ) {
+ checkWidget();
+ if( location == null ) {
+ SWT.error( SWT.ERROR_NULL_ARGUMENT );
+ }
+ setLocation( location.x, location.y );
+ }
+
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the receiver is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the receiver is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+ public void addSelectionListener( final SelectionListener listener ) {
+ checkWidget();
+ SelectionEvent.addListener( this, listener );
+ }
+
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+ public void removeSelectionListener( final SelectionListener listener ) {
+ checkWidget();
+ SelectionEvent.removeListener( this, listener );
+ }
+
+ String getNameText() {
+ return text;
+ }
+
+ void releaseParent() {
+ super.releaseParent();
+ parent.destroyToolTip( this );
+ }
+
+ private static int checkStyle( final int style ) {
+ int result;
+ int mask = SWT.ICON_INFORMATION | SWT.ICON_WARNING | SWT.ICON_ERROR;
+ if( ( style & mask ) == 0 ) {
+ result = style;
+ } else {
+ result = checkBits( style,
+ SWT.ICON_INFORMATION,
+ SWT.ICON_WARNING,
+ SWT.ICON_ERROR,
+ 0,
+ 0,
+ 0 );
+ }
+ return result;
+ }
+}

Back to the top