public abstract class BaseComponent extends Object implements IElementIdentifier
| Modifier and Type | Class and Description |
|---|---|
static class |
BaseComponent.SubComponent
Reference to a subcomponent.
|
| Constructor and Description |
|---|
BaseComponent() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_attach(Page page)
Attach this component and its children to their owning page.
|
protected void |
_initProps(Map<String,Object> props)
Initialize properties to be passed to widget factory.
|
void |
addChild(BaseComponent child) |
void |
addChild(BaseComponent child,
BaseComponent before) |
void |
addChild(BaseComponent child,
int index) |
void |
addChildren(Collection<? extends BaseComponent> children) |
void |
addEventForward(Class<? extends Event> eventClass,
BaseComponent target,
String forwardType) |
void |
addEventForward(String eventType,
BaseComponent target,
String forwardType) |
void |
addEventListener(Class<? extends Event> eventClass,
IEventListener eventListener) |
void |
addEventListener(Class<? extends Event> eventClass,
IEventListener eventListener,
boolean syncToClient) |
void |
addEventListener(String eventType,
IEventListener eventListener) |
void |
addEventListener(String eventType,
IEventListener eventListener,
boolean syncToClient) |
protected void |
afterAddChild(BaseComponent child) |
protected void |
afterRemoveChild(BaseComponent child) |
protected void |
afterSetParent(BaseComponent oldParent) |
protected boolean |
areEqual(Object obj1,
Object obj2)
Returns true if two objects are equal, allowing for null values.
|
protected void |
beforeAddChild(BaseComponent child) |
protected void |
beforeRemoveChild(BaseComponent child) |
protected void |
beforeSetParent(BaseComponent newParent) |
void |
bringToFront()
Override to cause a UI component to be brought to the forefront of the UI.
|
protected <T> T |
defaultify(T value,
T deflt)
Returns the input value if it is not null, or the default value otherwise.
|
void |
destroy() |
void |
destroyChildren() |
void |
detach() |
void |
finalize() |
Object |
findAttribute(String name) |
BaseComponent |
findByName(String name)
Looks up a component by its name within the namespace occupied by this component.
|
<T extends BaseComponent> |
findByName(String name,
Class<T> type)
Looks up a component of the specified type by its name within the namespace occupied by this
component.
|
BaseComponent |
findChildByData(Object data)
Find the first child containing the specified data object.
|
BaseComponent |
findChildByLabel(String label)
Find the first child whose label matches the specified value.
|
void |
fireEvent(Event event)
Send an event to this component's registered event listeners.
|
void |
fireEvent(String eventType) |
<T extends BaseComponent> |
getAncestor(Class<T> type)
Return first ancestor that is of the requested type.
|
<T> T |
getAncestor(Class<T> type,
boolean includeSelf)
Return first ancestor that is of the requested type.
|
Object |
getAttribute(String name) |
<T> T |
getAttribute(String name,
Class<T> clazz) |
<T> T |
getAttribute(String name,
T dflt) |
Map<String,Object> |
getAttributes() |
<T extends BaseComponent> |
getChild(Class<T> type)
Return the first child of the requested type.
|
BaseComponent |
getChildAt(int index)
Returns the child at the specified index.
|
int |
getChildCount()
Returns the number of children.
|
int |
getChildCount(Class<? extends BaseComponent> type) |
List<BaseComponent> |
getChildren() |
<T extends BaseComponent> |
getChildren(Class<T> type) |
protected String |
getContent() |
Object |
getData()
Returns the data object associated with the component.
|
<T> T |
getData(Class<T> type)
Returns the data object associated with the component if it is of the specified type;
otherwise returns null.
|
ComponentDefinition |
getDefinition() |
BaseComponent |
getFirstChild()
Returns the first child of this component.
|
String |
getId() |
int |
getIndex()
Returns the index of this child within its parent.
|
BaseComponent |
getLastChild()
Returns the last child of this component.
|
String |
getName() |
BaseComponent |
getNamespace()
Returns the namespace to which this component belongs.
|
BaseComponent |
getNextSibling()
Return the next sibling for this component.
|
Page |
getPage()
Returns the page to which this component belongs.
|
BaseComponent |
getParent() |
BaseComponent |
getPreviousSibling()
Return the previous sibling for this component.
|
BaseComponent |
getRoot()
Return the root component of this component's hierarchy.
|
boolean |
hasAttribute(String name) |
boolean |
hasEventListener(Class<? extends Event> eventClass) |
boolean |
hasEventListener(String eventType) |
void |
invoke(IElementIdentifier id,
String function,
Object... args)
Invoke a widget or sub-widget function on the client.
|
void |
invoke(String function,
Object... args)
Invoke a widget function on the client.
|
void |
invokeIfAttached(String function,
Object... args)
Invoke a widget function on the client only if attached to a page.
|
boolean |
isAncestor(BaseComponent comp)
Returns true if this component is the same as or an ancestor of the specified component.
|
boolean |
isContainer()
Returns true if this component may contain children.
|
protected boolean |
isContentSynced()
Returns true if the content property is to be synced to the client.
|
boolean |
isDead() |
boolean |
isNamespace()
Returns true if this component is a namespace boundary.
|
void |
notifyAncestors(Event event,
boolean includeThis)
Send an event to all the ancestors of this component.
|
protected String |
nullify(String value)
Converts empty string to null.
|
protected void |
onAttach(Page page) |
protected void |
onDestroy() |
Object |
removeAttribute(String name) |
void |
removeChild(BaseComponent child) |
void |
removeEventForward(Class<? extends Event> eventClass,
BaseComponent target,
String forwardType) |
void |
removeEventForward(String eventType,
BaseComponent target,
String forwardType) |
void |
removeEventListener(Class<? extends Event> eventClass,
IEventListener eventListener) |
void |
removeEventListener(Class<? extends Event> eventClass,
IEventListener eventListener,
boolean syncToClient) |
void |
removeEventListener(String eventType,
IEventListener eventListener) |
void |
removeEventListener(String eventType,
IEventListener eventListener,
boolean syncToClient) |
Object |
setAttribute(String name,
Object value) |
protected void |
setContent(String content) |
protected void |
setContentSynced(boolean contentSynced)
Set to true if the content property is to be synced to the client.
|
void |
setData(Object data)
Sets the data object to be associated with the component.
|
void |
setIndex(int index)
Moves this child to the specified index within its parent.
|
void |
setName(String name) |
void |
setParent(BaseComponent parent) |
BaseComponent.SubComponent |
sub(String subId)
Returns a subcomponent identifier.
|
void |
swapChildren(int index1,
int index2) |
void |
sync(String state,
Object value)
Synchronize a state value to the client.
|
String |
toString()
Returns basic information about this component for display purposes.
|
protected String |
trimify(String value)
Trims whitespace from a string and nullifies it.
|
protected void |
validate() |
protected static void |
validate(BaseComponent comp) |
protected void |
validateChild(BaseComponent child) |
void |
validateIsChild(BaseComponent child) |
protected boolean |
validatePage(Page page)
Validates that the specified page can be an owner of this component.
|
protected boolean |
validateParent(BaseComponent parent) |
void |
wireController(Object controller)
Wires a controller's annotated components and event handlers, using this component to resolve
name references.
|
protected static void validate(BaseComponent comp)
public ComponentDefinition getDefinition()
@Component.PropertyGetter(value="name") public String getName()
@Component.PropertySetter(value="name") public void setName(String name)
@Component.PropertyGetter(value="id") public String getId()
getId in interface IElementIdentifierpublic void detach()
public void destroy()
public void finalize()
throws Throwable
public void destroyChildren()
protected void onDestroy()
public boolean isDead()
protected void validate()
public BaseComponent getParent()
protected boolean validateParent(BaseComponent parent)
public void setParent(BaseComponent parent)
public <T> T getAttribute(String name, T dflt)
public boolean hasAttribute(String name)
public void validateIsChild(BaseComponent child)
protected void validateChild(BaseComponent child)
public void addChild(BaseComponent child)
public void addChild(BaseComponent child, int index)
public void addChild(BaseComponent child, BaseComponent before)
public void addChildren(Collection<? extends BaseComponent> children)
public void removeChild(BaseComponent child)
public void swapChildren(int index1,
int index2)
protected void beforeSetParent(BaseComponent newParent)
protected void afterSetParent(BaseComponent oldParent)
protected void beforeAddChild(BaseComponent child)
protected void afterAddChild(BaseComponent child)
protected void beforeRemoveChild(BaseComponent child)
protected void afterRemoveChild(BaseComponent child)
public List<BaseComponent> getChildren()
public <T extends BaseComponent> Iterable<T> getChildren(Class<T> type)
public int getChildCount()
public int getChildCount(Class<? extends BaseComponent> type)
public boolean isContainer()
public <T extends BaseComponent> T getChild(Class<T> type)
T - The type of child sought.type - The type of child sought.public BaseComponent getChildAt(int index)
index - The index of the child sought.public BaseComponent getFirstChild()
public BaseComponent getLastChild()
public BaseComponent getRoot()
public <T extends BaseComponent> T getAncestor(Class<T> type)
T - The type of ancestor sought.type - The type of ancestor sought.public <T> T getAncestor(Class<T> type, boolean includeSelf)
T - Expected return type.type - The type of ancestor sought.includeSelf - If true, include this component in the search.public boolean isAncestor(BaseComponent comp)
comp - Component to test.public int getIndex()
public void setIndex(int index)
index - New index for this child.public BaseComponent getNextSibling()
public BaseComponent getPreviousSibling()
public BaseComponent getNamespace()
@Component.PropertyGetter(value="namespace") public boolean isNamespace()
public Page getPage()
protected void onAttach(Page page)
protected boolean validatePage(Page page)
page - The page to be tested.protected void _attach(Page page)
page - Page to receive this component.protected void _initProps(Map<String,Object> props)
props - Properties for widget factory.public void sync(String state, Object value)
state - The state name.value - The state value.public void invoke(String function, Object... args)
function - The name of the function.args - Arguments for the function.public void invokeIfAttached(String function, Object... args)
function - The name of the function.args - Arguments for the function.public void invoke(IElementIdentifier id, String function, Object... args)
id - The id of the widget or sub-widget.function - The name of the function.args - Arguments for the function.public BaseComponent findByName(String name)
name - Component name or path. "^" in path means parent namespace.public <T extends BaseComponent> T findByName(String name, Class<T> type)
T - The expected return type.name - Component name or path.type - Expected return type.public BaseComponent findChildByData(Object data)
data - The data object to find.public BaseComponent findChildByLabel(String label)
label - The label to find.public BaseComponent.SubComponent sub(String subId)
subId - The sub identifier.public void addEventForward(String eventType, BaseComponent target, String forwardType)
public void addEventForward(Class<? extends Event> eventClass, BaseComponent target, String forwardType)
public void removeEventForward(String eventType, BaseComponent target, String forwardType)
public void removeEventForward(Class<? extends Event> eventClass, BaseComponent target, String forwardType)
public boolean hasEventListener(String eventType)
public void addEventListener(String eventType, IEventListener eventListener)
public void addEventListener(Class<? extends Event> eventClass, IEventListener eventListener)
public void addEventListener(String eventType, IEventListener eventListener, boolean syncToClient)
public void addEventListener(Class<? extends Event> eventClass, IEventListener eventListener, boolean syncToClient)
public void removeEventListener(String eventType, IEventListener eventListener)
public void removeEventListener(Class<? extends Event> eventClass, IEventListener eventListener)
public void removeEventListener(String eventType, IEventListener eventListener, boolean syncToClient)
public void removeEventListener(Class<? extends Event> eventClass, IEventListener eventListener, boolean syncToClient)
public void fireEvent(String eventType)
public void fireEvent(Event event)
event - Event to send.public void notifyAncestors(Event event, boolean includeThis)
stopPropagation method on the event.event - Event to send.includeThis - If true, include this component in the recipient chain.@Component.PropertySetter(value="controller", defer=true) public void wireController(Object controller)
controller - The controller to wire. If a string, is assumed to be the name of the
controller's implementation class in which case an instance of that class is
created.public void bringToFront()
protected String nullify(String value)
value - String value.protected String trimify(String value)
value - String value.protected <T> T defaultify(T value,
T deflt)
T - The argument class.value - The input value.deflt - The default value.protected boolean areEqual(Object obj1, Object obj2)
obj1 - First object to compare.obj2 - Second object to compare.@Component.PropertyGetter(value="data") public Object getData()
public <T> T getData(Class<T> type)
T - Expected return type.type - The expected type.@Component.PropertySetter(value="data") public void setData(Object data)
data - The data object.@Component.PropertyGetter(value="#text") protected String getContent()
@Component.PropertySetter(value="#text") protected void setContent(String content)
protected boolean isContentSynced()
protected void setContentSynced(boolean contentSynced)
contentSynced - If true, the content property is synced to the client.Copyright © 2017 Regenstrief Center for Biomedical Informatics. All rights reserved.