classafReflux::GlobalCommand

sys::Obj
  afReflux::GlobalCommand

@Js

Reusable commands that may be contextually enabled by Views and Panels.

GlobalCommands must be autobuilt by IoC. Contribute GlobalCommand instances to the GlobalCommands service in your AppModule:

@Contribute { serviceType=GlobalCommands# }
static Void contributeGlobalCommands(Configuration config) {
    config["myGlobCmd"] = config.autobuild(MyGlobalCommand#)
}

Use the contribution Id to access the command in the GlobalCommands service:

globalCommands.get("myGlobCmd")

globalCommands["myGlobCmd"]

GlobalCommands are disabled by default. To enable, add an enabler function or enable the fwt command directly.

GlobalCommands are automatically added to the EventHub, so to receive events they only need to implement the required event mixin.

Reflux defines the following GlobalCommands:

  • afReflux.cmdAbout
  • afReflux.cmdCopy
  • afReflux.cmdCut
  • afReflux.cmdExit
  • afReflux.cmdNavBackward
  • afReflux.cmdNavClear
  • afReflux.cmdNavForward
  • afReflux.cmdNavHome
  • afReflux.cmdNavUp
  • afReflux.cmdNew
  • afReflux.cmdPaste
  • afReflux.cmdRedo
  • afReflux.cmdRefresh
  • afReflux.cmdSave
  • afReflux.cmdSaveAll
  • afReflux.cmdSaveAs
  • afReflux.cmdToggleView
  • afReflux.cmdUndo
addEnabler

Source

Void addEnabler(Str listenerId, |->Bool listener, Bool update := true)

Adds a function that helps decide if the underlying command should be enabled or not.

If update if true then the underlying command is updated. Defaults to true.

Sometimes an enabler function gives undesirable results (such as IoC recursion errs) when added from a ctor. If this happens, try setting update to false.

addInvoker

Source

Void addInvoker(Str listenerId, |Event? listener)

Adds a function to be executed when the command is invoked.

command

Source

RefluxCommand command

The wrapped command.

doInvoke

Source

virtual Void doInvoke(Event? event)

Callback for subclasses.

enabled

Source

Bool enabled { private set }

Returns if this command is currently enabled or not. A GlobalCommand is enabled if any enabler function returns true.

make

Source

new make(Str baseName, |This in)

Creates a global command. The base name is used as a localisation key.

removeEnabler

Source

Void removeEnabler(Str listenerId)

Removes the specified enabler function.

removeInvoker

Source

Void removeInvoker(Str listenerId)

Removes the specified invoker function.

update

Source

virtual Void update()

Enables / disables the underlying fwt command based on the enabled property.