Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Custom Widget Ids for Widgets supplied by Extensions (Menu, Toolbar)(Custom Widget Ids for Widgets supplied by Extensions (Menu, Toolbar))
icon5.gif  Custom Widget Ids for Widgets supplied by Extensions (Menu, Toolbar) [message #949219] Thu, 18 October 2012 20:21 Go to next message
Christian Hager is currently offline Christian HagerFriend
Messages: 53
Registered: July 2009
Location: Germany
Member
I'm trying to add custom widget ids to widgets supplied by extensions (e.g. Toolbar-Items, Menus). I know there are ids like "w000" which are automatically added by rap but I would like to add custom ids like I can do with my own widgets using setData and WidgetUtil.CUSTOM_WIDGET_ID.

Is there a way to achive this? Or maybe it is possible to override the IdGenerator?

Thanks in advance for any hints or help.
Re: Custom Widget Ids for Widgets supplied by Extensions (Menu, Toolbar) [message #949903 is a reply to message #949219] Fri, 19 October 2012 12:22 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

I think this can only be achieved by a custom IdGenerator, which is
currently not supported. But feel free to file an enhancement request.

Regards,
Ralf

--
Ralf Sternberg

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

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Custom Widget Ids for Widgets supplied by Extensions (Menu, Toolbar) [message #952377 is a reply to message #949903] Sun, 21 October 2012 12:02 Go to previous messageGo to next message
Thomas Kratz is currently offline Thomas KratzFriend
Messages: 165
Registered: July 2009
Senior Member
Hi Ralf, Christian,

I would be interested in such an enhancement too. I worked around with a little hack
http://thomaskratz.blogspot.de/2012/08/eclipse-rap-ui-testing-contd.html

but this is really a hack and could be solved better by plugging in an id generator.

Therefore I filed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=392526
Re: Custom Widget Ids for Widgets supplied by Extensions (Menu, Toolbar) [message #1008619 is a reply to message #952377] Wed, 13 February 2013 10:29 Go to previous messageGo to next message
Gábor Lipták is currently offline Gábor LiptákFriend
Messages: 21
Registered: July 2009
Junior Member
I managed to implement a PhaseListener (http://download.eclipse.org/rt/rap/doc/1.5/help/html/reference/extension-points/org_eclipse_rap_ui_phaselistener.html), which traverses the current shell, and generates the id for the widgets, where it is not defined. The code likes something like this:

public class IDGeneratingPhaseListener implements PhaseListener {
private static final String GENERATED_ID_PREFIX = "GEN_";

private static final long serialVersionUID = 1L;

@Override
public void beforePhase(PhaseEvent event) {
Shell shell = Display.getCurrent().getActiveShell();
if ( shell.getData( WidgetUtil.CUSTOM_WIDGET_ID ) == null ) {
shell.setData( WidgetUtil.CUSTOM_WIDGET_ID, GENERATED_ID_PREFIX + "Shell");
}

generateIdentifiersForMenu( shell.getMenuBar() );
}

protected void generateIdentifiersForMenu( Menu menu ) {
if ( menu != null ) {
MenuItem[] children = menu.getItems();
for (MenuItem child : children) {
if ( child.getData( WidgetUtil.CUSTOM_WIDGET_ID ) == null ) {
child.setData(WidgetUtil.CUSTOM_WIDGET_ID, GENERATED_ID_PREFIX + child.getText().replace( ' ', '_') );
}
generateIdentifiersForMenu(child.getMenu());
}
}
}

@Override
public void afterPhase(PhaseEvent event) {
}

@Override
public PhaseId getPhaseId() {
return PhaseId.RENDER;
}

}

Of course to traverse the whole tree can take a while, so I do not suggest to take this extension to production.
Re: Custom Widget Ids for Widgets supplied by Extensions (Menu, Toolbar) [message #1009169 is a reply to message #1008619] Thu, 14 February 2013 15:24 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

FWIW, In RAP 2.0, there's an internal interface IdGenerator that is used
for creating ids. The idea is to register a custom IdGenerator. However,
there's still an issue with this approach, see [1].

https://bugs.eclipse.org/bugs/show_bug.cgi?id=392526

--
Ralf Sternberg

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

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:RAP 2.0 War deployment issue
Next Topic:Plans for the rendering engine on 2.0
Goto Forum:
  


Current Time: Fri Mar 29 04:54:35 GMT 2024

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

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

Back to the top