Class BaseEditorToolBar

java.lang.Object
com.inet.editor.BaseEditorToolBar
All Implemented Interfaces:
ContainerListener, EventListener

public class BaseEditorToolBar extends Object implements ContainerListener
This is the toolbar of the base editor. It support custom button groups which can be enabled, disabled or hidden. The groups will be loaded on demand, as required by the current document
  • Constructor Details

    • BaseEditorToolBar

      public BaseEditorToolBar(JTextPane editor)
      Creates the a toolbar controller and toolbar for a normal editor. To get the Swing component call getToolbar().
      Parameters:
      editor - the editor to which is this toolbar will be registered first
      Since:
      1.09
  • Method Details

    • addComponent

      public void addComponent(Component comp, Integer group, ActionListener listener)
      Adds a component to the model. This DOES NOT display the component!
      Parameters:
      comp - The component to add
      group - the group where to add the component
      listener - the ActionListener for this component(duplicate-safe!)
    • createComponentGroup

      public void createComponentGroup(Integer groupKey, boolean requiresLeftSep, boolean requiresRightSep, boolean visible)
      Creates a new component group for the toolbar.
      Parameters:
      groupKey - the key of the group which will be created
      requiresLeftSep - set to true, if the group requires a separator to the left
      requiresRightSep - set to true, if the group requires a separator to the right
      visible - should this group be visible immediatly?
    • addButtons

      protected void addButtons()
      Add buttons and commponent to the toolbar. You can override if you want add additional buttons.
    • isAutoSpellCheck

      protected boolean isAutoSpellCheck()
      Is the automatic spell checking enabled. The default is true. This can be overriden form a custom instance.
      Returns:
      true
    • notifyFormat

      public void notifyFormat(boolean isHtml)
      Inform this object of a content type change, will modify the format switch.
      Parameters:
      isHtml - true, if html
    • setToolbarVisible

      public void setToolbarVisible(boolean visible)
      Proxy for toolbar.setVisible(), will work without a toolbar as well
      Parameters:
      visible - true, to set visible
    • enableGroups

      public void enableGroups(Integer... groups)
      Enables / displays the given component groups on the toolbar.
      Parameters:
      groups - the groups to display
    • disableGroups

      public void disableGroups(Integer... groups)
      Disables / hides the given component groups on the toolbar.
      Parameters:
      groups - the groups to display
    • setEditable

      public void setEditable(boolean editable)
      Proxy for the Swing setEditable() function on the toolbar and it's components. Will display or hide all groups except the GROUP_DEFAULT
      Parameters:
      editable - true to enable, false to disable
    • setEnableFormatButtons

      protected void setEnableFormatButtons(boolean isHtml)
      Disables or enabled the format buttons which are only allowed for HTML
      Parameters:
      isHtml - true --> HTML
    • updateToolbar

      public void updateToolbar()
      This method has to be called, to display the changed made in the model. Adds or removes will only have a visible effect, if this function will be called afterwards!
      NOTE: GUI function, call in EDT only!
    • componentAdded

      public void componentAdded(ContainerEvent e)
      Specified by:
      componentAdded in interface ContainerListener
    • componentRemoved

      public void componentRemoved(ContainerEvent e)
      Specified by:
      componentRemoved in interface ContainerListener
    • setEnabled

      public void setEnabled(boolean enabled)
      Enables or disables all toolbar components.
      Parameters:
      enabled - true, if enabled, false otherwise
    • getToolbar

      public JToolBar getToolbar()
      returns the internal toolbar object, or null if it's not present.
      Returns:
      the internal toolbar object, or null if it's not present
    • setSelectionColor

      public void setSelectionColor(Color value)
      Sets the selection color.
      Parameters:
      value - the new selection color
    • setSearchVisible

      public void setSearchVisible(boolean visible)
      Displays or hides the search-button, if available
      Parameters:
      visible - true for visible, false for hidden
    • setBoldSelected

      public void setBoldSelected(boolean b)
      Sets the bold selected.
      Parameters:
      b - the new bold selected
    • setItalicSelected

      public void setItalicSelected(boolean b)
      Sets the italic selected.
      Parameters:
      b - the new italic selected
    • setUnderlineSelected

      public void setUnderlineSelected(boolean b)
      Sets the underline selected.
      Parameters:
      b - the new underline selected
    • setSelectedFontName

      public void setSelectedFontName(String fontName)
      Sets the selected font name.
      Parameters:
      fontName - the new selected font name
    • setSelectedFontSize

      public void setSelectedFontSize(Object fontSize)
      Sets the selected font size.
      Parameters:
      fontSize - the new selected font size
    • setLeftSelected

      public void setLeftSelected(boolean b)
      Sets the left selected.
      Parameters:
      b - the new left selected
    • setCenterSelected

      public void setCenterSelected(boolean b)
      Sets the center selected.
      Parameters:
      b - the new center selected
    • setRightSelected

      public void setRightSelected(boolean b)
      Sets the right selected.
      Parameters:
      b - the new right selected
    • setJustifySelected

      public void setJustifySelected(boolean b)
      Sets the justify selected.
      Parameters:
      b - the new justify selected
    • getFontNameComboBox

      public JComboBox<?> getFontNameComboBox()
      Gets the font name combo box.
      Returns:
      the font name combo box
    • getFontSizeComboBox

      public JComboBox<?> getFontSizeComboBox()
      Gets the font size combo box.
      Returns:
      the font size combo box
    • getFontColor

      public JButton getFontColor()
      Gets the font color.
      Returns:
      the font color
    • getColorMenu

      public JPopupMenu getColorMenu()
      Gets the color menu.
      Returns:
      the color menu
    • getColorList

      public ColorList getColorList()
      Gets the color list.
      Returns:
      the color list
    • getBold

      public JToggleButton getBold()
      Gets the bold.
      Returns:
      the bold
    • getItalic

      public JToggleButton getItalic()
      Gets the italic.
      Returns:
      the italic
    • getUnderline

      public JToggleButton getUnderline()
      Gets the underline.
      Returns:
      the underline
    • getLeft

      public JToggleButton getLeft()
      Gets the left.
      Returns:
      the left
    • getCenter

      public JToggleButton getCenter()
      Gets the center.
      Returns:
      the center
    • getRight

      public JToggleButton getRight()
      Gets the right.
      Returns:
      the right
    • getJustify

      public JToggleButton getJustify()
      Gets the justify.
      Returns:
      the justify
    • getBulletList

      public JButton getBulletList()
      Gets the bullet list.
      Returns:
      the bullet list
    • getNumberList

      public JButton getNumberList()
      Gets the number list.
      Returns:
      the number list
    • getBlockLeft

      public JButton getBlockLeft()
      Gets the block left.
      Returns:
      the block left
    • getBlockRight

      public JButton getBlockRight()
      Gets the block right button.
      Returns:
      the block right button
    • getHr

      public JButton getHr()
      Gets the horizontal ruler button.
      Returns:
      the horizontal ruler button
    • getHyperlink

      public JButton getHyperlink()
      Gets the hyperlink button.
      Returns:
      the hyperlink button
    • getUndoButton

      public JButton getUndoButton()
      Gets the undo button.
      Returns:
      the undo button
    • getRedoButton

      public JButton getRedoButton()
      Gets the redo button.
      Returns:
      the redo button
    • getHtmlFormat

      public JButton getHtmlFormat()
      Gets the html format button.
      Returns:
      the html format button
    • getAddimage

      public JButton getAddimage()
      Gets the 'add image' button.
      Returns:
      the 'add image' button
    • getSpellchecker

      public JButton getSpellchecker()
      Gets the spellchecker button.
      Returns:
      the spellchecker button
    • getAutoSpell

      public JToggleButton getAutoSpell()
      Gets the enable/disable auto spellchecker button.
      Returns:
      the enable/disable auto spellchecker button
    • getButtonoffset

      public int getButtonoffset()
      Gets the buttonoffset.
      Returns:
      the buttonoffset
    • setUndoButtonEnabled

      public void setUndoButtonEnabled(boolean canUndo)
      Sets the undo button enabled.
      Parameters:
      canUndo - the new undo button enabled
    • setRedoButtonEnabled

      public void setRedoButtonEnabled(boolean canRedo)
      Sets the redo button enabled.
      Parameters:
      canRedo - the new redo button enabled
    • getAddImageAction

      public Action getAddImageAction()
      Gets the adds the image action.
      Returns:
      the adds the image action or null
    • setAddImageEnabled

      public void setAddImageEnabled(boolean enabled)
      Sets the adds the image enabled.
      Parameters:
      enabled - the new adds the image enabled
    • setAutoSpellSelected

      public void setAutoSpellSelected(boolean enabled)
      Sets the auto spell selected.
      Parameters:
      enabled - the new auto spell selected
    • switchEditor

      public void switchEditor(JTextPane text)
      Switches the toolbar to another editor
      Parameters:
      text - the editor to switch to, must not be null
      Since:
      1.09