|
LEONARDI Application Composer - 8.9.0.40 by W4 S.A. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectleon.control.LyController
public abstract class LyController
The controller class is inherited by all view controllers. It provides de basic services and accessors common to all implementations of view controllers.
A controller is usually the result of the invocation of an action. Generic actions (_create, _consult, _table, _tree ...) create a new controller instance.
A controller implements the generic processing associated to a view, the integration between the view layer (graphical components) and the data Layer.
A controllers also implements the generic response to user interactions and content (data) modifications.
Controllers enable the views to be 'dynamic', and they are usually associated to a LyBehavior class which enable the user to override.
A LyBehavior instance is usually associated to a controller : LyBehavior enables the developper of a Leonardi aplication to change or extend the generic response of the controller to create the logic of the application.
Normally, simple developments tasks should be implemented as an inheritance of the LyBehavior. Creating you own controllers or inheritance from a generic controller if of course possible, but should be considered as a more advanced task not possible to achieve in the behavior.
Main tasks of a controller :
Controller are registered on the user session.
Field Summary | |
---|---|
static java.lang.String |
__VERSION
File version |
static int |
_nbControllers
Number of controllers for debug purpose. |
static long |
_nextId
Used to compute id sequentially (in test mode). |
static char |
CONTROLLER_ID_SEP
Separator for controller ids. |
static java.lang.String |
DEFAULT_IMAGE_FORMAT
Default image extension. |
static java.lang.String |
DEMAND_HELP
The key of the Help demand. |
static java.lang.String |
ID_SEP
Separator for view ids. |
Constructor Summary | |
---|---|
LyController(LySession session,
LyController parent)
Constructor. |
|
LyController(LySession session,
LyController parent,
java.lang.String id)
Constructor. |
Method Summary | |
---|---|
void |
actionDemand(LyActionDemand demand)
Invoked when an action notification is sent to this listener. |
void |
activateViewDemand(LyActivateViewDemand demand)
Invoked when an activate view notification is sent to this listener. |
void |
clearViewCache()
Clears all cached data for this controller (especially the view and the component). |
void |
demandPerformed(LyDemand demand)
Invoked when a notification is sent to this listener. |
void |
dragDropDemand(LyDragDropDemand demand)
Invoked when a Drag & Drop occurs. |
void |
free()
Free this controller. |
LyApplication |
getApplication()
Accessor to the current application instance. |
LyBehaviorInterface |
getBehavior()
Accessor to controller behavior A behavior is associated to a controller to let the Developer specify application logic in the behavior. |
java.lang.Class<?> |
getBehaviorInterface()
Method that gives the interface that must be implemented by the behavior associated to this controller. |
LyBuilder |
getBuilder()
Accessor to the internal builder. |
LyClassInfo |
getClassInfo(java.lang.String id)
Shortcut to get a classInfo of the application this method is a utility shortcut to getApplication().getClassInfo(id); |
LyComponent |
getComponent()
Accessor to the view component instance. |
LyEnvironment |
getEnvironment()
Accessor to the current Environment instance (shortcut for getSession().getEnvironment()). |
java.lang.String |
getId()
Accessor to the identifier of the controller. |
java.lang.String |
getImage(LyObject object)
Get the name of the image (key or path) representing an object instance. |
java.lang.String |
getImage(LyObjectInfo objectInfo)
Get the name of the image (key or path) representing an objectinfo. |
java.lang.String |
getImage(LyObjectInfo objectInfo,
int size)
Get the name of the image (key or path) representing an objectinfo. |
java.lang.String |
getImage(LyObjectInfo objectInfo,
int size,
boolean defaultImage)
Get the name of the image (key or path) representing an objectinfo. |
java.lang.String |
getImageFromPrefix(java.lang.String prefix)
Build an image path from a prefix. |
java.lang.String |
getImageFromPrefix(java.lang.String prefix,
java.lang.String format,
int height)
Build an image path from a prefix, an image extension and a specified height. |
java.lang.String |
getImageFromPrefix(java.lang.String prefix,
java.lang.String format,
int width,
int height)
Build an image path from a prefix, extension, and size. |
java.lang.Object |
getKeyValue(java.lang.String key)
Retrieves a value from a registered key. |
long |
getLastModified()
Accessor to the last modification date of this controller. |
java.lang.String |
getName()
Accessor to the name of the controller. |
LyObjectId |
getObjectId(java.lang.String id)
Factory for a LyObjectId instance for the specified String identifier This is a shortcut to : new LyObjectId(getApplication(), id). |
LyController |
getParent()
Accessor to the reference to the parent controller. |
LySession |
getSession()
Accessor to the session instance associated to this controller. |
java.lang.Object |
getUserData()
Gets user data : data stored on controller by application. |
LyView |
getView()
Accessor view that contains the component (getComponent) of the controller. |
abstract LyViewController |
getViewController()
Accessor to the view controller (Frame or dialog controller) which is the container of this view. |
LyViewManager |
getViewManager()
Accessor to the current view manager instance (shortcut for getViewManager()). |
boolean |
hasViewController()
Check the controller have a viewController. |
void |
helpDemand(LyHelpDemand demand)
Invoked when an help notification is sent to this listener. |
void |
hideView()
Hide the view. |
void |
hideView(boolean free)
Hide the view. |
boolean |
isFreed()
Internal method to check if this controller was freed. |
boolean |
isIdle()
Check idle status of the table. |
void |
menuDemand(LyMenuDemand demand)
Invoked when an menu item notification is sent to this listener. |
void |
selectionDemand(LySelectionDemand demand)
Invoked when an selection notification is sent to this listener. |
void |
setBuilder(LyBuilder builder)
Sets a builder for this controller. |
void |
setBuilderClass(java.lang.Class<?> builderClass)
Sets a builder class for this controller. |
void |
setIdle(boolean idle)
Sets idle status of the table. |
void |
setLastModified(long time)
Accessor to set the last modification date of this controller. |
void |
setName(java.lang.String name)
Accessor to the name of the controller. |
void |
setUserData(java.lang.Object userData)
Sets user data : data stored on controller by application. |
void |
showError(LyObject object,
LyError error)
Show an error for the specified object. |
void |
showError(java.lang.String message)
Show a popup message error box with the specified message. |
void |
showView()
Make the view visible to the user. |
void |
showWarning(java.lang.String message)
Show a popup message warning box with the specified message. |
java.lang.String |
toString()
Override generic method to display the name of this controller. |
void |
updateViewFromValues(LyDemand demand)
Update the view of the controller with the specified values from the demand (internal use) . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String __VERSION
public static java.lang.String DEFAULT_IMAGE_FORMAT
public static final java.lang.String ID_SEP
public static final char CONTROLLER_ID_SEP
public static int _nbControllers
public static long _nextId
public static final java.lang.String DEMAND_HELP
LyDemand.getSource()
Constructor Detail |
---|
public LyController(LySession session, LyController parent)
session
- current session associated to the controller. The controller automatically
registers on the specified session.parent
- parent controller (or null for 'root' controller). Controller hierarchy
indicates a child controller (for example a dialog created from a main view)public LyController(LySession session, LyController parent, java.lang.String id)
session
- current session associated to the controller. The controller automatically
registers on the specified session.parent
- parent controller (or null for 'root' controller). Controller hierarchy
indicates a child controller (for example a dialog created from a main view)id
- identifier of the controller : can not be null. To generate the id
automatically, use LyString.getRandomId() or alternate constructor.Method Detail |
---|
public void showView()
For any display, this method should consider that the page is ready to be shown and should be displayed.
public void hideView()
This method should consider that the page is closed and should disappear.
The view is only HIDDEN, not cleared (see free), so it should be possible to open it again with showView and resources allocated for the view are not freed.
public void hideView(boolean free)
This method should consider that the page is closed and should disappear.
free
- Indicates if only HIDDEN, not FREED (true).public void free()
public java.lang.String getId()
Additionally, this method is required for the LyDemandListener interface.
getId
in interface LyDemandListener
public java.lang.String getName()
public void setName(java.lang.String name)
name
- The name of the controller may be displayed to the user in a view.public LyController getParent()
public void setBuilder(LyBuilder builder)
If no builder was specified, the controller will create a default builder using the getDefaultBuilder() method.
builder
- the specified builder, or null to use default.public void setBuilderClass(java.lang.Class<?> builderClass)
If no builder class was specified, the controller will create a default builder using the getDefaultBuilder() method.
builderClass
- the specified builder class, or null to use default.public LyBuilder getBuilder()
public java.lang.Class<?> getBehaviorInterface()
public LyBehaviorInterface getBehavior()
public LyComponent getComponent()
public abstract LyViewController getViewController()
public LyView getView()
public LySession getSession()
getSession
in interface LyGetSessionInterface
public LyApplication getApplication()
public LyEnvironment getEnvironment()
public LyViewManager getViewManager()
public long getLastModified()
public void setLastModified(long time)
time
- the new modification timepublic java.lang.String toString()
toString
in class java.lang.Object
getName()
public boolean isFreed()
public void demandPerformed(LyDemand demand)
The listener should make the interpretation of the event, and update the view description if necessary.
demandPerformed
in interface LyDemandListener
demand
- demand parameters sent by the view component.interface
public void updateViewFromValues(LyDemand demand)
demand
- demand parameters sent by the view component.public void actionDemand(LyActionDemand demand)
This method is called by demandPerformed and may be overridden in subclasses.
Default implementation makes nothing.
demand
- demand parameters sent by the view component.demandPerformed(leon.view.event.LyDemand)
public void selectionDemand(LySelectionDemand demand)
This method is called by demandPerformed and may be overriden in subclasses.
Default implementation makes nothing.
demand
- demand parameters sent by the view component.demandPerformed(leon.view.event.LyDemand)
public void menuDemand(LyMenuDemand demand)
This method is called by demandPerformed and may be overriden in subclasses.
Default implementation makes nothing.
demand
- demand parameters sent by the view component.demandPerformed(leon.view.event.LyDemand)
public void helpDemand(LyHelpDemand demand)
This method is called by demandPerformed and may be overridden in subclasses.
Default implementation makes nothing.
demand
- demand parameters set by the view component.demandPerformed(leon.view.event.LyDemand)
public void activateViewDemand(LyActivateViewDemand demand)
This method is called by demandPerformed and may be overridden in subclasses.
Default implementation send a global event to the event manager.
demand
- demand parameters set by the view component.demandPerformed(leon.view.event.LyDemand)
public void dragDropDemand(LyDragDropDemand demand)
demand
- drag-drop demandpublic LyClassInfo getClassInfo(java.lang.String id)
id
- identifier of requested class.
public java.lang.String getImage(LyObject object)
object
- source object for image association.
public java.lang.String getImage(LyObjectInfo objectInfo)
objectInfo
- Info for which an image is searched.
getImageFromPrefix(java.lang.String)
public java.lang.String getImage(LyObjectInfo objectInfo, int size)
objectInfo
- Info for which an image is searched.size
- Requested size.
getImageFromPrefix(java.lang.String)
public java.lang.String getImage(LyObjectInfo objectInfo, int size, boolean defaultImage)
objectInfo
- Info for which an image is searched.size
- Requested size.defaultImage
- Produce a default image if image not found.
getImageFromPrefix(java.lang.String)
public java.lang.String getImageFromPrefix(java.lang.String prefix)
prefix
- the prefix to identify the image resource
LyImages
public final java.lang.String getImageFromPrefix(java.lang.String prefix, java.lang.String format, int height)
prefix
- the prefix to identify the image resourceformat
- the extension associated to the image, ".gif", ".jpg" or
LyController.DEFAULT_IMAGE_FORMAT to use default value.height
- requested height of the image.
LyImages
public java.lang.String getImageFromPrefix(java.lang.String prefix, java.lang.String format, int width, int height)
prefix
- the prefix to identify the image resourceformat
- the extension associated to the image, ".gif", ".jpg" or
LyController.DEFAULT_IMAGE_FORMAT to use default value.width
- requested height of the image.height
- requested height of the image.
LyImages
public LyObjectId getObjectId(java.lang.String id)
id
- object identifier.
public void showWarning(java.lang.String message)
message
- the message to displayLyViewManager
,
LyStrings
public void showError(java.lang.String message)
message
- the message to displayLyViewManager
,
LyStrings
public void showError(LyObject object, LyError error)
object
- The object in errorerror
- The error o showshowError(String)
public void clearViewCache()
This method may be invoked for memory optimization, but the controller is still valid and may be used. (Unlike free) Further usage, needs to rebuild internal component & view which may be time consuming.
public void setIdle(boolean idle)
idle
- a boolean indicating the idle modepublic boolean isIdle()
isIdle
in interface LyGuiListener
public boolean hasViewController()
public java.lang.Object getKeyValue(java.lang.String key)
getKeyValue
in interface LyEvaluator
key
- The key that must be used.
public final java.lang.Object getUserData()
public final void setUserData(java.lang.Object userData)
|
(c) January 2013 - W4 S.A. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |