Class ToolbarButton


  • public abstract class ToolbarButton
    extends java.lang.Object
    Representation of a toolbar button that should be added to the toolbar of the underlying CKEditor. Can be used to either execute Javascript or Java via callbacks.

    To execute Javascript in the browser, override getJavascriptToExecute() to return the Javascript code as String, that should be interpreted by the browser.

    To execute Java via callback, override execute() and ensure that getJavascriptToExecute() returns null.

    The available toolbars a button can be added to are configured via ToolbarConfiguration.getToolbarGroupConfiguration(). It is possible to specify the position of the button in the toolbar group via comma separated index, e.g. other,1 will place a new button at the first position of the toolbar group with the name other.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String buttonLabel  
      private java.lang.String buttonName  
      private java.lang.String commandName  
      private java.net.URL iconURL  
      private java.lang.String toolbar  
    • Constructor Summary

      Constructors 
      Constructor Description
      ToolbarButton​(java.lang.String buttonName, java.lang.String commandName, java.lang.String buttonLabel, java.lang.String toolbar, java.net.URL iconURL)
      Create a ToolbarButton with the given information.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object execute()
      The code that should be executed via Javascript callback when this button is pressed.
      java.lang.String getButtonLabel()  
      java.lang.String getButtonName()  
      java.lang.String getCommandName()  
      java.net.URL getIconURL()  
      java.lang.String getJavascriptToExecute()
      This method can be used to specify Javascript calls that should be executed.
      java.lang.String getToolbar()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • buttonName

        private final java.lang.String buttonName
      • commandName

        private final java.lang.String commandName
      • buttonLabel

        private final java.lang.String buttonLabel
      • toolbar

        private final java.lang.String toolbar
      • iconURL

        private final java.net.URL iconURL
    • Constructor Detail

      • ToolbarButton

        public ToolbarButton​(java.lang.String buttonName,
                             java.lang.String commandName,
                             java.lang.String buttonLabel,
                             java.lang.String toolbar,
                             java.net.URL iconURL)
        Create a ToolbarButton with the given information.
        Parameters:
        buttonName - The unique name of the dynamically created CKEditor button.
        commandName - The unique name of the dynamically created CKEditor command that is called by pressing this button.
        buttonLabel - The textual part of the button (if visible) and its tooltip.
        toolbar - The toolbar group into which the button will be added. An optional index value (separated by a comma) determines the button position within the group.
        iconURL - The URL of the image that should be show as button icon.
    • Method Detail

      • getButtonName

        public java.lang.String getButtonName()
        Returns:
        The unique name of the dynamically created CKEditor button.
      • getCommandName

        public java.lang.String getCommandName()
        Returns:
        The unique name of the dynamically created CKEditor command that is called by pressing this button.
      • getButtonLabel

        public java.lang.String getButtonLabel()
        Returns:
        The textual part of the button (if visible) and its tooltip.
      • getToolbar

        public java.lang.String getToolbar()
        Returns:
        The toolbar group into which the button will be added. An optional index value (separated by a comma) determines the button position within the group.
      • getIconURL

        public java.net.URL getIconURL()
        Returns:
        The URL of the image that should be show as button icon.
      • getJavascriptToExecute

        public java.lang.String getJavascriptToExecute()
        This method can be used to specify Javascript calls that should be executed. If this method does not return null, the specified Javascript code is evaluated. Otherwise the Java code specified in execute() is executed via Javascript callback.
        Returns:
        The Javascript to execute or null to execute the callback.
      • execute

        public java.lang.Object execute()
        The code that should be executed via Javascript callback when this button is pressed.
        Returns:
        A possible return value.