|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<Object> com.levigo.util.swing.action.Context
public class Context
The Context is the class in the middle of the context model. It contains context objects which
serve as arguments for Command
s.
The Context has just one owner, a JComponent
. A reference to this owner is
held inside the context. The Context is stored as ClientProperty of the owner.
Both, a FocusListener
and a ContainerListener
will
be created for and registered with the owner.
The context contains references on its own child contexts on which it is registered as a
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 Component
hierarchy of the application's UI.
Command
,
CommandAction
,
ContextListener
Nested Class Summary | |
---|---|
static class |
Context.Ancestors
Enum used to determine whether the aggregated view includes elements of ancestor (parent, grand-parent etc.) contexts. |
static class |
Context.Children
Enum used to determine whether the aggregated view includes elements of child contexts. |
Field Summary | |
---|---|
static String |
PROPERTY_KEY
The ClientProperty key used by the GUI Component to store its context object in. |
Method Summary | |
---|---|
boolean |
add(Object o)
Ensures that this collection contains the specified element (optional operation). |
void |
addChildContext(Context child)
Adds the context as child context and registers itself as ContextListener . |
void |
addContextChangeListener(ContextListener contextListener)
Adds ContextListener to the collection of the listeners. |
static boolean |
changed(JComponent c)
Propagate a context change for the Context associated with the given component. |
void |
clear()
Removes all of the elements from this collection (optional operation). |
void |
contextChanged()
Propagate context changes to all parent contexts and actions that are registered as ContextListener . |
static Context |
create(Context.Children ca,
Context.Ancestors aa)
Create an owner-less context with the given aggregation modes. |
static Context |
get(JComponent component)
Get the context for a given component by looking at the client properties. |
protected Collection<Context> |
getChildren()
Returns the child contexts. |
JComponent |
getOwner()
Returns the owner. |
Context |
getParent()
Return the parent context. |
static Context |
getPrivateContext(JComponent component)
Get the context for a given component by looking at the client properties. |
protected Collection<ContextListener> |
getRegisteredListeners()
Method getRegisteredListeners - ContextListener . |
static Context |
install(JComponent owner,
Context.Children ca,
Context.Ancestors aa)
Install a context with the given aggregation mode on the given owner. |
boolean |
isActive()
Returns the info if the context is active. |
Iterator<Object> |
iterator()
Returns an iterator over the elements in this context. |
boolean |
remove(Object o)
Removes a single instance of the specified element from this collection, if it is present (optional operation). |
void |
removeChildContext(Context child)
Removes the context from the collection of child contexts and unregisters itself as ContextListener . |
void |
removeContextChangeListener(ContextListener contextListener)
Removes ContextListener from the collection of listeners so that it doesn't receive
notifications any longer. |
void |
setActive(boolean active)
Sets the active. |
int |
size()
Returns the number of elements in this collection. |
String |
toString()
|
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Field Detail |
---|
public static String PROPERTY_KEY
Method Detail |
---|
public static Context get(JComponent component)
component
-
null
if no component in the hierarchy had a context.public static boolean changed(JComponent c)
c
- the changed component
true
if there was a context to which the change could be propagated,
false
otherwise.public static Context getPrivateContext(JComponent component)
null
if it doesn't have one. In contrast to get(JComponent)
,this
method doesn't look at ancestors in the component hierarchy.
component
-
null
if no component in the hierarchy had a context.public static Context install(JComponent owner, Context.Children ca, Context.Ancestors aa)
owner
-
public static Context create(Context.Children ca, Context.Ancestors aa)
ca
- aa
-
public Iterator<Object> iterator()
iterator
in interface Iterable<Object>
iterator
in interface Collection<Object>
iterator
in class AbstractCollection<Object>
public void addChildContext(Context child)
ContextListener
.
child
- which should be registered in the contextpublic void removeChildContext(Context child)
ContextListener
.
child
- which should be removed from the list of the contextpublic void addContextChangeListener(ContextListener contextListener)
ContextListener
to the collection of the listeners. Information about context
changes is sent to listeners registered here.
contextListener
- to add to the collection of listeners.ContextListener
public void removeContextChangeListener(ContextListener contextListener)
ContextListener
from the collection of listeners so that it doesn't receive
notifications any longer.
contextListener
- to remove from the collection of listeners.ContextListener
public void contextChanged()
ContextListener
.
ContextListener.contextChanged(Context)
public boolean add(Object o)
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.
add
in interface Collection<Object>
add
in class AbstractCollection<Object>
o
- element whose presence in this collection is to be ensured.
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.public void clear()
clear
in interface Collection<Object>
clear
in class AbstractCollection<Object>
UnsupportedOperationException
- if the clear method is not supported by this
collection.public boolean remove(Object o)
remove
in interface Collection<Object>
remove
in class AbstractCollection<Object>
o
- element to be removed from this collection, if present.
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.public int size()
size
in interface Collection<Object>
size
in class AbstractCollection<Object>
public boolean isActive()
public void setActive(boolean active)
active
- true
- active, false
- not active.protected Collection<Context> getChildren()
protected Collection<ContextListener> getRegisteredListeners()
ContextListener
.
public JComponent getOwner()
public String toString()
toString
in class AbstractCollection<Object>
Object.toString()
public Context getParent()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |