com.inet.editor
Class BaseEditorToolBar

java.lang.Object
  extended by com.inet.editor.BaseEditorToolBar
All Implemented Interfaces:
java.awt.event.ContainerListener, java.util.EventListener

public class BaseEditorToolBar
extends java.lang.Object
implements java.awt.event.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


Field Summary
static java.lang.Integer GROUP_DEFAULT
          Group for all components, which are directly added to the toolbar.
static java.lang.Integer GROUP_FORMATSWITCH
          The Constant GROUP_FORMATSWITCH.
static java.lang.Integer GROUP_HTMLFORMAT
          The Constant GROUP_HTMLFORMAT.
static java.lang.Integer GROUP_SPELLCHECKER
          The Constant GROUP_SPELLCHECKER.
static java.lang.Integer GROUP_UNDOREDO
          The Constant GROUP_UNDOREDO.
 
Constructor Summary
BaseEditorToolBar(BaseEditor editor, boolean hasToolbar, boolean isEditable, boolean isHtml)
          Creates the datamodel for the toolbar of the BaseEditor.
 
Method Summary
 void addComponent(java.awt.Component comp, java.lang.Integer group, java.awt.event.ActionListener listener)
          Adds a component to the model.
 void componentAdded(java.awt.event.ContainerEvent e)
          
 void componentRemoved(java.awt.event.ContainerEvent e)
          
 void createComponentGroup(java.lang.Integer groupKey, boolean requiresLeftSep, boolean requiresRightSep, boolean visible)
          Creates a new component group for the toolbar.
 void disableGroups(java.lang.Integer... groups)
          Disables / hides the given component groups on the toolbar.
 void enableGroups(java.lang.Integer... groups)
          Enables / displays the given component groups on the toolbar.
 javax.swing.JButton getAddimage()
          Gets the addimage.
 javax.swing.Action getAddImageAction()
          Gets the adds the image action.
 javax.swing.JToggleButton getAutoSpell()
          Gets the auto spell.
 javax.swing.JButton getBlockLeft()
          Gets the block left.
 javax.swing.JButton getBlockRight()
          Gets the block right.
 javax.swing.JToggleButton getBold()
          Gets the bold.
 javax.swing.JButton getBulletList()
          Gets the bullet list.
 int getButtonoffset()
          Gets the buttonoffset.
 javax.swing.JToggleButton getCenter()
          Gets the center.
 ColorList getColorList()
          Gets the color list.
 javax.swing.JPopupMenu getColorMenu()
          Gets the color menu.
 javax.swing.JButton getFontColor()
          Gets the font color.
 javax.swing.JComboBox getFontNameComboBox()
          Gets the font name combo box.
 javax.swing.JComboBox getFontSizeComboBox()
          Gets the font size combo box.
 javax.swing.JButton getHr()
          Gets the hr.
 javax.swing.JButton getHtmlFormat()
          Gets the html format.
 javax.swing.JButton getHyperlink()
          Gets the hyperlink.
 javax.swing.JToggleButton getItalic()
          Gets the italic.
 javax.swing.JToggleButton getJustify()
          Gets the justify.
 javax.swing.JToggleButton getLeft()
          Gets the left.
 javax.swing.JButton getNumberList()
          Gets the number list.
 javax.swing.JButton getRedoButton()
          Gets the redo button.
 javax.swing.JToggleButton getRight()
          Gets the right.
 javax.swing.JButton getSpellchecker()
          Gets the spellchecker.
 javax.swing.JToolBar getToolbar()
          returns the internal toolbar object, or null if it's not present.
 javax.swing.JToggleButton getUnderline()
          Gets the underline.
 javax.swing.JButton getUndoButton()
          Gets the undo button.
 void notifyFormat(boolean isHtml)
          Inform this object of a content type change, will modify the format switch.
 void setAddImageEnabled(boolean enabled)
          Sets the adds the image enabled.
 void setAutoSpellSelected(boolean enabled)
          Sets the auto spell selected.
 void setBoldSelected(boolean b)
          Sets the bold selected.
 void setCenterSelected(boolean b)
          Sets the center selected.
 void setEditable(boolean editable)
          Proxy for the Swing setEditable() function on the toolbar and it's components.
 void setEnabled(boolean enabled)
          Enables or disables all toolbar components.
 void setItalicSelected(boolean b)
          Sets the italic selected.
 void setJustifySelected(boolean b)
          Sets the justify selected.
 void setLeftSelected(boolean b)
          Sets the left selected.
 void setRedoButtonEnabled(boolean canRedo)
          Sets the redo button enabled.
 void setRightSelected(boolean b)
          Sets the right selected.
 void setSelectedFontName(java.lang.String fontName)
          Sets the selected font name.
 void setSelectedFontSize(java.lang.Object fontSize)
          Sets the selected font size.
 void setSelectionColor(java.awt.Color value)
          Sets the selection color.
 void setToolbarVisible(boolean visible)
          Proxy for toolbar.setVisible(), will work without a toolbar as well
 void setUnderlineSelected(boolean b)
          Sets the underline selected.
 void setUndoButtonEnabled(boolean canUndo)
          Sets the undo button enabled.
 void updateToolbar()
          This method has to be called, to display the changed made in the model.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP_DEFAULT

public static final java.lang.Integer GROUP_DEFAULT
Group for all components, which are directly added to the toolbar.


GROUP_SPELLCHECKER

public static final java.lang.Integer GROUP_SPELLCHECKER
The Constant GROUP_SPELLCHECKER.


GROUP_HTMLFORMAT

public static final java.lang.Integer GROUP_HTMLFORMAT
The Constant GROUP_HTMLFORMAT.


GROUP_UNDOREDO

public static final java.lang.Integer GROUP_UNDOREDO
The Constant GROUP_UNDOREDO.


GROUP_FORMATSWITCH

public static final java.lang.Integer GROUP_FORMATSWITCH
The Constant GROUP_FORMATSWITCH.

Constructor Detail

BaseEditorToolBar

public BaseEditorToolBar(BaseEditor editor,
                         boolean hasToolbar,
                         boolean isEditable,
                         boolean isHtml)
Creates the datamodel for the toolbar of the BaseEditor.

Parameters:
editor - the editor, which will use this toolbar
hasToolbar - true, if the editor has an toolbar on startup
isEditable - true, if the editor is editable by default
isHtml - true, if the first text of the editor will be HTML
Method Detail

addComponent

public void addComponent(java.awt.Component comp,
                         java.lang.Integer group,
                         java.awt.event.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(java.lang.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?

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(java.lang.Integer... groups)
Enables / displays the given component groups on the toolbar.

Parameters:
groups - the groups to display

disableGroups

public void disableGroups(java.lang.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

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(java.awt.event.ContainerEvent e)

Specified by:
componentAdded in interface java.awt.event.ContainerListener

componentRemoved

public void componentRemoved(java.awt.event.ContainerEvent e)

Specified by:
componentRemoved in interface java.awt.event.ContainerListener

setEnabled

public void setEnabled(boolean enabled)
Enables or disables all toolbar components.

Parameters:
enabled - true, if enabled, false otherwise

getToolbar

public javax.swing.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(java.awt.Color value)
Sets the selection color.

Parameters:
value - the new selection color

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(java.lang.String fontName)
Sets the selected font name.

Parameters:
fontName - the new selected font name

setSelectedFontSize

public void setSelectedFontSize(java.lang.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 javax.swing.JComboBox getFontNameComboBox()
Gets the font name combo box.

Returns:
the font name combo box

getFontSizeComboBox

public javax.swing.JComboBox getFontSizeComboBox()
Gets the font size combo box.

Returns:
the font size combo box

getFontColor

public javax.swing.JButton getFontColor()
Gets the font color.

Returns:
the font color

getColorMenu

public javax.swing.JPopupMenu getColorMenu()
Gets the color menu.

Returns:
the color menu

getColorList

public ColorList getColorList()
Gets the color list.

Returns:
the color list

getBold

public javax.swing.JToggleButton getBold()
Gets the bold.

Returns:
the bold

getItalic

public javax.swing.JToggleButton getItalic()
Gets the italic.

Returns:
the italic

getUnderline

public javax.swing.JToggleButton getUnderline()
Gets the underline.

Returns:
the underline

getLeft

public javax.swing.JToggleButton getLeft()
Gets the left.

Returns:
the left

getCenter

public javax.swing.JToggleButton getCenter()
Gets the center.

Returns:
the center

getRight

public javax.swing.JToggleButton getRight()
Gets the right.

Returns:
the right

getJustify

public javax.swing.JToggleButton getJustify()
Gets the justify.

Returns:
the justify

getBulletList

public javax.swing.JButton getBulletList()
Gets the bullet list.

Returns:
the bullet list

getNumberList

public javax.swing.JButton getNumberList()
Gets the number list.

Returns:
the number list

getBlockLeft

public javax.swing.JButton getBlockLeft()
Gets the block left.

Returns:
the block left

getBlockRight

public javax.swing.JButton getBlockRight()
Gets the block right.

Returns:
the block right

getHr

public javax.swing.JButton getHr()
Gets the hr.

Returns:
the hr

getHyperlink

public javax.swing.JButton getHyperlink()
Gets the hyperlink.

Returns:
the hyperlink

getUndoButton

public javax.swing.JButton getUndoButton()
Gets the undo button.

Returns:
the undo button

getRedoButton

public javax.swing.JButton getRedoButton()
Gets the redo button.

Returns:
the redo button

getHtmlFormat

public javax.swing.JButton getHtmlFormat()
Gets the html format.

Returns:
the html format

getAddimage

public javax.swing.JButton getAddimage()
Gets the addimage.

Returns:
the addimage

getSpellchecker

public javax.swing.JButton getSpellchecker()
Gets the spellchecker.

Returns:
the spellchecker

getAutoSpell

public javax.swing.JToggleButton getAutoSpell()
Gets the auto spell.

Returns:
the auto spell

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 javax.swing.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