Package com.inet.editor
Class BaseEditorToolBar
java.lang.Object
com.inet.editor.BaseEditorToolBar
- All Implemented Interfaces:
ContainerListener,EventListener
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThese are the names of the default components of the tool bar of theBaseEditor. -
Constructor Summary
ConstructorsConstructorDescriptionBaseEditorToolBar(JTextPane editor) Creates the a toolbar controller and toolbar for a normal editor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd buttons and commponent to the toolbar.voidaddComponent(Component comp, Integer group, ActionListener listener) Adds a component to the model.voidvoidvoidcreateComponentGroup(Integer groupKey, boolean requiresLeftSep, boolean requiresRightSep, boolean visible) Creates a new component group for the toolbar.voiddisableGroups(Integer... groups) Disables / hides the given component groups on the toolbar.voidenableGroups(Integer... groups) Enables / displays the given component groups on the toolbar.Gets the 'add image' button.Gets the adds the image action.Gets the enable/disable auto spellchecker button.Gets the block left.Gets the block right button.getBold()Gets the bold.Gets the bullet list.intGets the buttonoffset.Gets the center.Gets the color list.Gets the color menu.Gets the font color.JComboBox<?>Gets the font name combo box.JComboBox<?>Gets the font size combo box.getHr()Gets the horizontal ruler button.Gets the html format button.Gets the hyperlink button.Gets the italic.Gets the justify.getLeft()Gets the left.Gets the number list.Gets the redo button.getRight()Gets the right.Gets the spellchecker button.returns the internal toolbar object, or null if it's not present.Gets the underline.Gets the undo button.protected booleanIs the automatic spell checking enabled.voidnotifyFormat(boolean isHtml) Inform this object of a content type change, will modify the format switch.voidsetAddImageEnabled(boolean enabled) Sets the adds the image enabled.voidsetAutoSpellSelected(boolean enabled) Sets the auto spell selected.voidsetBoldSelected(boolean b) Sets the bold selected.voidsetCenterSelected(boolean b) Sets the center selected.voidsetEditable(boolean editable) Proxy for the Swing setEditable() function on the toolbar and it's components.voidsetEnabled(boolean enabled) Enables or disables all toolbar components.protected voidsetEnableFormatButtons(boolean isHtml) Disables or enabled the format buttons which are only allowed for HTMLvoidsetItalicSelected(boolean b) Sets the italic selected.voidsetJustifySelected(boolean b) Sets the justify selected.voidsetLeftSelected(boolean b) Sets the left selected.voidsetRedoButtonEnabled(boolean canRedo) Sets the redo button enabled.voidsetRightSelected(boolean b) Sets the right selected.voidsetSearchVisible(boolean visible) Displays or hides the search-button, if availablevoidsetSelectedFontName(String fontName) Sets the selected font name.voidsetSelectedFontSize(Object fontSize) Sets the selected font size.voidsetSelectionColor(Color value) Sets the selection color.voidsetToolbarVisible(boolean visible) Proxy for toolbar.setVisible(), will work without a toolbar as wellvoidsetUnderlineSelected(boolean b) Sets the underline selected.voidsetUndoButtonEnabled(boolean canUndo) Sets the undo button enabled.voidswitchEditor(JTextPane text) Switches the toolbar to another editorvoidThis method has to be called, to display the changed made in the model.
-
Constructor Details
-
BaseEditorToolBar
Creates the a toolbar controller and toolbar for a normal editor. To get the Swing component callgetToolbar().- Parameters:
editor- the editor to which is this toolbar will be registered first- Since:
- 1.09
-
-
Method Details
-
addComponent
Adds a component to the model. This DOES NOT display the component!- Parameters:
comp- The component to addgroup- the group where to add the componentlistener- theActionListenerfor 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 createdrequiresLeftSep- set to true, if the group requires a separator to the leftrequiresRightSep- set to true, if the group requires a separator to the rightvisible- 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
Enables / displays the given component groups on the toolbar.- Parameters:
groups- the groups to display
-
disableGroups
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
- Specified by:
componentAddedin interfaceContainerListener
-
componentRemoved
- Specified by:
componentRemovedin interfaceContainerListener
-
setEnabled
public void setEnabled(boolean enabled) Enables or disables all toolbar components.- Parameters:
enabled- true, if enabled, false otherwise
-
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
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
Sets the selected font name.- Parameters:
fontName- the new selected font name
-
setSelectedFontSize
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
Gets the font name combo box.- Returns:
- the font name combo box
-
getFontSizeComboBox
Gets the font size combo box.- Returns:
- the font size combo box
-
getFontColor
Gets the font color.- Returns:
- the font color
-
getColorMenu
Gets the color menu.- Returns:
- the color menu
-
getColorList
Gets the color list.- Returns:
- the color list
-
getBold
Gets the bold.- Returns:
- the bold
-
getItalic
Gets the italic.- Returns:
- the italic
-
getUnderline
Gets the underline.- Returns:
- the underline
-
getLeft
Gets the left.- Returns:
- the left
-
getCenter
Gets the center.- Returns:
- the center
-
getRight
Gets the right.- Returns:
- the right
-
getJustify
Gets the justify.- Returns:
- the justify
-
getBulletList
Gets the bullet list.- Returns:
- the bullet list
-
getNumberList
Gets the number list.- Returns:
- the number list
-
getBlockLeft
Gets the block left.- Returns:
- the block left
-
getBlockRight
Gets the block right button.- Returns:
- the block right button
-
getHr
Gets the horizontal ruler button.- Returns:
- the horizontal ruler button
-
getHyperlink
Gets the hyperlink button.- Returns:
- the hyperlink button
-
getUndoButton
Gets the undo button.- Returns:
- the undo button
-
getRedoButton
Gets the redo button.- Returns:
- the redo button
-
getHtmlFormat
Gets the html format button.- Returns:
- the html format button
-
getAddimage
Gets the 'add image' button.- Returns:
- the 'add image' button
-
getSpellchecker
Gets the spellchecker button.- Returns:
- the spellchecker button
-
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
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
Switches the toolbar to another editor- Parameters:
text- the editor to switch to, must not benull- Since:
- 1.09
-