Package com.diffplug.common.swt.jface
Class Actions
- java.lang.Object
-
- com.diffplug.common.swt.jface.Actions
-
public class Actions extends java.lang.ObjectProvides a fluent interface for constructing actions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classActions.StyleStyle enum for various kinds of IAction.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringUC_ARROW_DOWNstatic java.lang.StringUC_ARROW_LEFTstatic java.lang.StringUC_ARROW_RIGHTstatic java.lang.StringUC_ARROW_UPUnicode for arrows.static java.lang.StringUC_CMDUnicode for the Mac cmd icon.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IActionbuild()Returns an action with the specified properties.static Actionsbuilder()Defaults to a push style with no text, accelerator, or action.static ActionsbuilderCopy(IAction action)Copies all behavior from the given action.static IActioncreate(java.lang.String text, java.lang.Runnable action)Concise method for creating a push action.static IActioncreate(java.lang.String text, ImageDescriptor image, int accelerator, java.lang.Runnable action)Concise method for creating a push action.static IActioncreate(java.lang.String text, ImageDescriptor image, int accelerator, Listener listener)Concise method for creating a push action.static IActioncreate(java.lang.String text, ImageDescriptor image, java.lang.Runnable action)Concise method for creating a push action.static IActioncreate(java.lang.String text, ImageDescriptor image, Listener listener)Concise method for creating a push action.static IActioncreate(java.lang.String text, Listener listener)Concise method for creating a push action.static java.lang.StringgetAcceleratorString(int accelerator)Returns the given key accelerator as a string (including shift, control, command, etc).static voidrun(IAction action)Updates the `isChecked()` property of the given IAction (if necessary), then calls IAction::run.static voidrun(IAction action, Event e)Updates the `isChecked()` property of the given IAction (if necessary), then calls IAction::runWithEvent.ActionssetAccelerator(int accelerator)Sets the keyboard accelerator.ActionssetCallback(java.util.function.BiConsumer<IAction,Event> callback)Sets the callback to be the given BiConsumer.ActionssetImage(ImageDescriptor img)Sets the runnable.ActionssetListener(Listener listener)Sets the callback to be the given Listener.ActionssetRunnable(java.lang.Runnable run)Sets the callback to be the given Runnable.ActionssetStyle(Actions.Style style)Sets the style.ActionssetText(java.lang.String text)Sets the text and tooltip.ActionssetTooltip(java.lang.String tooltip)Sets the tooltip.static voidsetToolTipAccelAware(IAction action, java.lang.String tooltip)Sets the tooltip text for the given action while remaing aware of its accelerator.
-
-
-
Field Detail
-
UC_ARROW_UP
public static final java.lang.String UC_ARROW_UP
Unicode for arrows.- See Also:
- Constant Field Values
-
UC_ARROW_DOWN
public static final java.lang.String UC_ARROW_DOWN
- See Also:
- Constant Field Values
-
UC_ARROW_LEFT
public static final java.lang.String UC_ARROW_LEFT
- See Also:
- Constant Field Values
-
UC_ARROW_RIGHT
public static final java.lang.String UC_ARROW_RIGHT
- See Also:
- Constant Field Values
-
UC_CMD
public static final java.lang.String UC_CMD
Unicode for the Mac cmd icon.- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static IAction create(java.lang.String text, java.lang.Runnable action)
Concise method for creating a push action.
-
create
public static IAction create(java.lang.String text, ImageDescriptor image, java.lang.Runnable action)
Concise method for creating a push action.
-
create
public static IAction create(java.lang.String text, ImageDescriptor image, int accelerator, java.lang.Runnable action)
Concise method for creating a push action.
-
create
public static IAction create(java.lang.String text, Listener listener)
Concise method for creating a push action.
-
create
public static IAction create(java.lang.String text, ImageDescriptor image, Listener listener)
Concise method for creating a push action.
-
create
public static IAction create(java.lang.String text, ImageDescriptor image, int accelerator, Listener listener)
Concise method for creating a push action.
-
builder
public static Actions builder()
Defaults to a push style with no text, accelerator, or action.
-
builderCopy
public static Actions builderCopy(IAction action)
Copies all behavior from the given action.
-
setText
public Actions setText(java.lang.String text)
Sets the text and tooltip.
-
setTooltip
public Actions setTooltip(java.lang.String tooltip)
Sets the tooltip.
-
setStyle
public Actions setStyle(Actions.Style style)
Sets the style.
-
setRunnable
public Actions setRunnable(java.lang.Runnable run)
Sets the callback to be the given Runnable.
-
setListener
public Actions setListener(Listener listener)
Sets the callback to be the given Listener. It may receive a null event.
-
setCallback
public Actions setCallback(java.util.function.BiConsumer<IAction,Event> callback)
Sets the callback to be the given BiConsumer. Action will definitely be present, but event might be missing.
-
setAccelerator
public Actions setAccelerator(int accelerator)
Sets the keyboard accelerator.
-
setImage
public Actions setImage(ImageDescriptor img)
Sets the runnable.
-
build
public IAction build()
Returns an action with the specified properties.
-
setToolTipAccelAware
public static void setToolTipAccelAware(IAction action, java.lang.String tooltip)
Sets the tooltip text for the given action while remaing aware of its accelerator.
-
getAcceleratorString
public static java.lang.String getAcceleratorString(int accelerator)
Returns the given key accelerator as a string (including shift, control, command, etc).
-
run
public static void run(IAction action)
Updates the `isChecked()` property of the given IAction (if necessary), then calls IAction::run.
-
-