Styling of link inside a markup enabled label / table / tree [message #1439453] |
Tue, 07 October 2014 07:14 |
|
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 #1439683 is a reply to message #1439527] |
Tue, 07 October 2014 11:56 |
|
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 |
|
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 #1441971 is a reply to message #1441363] |
Fri, 10 October 2014 12:31 |
|
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>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02937 seconds