| Summary: | Add support for links in table cells | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Ivan Motsch <ivan.motsch> | ||||||||||||||||
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> | ||||||||||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||||||||||
| Severity: | enhancement | ||||||||||||||||||
| Priority: | P3 | CC: | claudio.guglielmo, ivan, stephan.leichtvogt | ||||||||||||||||
| Version: | 1.5 | ||||||||||||||||||
| Target Milestone: | 2.1 M1 | ||||||||||||||||||
| Hardware: | All | ||||||||||||||||||
| OS: | All | ||||||||||||||||||
| Whiteboard: | |||||||||||||||||||
| Bug Depends on: | |||||||||||||||||||
| Bug Blocks: | 401305 | ||||||||||||||||||
| Attachments: |
|
||||||||||||||||||
|
Description
Ivan Motsch
Created attachment 196745 [details]
patch for org.eclipse.rap.rwt
Created attachment 196746 [details]
patch for org.eclipse.rap.rwt.q07
I think that you can achieve the same behavior with TableEditor - see SWT snippets: http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet149.java?view=co but use Link widget instead of ProgressBar. Does it fit your needs? (In reply to comment #3) > I think that you can achieve the same behavior with TableEditor - see SWT > snippets: > http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet149.java?view=co > but use Link widget instead of ProgressBar. Does it fit your needs? Thanks for the hint. I tried the Link field before. For pure swt it does what it can in swt, but for rwt (with focus to web20 and inline html) it lacks the following: - just one line of text, no multiline support - missing support for bold, italic and other markups - missing support for rich alignments (table etc.) I could create a composite inside the cell and add multiple lables, links etc to it (for my case i needed approx 8 labels, 4 link fields and 3 composites per cell). But when having a table with approx. 1000 such rows, this results in a javascript error on the web page (overflow). As mentioned above i understand that rwt is sitting between (strict) swt and web20/browser. If it would be possible in any way to add my patch to rwt i would be very grateful, since i see rwt as much more powerful than just "rendering swt". Swt disappointed so many developers with its strict reduced set of capabilities when coompared to swing or modern web technologies. But with rwt i see light at the end of the tunnel that swt (with rwt as web2.0 extension) can make the race with other major web20 tools. Lets go:) Yes... I see your point. I have some questions in mind about your patch, but Ralf already asked most of them in bug 346768 comment #8. I will change the severity of this bug to "enhancement" as well. I updated the patch from Ivan Motsch and set the priority to P2. Our products rely on this enhancement. The patch works for itself. It does not rely on solving bug 346768. I hope you could review this patch and commit it for the 1.5 release. Created attachment 205806 [details] Patch as stated in comment 6 Creator Ivan Motsch<ivan.motsch@bsiag.com> Thanks for the patch, Stephan. I have some comments: This issue requests hyperlinks that trigger an event, just like in the SWT Link widget. If we go this way, should we limit the feature to links, or should we allow to embed widgets into table cells? As an example, checkboxes in table cells are also a common case. What do you think? To keep things simple, I would like to have markup to contain only "real" links, not those that trigger events, at least in the first version. Resetting priority to default. Please leave the prioritization to the RAP committers. EclipseSource offers professional support in case you need certain fixes urgently. With the bug 346768 fixed, "real" links are now supported in table items. Created attachment 213960 [details] Patch for org.eclipse.rap.rwt I updated the patch. The idea is to write <span tabindex="1" class="link" style="text-decoration:underline;" href="http://local/...">Local link</span> into a table to get an link which calls the server with an HyperLinkEvent. Created attachment 215715 [details] Patch for org.eclipse.rap.rwt Since the list does now support markup too (https://bugs.eclipse.org/bugs/show_bug.cgi?id=377890) it would be great if links were possible not only for tables but also for lists. The new patch contains list support as well as some improvements (event synchronization, firing on mouse up instead of mouse down). It would be great if you consider these requirements if you plan to implement such a feature. Created attachment 217428 [details]
Patch for org.eclipse.rap.rwt
Works with current git-head. (just after tree->grid change)
Fixed in master with commit 08f32b9e8af31faa44edede2ae75428233e43346. If the target of the hyperlink is set to "_rwt", default hyperlink behavior will be suppressed and a selection event will be fired on the server-side with event.detail == RWT.HYPERLINK and event.text == <href or text if href is missing>. Snippet:
...
Table table = new Table( parent, SWT.NONE );
table.setData( RWT.MARKUP_ENABLED, Boolean.TRUE );
table.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent event ) {
if( event.detail == RWT.HYPERLINK ) {
System.out.println( "Hyperlink clicked: " + event.text ); // event text contains "http://www.eclipse.org"
}
}
});
TableItem item = new TableItem( table, SWT.NONE );
tem.setText( "<a href=\"http://www.eclipse.org\" target=\"_rwt\">Eclipse.org</a>" );
....
Note: Click on a hyperlink will not select the item. This behavior is similar to a click on the item checkbox. Hyperlinks with target different from "_rwt" will behave as "real" hyperlinks - open page in browser.
Thank you very much for implementing this! It works very well, also with the list. I think not to select the row if a hyperlink gets clicked was a good decision. But actually I have to select the row on a hyperlink click. To do so I use the event.item to select the row by my self, which works fine for the table. But it does not for the list because the event.item is always null. Is this done by purpose? Is there another possibility to get the selected list item? (In reply to comment #14) > Thank you very much for implementing this! It works very well, also with the > list. > > I think not to select the row if a hyperlink gets clicked was a good > decision. But actually I have to select the row on a hyperlink click. To do > so I use the event.item to select the row by my self, which works fine for > the table. But it does not for the list because the event.item is always > null. Is this done by purpose? Is there another possibility to get the > selected list item? There is no ListItem widget - SelectionEvent#item is a widget. (In reply to comment #15) > (In reply to comment #14) > > Thank you very much for implementing this! It works very well, also with the > > list. > > > > I think not to select the row if a hyperlink gets clicked was a good > > decision. But actually I have to select the row on a hyperlink click. To do > > so I use the event.item to select the row by my self, which works fine for > > the table. But it does not for the list because the event.item is always > > null. Is this done by purpose? Is there another possibility to get the > > selected list item? > > There is no ListItem widget - SelectionEvent#item is a widget. Ok, that's why. But how can I select the row which contains the hyperlink? Can I somehow get the position of the click? Event.x and y are always 2. One idea that comes to my mind is to encode the the list item data (index or item text) in the link href. As href is not a real link location you could put there whatever you want - id, index etc... (In reply to comment #17) > One idea that comes to my mind is to encode the the list item data (index or > item text) in the link href. As href is not a real link location you could > put there whatever you want - id, index etc... Thanks, that works. |