LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.view
Class LyComponent

java.lang.Object
  extended by leon.view.LyComponent
Direct Known Subclasses:
LyAxis, LyCaption, LyCell, LyChartValue, LyCharType, LyColumn, LyCommands, LyConstraintBase, LyDay, LyEntry, LyFieldItem, LyFooter, LyFooters, LyHeader, LyHeadersBase, LyImage, LyInterval, LyIntervals, LyItem, LyLayout, LyLine, LyLink, LyListOption, LyMapContent, LyMapLink, LyMapNode, LyMapRegionBase, LyMenuBarBase, LyMenuBase, LyMessage, LyMessages, LyOption, LyPeriod, LyPointBase, LyPolygon, LyPopupMenuBase, LyRowBase, LyRowsBase, LySelectItem, LyTabBase, LyTip, LyTitleBarBase, LyToolBarBase, LyTreeNode, LyView

public abstract class LyComponent
extends java.lang.Object

This class implements the generic behavior of the classes of the viewer package. LyComponents are created when parsing the XML tree describing the graphical objects that must be shown to the user. LyComponent implements LyActionTransmitter methods, but the interface is NOT declared. Inherited classes just have to indicate that they implement this interface to benefit from transmission features.


Nested Class Summary
static class LyComponent.EventType
          Type of events available on abstract components.
 
Field Summary
static java.lang.String __VERSION
           
static int _nbComponents
           
static boolean INIT_RESOURCE_ID
          Boolean used for activating the search for id based If set to false, the initForId method for a component won't be called.
static java.lang.String INTERNAL_ID_SEP
          Separator used in internal ids.
static boolean REWRITING_MODE
          Boolean used for activating raw XML writing of components This boolean inhibits attributes initialization from properties and initFromModel.
static java.lang.String SEP_ID
          Id for sep components.
 
Constructor Summary
LyComponent()
          Default constructor.
 
Method Summary
static void addComponent(LyComponent component)
          Method to register a component in the association table.
 void addData(java.lang.String name, java.lang.String value)
          Add data to this component.
 void addEventFunction(LyComponent.EventType eventType, java.lang.String function)
          Add a function to the list of functions that must be called for a given event type.
 void clearChildrenBounds()
          Clears the content of the internal cache containing sub components sizes and positions.
abstract  LyComponent cloneComponent()
          Method for cloning a component.
 void free()
          Free this component.
 void freeze(boolean status)
          Freeze or unfreeze current view.
 int[] getBounds(LyComponent parentComponent)
          Returns the position and size of current component relatively to given component.
 LyComponent getChild(int i)
          Returns child component of index i.
 int getChildCount()
          Returns child component count.
 LyComponent getChildFromCache(java.lang.String id)
          Add the given id / component from child cache.
 int[] getChildrenBounds(LyComponent childrenComponent)
          Returns the position and size of given sub component relatively to current component.
 LyComponent getComponent(java.lang.String id)
          Retrieve a node from a view by its id.
 LyComponent getComponent(java.lang.String id, boolean skipCurrent)
          Retrieve a node from a view by its id.
 LyComponent getComponent(java.lang.String id, boolean skipCurrent, boolean useInternalId)
          Retrieve a node from a view by its id.
 LyComponent getComponent(java.lang.String id, java.lang.Class<?> componentClass)
          Retrieve a node from a view by its id.
 void getComponent(java.lang.String id, java.util.Vector<LyComponent> result)
          Retrieve nodes from a view by their ids.
 LyComponent getComponentAt(int[] position, int hMargin, int vMargin)
          Returns the component at given position with an error margin.
<T extends LyComponent>
T
getComponentAt(int[] position, int hMargin, int vMargin, java.lang.Class<T> componentClass)
          Returns the component at given position with an error margin.
static LyComponent getComponentByInternalId(java.lang.String internalId)
          Method used to get a component by its internal id.
 LyComponent getComponentByLabel(java.lang.String label)
          Retrieve a node from a view.
<T> void
getComponents(java.lang.Class<T> compClass, java.util.Vector<T> result)
          Retrieve nodes from a view by their class.
 LyComponent getComponentWithModel(LyComponent model)
          Retrieve a child component from a model.
 java.lang.String getData(java.lang.String name)
          Get data corresponding to the given data name.
 java.util.Hashtable<java.lang.String,java.lang.String> getDatas()
          Gets datas.
 LyEnvironment getEnvironment()
          Returns the component environment.
 java.lang.String getEventFunctions(LyComponent.EventType eventType, char sep)
          Return the list of functions that must be called for a given event type.
 java.lang.String getId()
          Gets component id (may be null).
 java.lang.String getIdCode()
          Internal code used as identifier for web components.
 java.lang.String getInternalId()
          Returns the internal id of this component (may be null).
 LyViewComponent getInternalView()
          Internal view implementation.
 LyViewComponent getInternalView(boolean build)
          Get internal view implementation.
 java.lang.Object getLock()
          Get a lock to prevent concurrent access Returns the one provided by the internal view implementation, otherwise returns this.
 LyComponent getModel()
          Gets model of this component.
 LyComponent getParent()
          Get parent component.
 LyArea getParentArea()
          Retrieve closest area that contains this component.
 LyForm getParentForm()
          Retrieve closest form that contains this component.
 java.lang.String getParentFormFieldId()
          Retrieve closest formField id that contains this component.
 LySplitter getParentSplitter()
          Retrieve closest splitter that contains this component.
 LySplitter getParentSplitter(LyComponent topComponent)
          Retrieve closest splitter that contains this component.
 LyTab getParentTab()
          Retrieve closest tab that contains this component.
 LyTab getParentTab(LyComponent topComponent)
          Retrieve closest tab that contains this component.
 LyTabs getParentTabs()
          Retrieve closest tabs that contains this component.
 LyTabs getParentTabs(LyComponent topComponent)
          Retrieve closest tabs that contains this component.
 LyView getParentView()
          Retrieve closest frame or dialog that contains this component.
 java.lang.String getRootController()
          Retrieves controller id for the component.
 LySetVisibleInterface getSetVisibleParent()
          Retrieve closest parent that implements the LySetVisibleInterface interface.
 java.lang.String getTag()
          Gets tag name corresponding to this component.
 LyViewManager getViewManager()
          Gets current view manager.
 boolean isFreed()
          Checks if this component was freed.
 boolean isFreeing()
          Checks if this component is freeing.
 void registerChildrenBounds()
          Registers in the internal cache position ans size of all sub components of current component.
static void removeComponent(LyComponent component)
          Method to remove a component from the association table.
 void reset()
          Reset this component.
 void resetChildrenCache()
          Empty children cache.
 void resetEventFunctions(LyComponent.EventType eventType)
          Remove all the functionc to the list of functions that must be called for a given event type, even the generic ones.
 void setDatas(java.util.Hashtable<java.lang.String,java.lang.String> datas)
          Sets datas.
 void setInternalView(LyViewComponent viewComponent)
          Reserved for internal use, do not use.
 void setVisible(boolean status)
          Shows or hides the component/node.
 boolean useEventDefaultFunction(LyComponent.EventType eventType)
          Indicates whether the default Leonardi function must be called for the given type of event.
 void writeXml(java.io.PrintWriter pw)
          Write XML description corresponding to this component.
abstract  void writeXml(java.io.PrintWriter pw, boolean debug)
          Write XML description corresponding to this component.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

SEP_ID

public static final java.lang.String SEP_ID
Id for sep components.


REWRITING_MODE

public static boolean REWRITING_MODE
Boolean used for activating raw XML writing of components This boolean inhibits attributes initialization from properties and initFromModel. Reserved for internal use.


INIT_RESOURCE_ID

public static boolean INIT_RESOURCE_ID
Boolean used for activating the search for id based If set to false, the initForId method for a component won't be called. Reserved for internal use.


INTERNAL_ID_SEP

public static java.lang.String INTERNAL_ID_SEP
Separator used in internal ids.


_nbComponents

public static int _nbComponents
Constructor Detail

LyComponent

public LyComponent()
Default constructor. Initialization is done with the init method.

Method Detail

addComponent

public static void addComponent(LyComponent component)
Method to register a component in the association table. For internal use only (in record or replay mode).


getComponentByInternalId

public static LyComponent getComponentByInternalId(java.lang.String internalId)
Method used to get a component by its internal id. For internal use only (in record or replay mode).


removeComponent

public static void removeComponent(LyComponent component)
Method to remove a component from the association table. For internal use only (in record or replay mode).


cloneComponent

public abstract LyComponent cloneComponent()
Method for cloning a component.


getInternalId

public java.lang.String getInternalId()
Returns the internal id of this component (may be null).


getTag

public java.lang.String getTag()
Gets tag name corresponding to this component.

Returns:
The corresponding tag name.

getId

public java.lang.String getId()
Gets component id (may be null).


getIdCode

public java.lang.String getIdCode()
Internal code used as identifier for web components.

Returns:
Internal code as a string.

getEnvironment

public LyEnvironment getEnvironment()
Returns the component environment.


getViewManager

public final LyViewManager getViewManager()
Gets current view manager.

Returns:
The current view manager.

getComponent

public final LyComponent getComponent(java.lang.String id)
Retrieve a node from a view by its id. Access is made from the root view only.

Parameters:
id - unique id of the node in the view.
Returns:
the node if found, null otherwise.

getComponent

public LyComponent getComponent(java.lang.String id,
                                java.lang.Class<?> componentClass)
Retrieve a node from a view by its id. Access is made from the root view only.

Parameters:
id - unique id of the node in the view.
componentClass - expected class
Returns:
the node if found and if class of node matches expected class, null otherwise.

getComponent

public final LyComponent getComponent(java.lang.String id,
                                      boolean skipCurrent)
Retrieve a node from a view by its id. Access is made from the root view only.

Parameters:
id - unique id of the node in the view.
Returns:
the node if found, null otherwise.

getComponent

public LyComponent getComponent(java.lang.String id,
                                boolean skipCurrent,
                                boolean useInternalId)
Retrieve a node from a view by its id. Access is made from the root view only.

Parameters:
id - unique id of the node in the view.
skipCurrent - indicates whether current component must be tested or not.
useInternalId - indicates whether internal identifiers may be used to retrieve node with given id.
Returns:
the node if found, null otherwise.

getComponent

public void getComponent(java.lang.String id,
                         java.util.Vector<LyComponent> result)
Retrieve nodes from a view by their ids. Note that this method does not use the component cache.

Parameters:
id - id of the nodes in the view.
result - The vector containing all the components which match the id.

getComponents

public <T> void getComponents(java.lang.Class<T> compClass,
                              java.util.Vector<T> result)
Retrieve nodes from a view by their class. Note that this method does not use the component cache.

Parameters:
compClass - class of the nodes in the view.
result - The vector containing all the components which belongs to the given class.

getComponentByLabel

public LyComponent getComponentByLabel(java.lang.String label)
Retrieve a node from a view. Access is made from the root view only.

Parameters:
label - label of the node in the view.
Returns:
the node if found, null otherwise.

getComponentWithModel

public LyComponent getComponentWithModel(LyComponent model)
Retrieve a child component from a model.

Parameters:
model - Model of the searched component.
Returns:
The child found or null if not found.

getInternalView

public final LyViewComponent getInternalView()
Internal view implementation. The nature of this object depends on the requested target (win, swing, html...) and is accessed through the setinterface package.


getInternalView

public LyViewComponent getInternalView(boolean build)
Get internal view implementation.

Parameters:
build - Indicates if this representation should be built if it doesn't exist.

setInternalView

public void setInternalView(LyViewComponent viewComponent)
Reserved for internal use, do not use.


getChild

public LyComponent getChild(int i)
Returns child component of index i.

Parameters:
i - index of component to get.
Returns:
child component of index i.

getChildCount

public int getChildCount()
Returns child component count.


getParent

public final LyComponent getParent()
Get parent component.

Returns:
parent component.

getModel

public final LyComponent getModel()
Gets model of this component.

Returns:
Model of this component if component was built from template or cloneComponent.

getBounds

public int[] getBounds(LyComponent parentComponent)
Returns the position and size of current component relatively to given component.

Parameters:
parentComponent - the component used to compute relative position of current component. If null, position of current component is computed with the top-left corner of the screen as the origin.
Returns:
an array of 4 integers (x position, y position, width, height) representing the position and size of current component.

getChildrenBounds

public int[] getChildrenBounds(LyComponent childrenComponent)
Returns the position and size of given sub component relatively to current component.

Parameters:
childrenComponent - the sub component whose relative position must be returned.
Returns:
an array of 4 integers (x position, y position, width, height) representing the position and size of given sub component.

registerChildrenBounds

public void registerChildrenBounds()
Registers in the internal cache position ans size of all sub components of current component.


clearChildrenBounds

public void clearChildrenBounds()
Clears the content of the internal cache containing sub components sizes and positions.


getComponentAt

public final LyComponent getComponentAt(int[] position,
                                        int hMargin,
                                        int vMargin)
Returns the component at given position with an error margin.

Parameters:
position - the position of the component we want to retrieve.
hMargin - the horizontal margin used to retrieve component at given position.
vMargin - the vertical margin used to retrieve component at given position.
Returns:
the component at given x and y position, or null if no component was found.

getComponentAt

public <T extends LyComponent> T getComponentAt(int[] position,
                                                int hMargin,
                                                int vMargin,
                                                java.lang.Class<T> componentClass)
Returns the component at given position with an error margin.

Parameters:
position - the position of the component we want to retrieve.
hMargin - the horizontal margin used to retrieve component at given position.
vMargin - the vertical margin used to retrieve component at given position.
componentClass - expected class
Returns:
the component at given x and y position, or null if no component was found.

resetChildrenCache

public void resetChildrenCache()
Empty children cache.
This method clears the content of the children caches. It must be called only when caches must be cleared for a good reason because it cancels cache optimization for this component.


getChildFromCache

public LyComponent getChildFromCache(java.lang.String id)
Add the given id / component from child cache.

Parameters:
id - to search in local cache.
Returns:
child if found or null

getRootController

public java.lang.String getRootController()
Retrieves controller id for the component. If the component has no controller, search recursively for the parent's controller.

Returns:
the id of the root controller for this component.

writeXml

public final void writeXml(java.io.PrintWriter pw)
Write XML description corresponding to this component.

Parameters:
pw - Print writer where the description is written.

writeXml

public abstract void writeXml(java.io.PrintWriter pw,
                              boolean debug)
Write XML description corresponding to this component.

Parameters:
pw - Print writer where the description is written.
debug - True if debug mode (full dump includinf optional ids and references of controllers).

getSetVisibleParent

public LySetVisibleInterface getSetVisibleParent()
Retrieve closest parent that implements the LySetVisibleInterface interface.

Returns:
closest parent that implements the LySetVisibleInterface interface.

getParentView

public LyView getParentView()
Retrieve closest frame or dialog that contains this component.

Returns:
closest frame or dialog that contains this component.

getParentArea

public LyArea getParentArea()
Retrieve closest area that contains this component.

Returns:
closest area that contains this component.

getParentForm

public LyForm getParentForm()
Retrieve closest form that contains this component.

Returns:
closest form that contains this component.

getParentTabs

public final LyTabs getParentTabs()
Retrieve closest tabs that contains this component.

Returns:
closest tabs that contains this component.

getParentTabs

public LyTabs getParentTabs(LyComponent topComponent)
Retrieve closest tabs that contains this component. Don't search after a fixed limit.

Parameters:
topComponent - limit of the search
Returns:
closest tabs that contains this component.

getParentSplitter

public final LySplitter getParentSplitter()
Retrieve closest splitter that contains this component.

Returns:
closest splitter that contains this component.

getParentSplitter

public LySplitter getParentSplitter(LyComponent topComponent)
Retrieve closest splitter that contains this component. Don't search after a fixed limit.

Parameters:
topComponent - limit of the search
Returns:
closest splitter that contains this component.

getParentTab

public final LyTab getParentTab()
Retrieve closest tab that contains this component.

Returns:
closest tab that contains this component.

getParentTab

public LyTab getParentTab(LyComponent topComponent)
Retrieve closest tab that contains this component. Don't search after a fixed limit.

Parameters:
topComponent - limit of the search
Returns:
closest tab that contains this component.

getParentFormFieldId

public java.lang.String getParentFormFieldId()
Retrieve closest formField id that contains this component.

Returns:
closest formField id that contains this component, null otherwise.

reset

public void reset()
Reset this component.


free

public void free()
Free this component.


isFreeing

public final boolean isFreeing()
Checks if this component is freeing.

Returns:
True id this component is freeing, false otherwise.

isFreed

public final boolean isFreed()
Checks if this component was freed.

Returns:
True id this component was freed, false otherwise.

setVisible

public void setVisible(boolean status)
Shows or hides the component/node.

Parameters:
status - new visibility status
See Also:
LySetVisibleInterface.setVisible(boolean)

freeze

public void freeze(boolean status)
Freeze or unfreeze current view.

Parameters:
status - indicates whether current view must be frozen or not.

getLock

public java.lang.Object getLock()
Get a lock to prevent concurrent access Returns the one provided by the internal view implementation, otherwise returns this.

Returns:
a valid lock for synchronized(), may not return null

setDatas

public void setDatas(java.util.Hashtable<java.lang.String,java.lang.String> datas)
Sets datas.

Parameters:
datas - Datas of the component.

getData

public final java.lang.String getData(java.lang.String name)
Get data corresponding to the given data name.

Parameters:
name - Name of the data.
Returns:
Value of the data, null if not found.

getDatas

public final java.util.Hashtable<java.lang.String,java.lang.String> getDatas()
Gets datas.

Returns:
Datas of the component.

addData

public void addData(java.lang.String name,
                    java.lang.String value)
Add data to this component.

Parameters:
name - Name of the data.
value - Value of the data.

addEventFunction

public void addEventFunction(LyComponent.EventType eventType,
                             java.lang.String function)
Add a function to the list of functions that must be called for a given event type. For example calling this function with the EventType.FOCUS_LOST and the "CheckValue()" parameters with the web viewer will call the CheckValue() Javascript function when focus will be lost on current component.

Parameters:
eventType - the type of event that will call the function
function - the function to be called by the event

resetEventFunctions

public void resetEventFunctions(LyComponent.EventType eventType)
Remove all the functionc to the list of functions that must be called for a given event type, even the generic ones.

Parameters:
eventType - the type of event that will call the function

useEventDefaultFunction

public boolean useEventDefaultFunction(LyComponent.EventType eventType)
Indicates whether the default Leonardi function must be called for the given type of event.

Parameters:
eventType - the type of event (see EventType enum)
Returns:
true if the default function must be called, false otherwise

getEventFunctions

public java.lang.String getEventFunctions(LyComponent.EventType eventType,
                                          char sep)
Return the list of functions that must be called for a given event type.

Parameters:
eventType - the type of event that will call the function
sep - the separator used to concatenate the function names
Returns:
the list of functions to be called separated by the sep character or an empty string if no additional function has been set for this type of event.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com