Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 137634 Details for
Bug 275117
Link widget does not support SWT.WRAP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch
patch.txt (text/plain), 60.33 KB, created by
Asen Draganov
on 2009-05-29 08:56:34 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Asen Draganov
Created:
2009-05-29 08:56:34 EDT
Size:
60.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt.q07 >Index: src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA.java,v >retrieving revision 1.10 >diff -u -r1.10 LinkLCA.java >--- src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA.java 28 Apr 2009 12:14:22 -0000 1.10 >+++ src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA.java 29 May 2009 12:40:12 -0000 >@@ -18,43 +18,35 @@ > import org.eclipse.rwt.internal.lifecycle.JSConst; > import org.eclipse.rwt.internal.service.ContextProvider; > 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.ILinkAdapter; >+import org.eclipse.swt.internal.widgets.Props; > import org.eclipse.swt.widgets.*; > > /** > * Life-cycle adapter for the Link widget > */ > public class LinkLCA extends AbstractWidgetLCA { >+ >+ //Constants for JS functions names >+ private static final String JS_FUNC_ADDTEXT = "addText"; >+ private static final String JS_FUNC_ADDLINK = "addLink"; >+ private static final String JS_FUNC_APPLYTEXT = "applyText"; >+ private static final String JS_FUNC_CLEAR = "clear"; > >- private static final String QX_TYPE = "qx.ui.layout.HorizontalBoxLayout"; >- >-// private static final String TYPE_POOL_ID = LinkLCA.class.getName(); >- >- private static final String JS_LINK_UTIL = "org.eclipse.swt.LinkUtil"; >- private static final String JS_FUNC_INIT = JS_LINK_UTIL + ".init"; >- private static final String JS_FUNC_ADD_LINK = JS_LINK_UTIL + ".addLink"; >- private static final String JS_FUNC_ADD_TEXT = JS_LINK_UTIL + ".addText"; >- private static final String JS_FUNC_ADD_STATE = JS_LINK_UTIL + ".addState"; >- private static final String JS_FUNC_REMOVE_STATE >- = JS_LINK_UTIL + ".removeState"; >- private static final String JS_FUNC_CLEAR = JS_LINK_UTIL + ".clear"; >- private static final String JS_FUNC_DESTROY = JS_LINK_UTIL + ".destroy"; >- private static final String JS_FUNC_SET_SELECTION_LISTENER >- = JS_LINK_UTIL + ".setSelectionListener"; >- >+ //Property names for preserveValues > private static final String PROP_TEXT = "text"; >- private static final String PROP_VARIANT = "variant"; >- static final String PROP_SEL_LISTENER = "selectionListener"; > > public void preserveValues( final Widget widget ) { > Link link = ( Link )widget; > ControlLCAUtil.preserveValues( link ); > IWidgetAdapter adapter = WidgetUtil.getAdapter( widget ); > adapter.preserve( PROP_TEXT, link.getText() ); >- Boolean newValue = Boolean.valueOf( SelectionEvent.hasListener( link ) ); >- adapter.preserve( PROP_SEL_LISTENER, newValue ); >+ boolean hasListeners = SelectionEvent.hasListener( link ); >+ adapter.preserve( Props.SELECTION_LISTENERS, >+ Boolean.valueOf( hasListeners ) ); > WidgetLCAUtil.preserveCustomVariant( link ); > } > >@@ -68,10 +60,7 @@ > public void renderInitialization( final Widget widget ) throws IOException { > Link link = ( Link )widget; > JSWriter writer = JSWriter.getWriterFor( link ); >- writer.newWidget( QX_TYPE ); >- writer.set( JSConst.QX_FIELD_APPEARANCE, "link" ); >- Object[] args = new Object[] { widget }; >- writer.callStatic( JS_FUNC_INIT, args ); >+ writer.newWidget( "org.eclipse.swt.widgets.Link" ); > ControlLCAUtil.writeStyleFlags( link ); > } > >@@ -80,13 +69,11 @@ > ControlLCAUtil.writeChanges( link ); > writeSelectionListener( link ); > writeText( link ); >- writeCustomVariant( link ); >+ WidgetLCAUtil.writeCustomVariant( link ); > } > > public void renderDispose( final Widget widget ) throws IOException { > JSWriter writer = JSWriter.getWriterFor( widget ); >- Object[] args = new Object[]{ widget }; >- writer.callStatic( JS_FUNC_DESTROY, args ); > writer.dispose(); > } > >@@ -94,9 +81,6 @@ > throws IOException > { > ControlLCAUtil.resetStyleFlags(); >- JSWriter writer = JSWriter.getWriterForResetHandler(); >- Object[] args = new Object[]{ JSWriter.WIDGET_REF }; >- writer.callStatic( JS_FUNC_CLEAR, args ); > } > > public String getTypePoolId( final Widget widget ) { >@@ -108,13 +92,12 @@ > private static void writeSelectionListener( final Link link ) > throws IOException > { >- Boolean newValue = Boolean.valueOf( SelectionEvent.hasListener( link ) ); >- Boolean defValue = Boolean.FALSE; >- String prop = PROP_SEL_LISTENER; >- if( WidgetLCAUtil.hasChanged( link, prop, newValue, defValue ) ) { >+ boolean hasListener = SelectionEvent.hasListener( link ); >+ Boolean newValue = Boolean.valueOf( hasListener ); >+ String prop = Props.SELECTION_LISTENERS; >+ if( WidgetLCAUtil.hasChanged( link, prop, newValue, Boolean.FALSE ) ) { > JSWriter writer = JSWriter.getWriterFor( link ); >- Object[] args = new Object[]{ link, newValue }; >- writer.callStatic( JS_FUNC_SET_SELECTION_LISTENER, args ); >+ writer.set( "hasSelectionListener", newValue ); > } > } > >@@ -122,8 +105,7 @@ > String newValue = link.getText(); > if( WidgetLCAUtil.hasChanged( link, PROP_TEXT, newValue, "" ) ) { > JSWriter writer = JSWriter.getWriterFor( link ); >- Object[] args = new Object[]{ link }; >- writer.callStatic( JS_FUNC_CLEAR, args ); >+ writer.call( JS_FUNC_CLEAR, null ); > ILinkAdapter adapter > = ( ILinkAdapter )link.getAdapter( ILinkAdapter.class ); > String displayText = adapter.getDisplayText(); >@@ -147,6 +129,7 @@ > if( pos < length ) { > writeNormalText( link, displayText.substring( pos, length ) ); > } >+ writeApplyText( link ); > } > } > >@@ -155,12 +138,11 @@ > { > JSWriter writer = JSWriter.getWriterFor( link ); > Object[] args = new Object[] { >- link, > // TODO [rst] mnemonics are already parsed by Link#parse() > // Revise when we're going to support underline once > WidgetLCAUtil.escapeText( text, false ) > }; >- writer.callStatic( JS_FUNC_ADD_TEXT, args ); >+ writer.call( JS_FUNC_ADDTEXT, args ); > } > > private static void writeLinkText( final Link link, >@@ -170,13 +152,17 @@ > { > JSWriter writer = JSWriter.getWriterFor( link ); > Object[] args = new Object[] { >- link, > // TODO [rst] mnemonics are already parsed by Link#parse() > // Revise when we're going to support underline once > WidgetLCAUtil.escapeText( text, false ), > new Integer( index ) > }; >- writer.callStatic( JS_FUNC_ADD_LINK, args ); >+ writer.call( JS_FUNC_ADDLINK, args ); >+ } >+ >+ private static void writeApplyText( final Link link ) throws IOException { >+ JSWriter writer = JSWriter.getWriterFor( link ); >+ writer.call( JS_FUNC_APPLYTEXT, null ); > } > > private static void processSelectionEvent( final Link link ) { >@@ -197,23 +183,4 @@ > } > } > } >- >- private static void writeCustomVariant( final Link link ) >- throws IOException >- { >- IWidgetAdapter adapter = WidgetUtil.getAdapter( link ); >- String oldValue = ( String )adapter.getPreserved( PROP_VARIANT ); >- String newValue = WidgetUtil.getVariant( link ); >- if( WidgetLCAUtil.hasChanged( link, PROP_VARIANT, newValue, null ) ) { >- JSWriter writer = JSWriter.getWriterFor( link ); >- Object[] args = new Object[] { link, "variant_" + oldValue }; >- if( oldValue != null ) { >- writer.callStatic( JS_FUNC_REMOVE_STATE, args ); >- } >- if( newValue != null ) { >- args = new Object[] { link, "variant_" + newValue }; >- writer.callStatic( JS_FUNC_ADD_STATE, args ); >- } >- } >- } > } >Index: src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java,v >retrieving revision 1.14 >diff -u -r1.14 QooxdooResourcesUtil.java >--- src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java 28 Apr 2009 20:10:54 -0000 1.14 >+++ src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java 29 May 2009 12:40:12 -0000 >@@ -58,8 +58,6 @@ > = "org/eclipse/swt/ToolItemUtil.js"; > private static final String MENU_UTIL_JS > = "org/eclipse/swt/MenuUtil.js"; >- private static final String LINK_UTIL_JS >- = "org/eclipse/swt/LinkUtil.js"; > private static final String WIDGET_UTIL_JS > = "org/eclipse/swt/WidgetUtil.js"; > private static final String CTAB_FOLDER_JS >@@ -140,6 +138,8 @@ > = "org/eclipse/swt/widgets/CheckBox.js"; > private static final String RADIOBUTTON_JS > = "org/eclipse/swt/widgets/RadioButton.js"; >+ private static final String LINK_JS >+ = "org/eclipse/swt/widgets/Link.js"; > > private QooxdooResourcesUtil() { > // prevent intance creation >@@ -205,7 +205,6 @@ > register( TABLE_COLUMN_JS, compress ); > register( TABLE_ITEM_JS, compress ); > register( TABLE_ROW_JS, compress ); >- register( LINK_UTIL_JS, compress ); > register( EXTERNALBROWSER_JS, compress ); > register( BROWSER_JS, compress ); > register( PROGRESS_BAR_JS, compress ); >@@ -221,6 +220,7 @@ > register( SLIDER_JS, compress ); > register( CHECKBOX_JS, compress ); > register( RADIOBUTTON_JS, compress ); >+ register( LINK_JS, compress ); > > // register contributions > registerContributions(); >Index: js/org/eclipse/swt/LinkUtil.js >=================================================================== >RCS file: js/org/eclipse/swt/LinkUtil.js >diff -N js/org/eclipse/swt/LinkUtil.js >--- js/org/eclipse/swt/LinkUtil.js 28 Apr 2009 12:14:22 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,160 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2002, 2009 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 >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Innoopract Informationssysteme GmbH - initial API and implementation >- ******************************************************************************/ >- >-/** >- * This class contains static functions needed for the SWT Link widget. >- */ >-qx.Class.define( "org.eclipse.swt.LinkUtil", { >- >- statics : { >- init : function( widget ) { >- widget.setTabIndex( -1 ); >- widget.setUserData( "nextTabIndex", 0 ); >- widget.addEventListener( "changeTabIndex", >- org.eclipse.swt.LinkUtil._onTabIndexChange ); >- }, >- >- destroy : function( widget ) { >- org.eclipse.swt.LinkUtil.clear( widget ); >- if( widget.hasEventListeners( "changeTabIndex" ) ) { >- widget.removeEventListener( "changeTabIndex", >- org.eclipse.swt.LinkUtil._onTabIndexChange ); >- } >- }, >- >- clear : function( widget ) { >- if( widget && !widget.getDisposed() ) { >- var children = widget.getChildren(); >- var child = children[ 0 ]; >- while( child ) { >- widget.remove( child ); >- if( child.hasEventListeners( "mousedown" ) ) { >- child.removeEventListener( "mousedown", >- org.eclipse.swt.LinkUtil._onMouseDown ); >- } >- if( child.hasEventListeners( "keydown" ) ) { >- child.removeEventListener( "keydown", >- org.eclipse.swt.LinkUtil._onKeyDown ); >- } >- child.dispose(); >- child = children[ 0 ]; >- } >- } >- }, >- >- addState : function( widget, state ) { >- if( widget ) { >- if( state.substr( 0, 8 ) == "variant_" ) { >- widget.addState( state ); >- var children = widget.getChildren(); >- for( var i = 0; i < children.length; i++ ) { >- children[ i ].addState( state ); >- } >- } >- } >- }, >- >- removeState : function( widget, state ) { >- if( widget ) { >- if( state.substr( 0, 8 ) == "variant_" ) { >- widget.removeState( state ); >- var children = widget.getChildren(); >- for( var i = 0; i < children.length; i++ ) { >- children[ i ].removeState( state ); >- } >- } >- } >- }, >- >- setSelectionListener : function( widget, value ) { >- widget.setUserData( "widgetSelectedListener", value ); >- }, >- >- addText : function( widget, text ) { >- if( widget ) { >- var newChild = org.eclipse.swt.LinkUtil._createLabel( widget, text ); >- newChild.setAppearance( "link-text" ); >- newChild.setWrap( false ); >- widget.add( newChild ); >- } >- }, >- >- addLink : function( widget, text, index ) { >- if( widget ) { >- uText = "<u>" + text + "</u>"; >- var newChild = org.eclipse.swt.LinkUtil._createLabel( widget, uText ); >- newChild.setUserData( "index", index ); >- newChild.setAppearance( "link-href" ); >- newChild.setWrap( false ); >- widget.add( newChild ); >- var tabIndex = widget.getUserData( "nextTabIndex" ); >- newChild.setTabIndex( tabIndex++ ); >- widget.setUserData( "nextTabIndex", tabIndex ); >- newChild.addEventListener( "mousedown", >- org.eclipse.swt.LinkUtil._onMouseDown, >- newChild ); >- newChild.addEventListener( "keydown", >- org.eclipse.swt.LinkUtil._onKeyDown, >- newChild ); >- } >- }, >- >- _createLabel : function( parent, text ) { >- // replace spaces with nbsp >- var replaced = text.replace( /\s/g, " " ); >- var label = new qx.ui.basic.Label( replaced, null, "html" ); >- return label; >- }, >- >- _onMouseDown : function( evt ) { >- var parent = this.getParent(); >- if( parent.getUserData( "widgetSelectedListener" ) ) { >- var req = org.eclipse.swt.Request.getInstance(); >- var wm = org.eclipse.swt.WidgetManager.getInstance(); >- var id = wm.findIdByWidget( parent ); >- var index = this.getUserData( "index" ); >- req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >- req.addEvent( "org.eclipse.swt.events.widgetSelected.index", index ); >- req.send(); >- } >- }, >- >- _onKeyDown : function( evt ) { >- var keyId = evt.getKeyIdentifier(); >- if ( keyId == "Enter" ) { >- var parent = this.getParent(); >- if( parent.getUserData( "widgetSelectedListener" ) ) { >- var req = org.eclipse.swt.Request.getInstance(); >- var wm = org.eclipse.swt.WidgetManager.getInstance(); >- var id = wm.findIdByWidget( parent ); >- var index = this.getUserData( "index" ); >- req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >- req.addEvent( "org.eclipse.swt.events.widgetSelected.index", index ); >- req.send(); >- } >- } >- }, >- >- _onTabIndexChange : function( evt ) { >- var tabIndex = evt.getValue(); >- if( tabIndex >= 0 ) { >- var target = evt.getCurrentTarget(); >- var children = target.getChildren(); >- for( var i = 0; i < children.length; i++ ) { >- child = children[ i ]; >- child.setTabIndex( tabIndex++ ); >- } >- target.setUserData( "nextTabIndex", tabIndex ); >- target.setTabIndex( -1 ); >- } >- } >- } >-}); >Index: js/org/eclipse/swt/theme/AppearancesBase.js >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/theme/AppearancesBase.js,v >retrieving revision 1.101 >diff -u -r1.101 AppearancesBase.js >--- js/org/eclipse/swt/theme/AppearancesBase.js 18 May 2009 09:42:20 -0000 1.101 >+++ js/org/eclipse/swt/theme/AppearancesBase.js 29 May 2009 12:40:12 -0000 >@@ -1590,6 +1590,7 @@ > var tv = new org.eclipse.swt.theme.ThemeValues( states ); > return { > cursor: "default", >+ padding : 2, > font : tv.getCssFont( "Link", "font" ), > border : tv.getCssBorder( "Link", "border" ), > textColor : tv.getCssColor( "*", "color" ) >@@ -1601,19 +1602,9 @@ > style : function( states ) { > var tv = new org.eclipse.swt.theme.ThemeValues( states ); > return { >- textColor : states.disabled ? "widget.graytext" : "undefined" >- } >- } >- }, >- >- "link-href" : { >- style : function( states ) { >- var tv = new org.eclipse.swt.theme.ThemeValues( states ); >- return { >- cursor : states.disabled ? "default" : "pointer", > textColor: states.disabled > ? "widget.graytext" >- : tv.getCssColor( "Link-Hyperlink", "color" ) >+ : "inherit" > } > } > }, >Index: js/org/eclipse/swt/widgets/Link.js >=================================================================== >RCS file: js/org/eclipse/swt/widgets/Link.js >diff -N js/org/eclipse/swt/widgets/Link.js >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ js/org/eclipse/swt/widgets/Link.js 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,326 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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 http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+ >+/** >+ * This class provides the client-side implementation for >+ * org.eclipse.swt.widgets.Link >+ */ >+qx.Class.define( "org.eclipse.swt.widgets.Link", { >+ extend : qx.ui.layout.CanvasLayout, >+ >+ construct : function() { >+ this.base( arguments ); >+ this.setAppearance( "link" ); >+ // Default values >+ this._text = ""; >+ this._hasSelectionListener = false; >+ this._hyperlinksHaveListeners = false; >+ this._linkColor; >+ // innerTab handling >+ this._currentLinkFocused = -1; >+ this._linksCount = 0; >+ // >+ this._link = new qx.ui.embed.HtmlEmbed(); >+ this._link.setAppearance( "link-text" ); >+ this.add( this._link ); >+ // >+ this.setHideFocus( true ); >+ // >+ this.__onMouseDown = qx.lang.Function.bindEvent( this._onMouseDown, this ); >+ this.__onKeyDown = qx.lang.Function.bindEvent( this._onKeyDown, this ); >+ // >+ this.addEventListener( "appear", this._onAppear, this ); >+ this.addEventListener( "changeEnabled", this._onChangeEnabled, this ); >+ this.addEventListener( "contextmenu", this._onContextMenu, this ); >+ // Event listener used for inner TabIndex change >+ this.addEventListener( "keypress", this._onKeyPress ); >+ this.addEventListener( "focusout", this._onFocusOut ); >+ // >+ this._link.addEventListener( "changeHtml", this._onChangeHtml, this ); >+ }, >+ >+ destruct : function() { >+ this._removeEventListeners(); >+ delete this.__onMouseDown; >+ delete this.__onKeyDown; >+ this.removeEventListener( "appear", this._onAppear, this ); >+ this.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this.removeEventListener( "changeEnabled", this._onChangeEnabled, this ); >+ this.removeEventListener( "keypress", this._onKeyPress ); >+ this.removeEventListener( "focusout", this._onFocusOut ); >+ this._link.removeEventListener( "changeHtml", this._onChangeHtml, this ); >+ this._link.dispose(); >+ }, >+ >+ members : { >+ _onContextMenu : function( evt ) { >+ var menu = this.getContextMenu(); >+ if( menu != null ) { >+ menu.setLocation( evt.getPageX(), evt.getPageY() ); >+ menu.setOpener( this ); >+ menu.show(); >+ evt.stopPropagation(); >+ } >+ }, >+ >+ _onAppear : function( evt ) { >+ this._link.setTabIndex( -1 ); >+ this._link.setHideFocus( true ); >+ this._applyHyperlinksStyleProperties(); >+ this._addEventListeners(); >+ }, >+ >+ _onChangeHtml : function( evt ) { >+ this._applyHyperlinksStyleProperties(); >+ this._addEventListeners(); >+ }, >+ >+ _applyTextColor : function( value, old ) { >+ this.base( arguments, value, old ); >+ var themeValues >+ = new org.eclipse.swt.theme.ThemeValues( this._getStates() ); >+ this._linkColor = themeValues.getCssColor( "Link-Hyperlink", "color" ); >+ themeValues.dispose(); >+ this._applyHyperlinksStyleProperties(); >+ }, >+ >+ _onChangeEnabled : function( evt ) { >+ this._applyHyperlinksStyleProperties(); >+ }, >+ >+ _getStates : function() { >+ if( !this.__states ) { >+ this.__states = {}; >+ } >+ return this.__states; >+ }, >+ >+ addState : function( state ) { >+ this.base( arguments, state ); >+ this._link.addState( state ); >+ }, >+ >+ removeState : function( state ) { >+ this.base( arguments, state ); >+ this._link.removeState( state ); >+ }, >+ >+ setHasSelectionListener : function( value ) { >+ this._hasSelectionListener = value; >+ }, >+ >+ addText : function( text ) { >+ this._text += text; >+ }, >+ >+ addLink : function( text, index ) { >+ this._text += "<span tabIndex=\"1\" "; >+ this._text += "style=\""; >+ this._text += "text-decoration:underline; "; >+ this._text += "\" "; >+ this._text += "id=\"" + index + "\""; >+ this._text += ">"; >+ this._text += text; >+ this._text += "</span>"; >+ this._linksCount++; >+ }, >+ >+ applyText : function() { >+ this._link.setHtml( this._text ); >+ if ( this._linksCount == 0 ) { >+ this.setTabIndex( -1 ); >+ } else { >+ this.setTabIndex( 1 ); >+ } >+ }, >+ >+ clear : function() { >+ this._removeEventListeners(); >+ this._text = ""; >+ this._linksCount = 0; >+ }, >+ >+ _applyHyperlinksStyleProperties : function() { >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ for( i = 0; i < hyperlinks.length; i++ ) { >+ if( this._linkColor ) { >+ if( this.isEnabled() ) { >+ hyperlinks[ i ].style.color = this._linkColor; >+ } else { >+ hyperlinks[ i ].style.color = ""; >+ } >+ } >+ if( this.isEnabled() ) { >+ hyperlinks[ i ].style.cursor = "pointer"; >+ } else { >+ hyperlinks[ i ].style.cursor = "default"; >+ } >+ } >+ } >+ }, >+ >+ _addEventListeners : function() { >+ var linkElement = this.getElement(); >+ if( linkElement && !this._hyperlinksHaveListeners ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ for( i = 0; i < hyperlinks.length; i++ ) { >+ qx.html.EventRegistration.addEventListener( hyperlinks[ i ], >+ "mousedown", >+ this.__onMouseDown ); >+ qx.html.EventRegistration.addEventListener( hyperlinks[ i ], >+ "keydown", >+ this.__onKeyDown ); >+ } >+ this._hyperlinksHaveListeners = true; >+ } >+ }, >+ >+ _removeEventListeners : function() { >+ var linkElement = this.getElement(); >+ if( linkElement && this._hyperlinksHaveListeners ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ for( i = 0; i < hyperlinks.length; i++ ) { >+ qx.html.EventRegistration.removeEventListener( hyperlinks[ i ], >+ "mousedown", >+ this.__onMouseDown ); >+ qx.html.EventRegistration.removeEventListener( hyperlinks[ i ], >+ "keydown", >+ this.__onKeyDown ); >+ } >+ this._hyperlinksHaveListeners = false; >+ } >+ }, >+ >+ _onMouseDown : function( e ) { >+ var target = this._getEventTarget( e ); >+ var index = target.id; >+ this._currentLinkFocused = index; >+ target.focus(); >+ var leftBtnPressed = this._isLeftMouseButtonPressed( e ); >+ if( this.isEnabled() && leftBtnPressed ) { >+ this._sendChanges( index ); >+ } >+ }, >+ >+ _isLeftMouseButtonPressed : function( e ) { >+ var leftBtnPressed; >+ if( e.which ) { >+ leftBtnPressed = ( e.which == 1 ); >+ } else if ( e.button ) { >+ if( qx.core.Variant.isSet( "qx.client", "mshtml" ) ) { >+ leftBtnPressed = ( e.button == 1 ); >+ } else { >+ leftBtnPressed = ( e.button == 0 ); >+ } >+ } >+ return leftBtnPressed; >+ }, >+ >+ _onKeyDown : function( e ) { >+ if( this.isEnabled() && e.keyCode == 13 ) { >+ var target = this._getEventTarget( e ); >+ var index = target.id; >+ this._sendChanges( index ); >+ } >+ }, >+ >+ _getEventTarget : function( e ) { >+ var target; >+ if( qx.core.Variant.isSet( "qx.client", "mshtml" ) ) { >+ target = window.event.srcElement; >+ } else { >+ target = e.target; >+ } >+ return target; >+ }, >+ >+ // Override of the _ontabfocus method from qx.ui.core.Widget >+ _ontabfocus : function() { >+ if( this._currentLinkFocused == -1 && this._linksCount > 0 ) { >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ hyperlinks[ 0 ].focus(); >+ this._currentLinkFocused = 0; >+ } >+ } >+ }, >+ >+ _onKeyPress : function( evt ) { >+ if( this.isFocused() >+ && evt.getKeyIdentifier() == "Tab" >+ && this._linksCount > 0 ) >+ { >+ if( !evt.isShiftPressed() >+ && this._currentLinkFocused >= 0 >+ && this._currentLinkFocused < ( this._linksCount - 1 ) ) >+ { >+ evt.stopPropagation(); >+ evt.preventDefault(); >+ this._currentLinkFocused++; >+ this._focusLinkByID( this._currentLinkFocused ); >+ } else if( !evt.isShiftPressed() >+ && this._currentLinkFocused == -1 ) >+ { >+ evt.stopPropagation(); >+ evt.preventDefault(); >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ hyperlinks[ 0 ].focus(); >+ this._currentLinkFocused = 0; >+ } >+ } else if( evt.isShiftPressed() >+ && this._currentLinkFocused > 0 >+ && this._currentLinkFocused <= ( this._linksCount - 1 ) ) >+ { >+ evt.stopPropagation(); >+ evt.preventDefault(); >+ this._currentLinkFocused--; >+ this._focusLinkByID( this._currentLinkFocused ); >+ } >+ } >+ }, >+ >+ _focusLinkByID : function( id ) { >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ hyperlinks[ id ].focus(); >+ } >+ }, >+ >+ _onFocusOut : function( evt ) { >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ if( this._currentLinkFocused >= 0 ) { >+ hyperlinks[ this._currentLinkFocused ].blur(); >+ } >+ } >+ this._currentLinkFocused = -1; >+ }, >+ >+ _sendChanges : function( index ) { >+ if( !org_eclipse_rap_rwt_EventUtil_suspend ) { >+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance(); >+ var id = widgetManager.findIdByWidget( this ); >+ var req = org.eclipse.swt.Request.getInstance(); >+ if( this._hasSelectionListener ) { >+ req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >+ req.addEvent( "org.eclipse.swt.events.widgetSelected.index", index ); >+ req.send(); >+ } >+ } >+ } >+ } >+} ); >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/swt/widgets/Link_Test.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Link_Test.java,v >retrieving revision 1.5 >diff -u -r1.5 Link_Test.java >--- src/org/eclipse/swt/widgets/Link_Test.java 4 Sep 2008 16:14:13 -0000 1.5 >+++ src/org/eclipse/swt/widgets/Link_Test.java 29 May 2009 12:40:14 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2002, 2007 Innoopract Informationssysteme GmbH. >+ * Copyright (c) 2002, 2009 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 >@@ -62,28 +62,40 @@ > assertEquals( "www.eclipse.org", ids[ 0 ] ); > assertEquals( "SWT", ids[ 1 ] ); > } >- >+ > public void testComputeSize() throws Exception { > RWTFixture.fakePhase( PhaseId.PROCESS_ACTION ); > Display display = new Display(); > Shell shell = new Shell( display , SWT.NONE ); > Link link = new Link( shell, SWT.NONE ); >- Point expected = new Point( 0, 0 ); >+ Point expected = new Point( 4, 4 ); > assertEquals( expected, link.computeSize( SWT.DEFAULT, SWT.DEFAULT ) ); > > String text > = "Visit the <A HREF=\"www.eclipse.org\">Eclipse.org</A> project and " > + "the <a>SWT</a> homepage."; > link.setText( text ); >- expected = new Point( 269, 15 ); >+ expected = new Point( 273, 18 ); > assertEquals( expected, link.computeSize( SWT.DEFAULT, SWT.DEFAULT ) ); > > link = new Link( shell, SWT.BORDER ); >- expected = new Point( 2, 2 ); >+ expected = new Point( 8, 8 ); > assertEquals( expected, link.computeSize( SWT.DEFAULT, SWT.DEFAULT ) ); > >- expected = new Point( 102, 102 ); >+ expected = new Point( 108, 108 ); > assertEquals( expected, link.computeSize( 100, 100 ) ); >+ >+ text = "<a>test & test2</a>"; >+ link = new Link( shell, SWT.NONE ); >+ link.setText( text ); >+ expected = new Point( 62, 18 ); >+ assertEquals( expected, link.computeSize( SWT.DEFAULT, SWT.DEFAULT ) ); >+ >+ text = "<a>test && test2</a>"; >+ link = new Link( shell, SWT.NONE ); >+ link.setText( text ); >+ expected = new Point( 73, 18 ); >+ assertEquals( expected, link.computeSize( SWT.DEFAULT, SWT.DEFAULT ) ); > } > > protected void setUp() throws Exception { >#P org.eclipse.rap.rwt.test.mockup >Index: js/org/eclipse/swt/LinkUtil.js >=================================================================== >RCS file: js/org/eclipse/swt/LinkUtil.js >diff -N js/org/eclipse/swt/LinkUtil.js >--- js/org/eclipse/swt/LinkUtil.js 11 Dec 2008 12:27:39 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,138 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2002, 2008 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 >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * Innoopract Informationssysteme GmbH - initial API and implementation >- ******************************************************************************/ >- >-/** >- * This class contains static functions needed for the SWT Link widget. >- */ >-qx.Class.define( "org.eclipse.swt.LinkUtil", { >- >- statics : { >- init : function( widget ) { >- widget.setTabIndex( -1 ); >- widget.setUserData( "nextTabIndex", 0 ); >- widget.addEventListener( "changeTabIndex", >- org.eclipse.swt.LinkUtil._onTabIndexChange ); >- }, >- >- destroy : function( widget ) { >- org.eclipse.swt.LinkUtil.clear( widget ); >- if( widget.hasEventListeners( "changeTabIndex" ) ) { >- widget.removeEventListener( "changeTabIndex", >- org.eclipse.swt.LinkUtil._onTabIndexChange ); >- } >- }, >- >- clear : function( widget ) { >- if( widget && !widget.getDisposed() ) { >- var children = widget.getChildren(); >- var child = children[ 0 ]; >- while( child ) { >- widget.remove( child ); >- if( child.hasEventListeners( "mousedown" ) ) { >- child.removeEventListener( "mousedown", >- org.eclipse.swt.LinkUtil._onMouseDown ); >- } >- if( child.hasEventListeners( "keydown" ) ) { >- child.removeEventListener( "keydown", >- org.eclipse.swt.LinkUtil._onKeyDown ); >- } >- // TODO [if] Replace child.dispose() with child.destroy() >- // when qx 0.7.4 is in place >- child.dispose(); >- child = children[ 0 ]; >- } >- } >- }, >- >- setSelectionListener : function( widget, value ) { >- widget.setUserData( "widgetSelectedListener", value ); >- }, >- >- addText : function( widget, text ) { >- if( widget ) { >- var newChild = org.eclipse.swt.LinkUtil._createLabel( widget, text ); >- newChild.setAppearance( "link-text" ); >- newChild.setWrap( false ); >- widget.add( newChild ); >- } >- }, >- >- addLink : function( widget, text, index ) { >- if( widget ) { >- uText = "<u>" + text + "</u>"; >- var newChild = org.eclipse.swt.LinkUtil._createLabel( widget, uText ); >- newChild.setUserData( "index", index ); >- newChild.setAppearance( "link-href" ); >- newChild.setWrap( false ); >- widget.add( newChild ); >- var tabIndex = widget.getUserData( "nextTabIndex" ); >- newChild.setTabIndex( tabIndex++ ); >- widget.setUserData( "nextTabIndex", tabIndex ); >- newChild.addEventListener( "mousedown", >- org.eclipse.swt.LinkUtil._onMouseDown, >- newChild ); >- newChild.addEventListener( "keydown", >- org.eclipse.swt.LinkUtil._onKeyDown, >- newChild ); >- } >- }, >- >- _createLabel : function( parent, text ) { >- // replace spaces with nbsp >- var replaced = text.replace( /\s/g, " " ); >- var label = new qx.ui.basic.Label( replaced, null, "html" ); >- return label; >- }, >- >- _onMouseDown : function( evt ) { >- var parent = this.getParent(); >- if( parent.getUserData( "widgetSelectedListener" ) ) { >- var req = org.eclipse.swt.Request.getInstance(); >- var wm = org.eclipse.swt.WidgetManager.getInstance(); >- var id = wm.findIdByWidget( parent ); >- var index = this.getUserData( "index" ); >- req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >- req.addEvent( "org.eclipse.swt.events.widgetSelected.index", index ); >- req.send(); >- } >- }, >- >- _onKeyDown : function( evt ) { >- var keyId = evt.getKeyIdentifier(); >- if ( keyId == "Enter" ) { >- var parent = this.getParent(); >- if( parent.getUserData( "widgetSelectedListener" ) ) { >- var req = org.eclipse.swt.Request.getInstance(); >- var wm = org.eclipse.swt.WidgetManager.getInstance(); >- var id = wm.findIdByWidget( parent ); >- var index = this.getUserData( "index" ); >- req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >- req.addEvent( "org.eclipse.swt.events.widgetSelected.index", index ); >- req.send(); >- } >- } >- }, >- >- _onTabIndexChange : function( evt ) { >- var tabIndex = evt.getValue(); >- if( tabIndex >= 0 ) { >- var target = evt.getCurrentTarget(); >- var children = target.getChildren(); >- for( var i = 0; i < children.length; i++ ) { >- child = children[ i ]; >- child.setTabIndex( tabIndex++ ); >- } >- target.setUserData( "nextTabIndex", tabIndex ); >- target.setTabIndex( -1 ); >- } >- } >- } >-}); >Index: js/org/eclipse/swt/widgets/Link.js >=================================================================== >RCS file: js/org/eclipse/swt/widgets/Link.js >diff -N js/org/eclipse/swt/widgets/Link.js >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ js/org/eclipse/swt/widgets/Link.js 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,326 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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 http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+ >+/** >+ * This class provides the client-side implementation for >+ * org.eclipse.swt.widgets.Link >+ */ >+qx.Class.define( "org.eclipse.swt.widgets.Link", { >+ extend : qx.ui.layout.CanvasLayout, >+ >+ construct : function() { >+ this.base( arguments ); >+ this.setAppearance( "link" ); >+ // Default values >+ this._text = ""; >+ this._hasSelectionListener = false; >+ this._hyperlinksHaveListeners = false; >+ this._linkColor; >+ // innerTab handling >+ this._currentLinkFocused = -1; >+ this._linksCount = 0; >+ // >+ this._link = new qx.ui.embed.HtmlEmbed(); >+ this._link.setAppearance( "link-text" ); >+ this.add( this._link ); >+ // >+ this.setHideFocus( true ); >+ // >+ this.__onMouseDown = qx.lang.Function.bindEvent( this._onMouseDown, this ); >+ this.__onKeyDown = qx.lang.Function.bindEvent( this._onKeyDown, this ); >+ // >+ this.addEventListener( "appear", this._onAppear, this ); >+ this.addEventListener( "changeEnabled", this._onChangeEnabled, this ); >+ this.addEventListener( "contextmenu", this._onContextMenu, this ); >+ // Event listener used for inner TabIndex change >+ this.addEventListener( "keypress", this._onKeyPress ); >+ this.addEventListener( "focusout", this._onFocusOut ); >+ // >+ this._link.addEventListener( "changeHtml", this._onChangeHtml, this ); >+ }, >+ >+ destruct : function() { >+ this._removeEventListeners(); >+ delete this.__onMouseDown; >+ delete this.__onKeyDown; >+ this.removeEventListener( "appear", this._onAppear, this ); >+ this.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this.removeEventListener( "changeEnabled", this._onChangeEnabled, this ); >+ this.removeEventListener( "keypress", this._onKeyPress ); >+ this.removeEventListener( "focusout", this._onFocusOut ); >+ this._link.removeEventListener( "changeHtml", this._onChangeHtml, this ); >+ this._link.dispose(); >+ }, >+ >+ members : { >+ _onContextMenu : function( evt ) { >+ var menu = this.getContextMenu(); >+ if( menu != null ) { >+ menu.setLocation( evt.getPageX(), evt.getPageY() ); >+ menu.setOpener( this ); >+ menu.show(); >+ evt.stopPropagation(); >+ } >+ }, >+ >+ _onAppear : function( evt ) { >+ this._link.setTabIndex( -1 ); >+ this._link.setHideFocus( true ); >+ this._applyHyperlinksStyleProperties(); >+ this._addEventListeners(); >+ }, >+ >+ _onChangeHtml : function( evt ) { >+ this._applyHyperlinksStyleProperties(); >+ this._addEventListeners(); >+ }, >+ >+ _applyTextColor : function( value, old ) { >+ this.base( arguments, value, old ); >+ var themeValues >+ = new org.eclipse.swt.theme.ThemeValues( this._getStates() ); >+ this._linkColor = themeValues.getCssColor( "Link-Hyperlink", "color" ); >+ themeValues.dispose(); >+ this._applyHyperlinksStyleProperties(); >+ }, >+ >+ _onChangeEnabled : function( evt ) { >+ this._applyHyperlinksStyleProperties(); >+ }, >+ >+ _getStates : function() { >+ if( !this.__states ) { >+ this.__states = {}; >+ } >+ return this.__states; >+ }, >+ >+ addState : function( state ) { >+ this.base( arguments, state ); >+ this._link.addState( state ); >+ }, >+ >+ removeState : function( state ) { >+ this.base( arguments, state ); >+ this._link.removeState( state ); >+ }, >+ >+ setHasSelectionListener : function( value ) { >+ this._hasSelectionListener = value; >+ }, >+ >+ addText : function( text ) { >+ this._text += text; >+ }, >+ >+ addLink : function( text, index ) { >+ this._text += "<span tabIndex=\"1\" "; >+ this._text += "style=\""; >+ this._text += "text-decoration:underline; "; >+ this._text += "\" "; >+ this._text += "id=\"" + index + "\""; >+ this._text += ">"; >+ this._text += text; >+ this._text += "</span>"; >+ this._linksCount++; >+ }, >+ >+ applyText : function() { >+ this._link.setHtml( this._text ); >+ if ( this._linksCount == 0 ) { >+ this.setTabIndex( -1 ); >+ } else { >+ this.setTabIndex( 1 ); >+ } >+ }, >+ >+ clear : function() { >+ this._removeEventListeners(); >+ this._text = ""; >+ this._linksCount = 0; >+ }, >+ >+ _applyHyperlinksStyleProperties : function() { >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ for( i = 0; i < hyperlinks.length; i++ ) { >+ if( this._linkColor ) { >+ if( this.isEnabled() ) { >+ hyperlinks[ i ].style.color = this._linkColor; >+ } else { >+ hyperlinks[ i ].style.color = ""; >+ } >+ } >+ if( this.isEnabled() ) { >+ hyperlinks[ i ].style.cursor = "pointer"; >+ } else { >+ hyperlinks[ i ].style.cursor = "default"; >+ } >+ } >+ } >+ }, >+ >+ _addEventListeners : function() { >+ var linkElement = this.getElement(); >+ if( linkElement && !this._hyperlinksHaveListeners ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ for( i = 0; i < hyperlinks.length; i++ ) { >+ qx.html.EventRegistration.addEventListener( hyperlinks[ i ], >+ "mousedown", >+ this.__onMouseDown ); >+ qx.html.EventRegistration.addEventListener( hyperlinks[ i ], >+ "keydown", >+ this.__onKeyDown ); >+ } >+ this._hyperlinksHaveListeners = true; >+ } >+ }, >+ >+ _removeEventListeners : function() { >+ var linkElement = this.getElement(); >+ if( linkElement && this._hyperlinksHaveListeners ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ for( i = 0; i < hyperlinks.length; i++ ) { >+ qx.html.EventRegistration.removeEventListener( hyperlinks[ i ], >+ "mousedown", >+ this.__onMouseDown ); >+ qx.html.EventRegistration.removeEventListener( hyperlinks[ i ], >+ "keydown", >+ this.__onKeyDown ); >+ } >+ this._hyperlinksHaveListeners = false; >+ } >+ }, >+ >+ _onMouseDown : function( e ) { >+ var target = this._getEventTarget( e ); >+ var index = target.id; >+ this._currentLinkFocused = index; >+ target.focus(); >+ var leftBtnPressed = this._isLeftMouseButtonPressed( e ); >+ if( this.isEnabled() && leftBtnPressed ) { >+ this._sendChanges( index ); >+ } >+ }, >+ >+ _isLeftMouseButtonPressed : function( e ) { >+ var leftBtnPressed; >+ if( e.which ) { >+ leftBtnPressed = ( e.which == 1 ); >+ } else if ( e.button ) { >+ if( qx.core.Variant.isSet( "qx.client", "mshtml" ) ) { >+ leftBtnPressed = ( e.button == 1 ); >+ } else { >+ leftBtnPressed = ( e.button == 0 ); >+ } >+ } >+ return leftBtnPressed; >+ }, >+ >+ _onKeyDown : function( e ) { >+ if( this.isEnabled() && e.keyCode == 13 ) { >+ var target = this._getEventTarget( e ); >+ var index = target.id; >+ this._sendChanges( index ); >+ } >+ }, >+ >+ _getEventTarget : function( e ) { >+ var target; >+ if( qx.core.Variant.isSet( "qx.client", "mshtml" ) ) { >+ target = window.event.srcElement; >+ } else { >+ target = e.target; >+ } >+ return target; >+ }, >+ >+ // Override of the _ontabfocus method from qx.ui.core.Widget >+ _ontabfocus : function() { >+ if( this._currentLinkFocused == -1 && this._linksCount > 0 ) { >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ hyperlinks[ 0 ].focus(); >+ this._currentLinkFocused = 0; >+ } >+ } >+ }, >+ >+ _onKeyPress : function( evt ) { >+ if( this.isFocused() >+ && evt.getKeyIdentifier() == "Tab" >+ && this._linksCount > 0 ) >+ { >+ if( !evt.isShiftPressed() >+ && this._currentLinkFocused >= 0 >+ && this._currentLinkFocused < ( this._linksCount - 1 ) ) >+ { >+ evt.stopPropagation(); >+ evt.preventDefault(); >+ this._currentLinkFocused++; >+ this._focusLinkByID( this._currentLinkFocused ); >+ } else if( !evt.isShiftPressed() >+ && this._currentLinkFocused == -1 ) >+ { >+ evt.stopPropagation(); >+ evt.preventDefault(); >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ hyperlinks[ 0 ].focus(); >+ this._currentLinkFocused = 0; >+ } >+ } else if( evt.isShiftPressed() >+ && this._currentLinkFocused > 0 >+ && this._currentLinkFocused <= ( this._linksCount - 1 ) ) >+ { >+ evt.stopPropagation(); >+ evt.preventDefault(); >+ this._currentLinkFocused--; >+ this._focusLinkByID( this._currentLinkFocused ); >+ } >+ } >+ }, >+ >+ _focusLinkByID : function( id ) { >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ hyperlinks[ id ].focus(); >+ } >+ }, >+ >+ _onFocusOut : function( evt ) { >+ var linkElement = this.getElement(); >+ if( linkElement ) { >+ var hyperlinks = linkElement.getElementsByTagName( "span" ); >+ if( this._currentLinkFocused >= 0 ) { >+ hyperlinks[ this._currentLinkFocused ].blur(); >+ } >+ } >+ this._currentLinkFocused = -1; >+ }, >+ >+ _sendChanges : function( index ) { >+ if( !org_eclipse_rap_rwt_EventUtil_suspend ) { >+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance(); >+ var id = widgetManager.findIdByWidget( this ); >+ var req = org.eclipse.swt.Request.getInstance(); >+ if( this._hasSelectionListener ) { >+ req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >+ req.addEvent( "org.eclipse.swt.events.widgetSelected.index", index ); >+ req.send(); >+ } >+ } >+ } >+ } >+} ); >#P org.eclipse.rap.rwt >Index: src/org/eclipse/swt/widgets/Link.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Link.java,v >retrieving revision 1.14 >diff -u -r1.14 Link.java >--- src/org/eclipse/swt/widgets/Link.java 20 Nov 2008 14:50:57 -0000 1.14 >+++ src/org/eclipse/swt/widgets/Link.java 29 May 2009 12:40:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH. >+ * Copyright (c) 2002, 2009 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 >@@ -35,6 +35,9 @@ > * @since 1.0 > */ > public class Link extends Control { >+ >+ //Must be kept in sync with appearance value in AppearancesBase.js >+ private final static int PADDING = 2; > > private String text = ""; > private String displayText = ""; >@@ -180,16 +183,23 @@ > SelectionEvent.removeListener( this, listener ); > } > >- public Point computeSize( final int wHint, final int hHint, final boolean changed ) { >+ public Point computeSize( final int wHint, >+ final int hHint, >+ final boolean changed ) { > checkWidget(); > int width = 0; > int height = 0; > int border = getBorderWidth(); > if( ( displayText.length() > 0 ) ) { >- // TODO [rst] change to textExtent when wrap supported >- Point extent = TextSizeDetermination.stringExtent( getFont(), displayText ); >+ // Replace '&' with '&&' to ensure proper size calculation with one '&', >+ // because the other will be escaped in >+ // TextSizeDetermination#createMeasureString() >+ String string = escapeAmpersand( displayText ); >+ Point extent = TextSizeDetermination.textExtent( getFont(), >+ string, >+ wHint ); > width = extent.x; >- height = extent.y + 2; >+ height = extent.y; > } > if( wHint != SWT.DEFAULT ) { > width = wHint; >@@ -197,14 +207,22 @@ > if( hHint != SWT.DEFAULT ) { > height = hHint; > } >- width += border * 2; >- height += border * 2; >+ width += border * 2 + PADDING * 2; >+ height += border * 2 + PADDING * 2; > return new Point( width, height ); > } >- >- public int getBorderWidth() { >- // TODO: [rst] why overriding control#getBorderWidth >- return ( ( style & SWT.BORDER ) != 0 ) ? 1 : 0; >+ >+ private static String escapeAmpersand( final String string ) { >+ int index = 0; >+ StringBuffer result = new StringBuffer(); >+ for( int i = 0; i < string.length(); i++ ) { >+ if( string.charAt( i ) == '&' ) { >+ result.append( "&&" ); >+ } else { >+ result.append( string.charAt( i ) ); >+ } >+ } >+ return result.toString(); > } > > public Object getAdapter( final Class adapter ) { >@@ -229,7 +247,7 @@ > } > return result; > } >- >+ > boolean isTabGroup() { > return true; > } >Index: src/org/eclipse/swt/internal/widgets/linkkit/Link.theme.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/linkkit/Link.theme.xml,v >retrieving revision 1.11 >diff -u -r1.11 Link.theme.xml >--- src/org/eclipse/swt/internal/widgets/linkkit/Link.theme.xml 19 Jan 2009 21:28:59 -0000 1.11 >+++ src/org/eclipse/swt/internal/widgets/linkkit/Link.theme.xml 29 May 2009 12:40:16 -0000 >@@ -32,6 +32,9 @@ > <property name="color" > type="color" > description="Text color for hyperlinks in Link widget." /> >+ >+ <state name="disabled" >+ description="Applies to hyperlinks of a disabled Link widget." /> > > </element> > >#P org.eclipse.rap.demo >Index: src/org/eclipse/rap/demo/controls/LinkTab.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/LinkTab.java,v >retrieving revision 1.5 >diff -u -r1.5 LinkTab.java >--- src/org/eclipse/rap/demo/controls/LinkTab.java 12 Jun 2008 14:00:45 -0000 1.5 >+++ src/org/eclipse/rap/demo/controls/LinkTab.java 29 May 2009 12:40:22 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2008 Innoopract Informationssysteme GmbH. >+ * Copyright (c) 2007, 2009 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,14 +14,18 @@ > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.CTabFolder; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.*; > import org.eclipse.swt.widgets.*; > > public class LinkTab extends ExampleTab { >+ >+ private static final String PROP_CONTEXT_MENU = "contextMenu"; > >+ private Link link1; > private Link customLink; >+ private Link fixedSizeLink; > > public LinkTab( final CTabFolder topFolder ) { > super( topFolder, "Link" ); >@@ -36,17 +40,42 @@ > createBgImageButton(); > createFontChooser(); > createCustomLinkControl( parent ); >+ createPropertyCheckbox( "Add Context Menu On First Link", >+ PROP_CONTEXT_MENU ); > } > > protected void createExampleControls( final Composite parent ) { > parent.setLayout( new GridLayout() ); > int style = getStyle(); >- Link link1 = new Link( parent, style ); >+ link1 = new Link( parent, style ); >+// link1.setText( "Lorem <a>ipsum</a> dolor sit amet" ); >+// link1.setEnabled( false ); >+// link1.setVisible( false ); > link1.setText( "Lorem <a>ipsum</a> dolor <a>sit amet</a>" ); >+ link1.addSelectionListener( new SelectionAdapter() { >+ public void widgetSelected( final SelectionEvent event ) { >+ String msg = "Link widget selected, text=" + event.text; >+ MessageDialog.openInformation( getShell(), "Information", msg ); >+ } >+ } ); >+ if( hasCreateProperty( PROP_CONTEXT_MENU ) ) { >+ Menu linkMenu = new Menu( link1 ); >+ MenuItem linkMenuItem = new MenuItem( linkMenu, SWT.PUSH ); >+ linkMenuItem.addSelectionListener( new SelectionAdapter() { >+ public void widgetSelected( final SelectionEvent event ) { >+ String message = "You requested a context menu for the Link"; >+ MessageDialog.openInformation( link1.getShell(), >+ "Information", >+ message ); >+ } >+ } ); >+ linkMenuItem.setText( "Link context menu item" ); >+ link1.setMenu( linkMenu ); >+ } > Link link2 = new Link( parent, style ); > link2.setText( "Link without href" ); > Link link3 = new Link( parent, style ); >- link3.setText( "<a>Link with one href</a>" ); >+ link3.setText( "<a>Link with one href \"&&<>\\\"</a>" ); > customLink = new Link( parent, style ); > customLink.setText( "Custom link, use controls to your right to change" ); > customLink.addSelectionListener( new SelectionAdapter() { >@@ -55,10 +84,14 @@ > MessageDialog.openInformation( getShell(), "Information", msg ); > } > } ); >+ fixedSizeLink = new Link( parent, style ); >+ fixedSizeLink.setText( "Fixed size Link with some very long text <a>that should be wrapped.</a>" ); >+ fixedSizeLink.setLayoutData( new GridData( 100, 100 ) ); > registerControl( link1 ); > registerControl( link2 ); > registerControl( link3 ); > registerControl( customLink ); >+ registerControl( fixedSizeLink ); > } > > private void createCustomLinkControl( final Composite parent ) { >Index: src/org/eclipse/rap/demo/controls/VariantsTab.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/VariantsTab.java,v >retrieving revision 1.4 >diff -u -r1.4 VariantsTab.java >--- src/org/eclipse/rap/demo/controls/VariantsTab.java 19 Aug 2008 13:16:57 -0000 1.4 >+++ src/org/eclipse/rap/demo/controls/VariantsTab.java 29 May 2009 12:40:22 -0000 >@@ -40,6 +40,7 @@ > > private Button myButton; > private Label myLabel; >+ private Link myLink; > private Text myText; > private List myList; > private Tree myTree; >@@ -81,6 +82,13 @@ > myLabel.setText( "Customized Label" ); > myLabel.setData( WidgetUtil.CUSTOM_VARIANT, getVariant() ); > registerControl( myLabel ); >+ >+ // myLink >+ myLink = new Link( parent, style ); >+ myLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); >+ myLink.setText( "Customized <a>Link</a>" ); >+ myLink.setData( WidgetUtil.CUSTOM_VARIANT, getVariant() ); >+ registerControl( myLink ); > > // myText > myText = new Text( parent, style ); >@@ -149,6 +157,7 @@ > private void setCustomVariant( final String variant ) { > myButton.setData( WidgetUtil.CUSTOM_VARIANT, variant ); > myLabel.setData( WidgetUtil.CUSTOM_VARIANT, variant ); >+ myLink.setData( WidgetUtil.CUSTOM_VARIANT, variant ); > myText.setData( WidgetUtil.CUSTOM_VARIANT, variant ); > myList.setData( WidgetUtil.CUSTOM_VARIANT, variant ); > myTree.setData( WidgetUtil.CUSTOM_VARIANT, variant ); >Index: theme1/theme.css >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.demo/theme1/theme.css,v >retrieving revision 1.37 >diff -u -r1.37 theme.css >--- theme1/theme.css 13 May 2009 20:09:13 -0000 1.37 >+++ theme1/theme.css 29 May 2009 12:40:22 -0000 >@@ -416,6 +416,14 @@ > padding: 10px; > } > >+Link-Hyperlink.special-red { >+ color: #ffaaaa; >+} >+ >+Link-Hyperlink.special-blue { >+ color: #aaaaff; >+} >+ > Button[PUSH].special-red, Button[TOGGLE].special-red { > border: 2px solid red; > } >#P org.eclipse.rap.rwt.q07.test >Index: src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA_Test.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.q07.test/src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA_Test.java,v >retrieving revision 1.5 >diff -u -r1.5 LinkLCA_Test.java >--- src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA_Test.java 29 Oct 2008 10:33:18 -0000 1.5 >+++ src/org/eclipse/swt/internal/widgets/linkkit/LinkLCA_Test.java 29 May 2009 12:40:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2002, 2008 Innoopract Informationssysteme GmbH. >+ * Copyright (c) 2002, 2009 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 >@@ -33,12 +33,12 @@ > Display display = new Display(); > Composite shell = new Shell( display, SWT.NONE ); > Link link = new Link( shell, SWT.NONE ); >- Boolean hasListeners; > RWTFixture.markInitialized( display ); > RWTFixture.preserveWidgets(); > IWidgetAdapter adapter = WidgetUtil.getAdapter( link ); >- hasListeners = ( Boolean )adapter.getPreserved( LinkLCA.PROP_SEL_LISTENER ); > assertEquals( "", adapter.getPreserved( Props.TEXT ) ); >+ Boolean hasListeners >+ = ( Boolean )adapter.getPreserved( Props.SELECTION_LISTENERS ); > assertEquals( Boolean.FALSE, hasListeners ); > RWTFixture.clearPreserved(); > link.setText( "some text" ); >@@ -52,8 +52,9 @@ > } ); > RWTFixture.preserveWidgets(); > adapter = WidgetUtil.getAdapter( link ); >- hasListeners = ( Boolean )adapter.getPreserved( LinkLCA.PROP_SEL_LISTENER ); > assertEquals( "some text", adapter.getPreserved( Props.TEXT ) ); >+ hasListeners >+ = ( Boolean )adapter.getPreserved( Props.SELECTION_LISTENERS ); > assertEquals( Boolean.TRUE, hasListeners ); > RWTFixture.clearPreserved(); > //control: enabled >@@ -235,10 +236,10 @@ > LinkLCA lca = new LinkLCA(); > lca.renderChanges( link ); > String markup = Fixture.getAllMarkup(); >- assertContains( "LinkUtil.clear( w )", markup ); >- assertContains( "LinkUtil.addText( w, \"Big \" )", markup ); >- assertContains( "LinkUtil.addLink( w, \"<b>Bang</b>\", 0 )", >- markup ); >+ assertContains( "clear()", markup ); >+ assertContains( "addText( \"Big \" )", markup ); >+ assertContains( "addLink( \"<b>Bang</b>\", 0 )", markup ); >+ assertContains( "applyText()", markup ); > } > > public void testEscape() throws Exception {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 275117
:
134586
|
137634
|
137829
|
137830
|
138371