diff options
author | Tim Buschtöns | 2013-08-02 09:15:57 +0000 |
---|---|---|
committer | Tim Buschtöns | 2013-08-02 11:45:45 +0000 |
commit | 8d117a9781b889e0364602fc4ded191e766d319f (patch) | |
tree | 4c9011d0f4b524d4df9909ddc8ad61c8474f5b61 | |
parent | d3d13e79d779131f526e00a51e4862b5e720f80e (diff) | |
download | org.eclipse.rap.incubator.clientscripting-8d117a9781b889e0364602fc4ded191e766d319f.tar.gz org.eclipse.rap.incubator.clientscripting-8d117a9781b889e0364602fc4ded191e766d319f.tar.xz org.eclipse.rap.incubator.clientscripting-8d117a9781b889e0364602fc4ded191e766d319f.zip |
Rename WidgetProxy to WidgetProxyFactorya and refactor
12 files changed, 301 insertions, 263 deletions
diff --git a/bundles/org.eclipse.rap.clientscripting.demo/src/org/eclipse/rap/clientscripting/demo/NumKey.js b/bundles/org.eclipse.rap.clientscripting.demo/src/org/eclipse/rap/clientscripting/demo/NumKey.js index 00b6c03..eaf9e0b 100644 --- a/bundles/org.eclipse.rap.clientscripting.demo/src/org/eclipse/rap/clientscripting/demo/NumKey.js +++ b/bundles/org.eclipse.rap.clientscripting.demo/src/org/eclipse/rap/clientscripting/demo/NumKey.js @@ -1,3 +1,5 @@ +//# sourceURL=NumKey.js + var handleEvent = function( event ) { var button = event.widget; var text = rap.getObject( button.getData( "textWidget" ) ); diff --git a/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/ClientScriptingUtil.js b/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/ClientScriptingUtil.js index d966f1a..c935814 100644 --- a/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/ClientScriptingUtil.js +++ b/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/ClientScriptingUtil.js @@ -19,26 +19,6 @@ org.eclipse.rap.clientscripting.ClientScriptingUtil = { _wrapperHelper : function(){}, - _getterMapping : { - "rwt.widgets.Text" : { - "getText" : function( widget ) { return function() { return widget.getValue(); }; }, - "getSelection" : function( widget ) { return function() { return widget.getSelection(); }; }, - "getEditable" : function( widget ) { return function() { return !widget.getReadOnly(); }; } - }, - "rwt.widgets.List" : { - "getSelection" : function( widget ) { - return function() { - var items = widget.getSelectedItems(); - var result = []; - for( var i = 0; i < items.length; i++ ) { - result[ i ] = rwt.util.Encoding.unescape( items[ i ].getLabel() ); - } - return result; - }; - } - } - }, - _eventTypeMapping : { "*" : { "KeyDown" : "keypress", @@ -98,14 +78,6 @@ org.eclipse.rap.clientscripting.ClientScriptingUtil = { return result; }, - disposeObject : function( object ) { - for( var key in object ) { - if( object.hasOwnProperty( key ) ) { - object[ key ] = null; - } - } - }, - postProcessEvent : function( event, wrappedEvent, originalEvent ) { var SWT = org.eclipse.rap.clientscripting.SWT; switch( event.type ) { @@ -119,66 +91,9 @@ org.eclipse.rap.clientscripting.ClientScriptingUtil = { } }, - attachSetter : function( proxy, source ) { - var id = ObjectRegistry.getId( source ); - var handler = id ? ObjectRegistry.getEntry( id ).handler : null; - if( handler ) { - var properties = handler.properties; - for( var i = 0; i < properties.length; i++ ) { - var property = properties[ i ]; - proxy[ "set" + rwt.util.Strings.toFirstUp( property ) ] = - this._createSetter( id, property ); - } - } - }, - - attachGetter : function( proxy, source ) { - if( source.classname ) { - var getterMap = this._getterMapping[ source.classname ]; - for( var key in getterMap ) { - proxy[ key ] = getterMap[ key ]( source ); - } - } - }, - - attachUserData : function( proxy, source ) { - var setter = this._setUserData; - var getter = this._getUserData; - proxy.setData = function( property, value ) { - setter( source, arguments ); - }; - proxy.getData = function( property ) { - return getter( source, arguments ); - }; - }, - - attachControlMethods : function( proxy, source ) { - var id = ObjectRegistry.getId( source ); - var ClientScriptingUtil = org.eclipse.rap.clientscripting.ClientScriptingUtil; - proxy.redraw = function() { - ClientScriptingUtil._initGC( source ); - }; - proxy.forceFocus = function() { - var result = false; - if( source.getEnabled() && ClientScriptingUtil._isVisible( source ) ) { - rwt.widgets.Display.getCurrent().setFocusControl( id ); - result = true; - } - return result; - }; - }, - - addDisposeListener : function( widget, listener ) { - var orgDestroy = widget.destroy; - widget.destroy = function() { - listener( this ); - orgDestroy.call( widget ); - }; - }, - initEvent : function( event, type, target, originalEvent ) { var SWT = org.eclipse.rap.clientscripting.SWT; - event.widget = org.eclipse.rap.clientscripting.WidgetProxy.getInstance( target ); + event.widget = org.eclipse.rap.clientscripting.WidgetProxyFactory.getWidgetProxy( target ); event.type = type; switch( type ) { case SWT.KeyDown: @@ -202,50 +117,6 @@ org.eclipse.rap.clientscripting.ClientScriptingUtil = { } }, - _createSetter : function( id, property ) { - var setProperty = this._setProperty; - var result = function( value ) { - setProperty( id, property, value ); - }; - return result; - }, - - _setProperty : function( id, property, value ) { - var props = {}; - props[ property ] = value; - rwt.remote.MessageProcessor.processOperation( { - "target" : id, - "action" : "set", - "properties" : props - } ); - }, - - _setUserData : function( source, args ) { - if( args.length !== 2 ) { - var msg = "Wrong number of arguments in SetData: Expected 2, found " + args.length; - throw new Error( msg ); - } - var property = args[ 0 ]; - var value = args[ 1 ]; - var USERDATA_KEY = org.eclipse.rap.clientscripting.WidgetProxy._USERDATA_KEY; - var data = rwt.remote.HandlerUtil.getServerData( source ); - data[ property ] = value; - }, - - _getUserData : function( source, args ) { - if( args.length !== 1 ) { - var msg = "Wrong number of arguments in SetData: Expected 1, found " + args.length; - throw new Error( msg ); - } - var property = args[ 0 ]; - var result = null; - var data = rwt.remote.HandlerUtil.getServerData( source ); - if( typeof data[ property ] !== "undefined" ) { - result = data[ property ]; - } - return result; - }, - _initKeyEvent : function( event, originalEvent ) { var charCode = originalEvent.getCharCode(); var SWT = org.eclipse.rap.clientscripting.SWT; @@ -297,39 +168,17 @@ org.eclipse.rap.clientscripting.ClientScriptingUtil = { }, _getGCFor : function( widget ) { - var gc = widget.getUserData( org.eclipse.rap.clientscripting.WidgetProxy._GC_KEY ); + var gc = widget.getUserData( org.eclipse.rap.clientscripting.WidgetProxyFactory._GC_KEY ); if( gc == null ) { gc = this._findExistingGC( widget ); if( gc == null ) { gc = new rwt.widgets.GC( widget ); } - widget.setUserData( org.eclipse.rap.clientscripting.WidgetProxy._GC_KEY, gc ); + widget.setUserData( org.eclipse.rap.clientscripting.WidgetProxyFactory._GC_KEY, gc ); } return gc; }, - _initGC : function( widget ) { - var gc = this._getGCFor( widget ); - var width = widget.getInnerWidth(); - var height = widget.getInnerHeight(); - var fillStyle = widget.getBackgroundColor(); - var strokeStyle = widget.getTextColor(); - var font = [[]]; - if( widget.getFont() ) { - font[ 0 ] = widget.getFont().getFamily(); - font[ 1 ] = widget.getFont().getSize(); - font[ 2 ] = widget.getFont().getBold(); - font[ 3 ] = widget.getFont().getItalic(); - } - gc.init( - width, - height, - font, - rwt.util.Colors.stringToRgb( fillStyle ? fillStyle : "#000000" ), - rwt.util.Colors.stringToRgb( strokeStyle ? strokeStyle : "#000000" ) - ); - }, - _findExistingGC : function( widget ) { var children = widget._getTargetNode().childNodes; var result = null; @@ -341,16 +190,6 @@ org.eclipse.rap.clientscripting.ClientScriptingUtil = { return result; }, - _isVisible : function( widget ) { - var result = true; - var current = widget; - while( current && result ) { - result = current.getVisibility(); - current = current.getParent(); - } - return result; - }, - _initVerifyEvent : function( event, originalEvent ) { var text = originalEvent.getTarget(); if( text.classname === "rwt.widgets.Text" ) { diff --git a/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/SWT.js b/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/SWT.js index b0ba007..e189a4e 100644 --- a/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/SWT.js +++ b/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/SWT.js @@ -13,7 +13,7 @@ rwt.qx.Class.createNamespace( "org.eclipse.rap.clientscripting", {} ); /** - * Note: Thise class is available within ClientScriptingFunction simpl as "SWT" (no namespace) + * Note: Thise class is available within ClientScriptingFunction simply as "SWT" (no namespace) */ org.eclipse.rap.clientscripting.SWT = { diff --git a/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/WidgetProxy.js b/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/WidgetProxy.js deleted file mode 100644 index f5338c6..0000000 --- a/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/WidgetProxy.js +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 EclipseSource and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * EclipseSource - initial API and implementation - ******************************************************************************/ - -(function(){ - -rwt.qx.Class.createNamespace( "org.eclipse.rap.clientscripting", {} ); - -org.eclipse.rap.clientscripting.WidgetProxy = function( originalWidget ) { - var ClientScriptingUtil = org.eclipse.rap.clientscripting.ClientScriptingUtil; - ClientScriptingUtil.attachSetter( this, originalWidget ); - ClientScriptingUtil.attachGetter( this, originalWidget ); - ClientScriptingUtil.attachUserData( this, originalWidget ); - if( rwt.remote.WidgetManager.getInstance().isControl( originalWidget ) ) { - ClientScriptingUtil.attachControlMethods( this, originalWidget ); - } - ClientScriptingUtil.addDisposeListener( originalWidget, function() { - org.eclipse.rap.clientscripting.WidgetProxy.disposeWidgetProxy( originalWidget ); - } ); -}; - -org.eclipse.rap.clientscripting.WidgetProxy._PROXY_KEY = - "org.eclipse.rap.clientscripting.WidgetProxy.PROXY"; - -org.eclipse.rap.clientscripting.WidgetProxy._GC_KEY = - "org.eclipse.rap.clientscripting.WidgetProxy.GC"; - -org.eclipse.rap.clientscripting.WidgetProxy.getInstance = function( widget ) { - return rap._.getWrapperFor( widget ); -}; - -var getWrapperFor = rap._.getWrapperFor; -rap._.getWrapperFor = function( obj ) { - var result = getWrapperFor.call( rap._, obj ); - var PROXY_KEY = org.eclipse.rap.clientscripting.WidgetProxy._PROXY_KEY; - if( obj.getUserData( PROXY_KEY ) == null ) { - org.eclipse.rap.clientscripting.WidgetProxy.call( result, obj ); - obj.setUserData( PROXY_KEY, result ); - } - return result; -}; - -org.eclipse.rap.clientscripting.WidgetProxy.disposeWidgetProxy = function( widget ) { - var protoInstance = widget.getUserData( this._PROXY_KEY ); - var userData = widget.getUserData( rwt.remote.HandlerUtil.SERVER_DATA ); - org.eclipse.rap.clientscripting.ClientScriptingUtil.disposeObject( protoInstance ); - org.eclipse.rap.clientscripting.ClientScriptingUtil.disposeObject( userData ); -}; - -}()); diff --git a/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/WidgetProxyFactory.js b/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/WidgetProxyFactory.js new file mode 100644 index 0000000..e9cc6c1 --- /dev/null +++ b/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/WidgetProxyFactory.js @@ -0,0 +1,223 @@ +/******************************************************************************* + * Copyright (c) 2012, 2013 EclipseSource and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * EclipseSource - initial API and implementation + ******************************************************************************/ + +(function(){ + +var ObjectRegistry = rwt.remote.ObjectRegistry; + +rwt.qx.Class.createNamespace( "org.eclipse.rap.clientscripting", {} ); + +org.eclipse.rap.clientscripting.WidgetProxyFactory = { + + _PROXY_KEY : "org.eclipse.rap.clientscripting.WidgetProxyFactory.PROXY", + _GC_KEY : "org.eclipse.rap.clientscripting.WidgetProxyFactory.GC", + + getWidgetProxy : function( widget ) { + // TODO [tb] : this delegates back to _initWrapper, see init.js. Should be simplified in RAP 2.2 + return rap._.getWrapperFor( widget ); + }, + + _initWrapper : function( originalWidget, wrapper ) { + this._attachSetter( wrapper, originalWidget ); + this._attachGetter( wrapper, originalWidget ); + this._attachUserData( wrapper, originalWidget ); + if( rwt.remote.WidgetManager.getInstance().isControl( originalWidget ) ) { + this._attachControlMethods( wrapper, originalWidget ); + } + this._addDisposeListener( originalWidget, function() { + org.eclipse.rap.clientscripting.WidgetProxyFactory._disposeWidgetProxy( originalWidget ); + } ); + }, + + _addDisposeListener : function( widget, listener ) { + var orgDestroy = widget.destroy; + widget.destroy = function() { + listener( this ); + orgDestroy.call( widget ); + }; + }, + + _disposeWidgetProxy : function( widget ) { + var protoInstance = widget.getUserData( this._PROXY_KEY ); + var userData = widget.getUserData( rwt.remote.HandlerUtil.SERVER_DATA ); + org.eclipse.rap.clientscripting.WidgetProxyFactory._disposeObject( protoInstance ); + org.eclipse.rap.clientscripting.WidgetProxyFactory._disposeObject( userData ); + }, + + _disposeObject : function( object ) { + for( var key in object ) { + if( object.hasOwnProperty( key ) ) { + object[ key ] = null; + } + } + }, + + ///////////////// + // setter support + + _attachSetter : function( proxy, source ) { + var id = ObjectRegistry.getId( source ); + var handler = id ? ObjectRegistry.getEntry( id ).handler : null; + if( handler ) { + var properties = handler.properties; + for( var i = 0; i < properties.length; i++ ) { + var property = properties[ i ]; + proxy[ "set" + rwt.util.Strings.toFirstUp( property ) ] = + this._createSetter( id, property ); + } + } + }, + + _createSetter : function( id, property ) { + var setProperty = this._setProperty; + var result = function( value ) { + setProperty( id, property, value ); + }; + return result; + }, + + _setProperty : function( id, property, value ) { + var props = {}; + props[ property ] = value; + rwt.remote.MessageProcessor.processOperation( { + "target" : id, + "action" : "set", + "properties" : props + } ); + }, + + ///////////////// + // Getter support + + _attachGetter : function( proxy, source ) { + if( source.classname ) { + var getterMap = this._getterMapping[ source.classname ]; + for( var key in getterMap ) { + proxy[ key ] = getterMap[ key ]( source ); + } + } + }, + + _getterMapping : { + "rwt.widgets.Text" : { + "getText" : function( widget ) { return function() { return widget.getValue(); }; }, + "getSelection" : function( widget ) { return function() { return widget.getSelection(); }; }, + "getEditable" : function( widget ) { return function() { return !widget.getReadOnly(); }; } + }, + "rwt.widgets.List" : { + "getSelection" : function( widget ) { + return function() { + var items = widget.getSelectedItems(); + var result = []; + for( var i = 0; i < items.length; i++ ) { + result[ i ] = rwt.util.Encoding.unescape( items[ i ].getLabel() ); + } + return result; + }; + } + } + }, + + /////////////////// + // widget data + + _attachUserData : function( proxy, source ) { + var setter = this._setUserData; + var getter = this._getUserData; + proxy.setData = function( property, value ) { + setter( source, arguments ); + }; + proxy.getData = function( property ) { + return getter( source, arguments ); + }; + }, + + _setUserData : function( source, args ) { + if( args.length !== 2 ) { + var msg = "Wrong number of arguments in SetData: Expected 2, found " + args.length; + throw new Error( msg ); + } + var property = args[ 0 ]; + var value = args[ 1 ]; + var USERDATA_KEY = org.eclipse.rap.clientscripting.WidgetProxyFactory._USERDATA_KEY; + var data = rwt.remote.HandlerUtil.getServerData( source ); + data[ property ] = value; + }, + + _getUserData : function( source, args ) { + if( args.length !== 1 ) { + var msg = "Wrong number of arguments in SetData: Expected 1, found " + args.length; + throw new Error( msg ); + } + var property = args[ 0 ]; + var result = null; + var data = rwt.remote.HandlerUtil.getServerData( source ); + if( typeof data[ property ] !== "undefined" ) { + result = data[ property ]; + } + return result; + }, + + /////////////////////// + // misc methods support + + _attachControlMethods : function( proxy, source ) { + var id = ObjectRegistry.getId( source ); + var that = this; + proxy.redraw = function() { + that._initGC( source ); + }; + proxy.forceFocus = function() { + var result = false; + if( source.getEnabled() && that._isVisible( source ) ) { + rwt.widgets.Display.getCurrent().setFocusControl( id ); + result = true; + } + return result; + }; + }, + + _isVisible : function( widget ) { + var result = true; + var current = widget; + while( current && result ) { + result = current.getVisibility(); + current = current.getParent(); + } + return result; + }, + + _initGC : function( widget ) { + var gc = org.eclipse.rap.clientscripting.ClientScriptingUtil._getGCFor( widget ); + var width = widget.getInnerWidth(); + var height = widget.getInnerHeight(); + var fillStyle = widget.getBackgroundColor(); + var strokeStyle = widget.getTextColor(); + var font = [[]]; + if( widget.getFont() ) { + font[ 0 ] = widget.getFont().getFamily(); + font[ 1 ] = widget.getFont().getSize(); + font[ 2 ] = widget.getFont().getBold(); + font[ 3 ] = widget.getFont().getItalic(); + } + gc.init( + width, + height, + font, + rwt.util.Colors.stringToRgb( fillStyle ? fillStyle : "#000000" ), + rwt.util.Colors.stringToRgb( strokeStyle ? strokeStyle : "#000000" ) + ); + + } + +}; + +}()); diff --git a/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/init.js b/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/init.js new file mode 100644 index 0000000..39ac256 --- /dev/null +++ b/bundles/org.eclipse.rap.clientscripting/js/org/eclipse/rap/clientscripting/init.js @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2013 EclipseSource and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * EclipseSource - initial API and implementation + ******************************************************************************/ + +// NOTE: To be loaded after all other ClientScripting classes +(function(){ + + ////////////////////////// + // Attach to rap.getObject + + var getWrapperFor = rap._.getWrapperFor; + rap._.getWrapperFor = function( obj ) { + var result = getWrapperFor.call( rap._, obj ); + var PROXY_KEY = org.eclipse.rap.clientscripting.WidgetProxyFactory._PROXY_KEY; + if( obj.getUserData( PROXY_KEY ) == null ) { + org.eclipse.rap.clientscripting.WidgetProxyFactory._initWrapper( obj, result ); + obj.setUserData( PROXY_KEY, result ); + } + return result; + }; + + }()); diff --git a/bundles/org.eclipse.rap.clientscripting/src/org/eclipse/rap/clientscripting/Script.java b/bundles/org.eclipse.rap.clientscripting/src/org/eclipse/rap/clientscripting/Script.java index f4ba7dc..3b895c7 100644 --- a/bundles/org.eclipse.rap.clientscripting/src/org/eclipse/rap/clientscripting/Script.java +++ b/bundles/org.eclipse.rap.clientscripting/src/org/eclipse/rap/clientscripting/Script.java @@ -18,7 +18,7 @@ import org.eclipse.rap.rwt.remote.RemoteObject; public class Script { private static final String REMOTE_TYPE = "rwt.clientscripting.Script"; - private RemoteObject remoteObject; + private final RemoteObject remoteObject; public Script( String scriptCode ) { if( scriptCode == null ) { diff --git a/bundles/org.eclipse.rap.clientscripting/src/org/eclipse/rap/clientscripting/internal/resources/ClientScriptingResources.java b/bundles/org.eclipse.rap.clientscripting/src/org/eclipse/rap/clientscripting/internal/resources/ClientScriptingResources.java index 4238945..2d8b535 100644 --- a/bundles/org.eclipse.rap.clientscripting/src/org/eclipse/rap/clientscripting/internal/resources/ClientScriptingResources.java +++ b/bundles/org.eclipse.rap.clientscripting/src/org/eclipse/rap/clientscripting/internal/resources/ClientScriptingResources.java @@ -33,8 +33,9 @@ public final class ClientScriptingResources { "Function.js", "ListenerAdapter.js", "SWT.js", - "WidgetProxy.js", - "ScriptHandler.js" + "WidgetProxyFactory.js", + "ScriptHandler.js", + "init.js" }; public static void ensure() { diff --git a/tests/org.eclipse.rap.clientscripting.jstest/js/org/eclipse/rap/clientscripting/EventProxy_Test.js b/tests/org.eclipse.rap.clientscripting.jstest/js/org/eclipse/rap/clientscripting/EventProxy_Test.js index 82e53ff..984eee6 100644 --- a/tests/org.eclipse.rap.clientscripting.jstest/js/org/eclipse/rap/clientscripting/EventProxy_Test.js +++ b/tests/org.eclipse.rap.clientscripting.jstest/js/org/eclipse/rap/clientscripting/EventProxy_Test.js @@ -15,7 +15,7 @@ var EventBinding = org.eclipse.rap.clientscripting.EventBinding; var TestUtil = org.eclipse.rwt.test.fixture.TestUtil; var Processor = rwt.remote.MessageProcessor; var ObjectManager = rwt.remote.ObjectRegistry; -var WidgetProxy = org.eclipse.rap.clientscripting.WidgetProxy; +var WidgetProxyFactory = org.eclipse.rap.clientscripting.WidgetProxyFactory; var SWT = org.eclipse.rap.clientscripting.SWT; var text; @@ -495,7 +495,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.EventProxy_Test", { gc = ev.gc; } } ); - WidgetProxy.getInstance( canvas ).redraw(); + WidgetProxyFactory.getWidgetProxy( canvas ).redraw(); assertNotNull( gc ); assertTrue( gc.stroke instanceof Function ); @@ -521,8 +521,8 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.EventProxy_Test", { gc.push( ev.gc ); } } ); - WidgetProxy.getInstance( canvas ).redraw(); - WidgetProxy.getInstance( canvas ).redraw(); + WidgetProxyFactory.getWidgetProxy( canvas ).redraw(); + WidgetProxyFactory.getWidgetProxy( canvas ).redraw(); assertTrue( gc[ 0 ].stroke instanceof Function ); assertIdentical( gc[ 0 ], gc[ 1 ] ); @@ -557,7 +557,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.EventProxy_Test", { gc = ev.gc; } } ); - WidgetProxy.getInstance( canvas ).redraw(); + WidgetProxyFactory.getWidgetProxy( canvas ).redraw(); assertIdentical( serverGc.getNativeContext(), gc ); canvas.destroy(); @@ -592,8 +592,8 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.EventProxy_Test", { gc.fillStyle = "#00ff00"; } } ); - WidgetProxy.getInstance( canvas ).redraw(); - WidgetProxy.getInstance( canvas ).redraw(); + WidgetProxyFactory.getWidgetProxy( canvas ).redraw(); + WidgetProxyFactory.getWidgetProxy( canvas ).redraw(); assertEquals( [ "#bbbbbb", "#aaaaaa", "italic 11px Arial" ], props ); canvas.destroy(); @@ -624,8 +624,8 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.EventProxy_Test", { gc.fillStyle = "#00ff00"; } } ); - WidgetProxy.getInstance( canvas ).redraw(); - WidgetProxy.getInstance( canvas ).redraw(); + WidgetProxyFactory.getWidgetProxy( canvas ).redraw(); + WidgetProxyFactory.getWidgetProxy( canvas ).redraw(); assertEquals( [ "#000000", "#000000" ], props ); canvas.destroy(); diff --git a/tests/org.eclipse.rap.clientscripting.jstest/js/org/eclipse/rap/clientscripting/WidgetProxy_Test.js b/tests/org.eclipse.rap.clientscripting.jstest/js/org/eclipse/rap/clientscripting/WidgetProxyFactory_Test.js index 935e2c5..4dbf50d 100644 --- a/tests/org.eclipse.rap.clientscripting.jstest/js/org/eclipse/rap/clientscripting/WidgetProxy_Test.js +++ b/tests/org.eclipse.rap.clientscripting.jstest/js/org/eclipse/rap/clientscripting/WidgetProxyFactory_Test.js @@ -14,20 +14,20 @@ var TestUtil = org.eclipse.rwt.test.fixture.TestUtil; var Processor = rwt.remote.MessageProcessor; var ObjectManager = rwt.remote.ObjectRegistry; -var WidgetProxy = org.eclipse.rap.clientscripting.WidgetProxy; +var WidgetProxyFactory = org.eclipse.rap.clientscripting.WidgetProxyFactory; var EventBinding = org.eclipse.rap.clientscripting.EventBinding; var SWT = org.eclipse.rap.clientscripting.SWT; var text; -rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { +rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxyFactory_Test", { extend : rwt.qx.Object, members : { testCreateTextWidgetProxyFromPublicAPI : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); var otherProxy = rap.getObject( "w3" ); @@ -35,14 +35,14 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testCreateTextWidgetProxyTwice : function() { - var widgetProxy1 = WidgetProxy.getInstance( text ); - var widgetProxy2 = WidgetProxy.getInstance( text ); + var widgetProxy1 = WidgetProxyFactory.getWidgetProxy( text ); + var widgetProxy2 = WidgetProxyFactory.getWidgetProxy( text ); assertTrue( widgetProxy1 === widgetProxy2 ); }, testDisposeWidgetProxy : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); text.destroy(); TestUtil.flush(); @@ -55,7 +55,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testDisposeUserData : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); widgetProxy.setData( "key", {} ); var data = rwt.remote.HandlerUtil.getServerData( text ); assertFalse( TestUtil.hasNoObjects( data ) ); @@ -67,7 +67,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testSetter : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); widgetProxy.setText( "foo" ); @@ -75,8 +75,8 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testSetGetData : function() { - var widgetProxy1 = WidgetProxy.getInstance( text ); - var widgetProxy2 = WidgetProxy.getInstance( text ); + var widgetProxy1 = WidgetProxyFactory.getWidgetProxy( text ); + var widgetProxy2 = WidgetProxyFactory.getWidgetProxy( text ); widgetProxy1.setData( "myKey", 24 ); @@ -85,7 +85,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testSetDataTooManyArguments : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); try { widgetProxy.setData( "myKey", 24, "foo" ); fail(); @@ -95,7 +95,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testSetDataTooFewArguments : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); try { widgetProxy.setData( 24 ); fail(); @@ -105,7 +105,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testGetDataTooManyArguments : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); try { widgetProxy.getData( "myKey", 24 ); fail(); @@ -115,7 +115,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testGetDataTooFewArguments : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); try { widgetProxy.getData(); fail(); @@ -126,7 +126,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { testSetTextSync : function() { TestUtil.initRequestLog(); - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); widgetProxy.setText( "foo" ); rwt.remote.Server.getInstance().send(); @@ -135,7 +135,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testTextGetText : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); text.setValue( "foo" ); var value = widgetProxy.getText(); @@ -144,7 +144,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testTextGetSelection : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); text.setValue( "foo" ); text.setSelection( [ 1,2 ] ); @@ -154,7 +154,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testTextGetEditable_returnsTrue : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); var value = widgetProxy.getEditable(); @@ -162,7 +162,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testTextGetEditable_returnsFalse : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); widgetProxy.setEditable( false ); var value = widgetProxy.getEditable(); @@ -171,7 +171,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testTextForceFocus : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); text.blur(); var value = widgetProxy.forceFocus(); @@ -181,7 +181,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testTextForceFocus_NotVisible : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); text.blur(); text.setVisibility( false ); @@ -192,7 +192,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testTextForceFocus_ParentNotVisible : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); text.blur(); text.getParent().setVisibility( false ); TestUtil.flush(); @@ -204,7 +204,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { }, testTextForceFocus_NotEnabled : function() { - var widgetProxy = WidgetProxy.getInstance( text ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( text ); text.blur(); text.setEnabled( false ); @@ -227,7 +227,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { } ); var list = ObjectManager.getObject( "w4" ); TestUtil.flush(); - var widgetProxy = WidgetProxy.getInstance( list ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( list ); TestUtil.click( list.getItems()[ 1 ] ); var value = widgetProxy.getSelection(); @@ -248,7 +248,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { } ); var list = ObjectManager.getObject( "w4" ); TestUtil.flush(); - var widgetProxy = WidgetProxy.getInstance( list ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( list ); TestUtil.click( list.getItems()[ 1 ] ); var value = widgetProxy.getSelection(); @@ -267,7 +267,7 @@ rwt.qx.Class.define( "org.eclipse.rap.clientscripting.WidgetProxy_Test", { } } ); var canvas = ObjectManager.getObject( "w4" ); - var widgetProxy = WidgetProxy.getInstance( canvas ); + var widgetProxy = WidgetProxyFactory.getWidgetProxy( canvas ); var logger = this._createLogger(); TestUtil.flush(); new EventBinding( canvas, "Paint", logger ); diff --git a/tests/org.eclipse.rap.clientscripting.jstest/src/org/eclipse/rap/clientscripting/internal/ClientScriptingResourcesContribution.java b/tests/org.eclipse.rap.clientscripting.jstest/src/org/eclipse/rap/clientscripting/internal/ClientScriptingResourcesContribution.java index 9f24e60..3b13660 100644 --- a/tests/org.eclipse.rap.clientscripting.jstest/src/org/eclipse/rap/clientscripting/internal/ClientScriptingResourcesContribution.java +++ b/tests/org.eclipse.rap.clientscripting.jstest/src/org/eclipse/rap/clientscripting/internal/ClientScriptingResourcesContribution.java @@ -29,8 +29,9 @@ public class ClientScriptingResourcesContribution implements TestContribution { "EventBinding.js", "EventBindingAdapter.js", "EventProxy.js", - "WidgetProxy.js", - "ScriptHandler.js" + "WidgetProxyFactory.js", + "ScriptHandler.js", + "init.js" }; public String getName() { diff --git a/tests/org.eclipse.rap.clientscripting.jstest/src/org/eclipse/rap/clientscripting/internal/ClientScriptingTestContribution.java b/tests/org.eclipse.rap.clientscripting.jstest/src/org/eclipse/rap/clientscripting/internal/ClientScriptingTestContribution.java index 00d30ef..e87ba40 100644 --- a/tests/org.eclipse.rap.clientscripting.jstest/src/org/eclipse/rap/clientscripting/internal/ClientScriptingTestContribution.java +++ b/tests/org.eclipse.rap.clientscripting.jstest/src/org/eclipse/rap/clientscripting/internal/ClientScriptingTestContribution.java @@ -24,7 +24,7 @@ public class ClientScriptingTestContribution implements TestContribution { "Function_Test.js", "EventBinding_Test.js", "EventProxy_Test.js", - "WidgetProxy_Test.js", + "WidgetProxyFactory_Test.js", "Script_Test.js", }; |