public class Actions extends Object
Provides a fluent interface for constructing actions.
Modifier and Type | Class and Description |
---|---|
static class |
Actions.Style
Style enum for various kinds of IAction.
|
Modifier and Type | Field and Description |
---|---|
static String |
UC_ARROW_DOWN |
static String |
UC_ARROW_LEFT |
static String |
UC_ARROW_RIGHT |
static String |
UC_ARROW_UP
Unicode for arrows.
|
static String |
UC_CMD
Unicode for the Mac cmd icon.
|
Modifier and Type | Method and Description |
---|---|
IAction |
build()
Returns an action with the specified properties.
|
static Actions |
builder()
Defaults to a push style with no text, accelerator, or action.
|
static Actions |
builderCopy(IAction action)
Copies all behavior from the given action.
|
static IAction |
create(String text,
ImageDescriptor image,
int accelerator,
Listener listener)
Concise method for creating a push action.
|
static IAction |
create(String text,
ImageDescriptor image,
int accelerator,
Runnable action)
Concise method for creating a push action.
|
static IAction |
create(String text,
ImageDescriptor image,
Listener listener)
Concise method for creating a push action.
|
static IAction |
create(String text,
ImageDescriptor image,
Runnable action)
Concise method for creating a push action.
|
static IAction |
create(String text,
Listener listener)
Concise method for creating a push action.
|
static IAction |
create(String text,
Runnable action)
Concise method for creating a push action.
|
static String |
getAcceleratorString(int accelerator)
Returns the given key accelerator as a string (including shift, control, command, etc).
|
static void |
run(IAction action)
Updates the
isChecked() property of the given IAction (if necessary), then calls IAction::run. |
static void |
run(IAction action,
Event e)
Updates the
isChecked() property of the given IAction (if necessary), then calls IAction::runWithEvent. |
Actions |
setAccelerator(int accelerator)
Sets the keyboard accelerator.
|
Actions |
setCallback(BiConsumer<IAction,Event> callback)
Sets the callback to be the given BiConsumer.
|
Actions |
setImage(ImageDescriptor img)
Sets the runnable.
|
Actions |
setListener(Listener listener)
Sets the callback to be the given Listener.
|
Actions |
setRunnable(Runnable run)
Sets the callback to be the given Runnable.
|
Actions |
setStyle(Actions.Style style)
Sets the style.
|
Actions |
setText(String text)
Sets the text and tooltip.
|
Actions |
setTooltip(String tooltip)
Sets the tooltip.
|
static void |
setToolTipAccelAware(IAction action,
String tooltip)
Sets the tooltip text for the given action while remaing aware of its accelerator.
|
public static final String UC_ARROW_UP
Unicode for arrows.
public static final String UC_ARROW_DOWN
public static final String UC_ARROW_LEFT
public static final String UC_ARROW_RIGHT
public static final String UC_CMD
Unicode for the Mac cmd icon.
public static IAction create(String text, Runnable action)
Concise method for creating a push action.
public static IAction create(String text, ImageDescriptor image, Runnable action)
Concise method for creating a push action.
public static IAction create(String text, ImageDescriptor image, int accelerator, Runnable action)
Concise method for creating a push action.
public static IAction create(String text, Listener listener)
Concise method for creating a push action.
public static IAction create(String text, ImageDescriptor image, Listener listener)
Concise method for creating a push action.
public static IAction create(String text, ImageDescriptor image, int accelerator, Listener listener)
Concise method for creating a push action.
public static Actions builder()
Defaults to a push style with no text, accelerator, or action.
public static Actions builderCopy(IAction action)
Copies all behavior from the given action.
public Actions setStyle(Actions.Style style)
Sets the style.
public Actions setListener(Listener listener)
Sets the callback to be the given Listener. It may receive a null event.
public Actions setCallback(BiConsumer<IAction,Event> callback)
Sets the callback to be the given BiConsumer. Action will definitely be present, but event might be missing.
public Actions setAccelerator(int accelerator)
Sets the keyboard accelerator.
public Actions setImage(ImageDescriptor img)
Sets the runnable.
public IAction build()
Returns an action with the specified properties.
public static void setToolTipAccelAware(IAction action, String tooltip)
Sets the tooltip text for the given action while remaing aware of its accelerator.
public static String getAcceleratorString(int accelerator)
Returns the given key accelerator as a string (including shift, control, command, etc).
public static void run(IAction action)
Updates the isChecked()
property of the given IAction (if necessary), then calls IAction::run.