Class BoundCommand
java.lang.Object
be.imgn.swing.ui.BoundCommand
- All Implemented Interfaces:
DynamicEntry, MenuEntry, ToolBarEntry
A command of a view, turned into Swing objects. Each created component shares the command's
Action, so text,
icon, tooltip, enabled and selected state stay in sync.-
Nested Class Summary
Nested classes/interfaces inherited from interface DynamicEntry
DynamicEntry.ItemNested classes/interfaces inherited from interface MenuEntry
MenuEntry.Dynamic -
Field Summary
Fields inherited from interface DynamicEntry
NUMBERED, SEPARATORFields inherited from interface ToolBarEntry
SEPARATOR -
Method Summary
Modifier and TypeMethodDescriptionasAction()Returns the command's Swing action, the same on each call.voidcancel()Cancels every task the command started that hasn't ended, waiting ones included; does nothing when there is none.Returns a new button for the command.Returns a new check box menu item for a command with a selected state.Returns a new menu item for the command.Returns a new toggle button for a command with a selected state.booleanexecute()Runs the command as if activated, with aTrigger.Programmatictrigger and no modifier, if it is enabled.booleanexecute(CommandContext context) Runs the command as if activated, if it is enabled: whether it is enabled is theenabledobservable's current value, not the state of theAction, which follows it one posted update later.id()Returns the id, also the action command of every component created for the command.running()Returns whether the command is running:truefrom the moment it starts a task until every task it started has ended, waiting ones included;falseotherwise.toString()
-
Method Details
-
id
Returns the id, also the action command of every component created for the command.- Returns:
- the id
-
createButton
-
createMenuItem
-
createToggleButton
Returns a new toggle button for a command with a selected state.- Returns:
- the toggle button
- Throws:
IllegalStateException- if the command has no selected state
-
createCheckBoxMenuItem
Returns a new check box menu item for a command with a selected state.- Returns:
- the menu item
- Throws:
IllegalStateException- if the command has no selected state
-
asAction
Returns the command's Swing action, the same on each call.- Returns:
- the action
-
execute
public boolean execute()Runs the command as if activated, with aTrigger.Programmatictrigger and no modifier, if it is enabled.- Returns:
trueif the command ran,falseif it is disabled
-
execute
Runs the command as if activated, if it is enabled: whether it is enabled is theenabledobservable's current value, not the state of theAction, which follows it one posted update later.- Parameters:
context- how the command was activated- Returns:
trueif the command ran,falseif it is disabled
-
running
Returns whether the command is running:truefrom the moment it starts a task until every task it started has ended, waiting ones included;falseotherwise. A task has ended once its last hook has run, and the value changes on the EDT, after those hooks. A command whose handler returnsvoid, or returnsTask.none(), starts nothing, so it isn't running.- Returns:
- whether the command is running
-
cancel
public void cancel()Cancels every task the command started that hasn't ended, waiting ones included; does nothing when there is none. It may be called from any thread, and runs on the EDT, asexecute()does. -
toString
-