Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Styling of link inside a markup enabled label / table / tree(Is it possible to override default decoration pattern (to only display underline on hover))
Styling of link inside a markup enabled label / table / tree [message #1439453] Tue, 07 October 2014 07:14 Go to next message
Bruno Sinou is currently offline Bruno SinouFriend
Messages: 22
Registered: December 2010
Location: Berlin
Junior Member
Hello,

In a RAP 2.2 application, I would like to change the default colors and decoration behaviour of links defined by adding a <a> anchor in the displayed text.

Statically forcing color and decoration can be done adding a style to these anchor
 Label label = new Label(parent, SWT.WRAP);
label.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);
StringBuilder builder = new StringBuilder().append("My label with a ");
builder.append("<a  style='color:#ff0000; text-decoration:none;' ");
builder.append(" href=\"http://example.com\" target=\"_blank\" >");
builder.append("link</a>");
label.setText(builder.toString());


But I would rather like to override the a:link, a:visited, a:hover, a:active default CSS style. I don't want specific behaviour for a specific label or table, and it is OK if I can change the default for the whole application.

I also tried to override the various default styles. For instance, adding the below CSS extension and removing the above hard-coded style will change the whole text color of a given row on hover events, *except the content of the <a> markup*.
 Table-RowOverlay:hover {
	color:#00ff00;
}


So I'm kind of stuck and any hint would be greatly appreciated,

Best regards

Bruno
Re: Styling of link inside a markup enabled label / table / tree [message #1439527 is a reply to message #1439453] Tue, 07 October 2014 08:44 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
if you want to attach a global CSS style rules to your application add
WebClient.HEAD_HTML to your application entry point properties:
----
public class BarApplication implements ApplicationConfiguration {

public void configure( Application application ) {
Map<String, String> properties = new HashMap<String, String>();
properties.put( WebClient.HEAD_HTML, *<valid style html tag with
content>* );
application.addEntryPoint( "/foo", Bar.class, properties );
}
}
---
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Styling of link inside a markup enabled label / table / tree [message #1439683 is a reply to message #1439527] Tue, 07 October 2014 11:56 Go to previous messageGo to next message
Bruno Sinou is currently offline Bruno SinouFriend
Messages: 22
Registered: December 2010
Location: Berlin
Junior Member
Ivan,

Many thanks for your quick answer, it works like a charm.

Regards,

Bruno

PS: Just for the record, doing this works for me:
String propValue = "<style type='text/css'> a:link { color: #333333;  text-decoration:none;  } a:hover { text-decoration:underline; } </style>
properties.put( WebClient.HEAD_HTML, propValue);

Nota: order of the rules is important in CSS...
Re: Styling of link inside a markup enabled label / table / tree [message #1441354 is a reply to message #1439683] Thu, 09 October 2014 16:01 Go to previous messageGo to next message
Bruno Sinou is currently offline Bruno SinouFriend
Messages: 22
Registered: December 2010
Location: Berlin
Junior Member
Hello again,

I was wondering if a similar mechanism also exists for the RAP workbench. The WebClient.HEAD_HTML (org.eclipse.rap.rwt.webclient.additionalHeaders) seems to be stand alone application specific and I don't see how to add a property map when declaring the entry points in the plugin.xml.

The goal is here also to be able to customize the normal / hover behaviour of links in a markup enabled table / label / tree of the workbench.

Any hint would be greatly appreciated.

Regards

Bruno
Re: Styling of link inside a markup enabled label / table / tree [message #1441363 is a reply to message #1441354] Thu, 09 October 2014 16:13 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
you should use branding extension and add additionalHeaders there. In
this case you need additional (external) CSS file.
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Styling of link inside a markup enabled label / table / tree [message #1441971 is a reply to message #1441363] Fri, 10 October 2014 12:31 Go to previous messageGo to next message
Bruno Sinou is currently offline Bruno SinouFriend
Messages: 22
Registered: December 2010
Location: Berlin
Junior Member
Hello Ivan,

Once again, many thanks for your prompt answer.

I had to look a little bit around to fine tune this and doing so, I found something weird in the method:
org.eclipse.rap.ui.internal.branding.BrandingExtension.readAdditionalHeader()
Our current version is 2.2.0.20131121-1623
... line 91 and following
// loop through all additional headers
    IConfigurationElement[] additionalHeaders = element.getChildren( ELEM_ADITIONAL_HEADERS );
    if( additionalHeaders.length > 0 ) {
      IConfigurationElement additionalHeader = additionalHeaders[ 0 ];
      readAdditionalHeader( branding, additionalHeader );
    }

It seems like you only take the first element, while saying that you would loop for all additional headers.
Is it a bug or a volontary behaviour ?

Furthermore, in the <additionalHeaders> tag of the branding, only <link> and <meta> tags are accepted, why not "<style>" tag also ?

Anyway it works all fine for me, thanks again.

Bruno

PS: In case it is usefull for anyone, I develop a little bit the answer:
In plugin.xml of bundle com.example.ui, having resources icon & theme folder with correct files :
<extension point="org.eclipse.rap.ui.branding">
	<branding
		id="com.example.ui.defaultBranding"
		themeId="com.example.ui.defaultTheme"
		title="A Rap UI"
		favicon="icons/favicon.png">
		<additionalHeaders>
			<!-- no leading slash -->
    			<link
				href="theme/headerExt.css"
    			 	rel="stylesheet" />
		</additionalHeaders>
	</branding>
</extension>

<!-- the corresponding CSS extension file must be registered -->
<extension
	point="org.eclipse.equinox.http.registry.resources">
	<!-- a leading slash -->        
	<resource
        	alias="/theme/headerExt.css"
		base-name="theme/headerExt.css">
        </resource>
</extension>  
Re: Styling of link inside a markup enabled label / table / tree [message #1443775 is a reply to message #1441971] Mon, 13 October 2014 07:44 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
the "additionalHeader" element is only one (it is defined in
org.eclipse.rap.ui\schema\rap\branding.exsd). It could have many
link/meta child elements and we are processing all of them. Using
external CSS file is the "modern" and the easiest way to do the things.
Maintain a very long CSS string in extension text field is not practical.
HTH,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:How to use icon font in RAP widgets?
Next Topic:No access to ajax.googleapis.com
Goto Forum:
  


Current Time: Thu Mar 28 14:36:11 GMT 2024

Powered by FUDForum. Page generated in 0.02937 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top