LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.data
Class LyContext

java.lang.Object
  extended by leon.data.LyContext

public class LyContext
extends java.lang.Object

This class represents a context managed by the context manager. A context is associated with a user session (LyDataSession).

See Also:
LyObject, LyOperation, LyContextManager

Nested Class Summary
static class LyContext.Position
          Indicates the insertion positions of the operations of this context into the parent operation list.
static class LyContext.Status
          Status of the context.
static class LyContext.Type
          Type of the context.
 
Field Summary
static java.lang.String __VERSION
          File version.
 
Method Summary
 void addSon(LyContext son)
          Adds a son to the list of sons of this context.
 void addUserOperation(LyUserOperationInterface callback, LyObject object, java.lang.Object userData)
           
 LyContext.Status commit()
          To commit the context.
 LyResponse createObject(LyObject object)
          Create a new object in this context.
 LyResponse deleteObject(LyObject object)
          Delete an object in this context.
 void disableEvents()
          To disable the events sending.
 void disableUndo()
          Marks this context as ignored for undo/redo by the context manager.
 void disableUpdateRelations()
          To disable the relations update.
 void enableControl(int control, boolean enable)
          Enable/Disable the given control on objects in this context.
 void enableEvents(boolean enable)
          To enable/disable the events sending.
 short getErrorLevel()
          Checks if this context has errors.
 java.lang.String getErrorMessage()
          Accessor to the error message produced on last operation sent.
 java.util.Vector<LyError> getErrors(short level)
          Gets the list of errors on objects with the specified level.
 java.util.Collection<LyContext> getInternalSons()
          To get all the internal sons context of this context. getInternalSons() is for internal use, applications should use getSons() instead.
 java.util.Collection<LyContext> getInternalSons(boolean allInternalAndOthers)
          To get all the internal sons context of this context. getInternalSons() is for internal use, applications should use getSons() instead.
 java.util.Vector<LyObject> getObjectsInError()
          Gets the list of objects updated by this context and its sons with LEVEL_ERROR errors.
 java.util.ArrayList<LyOperation> getOperations()
          Get the list of operations of this context.
 LyContext getParent()
          Accessor to the parent of this context.
 LyContext getRootContext()
          Gets the root context of this context.
 LyDataSession getSession()
          Accessor to the associated user session.
 java.util.Collection<LyContext> getSons()
          To get all the sons of this context.
 LyContext.Status getStatus()
          Accessor to the current status.
 LyContext.Type getType()
          Accessor to the type of this context.
 boolean isAlreadyCreated(LyObject object)
          Check if the specified object has already been created in this context or in another comitted context.
 boolean isEmpty()
          Checks if this context is empty or not (i.e. has operations or not).
 boolean isEnded()
          Tests if this context has been committed or rollbacked.
 boolean isOnlyLocal()
          Getter of the _onlyLocal attribute.
 boolean isRedoAvailable()
          To test if a redo operation can be done.
 boolean isSon(LyContext context)
          Tests if the specified context is a son of this context.
 boolean isUndoAvailable()
          To test if an undo operation can be done.
 void redo()
          Redo the last operation undone in this context.
 void rehash(java.util.Collection<LyObject> objects)
          To rehash a colection of LyObjects.
 void rehash(LyObject object)
          To rehash a LyObject.
 void rollback()
          Rollback the current context.
 void sendEvents()
          This method send all pending operations locally to update objects.
 void sendUserEvent(LyObject object, LyAdvancedDataSourceEvent userEvent)
          Send an user evetn in this context.
 void setHidden(LyObject object, boolean state)
          Set the hidden state of an object in this context.
 void setIgnoreUndo(boolean ignore)
          To mark operation as undo ignore.
 void setInsertPosition(LyContext.Position position)
          Indicates if the operations of this context must be inserted at the beginning of the parent operations or at the end.
 void setInternal()
          Marks this context as internal.
 void setKeepOrder(boolean keepOrder)
          To force the context to keep (or not) the order of its sons operations.
 void setLinkUndo(boolean link)
          To mark operations as linked for undo/redo.
 void setListener(LyContextListener listener)
          Sets listener of this context.
 void setName(java.lang.String name)
          Modifier of the name of this context.
 LyResponse setObject(LyObject object)
          Set an object in this context.
 void setOnlyLocal(boolean onlyLocal)
          To force or not all operations in this context to be only local.
 void setSelected(LyObject object, boolean state)
          Set the selection state of an object in this context.
 void setValue(LyObject object, LyFieldInfo fieldInfo, java.lang.Object value)
          Set a value for an object in this context.
 void setValue(LyObject object, LyValue value)
          Set a value for an object in this context.
 void setValue(LyObject object, java.lang.String fieldId, java.lang.Object value)
          Set a value for an object in this context.
 void setValues(LyObject object, LyValueSet values)
          Set values for an object in this context.
 java.lang.String toString()
          Gets this object as a string.
 void undo()
          Undo the last operation of this context.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
File version.

See Also:
Constant Field Values
Method Detail

getStatus

public final LyContext.Status getStatus()
Accessor to the current status.

Returns:
the current status

isEnded

public boolean isEnded()
Tests if this context has been committed or rollbacked.

Returns:
true if this context has been committed or rollbacked, false otherwise.

getSession

public final LyDataSession getSession()
Accessor to the associated user session.

Returns:
the associated session

getType

public final LyContext.Type getType()
Accessor to the type of this context.

Returns:
the type of this context

getParent

public LyContext getParent()
Accessor to the parent of this context.

Returns:
The parent context of this context (may be null).

setName

public void setName(java.lang.String name)
Modifier of the name of this context.

Parameters:
name - The new name of this context.

getErrorMessage

public final java.lang.String getErrorMessage()
Accessor to the error message produced on last operation sent.

Returns:
the error message

disableUndo

public void disableUndo()
Marks this context as ignored for undo/redo by the context manager.


setInternal

public void setInternal()
Marks this context as internal. This method is for internal use only.


setListener

public void setListener(LyContextListener listener)
Sets listener of this context.

Parameters:
listener - a context listener

addSon

public void addSon(LyContext son)
Adds a son to the list of sons of this context.

Parameters:
son - The son to add
Throws:
java.lang.IllegalStateException - if the son has another parent context.
java.lang.IllegalArgumentException - if the types of the current context and the specified context are not compatible.

getSons

public java.util.Collection<LyContext> getSons()
To get all the sons of this context.

Returns:
A collection of the sons of this context or null if this context has no son.

getInternalSons

public java.util.Collection<LyContext> getInternalSons()
To get all the internal sons context of this context. getInternalSons() is for internal use, applications should use getSons() instead.

Returns:
A collection of the sons of this context or null if this context has no internal son.

getInternalSons

public java.util.Collection<LyContext> getInternalSons(boolean allInternalAndOthers)
To get all the internal sons context of this context. getInternalSons() is for internal use, applications should use getSons() instead.

Parameters:
allInternalAndOthers - all sons whatever they are internal or not
Returns:
A collection of the sons of this context or null if this context has no internal son.

isSon

public boolean isSon(LyContext context)
Tests if the specified context is a son of this context.

Parameters:
context - The context to test
Returns:
true if the given context is a son of the current context, false otherwise.

getRootContext

public LyContext getRootContext()
Gets the root context of this context.

Returns:
The root context of this context or this if this context has no parent.

getOperations

public java.util.ArrayList<LyOperation> getOperations()
Get the list of operations of this context. Only not saved operatrions are returned. For security and consistency, the list of returned operation is a copy of the original list.

Returns:
The list of operations of this context.

sendEvents

public void sendEvents()
This method send all pending operations locally to update objects.


commit

public LyContext.Status commit()
To commit the context. All registered operations are committed.

Returns:
the status of the context at the end of the commit operation. This status could be : Status.ERROR if there is one error in an object updated by this context, Status.COMPLETED if the commit operation succeed, Status.ROLLBACKED if the context has been rollbacked.
Throws:
java.lang.IllegalStateException - if the context has some sons contexts.

rollback

public void rollback()
Rollback the current context.


deleteObject

public LyResponse deleteObject(LyObject object)
Delete an object in this context.

Parameters:
object - Object to delete.
Returns:
Response to the deletion.
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED.
LyIllegalOperationException - if this context has not the rights to do the deletion
See Also:
LyObject.delete(boolean)

createObject

public LyResponse createObject(LyObject object)
Create a new object in this context.

Parameters:
object - Object to create.
Returns:
Response to the creation.
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED.
LyIllegalOperationException - if this context has not the rights to do the creation
See Also:
LyObject.create(boolean)

setObject

public LyResponse setObject(LyObject object)
Set an object in this context.

Parameters:
object - Object to modify.
Returns:
Response to the modification.
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED.
LyIllegalOperationException - if this context has not the rights to do the modification
See Also:
LyObject.set(boolean)

setValue

public void setValue(LyObject object,
                     java.lang.String fieldId,
                     java.lang.Object value)
Set a value for an object in this context.

Parameters:
object - Object to modify.
fieldId - Name of the fieldInfo to set.
value - The value for this fieldInfo.
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED.
LyIllegalOperationException - if this context has not the rights to do the modification

setValue

public void setValue(LyObject object,
                     LyFieldInfo fieldInfo,
                     java.lang.Object value)
Set a value for an object in this context.

Parameters:
object - Object to modify.
fieldInfo - The fieldInfo to set.
value - The value for this fieldInfo.
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED.
LyIllegalOperationException - if this context has not the rights to do the modification

setValue

public void setValue(LyObject object,
                     LyValue value)
Set a value for an object in this context.

Parameters:
object - Object to modify.
value - The value to set
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED.
LyIllegalOperationException - if this context has not the rights to do the modification

setValues

public void setValues(LyObject object,
                      LyValueSet values)
Set values for an object in this context.

Parameters:
object - Object to modify.
values - The values to set
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED.
LyIllegalOperationException - if this context has not the rights to do the modification

setSelected

public void setSelected(LyObject object,
                        boolean state)
Set the selection state of an object in this context.

Parameters:
object - Object to modify.
state - The new selection state
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED or if the object does'nt exist.

setHidden

public void setHidden(LyObject object,
                      boolean state)
Set the hidden state of an object in this context.

Parameters:
object - Object to modify.
state - The new hidden state
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED or if the object does'nt exist.

sendUserEvent

public void sendUserEvent(LyObject object,
                          LyAdvancedDataSourceEvent userEvent)
Send an user evetn in this context.

Parameters:
object - Object concerned by the event.
userEvent - The event to send
Throws:
java.lang.IllegalStateException - if the context has the status Status.ROLLBACKED or STATUS_COMPLETED or if the object does'nt exist.

setIgnoreUndo

public void setIgnoreUndo(boolean ignore)
To mark operation as undo ignore. For internal use only.

Parameters:
ignore - true to ignore operations for undo, false otherwise.

setKeepOrder

public void setKeepOrder(boolean keepOrder)
To force the context to keep (or not) the order of its sons operations.

Parameters:
keepOrder - true to keep the order of the sons operation INTERNAL USE ONLY

setInsertPosition

public void setInsertPosition(LyContext.Position position)
Indicates if the operations of this context must be inserted at the beginning of the parent operations or at the end.

Parameters:
position - the insertion position. INTERNAL USE ONLY

setLinkUndo

public void setLinkUndo(boolean link)
To mark operations as linked for undo/redo. For internal use only.

Parameters:
link - true to link operations, false otherwise.

isUndoAvailable

public boolean isUndoAvailable()
To test if an undo operation can be done.

Returns:
true if an undo is available, false otherwise.

isRedoAvailable

public boolean isRedoAvailable()
To test if a redo operation can be done.

Returns:
true if a redo is available, false otherwise.

undo

public void undo()
Undo the last operation of this context.


redo

public void redo()
Redo the last operation undone in this context.


getErrorLevel

public short getErrorLevel()
Checks if this context has errors.

Returns:
the maximum error level of this context or its sons.

getObjectsInError

public java.util.Vector<LyObject> getObjectsInError()
Gets the list of objects updated by this context and its sons with LEVEL_ERROR errors.

Returns:
The list of objects updated by this context and its sons with LEVEL_ERROR errors or null if there is no objects with LEVEL_ERROR errors.

getErrors

public java.util.Vector<LyError> getErrors(short level)
Gets the list of errors on objects with the specified level.

Parameters:
level - Level of the errors
Returns:
The list of errors with the specified level for this context or null if there is no errors.

toString

public java.lang.String toString()
Gets this object as a string.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this context.

enableControl

public void enableControl(int control,
                          boolean enable)
Enable/Disable the given control on objects in this context.

Parameters:
control - Control that is enabled or disabled (see LyObject.CONTROL_XXX).
enable - Boolean indicating if the control is enabled or disabled.

isAlreadyCreated

public boolean isAlreadyCreated(LyObject object)
Check if the specified object has already been created in this context or in another comitted context.

Parameters:
object - The object ot test.
Returns:
true if the specified object has already been created, false otherwise.

disableUpdateRelations

public void disableUpdateRelations()
To disable the relations update.


disableEvents

public final void disableEvents()
To disable the events sending.


enableEvents

public void enableEvents(boolean enable)
To enable/disable the events sending.

Parameters:
enable - Boolean that indicates if events are enabled or disabled.

rehash

public void rehash(java.util.Collection<LyObject> objects)
To rehash a colection of LyObjects.

Parameters:
objects - The collection of LyObject to rehash.

rehash

public void rehash(LyObject object)
To rehash a LyObject.

Parameters:
object - The object to rehash.

setOnlyLocal

public void setOnlyLocal(boolean onlyLocal)
To force or not all operations in this context to be only local.

Parameters:
onlyLocal - true to force operations to be local, false otherwise.

isOnlyLocal

public boolean isOnlyLocal()
Getter of the _onlyLocal attribute.

Returns:
true if all operations of this context must be local.

isEmpty

public boolean isEmpty()
Checks if this context is empty or not (i.e. has operations or not).

Returns:
True if this context has no operation, false otherwise.

addUserOperation

public void addUserOperation(LyUserOperationInterface callback,
                             LyObject object,
                             java.lang.Object userData)

(c) January 2013 - W4 S.A.

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