public class ShadowMenu extends AbstractContextual implements Comparable<ShadowMenu>, Collection<ModuleInfo>, Runnable, Named
A ShadowMenu
is a tree node with links to other tree nodes. It is
possible to traverse the entire menu structure from any given node, though by
convention the root node is used to represent the menu as a whole.
The class is implemented as a Collection
of modules (i.e.,
ModuleInfo
objects), with the tree structure generated from the
modules' menu paths (see UIDetails.getMenuPath()
). The class also
implements Runnable
, with each leaf node retaining a link to its
corresponding ModuleInfo
, and executing that module when
run()
is called.
MenuCreator
,
MenuPath
,
MenuEntry
Constructor and Description |
---|
ShadowMenu(Context context,
Collection<? extends ModuleInfo> modules)
Constructs a root menu node populated with the given modules.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(ModuleInfo o)
Adds the given module to the menu structure.
|
boolean |
addAll(Collection<? extends ModuleInfo> c)
Adds the given modules to the menu structure.
|
void |
clear() |
int |
compareTo(ShadowMenu c) |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
List<ShadowMenu> |
getChildren()
Gets this node's children, sorted by weight.
|
URL |
getIconURL()
Gets the URL of the icon associated with this node's
MenuEntry . |
ShadowMenu |
getMenu(MenuPath menuPath)
Gets the node with the given menu path (relative to this node), or null if
no such menu node.
|
ShadowMenu |
getMenu(String path) |
int |
getMenuDepth()
Gets how deep into the menu structure this node is.
|
MenuEntry |
getMenuEntry()
Gets the menu entry corresponding to this node.
|
ModuleInfo |
getModuleInfo()
Gets the module linked to this node, or null if node is not a leaf.
|
String |
getName()
Gets the name of the object.
|
ShadowMenu |
getParent()
Gets this node's parent, or null if it is a root node.
|
boolean |
isCheckBox()
Returns true if this node is a checkbox.
|
boolean |
isEmpty() |
boolean |
isLeaf()
Returns true if this node has no children.
|
boolean |
isRadioButton()
Returns true if this node is a radio button.
|
boolean |
isToggle()
Returns true if this node is selectable (checkbox or radio button).
|
ShadowMenuIterator |
iterator() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
void |
run()
Executes the module linked to this node.
|
void |
setName(String name)
Sets the name of the object.
|
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
boolean |
update(ModuleInfo module)
Updates the menu structure to reflect changes in the given module.
|
boolean |
updateAll(Collection<? extends ModuleInfo> c)
Updates the menu structure to reflect changes in the given modules.
|
context, getContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, parallelStream, removeIf, spliterator, stream
setContext
public ShadowMenu(Context context, Collection<? extends ModuleInfo> modules)
public ModuleInfo getModuleInfo()
public ShadowMenu getMenu(MenuPath menuPath)
For example, asking for "File > New > Image..." from the root application menu node would retrieve the node for "Image...", as would asking for "New > Image..." from the "File" node.
public ShadowMenu getMenu(String path)
public MenuEntry getMenuEntry()
public int getMenuDepth()
public ShadowMenu getParent()
public List<ShadowMenu> getChildren()
public boolean isLeaf()
public boolean isToggle()
public boolean isCheckBox()
public boolean isRadioButton()
public URL getIconURL()
MenuEntry
.PluginInfo.getIconURL()
public boolean update(ModuleInfo module)
public boolean updateAll(Collection<? extends ModuleInfo> c)
public String getName()
Named
public void setName(String name)
Named
public int compareTo(ShadowMenu c)
compareTo
in interface Comparable<ShadowMenu>
public void run()
public boolean add(ModuleInfo o)
UIDetails.isVisible()
returns false), it is ignored.
add
in interface Collection<ModuleInfo>
public boolean addAll(Collection<? extends ModuleInfo> c)
UIDetails.isVisible()
returns false), it is ignored.
addAll
in interface Collection<ModuleInfo>
public void clear()
clear
in interface Collection<ModuleInfo>
public boolean contains(Object o)
contains
in interface Collection<ModuleInfo>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<ModuleInfo>
public boolean isEmpty()
isEmpty
in interface Collection<ModuleInfo>
public ShadowMenuIterator iterator()
iterator
in interface Iterable<ModuleInfo>
iterator
in interface Collection<ModuleInfo>
public boolean remove(Object o)
remove
in interface Collection<ModuleInfo>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<ModuleInfo>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<ModuleInfo>
public int size()
size
in interface Collection<ModuleInfo>
public Object[] toArray()
toArray
in interface Collection<ModuleInfo>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<ModuleInfo>
Copyright © 2015–2022 SciJava. All rights reserved.