Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Patch RAP script from entrypoint
Patch RAP script from entrypoint [message #1696440] Tue, 26 May 2015 13:47 Go to next message
Wim Anckaert is currently offline Wim AnckaertFriend
Messages: 32
Registered: December 2012
Member
Hello,

I'm trying to implement the patch of https://bugs.eclipse.org/bugs/show_bug.cgi?id=467509 through my entrypoint as it's only fixed for version RAP 3.0.

I have copied EventUtil.js of RAP 2.3 and added it to my plugin.
I've changed the two javascript methods : notifySelected & notifyDefaultSelected and added two console.log messages when this is called.

In my entrypoint in the createUI I load that javascript file through the ResourceManager:
ResourceManager rm = RWT.getResourceManager();
            if (!rm.isRegistered("xepos/rwt/remote/EventUtil.js")) {
                InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("rwt/remote/EventUtil.js");
                try {
                    rm.register("xepos/rwt/remote/EventUtil.js", inputStream);
                } finally {
                    inputStream.close();
                }
            }


and then I load the javascript :
JavaScriptLoader loader = RWT.getClient().getService(JavaScriptLoader.class);
            String location = rm.getLocation("xepos/rwt/remote/EventUtil.js");
            if (location != null && !location.trim().equals("")) {
                loader.require(location);
                System.out.println("loaded");
            }


In my java console I get "loaded".
In my javascript console I get for each altered method a console print. So I think the javascript is correctly loaded.

But then no events happen anymore.
The buttons in my application doesn't respond anymore.

I'm doing something wrong, Does the patch have to be applied in another way?

tx for any help.
Re: Patch RAP script from entrypoint [message #1696449 is a reply to message #1696440] Tue, 26 May 2015 14:18 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 Wim,
this is what I ment in the bug report:

StringBuilder code = new StringBuilder();
code.append( "(function() {" );
code.append( " var notifySelectedOrig =
rwt.remote.EventUtil.notifySelected;" );
code.append( " rwt.remote.EventUtil.notifySelected = function(
target ) {" );
code.append( " if( !target.isDisposed() ) {" );
code.append( " notifySelectedOrig.apply( this, [ target ] );" );
code.append( " }" );
code.append( " };" );
code.append( "}() );" );
JavaScriptExecutor executor = RWT.getClient().getService(
JavaScriptExecutor.class );
executor.execute( code.toString() );

Execute this code in your entry point. You have to do the same for
rwt.remote.EventUtil.notifyDefaultSelected.
HTH,
Ivan

--
Ivan Furnadjiev

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

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Patch RAP script from entrypoint [message #1696460 is a reply to message #1696449] Tue, 26 May 2015 14:48 Go to previous messageGo to next message
Wim Anckaert is currently offline Wim AnckaertFriend
Messages: 32
Registered: December 2012
Member
Ty very much Ivan,
it works !

I've linked the bug to this post for future references.
Re: Patch RAP script from entrypoint [message #1696481 is a reply to message #1696460] Tue, 26 May 2015 15:38 Go to previous message
Wim Anckaert is currently offline Wim AnckaertFriend
Messages: 32
Registered: December 2012
Member
  StringBuilder code = new StringBuilder();
            code.append("(function() {");
            code.append(" var notifySelectedOrig = rwt.remote.EventUtil.notifySelected;");
            code.append(" rwt.remote.EventUtil.notifySelected = function( ) {");
            code.append(" var target = arguments[0]; ");
            code.append(" if( !target.isDisposed() ) {");
            code.append("  notifySelectedOrig.apply( this, arguments );");
            code.append(" }");
            code.append(" };");
            code.append("}() );");

            JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
            executor.execute(code.toString());
            code = new StringBuilder();
            code.append("(function() {");
            code.append(" var notifyDefaultSelectedOrig = rwt.remote.EventUtil.notifyDefaultSelected;");
            code.append(" rwt.remote.EventUtil.notifyDefaultSelected = function( ) {");
            code.append(" var target = arguments[0]; ");
            code.append(" if( !target.isDisposed() ) {");
            code.append("  notifyDefaultSelectedOrig.apply( this, arguments );");
            code.append(" }");
            code.append(" };");
            code.append("}() );");
            executor = RWT.getClient().getService(JavaScriptExecutor.class);
            executor.execute(code.toString());


I updated the code because I had problems with my treeviewer, not all parameters were passed.
Previous Topic:SWT.RIGHT in trim contributions toolbar
Next Topic:pack truncates table column header with clip text-overflow
Goto Forum:
  


Current Time: Thu Apr 25 23:42:17 GMT 2024

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

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

Back to the top