java.lang.Object
java.util.AbstractCollection<Object>
com.levigo.jadice.web.client.util.context.Context
All Implemented Interfaces:
Iterable<Object>, Collection<Object>

public class Context extends AbstractCollection<Object>

The Context is the center of the context model. It holds context objects which serve as arguments for Commands.

The Context has just one owner, a IsWidget. A reference to this owner is held inside the context. The Context is stored as ClientProperty of the owner.

The context contains references on its own child contexts on which is registered as ContextListener.

The context contains the collection of the components from the child contexts as cachedActiveChildsContextObjects. The context objects contains information for the commands. (For example: items, session, viewer...).

The contexts form a hierarchy reflecting the IsWidget hierarchy of the application's UI.

See Also:
  • Method Details

    • get

      public static Context get(com.google.gwt.user.client.ui.IsWidget component)
      Get the context for a given component by looking at the client properties. If the component does have a context, it is returned. Otherwise the component hierarchy is searched upwards until a context is found or the root is reached.
      Parameters:
      component - The IsWidget which presumably has an attached Context.
      Returns:
      the context or null if no component in the hierarchy had a context.
    • changed

      public static boolean changed(com.google.gwt.user.client.ui.IsWidget c)
      Propagate a context change for the Context associated with the given component. Don't propagate a change, if the component doesn't have a context.
      Parameters:
      c - The element to be evaluated.
      Returns:
      true if there was a context to which the change could be propagated, false otherwise.
    • getPrivateContext

      public static Context getPrivateContext(com.google.gwt.user.client.ui.IsWidget component)
      Get the context for a given component by looking at the client properties. Return the context or null if it doesn't have one. In contrast to get(IsWidget),this method doesn't look at ancestors in the component hierarchy.
      Parameters:
      component - The IsWidget which is searched for an attached Context
      Returns:
      the context or null if no component in the hierarchy had a context.
    • install

      public static Context install(com.google.gwt.user.client.ui.IsWidget owner, Context.Children ca, Context.Ancestors aa)
      Install a context with the given aggregation mode on the given owner. Wire it to its parent, if the owner already has one, otherwise postpone the wiring until the owner is added to one.
      Parameters:
      owner - The object where the Context is installed to
      ca - The children
      aa - The ancestors
      Returns:
      The newly installed context.
    • destroy

      @Deprecated public static void destroy(Context context)
      Deprecated.
      This method was deprecated on the moment when it was created, as it is only intended to be a temporary workaround. Especially when working with tabs,where each tab has its own viewer, this method is needed. See more in the reference handbook, section "known issues", available e.g. on the public available web site
      Parameters:
      context - the context holding the to be removed items like the PageView
    • setAutoHierarchyManagement

      public void setAutoHierarchyManagement(boolean autoHierarchyManagement)
    • iterator

      public Iterator<Object> iterator()
      Returns an iterator over the elements in this context. There are no guarantees concerning the order in which the elements are returned.

      depending on the

      Returns an iterator over the elements in this context as well as all of the parent contexts up to the root context. The Elements are returned by context with the local (this) context's first, then the parent's Objects etc.

      Specified by:
      iterator in interface Collection<Object>
      Specified by:
      iterator in interface Iterable<Object>
      Specified by:
      iterator in class AbstractCollection<Object>
      Returns:
      an Iterator over the elements in this context
    • addChildContext

      public void addChildContext(Context child)
      Adds the context as child context and registers itself as ContextListener.
      Parameters:
      child - the Context which should be registered in the context
    • removeChildContext

      public void removeChildContext(Context child)
      Removes the context from the collection of child contexts and unregisters itself as ContextListener.
      Parameters:
      child - which should be removed from the list of the context
    • addContextChangeListener

      public void addContextChangeListener(ContextListener contextListener)
      Adds a ContextListener to the collection of the listeners. Information about context changes is sent to listeners registered here.
      Parameters:
      contextListener - the ContextListener to be added to the collection of listeners.
    • removeContextChangeListener

      public void removeContextChangeListener(ContextListener contextListener)
      Removes a ContextListener from the collection of listeners so that it doesn't receive notifications any longer.
      Parameters:
      contextListener - the ContextListener to remove from the collection of listeners.
    • contextChanged

      public void contextChanged()
      Propagate context changes to all parent contexts and actions that are registered as ContextListener.
    • add

      public boolean add(Object o)

      Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.)

      Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.

      If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false ). This preserves the invariant that a collection always contains the specified element after this call returns.

      Specified by:
      add in interface Collection<Object>
      Overrides:
      add in class AbstractCollection<Object>
      Parameters:
      o - element whose presence in this collection is to be ensured.
      Returns:
      true if this collection changed as a result of the call
      Throws:
      UnsupportedOperationException - add is not supported by this collection.
      ClassCastException - class of the specified element prevents it from being added to this collection.
      NullPointerException - if the specified element is null and this collection does not support null elements.
      IllegalArgumentException - some aspect of this element prevents it from being added to this collection.
    • clear

      public void clear()
      Removes all of the elements from this collection (optional operation). This collection will be empty after this method returns unless it throws an exception.
      Specified by:
      clear in interface Collection<Object>
      Overrides:
      clear in class AbstractCollection<Object>
      Throws:
      UnsupportedOperationException - if the clear method is not supported by this collection.
    • remove

      public boolean remove(Object o)
      Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : o.equals(e)), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).
      Specified by:
      remove in interface Collection<Object>
      Overrides:
      remove in class AbstractCollection<Object>
      Parameters:
      o - the element to be removed from this collection, if present.
      Returns:
      true if this collection changed as a result of the call. false otherwise.
      Throws:
      ClassCastException - if the type of the specified element is incompatible with this collection (optional).
      NullPointerException - if the specified element is null and this collection does not support null elements (optional).
      UnsupportedOperationException - remove is not supported by this collection.
    • size

      public int size()
      Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements this method will return Integer.MAX_VALUE.
      Specified by:
      size in interface Collection<Object>
      Specified by:
      size in class AbstractCollection<Object>
      Returns:
      the number of elements in this collection
    • isActive

      public boolean isActive()
      Returns the info if the context is active.
      Returns:
      true if this context is active. false otherwise.
    • setActive

      public void setActive(boolean active)
      Sets the Sets the active. This property is important to read the context objects just from the active child context.
      Parameters:
      active - the stat
    • getChildren

      protected Collection<Context> getChildren()
      Returns the child contexts.
      Returns:
      a collection of the child contexts
    • getRegisteredListeners

      protected Collection<ContextListener> getRegisteredListeners()
      Returns the registered ContextListeners
      Returns:
      a collection of the ContextListeners
    • getOwner

      public com.google.gwt.user.client.ui.IsWidget getOwner()
      Returns the GUI component this context is associated with - the owner.
      Returns:
      the GUI component this context is associated with.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractCollection<Object>
    • getParent

      public Context getParent()
      Return the parent context of this context.
      Returns:
      the parent context of this context.