r3-legacy/src/r3-a-3-api-component.js

68 lines
1.4 KiB
JavaScript

/**
* API Component Interface - Do not construct objects of this type directly
* @param parent
* @param id
* @param name
* @param register
* @param selected
* @constructor
*/
R3.API.Component = function(
parent,
id,
name,
register,
selected
) {
if (R3.Utils.UndefinedOrNull(parent)) {
parent = null;
}
this.parent = parent;
if (R3.Utils.UndefinedOrNull(id)) {
id = R3.Utils.RandomId();
}
this.id = id;
this.componentType = R3.GetComponentType(this);
if (R3.Utils.UndefinedOrNull(name)) {
name = R3.Component.GetComponentFriendlyName(this.componentType) + ' (' + this.id + ')';
}
this.name = name;
if (R3.Utils.UndefinedOrNull(register)) {
register = true;
}
this.register = register;
if (R3.Utils.UndefinedOrNull(selected)) {
selected = false;
}
this.selected = selected;
};
R3.API.Component.prototype.constructor = R3.API.Component;
/**
* Wrapper for R3.Utils.GetFirstParent
* @param constructor
* @returns {*}
*/
R3.API.Component.prototype.getFirstParent = function(constructor) {
return R3.Utils.GetFirstParent(this, constructor);
};
/**
* Wrapper for R3.Utils.GetParent
* @param property
* @param index
* @param constructor
* @returns {*}
*/
R3.API.Component.getParent = function(property, index, constructor) {
return R3.Utils.GetParent(this, property, index, constructor);
};