|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchrriis.uihierarchy.UIH
The user interface hierarchy core class. This is the base class that allows
to create easily some simple to complex user interfaces containment
hierarchies.
The first steps to creating a hierarchy is to get a clear representation of
it. Let's take this simple example:
* Content pane of a root pane container.
+ A panel, using a gridBag layout, added to the center.
- A label "A label: " in the cell [0, 0], left
aligned.
- A button "A button" in the cell [0, 1].
Then to call UIH the same way:
UIH h = new UIH();
h.openNew(getContentPane());
h.open().layout(new GridBagLayout()).constrain(BorderLayout.CENTER);
h.add("A label: ").constrain("anchor=WEST");
h.add(new JButton("A button")).constrain("gridx=0, gridy=1");
h.close();
h.close();
When building the hierarchy containment tree, four methods are important:
openNew
: open a new containment hierarchy.
open
: open a new level in the containment hierarchy.
add
: add a component at the current hierarchy level.
close
: close a level.
openNew
, open
and add
methods
return an object representing the level, on which it is possible to perform
additional operations like setting the constraints or the layout.
openNew
method assumes that the container it contains
already belongs to a parent. Thus, it is used to start the complete
hierarchy, or to add a new level for which the container must not be added to
the container of the parent level.
UIH
.
chrriis.uihierarchy.constraints
are pre-defined to handle Strings.
The example above is using one of them. Note that it is possible to register
custom constraints handler for existing or custom layouts. It is also
possible to use a handler when invoking the method: the constraints for the
component will be obtained from this handler.
XmlUIHierarchy
class (more about this topic is explained in the
corresponding class documentation).
close()
is invoked, the
containement hierarchy gets created.
Accessor
by invoking the createAccessor(String)
method using some names that were used to map
some levels.
print
the hierarchy that is under creation. It is a convenient method to facilitate
debugging.
Nested Class Summary | |
class |
UIH.SingleLevelHandler
A handler of a child level |
Field Summary | |
UIH |
_
A reference to this UIH instance. |
Constructor Summary | |
UIH()
Construct a hierarchy of components. |
|
UIH(UIHConfig uihConfig)
Construct a hierarchy of components, using the specific configuration. |
Method Summary | |
HLeaf |
add()
Create a leaf in the hierarchy. |
HLeaf |
add(Object component)
Create a leaf in the hierarchy with a specific component. |
UIH.SingleLevelHandler |
add(SingleLevelAccessor accessor)
Add a child level and its sub levels from an accessor of a single level. |
void |
close()
Close a hierarchy level. |
Accessor |
createAccessor(String names)
Create an accessor for some mapped levels. |
Accessor |
createAccessor(String names,
String excludedNames)
Create an accessor for some mapped levels, with excluding some. |
void |
debug(String names)
Add some levels to the debugging process, using default parameters. |
void |
debug(String names,
Object parameters)
Add some levels to the debugging process, using default parameters. |
Component |
getComponent()
Get the last component (or container) that was added. |
UIHConfig |
getConfig()
Get the configuration of this hierarchy instance. |
Container |
getContainer()
Get the container for which the hierarchy is currently being defined, or the last root container that was created if the hierarchy is completed. |
boolean |
isClosed()
Indicate whether the hierarchy is closed. |
HNode |
open()
Create a node in the hierarchy. |
HNode |
open(Object container)
Create a node in the hierarchy with a specific container. |
HRootNode |
openNew(Object container)
Start a hierarchy. |
UIH |
print()
Print the hierarchy to help debugging. |
void |
realize()
Realize the hierarchy. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public final UIH _
UIH h = new UIH();
h.openNew(getContentPane());
h._.open().layout(new GridBagLayout()).constrain(BorderLayout.CENTER);
h._._.add("A label: ").constrain("anchor=WEST");
h._._.add(new JButton("A button")).constrain("gridx=0, gridy=1");
h._.close();
h.close();
Constructor Detail |
public UIH()
public UIH(UIHConfig uihConfig)
uihConfig
- The configuration to use.Method Detail |
public Accessor createAccessor(String names)
names
- The names of the hierarchy levels to get, in a comma separated
String if more than one name is to be specified.
AccessorFactory
public Accessor createAccessor(String names, String excludedNames)
names
- The names of the hierarchy levels to get, in a comma separated
String if more than one name is to be specified.excludedNames
- The names of the levels to exclude when creating an
accessor on the names.
AccessorFactory
public UIH print()
public Container getContainer()
public boolean isClosed()
public Component getComponent()
public HRootNode openNew(Object container)
container
- The container to add to the hierarchy.
public HNode open()
public HNode open(Object container)
container
- The container to add to the hierarchy.
public HLeaf add()
public HLeaf add(Object component)
component
- The component to add to the hierarchy.
public UIH.SingleLevelHandler add(SingleLevelAccessor accessor)
accessor
- The accessor from which to retrieve the hierarchy to add.
public void close()
public void realize()
public UIHConfig getConfig()
UIHClassConfig
class.
public void debug(String names)
names
- The names of the mapped levels to debug.public void debug(String names, Object parameters)
names
- The names of the mapped levels to debug.parameters
- The parameters to use to debug, which can actually be a
debugger to use.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |