public final class TraversableContext extends Namespace
TraversableContext
class provides the means for
a Traversable
to find the data objects that it is
responsible for editing whenever it is entered or exited.
The important characteristic of TraversableContext
is that Traversable
implementations be able to search
for their data objects by a fixed name, even when multiple data
objects of the same type are being edited by the same
Traversable
implementation. This capability requires the
participation of the MetaTraversable
class through the
name link mechanism provided by its MetaTraversable.setNameLink(String, String)
method.
See the javadoc for Traversable
for more details on its
interactions with the TraversableContext
.
See the javadoc for Namespace
for details on how data
is stored and retrieved in a context-sensitive manner.
Note: The TraversableContext
class
is currently declared final
. This may be relaxed in
the future after the API is considered stable for both property
dialogs and wizards, and subclassing issues have been thoroughly
considered.
Modifier and Type | Field and Description |
---|---|
static int |
BACKWARD_TRAVERSAL
Constant that indicates that the direction of traversal for the
Traversable.onEntry(TraversableContext) and
Traversable.onExit(TraversableContext) methods. |
static int |
FOCUS_TRAVERSAL
Constant that indicates that the direction of traversal for the
Traversable.onEntry(TraversableContext) and
Traversable.onExit(TraversableContext) methods. |
static int |
FORWARD_TRAVERSAL
Constant that indicates that the direction of traversal for the
Traversable.onEntry(TraversableContext) and
Traversable.onExit(TraversableContext) methods. |
static int |
RANDOM_ACCESS_TRAVERSAL
Constant that indicates that the direction of traversal for the
Traversable.onEntry(TraversableContext) and
Traversable.onExit(TraversableContext) methods. |
Constructor and Description |
---|
TraversableContext(Namespace namespace,
int direction)
This constructor creates a new instance using the specified
Namespace as the data context. |
TraversableContext(Navigable navigable,
int direction)
This constructor creates a new instance using the specified
Navigable to determine the data context. |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getDesignTimeObject(java.lang.String key)
Experimental.
|
DialogCallbacks |
getDialogCallbacks() |
int |
getDirection()
Returns the direction that the traversal is occurring in.
|
PropertyStorage |
getPropertyStorage() |
WizardCallbacks |
getWizardCallbacks() |
NavigableContext |
newNavigableContext() |
void |
putDesignTimeObject(java.lang.String key,
java.lang.Object dtObject)
Experimental.
|
void |
setDialogCallbacks(DialogCallbacks callbacks) |
void |
setWizardCallbacks(WizardCallbacks callbacks) |
protected java.lang.String |
translateKey(java.lang.String key)
This method is used to remap a key that is used when invoking
either the
Namespace.find(String) or #findAndReplace(String,
Object method. |
public static final int RANDOM_ACCESS_TRAVERSAL
Traversable.onEntry(TraversableContext)
and
Traversable.onExit(TraversableContext)
methods.
This constant means that the Traversable
is being entered
or exited in a random-access manner. Random-access traversal
typically occurs in a properties dialog.public static final int FORWARD_TRAVERSAL
Traversable.onEntry(TraversableContext)
and
Traversable.onExit(TraversableContext)
methods.
This constant means that the Traversable
is being entered
or exited in a sequentially forward direction. Forward traversal
typically occurs in a wizard.public static final int BACKWARD_TRAVERSAL
Traversable.onEntry(TraversableContext)
and
Traversable.onExit(TraversableContext)
methods.
This constant means that the Traversable
is being entered
or exited in a sequentially backward direction. Backward
traversal typically occurs in a wizard.public static final int FOCUS_TRAVERSAL
Traversable.onEntry(TraversableContext)
and
Traversable.onExit(TraversableContext)
methods.
This constant means that the Traversable
is being entered
by gaining input focus or is being exited by losing input focus.
Focus traversal typically occurs in dialogs, wizards, or editors
that are are modeless.public TraversableContext(Navigable navigable, int direction)
Navigable
to determine the data context. The traversal
direction is set according to the specified int
.navigable
- the Navigable
whose data context will
be associated with the TraversableContext
. This must
not be null
or else a NullPointerException
will be thrown.direction
- the traversal direction associated with the
creation of the TraversableContext
. The value must
be one of RANDOM_ACCESS_TRAVERSAL
, FORWARD_TRAVERSAL
, BACKWARD_TRAVERSAL
, or FOCUS_TRAVERSAL
, or else an IllegalArgumentException
will be thrown.java.lang.NullPointerException
- if the specified Navigable
is null
.java.lang.IllegalArgumentException
- if the specified
direction
is not a legally accepted value.public TraversableContext(Namespace namespace, int direction)
Namespace
as the data context. The traversal direction
is set according to the specified int
. Because
no MetaTraversable
is set through this method, the new
TraversableContext
does not remap any data keys.
(Remapping data keys is typically only needed in cases where
the same Traversable implementation reappears more than once
in a particular MDDPanel
but edits different objects
at the same level in the TraversableContext
. Since
the Traversable accesses its data by a fixed key, that fixed
key needs to be remapped to a real name when the key could
possibly be resolved to more than one object.)public int getDirection()
public WizardCallbacks getWizardCallbacks()
public void setWizardCallbacks(WizardCallbacks callbacks)
public DialogCallbacks getDialogCallbacks()
public void setDialogCallbacks(DialogCallbacks callbacks)
public PropertyStorage getPropertyStorage()
public java.lang.Object getDesignTimeObject(java.lang.String key)
public void putDesignTimeObject(java.lang.String key, java.lang.Object dtObject)
public NavigableContext newNavigableContext()
protected java.lang.String translateKey(java.lang.String key)
Namespace
Namespace.find(String)
or #findAndReplace(String,
Object
method. In general, translation will not be necessary,
so this method by default returns the specified key itself.
A subclass that requires key mappings should override this method
to provide the proper key mapping behavior.translateKey
in class Namespace