Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 211793 Details for
Bug 371252
[Protocol] Use JSON arrays for operations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
client changes
protocolUpdate.patch (text/plain), 19.00 KB, created by
Tim Buschtoens
on 2012-02-29 08:29:10 EST
(
hide
)
Description:
client changes
Filename:
MIME Type:
Creator:
Tim Buschtoens
Created:
2012-02-29 08:29:10 EST
Size:
19.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt >Index: js/org/eclipse/rwt/protocol/Processor.js >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/js/org/eclipse/rwt/protocol/Processor.js,v >retrieving revision 1.26 >diff -u -r1.26 Processor.js >--- js/org/eclipse/rwt/protocol/Processor.js 13 Feb 2012 09:48:15 -0000 1.26 >+++ js/org/eclipse/rwt/protocol/Processor.js 29 Feb 2012 13:25:37 -0000 >@@ -17,7 +17,7 @@ > this.processMeta( messageObject.meta ); > var operations = messageObject.operations; > for( var i = 0; i < operations.length; i++ ) { >- this.processOperation( operations[ i ] ); >+ this.processOperationArray( operations[ i ] ); > } > }, > >@@ -28,23 +28,24 @@ > } > }, > >- processOperation : function( operation ) { >+ processOperationArray : function( operation ) { >+ var action = operation[ 0 ]; > try { >- switch( operation.action ) { >+ switch( action ) { > case "create": >- this._processCreate( operation.target, operation.type, operation.properties ); >+ this._processCreate( operation[ 1 ], operation[ 2 ], operation[ 3 ] ); > break; > case "set": >- this._processSet( operation.target, operation.properties ); >+ this._processSet( operation[ 1 ], operation[ 2 ] ); > break; >- case "destroy": >- this._processDestroy( operation.target ); >+ case "listen": >+ this._processListen( operation[ 1 ], operation[ 2 ] ); > break; > case "call": >- this._processCall( operation.target, operation.method, operation.properties ); >+ this._processCall( operation[ 1 ], operation[ 2 ], operation[ 3 ] ); > break; >- case "listen": >- this._processListen( operation.target, operation.properties ); >+ case "destroy": >+ this._processDestroy( operation[ 1 ] ); > break; > } > } catch( ex ) { >@@ -52,6 +53,26 @@ > } > }, > >+ processOperation : function( operation ) { >+ switch( operation.action ) { >+ case "create": >+ this._processCreate( operation.target, operation.type, operation.properties ); >+ break; >+ case "set": >+ this._processSet( operation.target, operation.properties ); >+ break; >+ case "destroy": >+ this._processDestroy( operation.target ); >+ break; >+ case "call": >+ this._processCall( operation.target, operation.method, operation.properties ); >+ break; >+ case "listen": >+ this._processListen( operation.target, operation.properties ); >+ break; >+ } >+ }, >+ > //////////// > // Internals > >@@ -133,9 +154,9 @@ > } else { > errorstr = "No Error given!"; > } >- var msg = "Operation \"" + operation.action + "\""; >- msg += " on target \"" + operation.target + "\""; >- var objectEntry = org.eclipse.rwt.protocol.ObjectManager.getEntry( operation.target ); >+ var msg = "Operation \"" + operation[ 0 ] + "\""; >+ msg += " on target \"" + operation[ 1 ] + "\""; >+ var objectEntry = org.eclipse.rwt.protocol.ObjectManager.getEntry( operation[ 1 ] ); > var target = objectEntry ? objectEntry.object : null; > msg += " of type \"" + ( target && target.classname ? target.classname : target ) + "\""; > msg += " failed:"; >@@ -146,8 +167,22 @@ > > _getPropertiesString : function( operation ) { > var result = ""; >- for( var key in operation.properties ) { >- result += key + " = " + operation.properties[ key ] + "\n"; >+ var properties; >+ switch( operation[ 0 ] ) { >+ case "set": >+ case "listen": >+ properties = operation[ 2 ]; >+ break; >+ case "create": >+ case "call": >+ properties = operation[ 3 ]; >+ break; >+ default: >+ properties = {}; >+ break; >+ } >+ for( var key in properties ) { >+ result += key + " = " + properties[ key ] + "\n"; > } > return result; > }, >#P org.eclipse.rap.rwt.jstest >Index: js/org/eclipse/rwt/test/tests/ProtocolTest.js >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.jstest/js/org/eclipse/rwt/test/tests/ProtocolTest.js,v >retrieving revision 1.23 >diff -u -r1.23 ProtocolTest.js >--- js/org/eclipse/rwt/test/tests/ProtocolTest.js 23 Jan 2012 15:55:00 -0000 1.23 >+++ js/org/eclipse/rwt/test/tests/ProtocolTest.js 29 Feb 2012 13:25:37 -0000 >@@ -40,12 +40,8 @@ > "height" : 33, > "width" : 24 > }; >- var operation = { >- "target" : "dummyId", >- "action" : "set", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ var operation = [ "set", "dummyId", properties ]; >+ processor.processOperationArray( operation ); > assertEquals( [ "width", 24, "height", 33 ], targetObject.getLog() ); > registry.remove( "dummyType" ); > }, >@@ -60,12 +56,7 @@ > var properties = { > "height" : 33 > }; >- var operation = { >- "target" : "dummyId", >- "action" : "set", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "set", "dummyId", properties ] ); > assertEquals( [ "height", 33 ], targetObject.getLog() ); > registry.remove( "dummyType" ); > }, >@@ -82,12 +73,7 @@ > "width" : 24, > "top" : 14 > }; >- var operation = { >- "target" : "dummyId", >- "action" : "set", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "set", "dummyId", properties ] ); > assertEquals( [ "width", 24, "height", 33 ], targetObject.getLog() ); > registry.remove( "dummyType" ); > }, >@@ -101,12 +87,7 @@ > "height" : 33, > "width" : 24 > }; >- var operation = { >- "target" : "dummyId", >- "action" : "set", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "set", "dummyId", properties ] ); > assertEquals( [], targetObject.getLog() ); > registry.remove( "dummyType" ); > }, >@@ -126,12 +107,7 @@ > var properties = { > "awesomeness" : 1 > }; >- var operation = { >- "target" : "dummyId", >- "action" : "set", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "set", "dummyId", properties ] ); > assertEquals( [ "coolness", 100 ], targetObject.getLog() ); > registry.remove( "dummyType" ); > }, >@@ -147,13 +123,7 @@ > var properties = { > style : [] > }; >- var operation = { >- type : "dummyType", >- "target" : "dummyId", >- "action" : "create", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "create", "dummyId", "dummyType", properties ] ); > var result = this._getTargetById( "dummyId" ); > assertEquals( "myclass", result.classname ); > registry.remove( "dummyType" ); >@@ -162,19 +132,11 @@ > testProcessCreateAdapterHasNoConstructorFails : function() { > var registry = org.eclipse.rwt.protocol.AdapterRegistry; > var processor = org.eclipse.rwt.protocol.Processor; >- registry.add( "dummyType", { >- } ); >- var properties = { >- }; >+ registry.add( "dummyType", {} ); >+ var properties = {}; > var error = null; >- var operation = { >- type : "dummyType", >- "target" : "dummyId", >- "action" : "create", >- "properties" : properties >- }; > try { >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "create", "dummyId", "dummyType", properties ] ); > } catch ( ex ) { > error = ex; > } >@@ -191,13 +153,7 @@ > var properties = { > style : [ "BORDER", "FLAT" ] > }; >- var operation = { >- type : "dummyType", >- "target" : "dummyId", >- "action" : "create", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "create", "dummyId", "dummyType", properties ] ); > var result = this._getTargetById( "dummyId" ); > // NOTE: Order is NOT relevant! > assertTrue( result.getLog().indexOf( "rwt_BORDER" ) !== -1 ); >@@ -214,13 +170,7 @@ > var properties = { > style : [ "BORDER", "FLAT" ] > }; >- var operation = { >- type : "dummyType", >- "target" : "dummyId", >- "action" : "create", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "create", "dummyId", "dummyType", properties ] ); > var result = this._getTargetById( "dummyId" ); > var style = result.getStyleMap(); > assertTrue( style.BORDER ); >@@ -237,13 +187,7 @@ > var properties = { > style : [ "BORDER", "FLAT" ] > }; >- var operation = { >- type : "dummyType", >- "target" : "dummyId", >- "action" : "create", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "create", "dummyId", "dummyType", properties ] ); > var result = this._getTargetById( "dummyId" ); > assertIdentical( properties.style, result.getProperties().style ); > registry.remove( "dummyType" ); >@@ -260,13 +204,7 @@ > style : [], > width : 34 > }; >- var operation = { >- type : "dummyType", >- "target" : "dummyId", >- "action" : "create", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "create", "dummyId", "dummyType", properties ] ); > var result = this._getTargetById( "dummyId" ); > assertEquals( [ "width", 34 ], result.getLog() ); > registry.remove( "dummyType" ); >@@ -309,11 +247,7 @@ > return [ target ]; > } > } ); >- var operation = { >- "target" : "dummyId", >- "action" : "destroy" >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "destroy", "dummyId" ] ); > assertEquals( [ "destroy" ], target.getLog() ); > assertNull( target.getParent() ); > assertTrue( this._getTargetById( "dummyId" ) == null ); >@@ -335,11 +269,7 @@ > return [ target ]; > } > } ); >- var operation = { >- "target" : "dummyId", >- "action" : "destroy" >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "destroy", "dummyId" ] ); > assertEquals( [ "foo", "destroy" ], target.getLog() ); > assertTrue( this._getTargetById( "dummyId" ) == null ); > registry.remove( "dummyType" ); >@@ -352,15 +282,8 @@ > methods : [ "doFoo" ] > } ); > var targetObject = this._getDummyTarget( "dummyId" ); >- var properties = { >- }; >- var operation = { >- "target" : "dummyId", >- "action" : "call", >- "method" : "doFoo", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ var properties = {}; >+ processor.processOperationArray( [ "call", "dummyId", "doFoo", properties ] ); > assertEquals( "foo", targetObject.getLog()[ 0 ] ); > assertIdentical( properties, targetObject.getLog()[ 1 ] ); > registry.remove( "dummyType" ); >@@ -379,13 +302,7 @@ > } ); > var targetObject = this._getDummyTarget( "dummyId" ); > var properties = {}; >- var operation = { >- "target" : "dummyId", >- "action" : "call", >- "method" : "doBar", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "call", "dummyId", "doBar", properties ] ); > assertEquals( "foo", targetObject.getLog()[ 0 ] ); > assertIdentical( properties, targetObject.getLog()[ 1 ] ); > registry.remove( "dummyType" ); >@@ -401,13 +318,7 @@ > var properties = { > "foo" : [ 17, 42 ] > }; >- var operation = { >- "target" : "dummyId", >- "action" : "call", >- "method" : "doFoo", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "call", "dummyId", "doFoo", properties ] ); > assertEquals( "foo", targetObject.getLog()[ 0 ] ); > var args = targetObject.getLog()[ 1 ]; > assertEquals( properties, args ); >@@ -424,12 +335,7 @@ > var properties = { > name : "doFoo" > }; >- var operation = { >- "target" : "dummyId", >- "action" : "call", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "call", "dummyId", undefined, properties ] ); > assertEquals( 0, targetObject.getLog().length ); > registry.remove( "dummyType" ); > }, >@@ -439,15 +345,8 @@ > var processor = org.eclipse.rwt.protocol.Processor; > registry.add( "dummyType", { } ); > var targetObject = this._getDummyTarget( "dummyId" ); >- var properties = { >- name : "doFoo" >- }; >- var operation = { >- "target" : "dummyId", >- "action" : "call", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ var properties = { name : "doFoo" }; >+ processor.processOperationArray( [ "call", "dummyId", "", properties ] ); > assertEquals( 0, targetObject.getLog().length ); > registry.remove( "dummyType" ); > }, >@@ -462,12 +361,7 @@ > var properties = { > add : [ "foo" ] > }; >- var operation = { >- "target" : "dummyId", >- "action" : "listen", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "listen", "dummyId", properties ] ); > // succeeds by not crashing > registry.remove( "dummyType" ); > targetObject.destroy(); >@@ -481,12 +375,7 @@ > var properties = { > add : [ "mouse" ] > }; >- var operation = { >- "target" : "dummyId", >- "action" : "listen", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "listen", "dummyId", properties ] ); > // NOTE: hasEventListeners may return "undefined" instead of "false" > assertTrue( !targetObject.hasEventListeners( "mousedown" ) ); > assertTrue( !targetObject.hasEventListeners( "mouseup" ) ); >@@ -504,21 +393,11 @@ > var properties = { > "foo" : true > }; >- var operation = { >- "target" : "dummyId", >- "action" : "listen", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "listen", "dummyId", properties ] ); > properties = { > "foo" : false > }; >- var operation = { >- "target" : "dummyId", >- "action" : "listen", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "listen", "dummyId", properties ] ); > assertEquals( [ "fooListener", true, "fooListener", false ], targetObject.getLog() ); > targetObject.destroy(); > }, >@@ -538,78 +417,16 @@ > var properties = { > "bar" : true > }; >- var operation = { >- "target" : "dummyId", >- "action" : "listen", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "listen", "dummyId", properties ] ); > assertTrue( targetObject.getMyData( "barListener" ) ); > properties = { > "bar" : false > }; >- var operation = { >- "target" : "dummyId", >- "action" : "listen", >- "properties" : properties >- }; >- processor.processOperation( operation ); >+ processor.processOperationArray( [ "listen", "dummyId", properties ] ); > assertNull( targetObject.getMyData( "barListener" ) ); > targetObject.destroy(); > }, > >- testProcessExecuteWrongType : function() { >- var registry = org.eclipse.rwt.protocol.AdapterRegistry; >- var processor = org.eclipse.rwt.protocol.Processor; >- globalTemp = 1; >- var properties = { >- scriptType : "java", >- script : "globalTemp++;" >- }; >- var operation = { >- "target" : "dummyId", >- "action" : "executeScript", >- "properties" : properties >- }; >- processor.processOperation( operation ); >- assertEquals( 1, globalTemp ); >- delete globalTemp; >- }, >- >- testProcessExecuteScriptMissing : function() { >- var registry = org.eclipse.rwt.protocol.AdapterRegistry; >- var processor = org.eclipse.rwt.protocol.Processor; >- globalTemp = 1; >- var properties = { >- scriptType : "text/javascript" >- }; >- var operation = { >- "target" : "dummyId", >- "action" : "executeScript", >- "properties" : properties >- }; >- processor.processOperation( operation ); >- assertEquals( 1, globalTemp ); >- delete globalTemp; >- }, >- >- >- testProcessExecuteScriptWithError : function() { >- var registry = org.eclipse.rwt.protocol.AdapterRegistry; >- var processor = org.eclipse.rwt.protocol.Processor; >- var properties = { >- scriptType : "text/javascript", >- script : "x=null;x.test().bla();" >- }; >- var operation = { >- "target" : "dummyId", >- "action" : "executeScript", >- "properties" : properties >- }; >- processor.processOperation( operation ); >- //suceeds by not crashing >- }, >- > testProcessMessage : function() { > var registry = org.eclipse.rwt.protocol.AdapterRegistry; > var processor = org.eclipse.rwt.protocol.Processor; >@@ -617,20 +434,8 @@ > properties : [ "width", "height" ] > } ); > var targetObject = this._getDummyTarget( "dummyId" ); >- var operation1 = { >- "target" : "dummyId", >- "action" : "set", >- "properties" : { >- "height" : 33 >- } >- }; >- var operation2 = { >- "target" : "dummyId", >- "action" : "set", >- "properties" : { >- "width" : 24 >- } >- }; >+ var operation1 = [ "set", "dummyId", { "height" : 33 } ]; >+ var operation2 = [ "set", "dummyId", { "width" : 24 } ]; > var message = { > "meta" : {}, > "operations" : [ operation1, operation2 ] >@@ -647,13 +452,7 @@ > properties : [ "width", "height", "fail" ] > } ); > var targetObject = this._getDummyTarget( "dummyId" ); >- var operation = { >- "target" : "dummyId", >- "action" : "set", >- "properties" : { >- "fail" : 99 >- } >- }; >+ var operation = [ "set", "dummyId", { "fail" : 99 } ]; > var message = { > "meta" : {}, > "operations" : [ operation ]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 371252
: 211793 |
211841