Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* Copyright: 2004, 2012 1&1 Internet AG, Germany, http://www.1und1.de,
* and EclipseSource
*
* 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:
* 1&1 Internet AG and others - original API and implementation
* EclipseSource - adaptation for the Eclipse Rich Ajax Platform
******************************************************************************/
/**
* This class is one of the most important parts of qooxdoo's
* object-oriented features.
*
* Its {@link #define} method is used to create qooxdoo classes.
*
* Each instance of a class defined by {@link #define} has
* the following keys attached to the constructor and the prototype:
*
*
*
classname
The fully-qualified name of the class (e.g. "qx.ui.core.Widget").
*
basename
The namespace part of the class name (e.g. "qx.ui.core").
*
constructor
A reference to the constructor of the class.
*
superclass
A reference to the constructor of the super class.
*
*
* Each method may access static members of the same class by using
* this.self(arguments) ({@link rwt.qx.Object#self}):
*
*
* Each overriding method may call the overridden method by using
* this.base(arguments [, ...]) ({@link rwt.qx.Object#base}). This is also true for calling
* the constructor of the superclass.
*
*
* @type static
* @param name {String} Name of the class
* @param config {Map ? null} Class definition structure. The configuration map has the following keys:
*
*
Name
Type
Description
*
type
String
* Type of the class. Valid types are "abstract", "static" and "singleton".
* If unset it defaults to a regular non-static class.
*
*
extend
Class
The super class the current class inherits from.
*
implement
Interface | Interface[]
Single interface or array of interfaces the class implements.
*
include
Mixin | Mixin[]
Single mixin or array of mixins, which will be merged into the class.
*
construct
Function
The constructor of the class.
*
statics
Map
Map of static members of the class.
*
properties
Map
Map of property definitions. For a description of the format of a property definition see
* {@link rwt.qx.Property} or the legacy version {@link rwt.qx.LegacyProperty}.
*
members
Map
Map of instance members of the class.
*
settings
Map
Map of settings for this class. For a description of the format of a setting see
* {@link rwt.qx.Setting}.
*
variants
Map
Map of settings for this class. For a description of the format of a setting see
* {@link rwt.util.Variant}
*
events
Map
* Map of events the class fires. The keys are the names of the events and the values are the
* corresponding event type class names.
*
*
defer
Function
Function that is called at the end of processing the class declaration. It allows access to the declared statics, members and properties.
*
destruct
Function
The destructor of the class.
*
* @return {void}
* @throws TODOC
*/
define : function( name, config ) {
if( this._stopLoading ) {
throw new Error( "Stop loading " + name );
}
try {
config = this._normalizeConfig( config );
this.__validateConfig( name, config );
var clazz;
if( !config.extend ) {
clazz = config.statics || {};
} else {
if( !config.construct ) {
config.construct = this.__createDefaultConstructor();
}
clazz = this.__wrapConstructor(config.construct, name, config.type);
if( config.statics ) {
var key;
for( var i = 0, a = rwt.util.Objects.getKeys( config.statics ), l = a.length; i < l; i++ ) {
key = a[ i ];
clazz[ key ] = config.statics[ key ];
}
}
}
var basename = this.createNamespace( name, clazz, false );
clazz.name = clazz.classname = name;
clazz.basename = basename;
this.__registry[ name ] = clazz;
// Attach toString
if( !clazz.hasOwnProperty( "toString" ) ) {
clazz.toString = this.genericToString;
}
if( config.extend ) {
var superproto = config.extend.prototype;
var Helper = this.__createEmptyFunction();
Helper.prototype = superproto;
var proto = new Helper();
clazz.prototype = proto;
proto.name = proto.classname = name;
proto.basename = basename;
config.construct.base = clazz.superclass = config.extend;
config.construct.self = clazz.constructor = proto.constructor = clazz;
if( config.destruct ) {
clazz.$$destructor = config.destruct;
}
var that = this;
clazz.$$initializer = function() {
//console.log( "init " + name );
if( config.properties ) {
that.__addProperties(clazz, config.properties, true);
}
if( config.members ) {
that.__addMembers(clazz, config.members, true, true, false);
}
if( config.events ) {
that.__addEvents(clazz, config.events, true);
}
if( config.include ) {
for (var i=0, l=config.include.length; iWARNING: You may break working classes and features.
*
* @type static
* @param clazz {Class} An existing class which should be modified by including the mixin.
* @param mixin {Mixin} The mixin to be included.
*/
patch : function(clazz, mixin)
{
rwt.qx.Class.__addMixin(clazz, mixin, true);
},
/**
* Whether a class is a direct or indirect sub class of another class,
* or both classes coincide.
*
* @type static
* @param clazz {Class} the class to check.
* @param superClass {Class} the potential super class
* @return {Boolean} whether clazz is a sub class of superClass.
*/
isSubClassOf : function(clazz, superClass)
{
if (!clazz) {
return false;
}
if (clazz == superClass) {
return true;
}
if (clazz.prototype instanceof superClass) {
return true;
}
return false;
},
/**
* Returns the definition of the given property. Returns null
* if the property does not exist.
*
* TODO: Correctly support refined properties?
*
* @type member
* @param clazz {Class} class to check
* @param name {String} name of the event to check for
* @return {Map|null} whether the object support the given event.
*/
getPropertyDefinition : function(clazz, name)
{
while (clazz)
{
if (clazz.$$properties && clazz.$$properties[name]) {
return clazz.$$properties[name];
}
clazz = clazz.superclass;
}
return null;
},
/**
* Returns the class or one of its superclasses which contains the
* declaration for the given property in its class definition. Returns null
* if the property is not specified anywhere.
*
* @param clazz {Class} class to look for the property
* @param name {String} name of the property
* @return {Class | null} The class which includes the property
*/
getByProperty : function(clazz, name)
{
while (clazz)
{
if (clazz.$$properties && clazz.$$properties[name]) {
return clazz;
}
clazz = clazz.superclass;
}
return null;
},
/**
* Whether a class has the given property
*
* @type member
* @param clazz {Class} class to check
* @param name {String} name of the property to check for
* @return {Boolean} whether the class includes the given property.
*/
hasProperty : function(clazz, name) {
return !!this.getPropertyDefinition(clazz, name);
},
/**
* Returns the event type of the given event. Returns null if
* the event does not exist.
*
* @type member
* @param clazz {Class} class to check
* @param name {String} name of the event
* @return {Map|null} Event type of the given event.
*/
getEventType : function(clazz, name)
{
var clazz = clazz.constructor;
while (clazz.superclass)
{
if (clazz.$$events && clazz.$$events[name] !== undefined) {
return clazz.$$events[name];
}
clazz = clazz.superclass;
}
return null;
},
/**
* Whether a class supports the given event type
*
* @type member
* @param clazz {Class} class to check
* @param name {String} name of the event to check for
* @return {Boolean} whether the class supports the given event.
*/
supportsEvent : function(clazz, name) {
return !!this.getEventType(clazz, name);
},
/**
* Whether a class directly includes a mixin.
*
* @type static
* @param clazz {Class} class to check
* @param mixin {Mixin} the mixin to check for
* @return {Boolean} whether the class includes the mixin directly.
*/
hasOwnMixin: function(clazz, mixin) {
return clazz.$$includes && clazz.$$includes.indexOf(mixin) !== -1;
},
/**
* Returns the class or one of its superclasses which contains the
* declaration for the given mixin. Returns null if the mixin is not
* specified anywhere.
*
* @param clazz {Class} class to look for the mixin
* @param mixin {Mixin} mixin to look for
* @return {Class | null} The class which directly includes the given mixin
*/
getByMixin : function(clazz, mixin)
{
var list, i, l;
while (clazz)
{
if (clazz.$$includes)
{
list = clazz.$$flatIncludes;
for (i=0, l=list.length; i 0 ) {
target = inits.pop();
target.$$initializer();
delete target.$$initializer;
}
}
},
/**
* Generate a wrapper of the original class constructor in order to enable
* some of the advanced OO features (e.g. abstract class, singleton, mixins)
*
* @param construct {Function} the original constructor
* @param name {String} name of the class
* @param type {String} the user specified class type
*/
__wrapConstructor : function(construct, name, type)
{
var init = this.__initializeClass;
var wrapper = function() {
// We can access the class/statics using arguments.callee
var clazz=arguments.callee.constructor;
init( clazz );
// Attach local properties
if( !clazz.$$propertiesAttached ) {
rwt.qx.Property.attach( clazz );
}
// Execute default constructor
var retval=clazz.$$original.apply(this,arguments);
// Initialize local mixins
if(clazz.$$includes){var mixins=clazz.$$flatIncludes;
for(var i=0,l=mixins.length;i