|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dsto.dfc.util.BasicPropertyEventSource dsto.dfc.swing.commands.CommandView
public class CommandView
A list of Command
's and sub-CommandView's intended to
define the commands presented in a given UI context, such as a main
menu or a toolbar. See CommandMenus
and CommandToolBars
for examples of how to present command views in a
UI. The internal implementation manages a tree of CommandViewNode
's representing the merged commands both from this
view and the commands from child command views.
An object (usually a Component) that wishes to export a set of
commands for inclusion in a main menu, toolbar, etc will implement
the CommandSource
interface and export CommandView's with
the appropriate commands (and any command views, including those
originating from any contained components).
CommandSource
,
Command
,
CommandMenus
,
CommandToolBars
,
Serialized FormField Summary | |
---|---|
static String |
CONTEXT_MENU_VIEW
|
static String |
MAIN_MENU_VIEW
|
static String |
TOOLBAR_VIEW
|
Constructor Summary | |
---|---|
CommandView(String viewName)
Create a new command view. |
Method Summary | |
---|---|
void |
activate()
Logically active this view, bringing any of its overloaded commands to the 'top', making them active. |
protected void |
activateSubtree(CommandViewNode root,
CommandViewNode subRoot)
|
void |
addCommand(Command command)
Add a command to the end of the view. |
void |
addCommand(Command command,
int index)
Add a command to the view at a specific index. |
void |
addCommands(Collection commands)
|
protected void |
addEntry(Object entry,
CommandViewNode rootNode,
int index)
|
void |
addGroup(String group)
|
void |
addGroup(String group,
int index)
Add an empty command group to the view. |
void |
addView(CommandView view)
Add a child command view to this view. |
void |
addView(CommandView view,
int index)
Add a child command view with a specific index. |
void |
clearCommandProperties()
Remove all command client properties. |
protected void |
commandPropertyChanged(PropertyChangeEvent e)
|
boolean |
containsCommand(Command command)
|
boolean |
containsGroup(String group)
|
boolean |
containsView(CommandView subView)
|
Command |
findCommand(String commandName)
Find the first instance of a command with a matching name in a breadth-first search of subviews. |
CommandView |
findViewForCommand(String commandName)
Find the first view in a breadth-first search of subviews that contains a command with a matching name. |
Command |
getCommand(Class commandClass)
|
Command |
getCommand(int index)
Get the command at a given ordinal. |
Command |
getCommand(String commandName)
|
Object |
getCommandProperty(String commandName,
Object key)
Get a client property for a command. |
boolean |
getCommandProperty(String commandName,
Object key,
boolean defaultValue)
Get a boolean client property for a command. |
Object |
getCommandProperty(String commandName,
Object key,
Object defaultValue)
Get a client property for a command. |
Command |
getDefaultCommand()
|
Object |
getEntry(int index)
Get the the entry at a given index in the view. |
int |
getEntryCount()
The number of entries (views and commands in this view). |
int |
getIndex(Command command)
|
int |
getIndex(CommandView view)
Get the index associated with a sub view a CommandView. |
protected int |
getMajorIndex(CommandViewNode node)
Get the index associated with a node of a subtree contained in this view. |
CommandViewNode |
getTreeRoot()
The root of the merged command tree. |
CommandView |
getView(int index)
Get the command at a given ordinal. |
String |
getViewName()
|
protected CommandViewNode |
makeVine(String group)
|
protected CommandViewNode |
makeVine(String group,
Command command)
Make a vine (tree where all nodes have at most one child) from a command. |
protected void |
merge(CommandViewNode parent,
CommandViewNode subtreeNode,
int majorIndex)
Merge (mount) a subtree node and all its children onto a node of this tree. |
protected void |
remergeMinorIndex(CommandViewNode parent,
CommandViewNode subtreeNode)
Remerge a subtree node and all its children with a changed minor index. |
void |
removeAll()
Remove all commands and command views from this view. |
void |
removeCommand(Class commandClass)
|
void |
removeCommand(Command command)
|
Command |
removeCommand(String commandName)
|
void |
removeCommands(Collection commands)
|
protected void |
removeEntry(Object entry)
|
protected void |
removeEntry(Object entry,
int index)
|
void |
removeGroup(String group)
|
void |
removeView(CommandView view)
Remove a child command view. |
void |
setCommandProperty(String commandName,
Object key,
Object value)
Set a client property for a command. |
void |
setDefaultCommand(Command newValue)
The default command for this view. |
protected void |
shiftMajorIndexes(CommandViewNode node,
int startIndex,
int delta)
Shift all the major indicies of nodes of a tree by a given amount. |
protected void |
subtreeChildAdded(CommandViewNodeEvent e)
|
protected void |
subtreeChildMoved(CommandViewNodeEvent e)
|
protected void |
subtreeChildRemoved(CommandViewNodeEvent e)
|
protected void |
subtreeCommandChanged(CommandViewNodeEvent e)
|
protected void |
unmerge(CommandViewNode parent,
CommandViewNode subtreeNode)
Reverse the effect of merge (). |
protected void |
updateCommandGroup(Command command)
Updates command tree when a command changes its group. |
protected void |
viewPropertyChanged(PropertyChangeEvent e)
|
Methods inherited from class dsto.dfc.util.BasicPropertyEventSource |
---|
addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener, setPropertyChangeSource |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String MAIN_MENU_VIEW
public static final String CONTEXT_MENU_VIEW
public static final String TOOLBAR_VIEW
Constructor Detail |
---|
public CommandView(String viewName)
viewName
- The view name (usually one of MAIN_MENU_VIEW,
CONTEXT_MENU_VIEW or TOOLBAR_VIEW).Method Detail |
---|
public String getViewName()
public Command getDefaultCommand()
public void setDefaultCommand(Command newValue)
public void setCommandProperty(String commandName, Object key, Object value)
commandName
- The command's name (eg as obtained by getName ()).key
- The property key.value
- The property value.getCommandProperty(String,Object,Object)
public boolean getCommandProperty(String commandName, Object key, boolean defaultValue)
commandName
- The command's name (eg as obtained by getName ()).key
- The property key.defaultValue
- The value to return if property is not set.
ClassCastException
- if the property exists but is not boolean.setCommandProperty(java.lang.String, java.lang.Object, java.lang.Object)
public Object getCommandProperty(String commandName, Object key, Object defaultValue)
commandName
- The command's name (eg as obtained by getName ()).key
- The property key.defaultValue
- The value to return if property is not set.
setCommandProperty(java.lang.String, java.lang.Object, java.lang.Object)
public Object getCommandProperty(String commandName, Object key)
commandName
- The command's name (eg as obtained by getName ()).key
- The property key.
setCommandProperty(java.lang.String, java.lang.Object, java.lang.Object)
public void clearCommandProperties()
setCommandProperty(java.lang.String, java.lang.Object, java.lang.Object)
public CommandView findViewForCommand(String commandName)
commandName
- The name of the command.
public Command findCommand(String commandName)
public void activate()
WindowFocusTracker
for an example of resolving overloaded
commands (via input focus) using this facility.
public CommandViewNode getTreeRoot()
public boolean containsView(CommandView subView)
public boolean containsCommand(Command command)
public boolean containsGroup(String group)
public void addView(CommandView view)
public void addView(CommandView view, int index)
public void removeView(CommandView view)
public void addCommand(Command command)
public void addCommands(Collection commands)
public void removeCommands(Collection commands)
public void removeAll()
public void addCommand(Command command, int index)
public void removeCommand(Command command)
public Command removeCommand(String commandName)
public void addGroup(String group)
addGroup(String,int)
public void addGroup(String group, int index)
public void removeGroup(String group)
public Command getCommand(String commandName)
public void removeCommand(Class commandClass)
public Command getCommand(Class commandClass)
public int getEntryCount()
public Command getCommand(int index) throws IndexOutOfBoundsException, ClassCastException
IndexOutOfBoundsException
- if index is not valid.
ClassCastException
- if entry at index is not a command.public CommandView getView(int index) throws IndexOutOfBoundsException, ClassCastException
IndexOutOfBoundsException
- if index is not valid.
ClassCastException
- if entry at index is not a command.public Object getEntry(int index)
index
- The index of the entry.
public int getIndex(CommandView view)
public int getIndex(Command command)
protected int getMajorIndex(CommandViewNode node)
node
- A node from a direct subtree of this view.
protected void shiftMajorIndexes(CommandViewNode node, int startIndex, int delta)
node
- The root of the tree.startIndex
- The lower bound of indexes to change.delta
- The amount to shift the index by.CommandViewNode.shiftMajorIndexes(int, int)
protected CommandViewNode makeVine(String group, Command command)
group
- The group to place the command in.command
- The command.
protected CommandViewNode makeVine(String group)
protected void addEntry(Object entry, CommandViewNode rootNode, int index)
protected void removeEntry(Object entry)
protected void removeEntry(Object entry, int index)
protected void merge(CommandViewNode parent, CommandViewNode subtreeNode, int majorIndex)
parent
- The parent of the new merged node.subtreeNode
- The subtree node to merge into a child of
parent.majorIndex
- The major index to associate with the merge.unmerge(dsto.dfc.swing.commands.CommandViewNode, dsto.dfc.swing.commands.CommandViewNode)
,
CommandViewNode.mergeChild(dsto.dfc.swing.commands.CommandViewNode, int, int)
protected void unmerge(CommandViewNode parent, CommandViewNode subtreeNode)
parent
- The parent of the merged node.subtreeNode
- The subtree node that should be unmerged.protected void remergeMinorIndex(CommandViewNode parent, CommandViewNode subtreeNode)
parent
- The parent of the merged node.subtreeNode
- The subtree node.merge(dsto.dfc.swing.commands.CommandViewNode, dsto.dfc.swing.commands.CommandViewNode, int)
protected void updateCommandGroup(Command command)
protected void activateSubtree(CommandViewNode root, CommandViewNode subRoot)
protected void commandPropertyChanged(PropertyChangeEvent e)
protected void viewPropertyChanged(PropertyChangeEvent e)
protected void subtreeChildAdded(CommandViewNodeEvent e)
protected void subtreeChildRemoved(CommandViewNodeEvent e)
protected void subtreeChildMoved(CommandViewNodeEvent e)
protected void subtreeCommandChanged(CommandViewNodeEvent e)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |