public class EditorStatusBar extends java.lang.Object implements java.awt.event.ActionListener, javax.swing.event.ChangeListener, EditorPlugin, FeedbackManager
StatusBarPlugin
provides a status bar UI component
that works with the BasicEditorPane. It is implemented as a plugin
as a convenient way to attach to the editor pane.
To use this plugin, install it into the editor pane by calling
installPlugin()
on the BasicEditorPane
. Modifier and Type | Class and Description |
---|---|
protected static class |
EditorStatusBar.StatusBarCell
The
StatusBarCell is just a label that can be added
to our status bar which takes care of making sure that its size
remains fairly constant for the types of strings which can contain
it (otherwise, it looks pretty bad for the cells to be changing
in width, say when you switch between insert and overwrite mode.) |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BLANK_MESSAGE
An empty message just to set the height of the status bar.
|
static java.lang.String[] |
EOL_CELL_STRINGS
The array of strings for the EOL type cell for sizing.
|
static java.lang.String |
EOL_MACINTOSH
String for file with Macintosh-OS9-style EOL terminators
(single CR.)
|
static java.lang.String |
EOL_UNIX
String for file with UNIX-style EOL terminators
(single LF.)
|
static java.lang.String |
EOL_WINDOWS
String for file with Windows-style EOL terminators
(CR/LF pair.)
|
static java.lang.String |
INSERT_MODE
String for insert mode.
|
static java.lang.String[] |
INSERT_OVERWRITE_CELL_STRINGS
The array of cell strings for the InsertOverwrite cell for sizing.
|
static java.lang.String |
LINE_COLUMN
String for the line and column info.
|
static java.lang.String[] |
LINE_NUMBER_CELL_STRINGS
The array of strings for the line number cell for sizing.
|
static java.lang.String[] |
LINE_NUMBER_WITH_TOTAL_CELL_STRINGS
The array of strings for the line number with total cell for sizing.
|
static java.lang.String |
LINE_WITH_TOTAL_COLUMN
String for the line (with total) and column info.
|
static java.lang.String |
MODIFIED
String for modified label.
|
static java.lang.String[] |
MODIFIED_CELL_STRINGS
The array of strings for the Modified cell for sizing.
|
static java.lang.String |
OFFSET
String for the line and column info.
|
static java.lang.String[] |
OFFSET_CELL_STRINGS
The array of strings for the line number cell for sizing.
|
static java.lang.String |
OVERWRITE_MODE
String for overwrite mode.
|
static java.lang.String |
PROTECTED
String for the protected label.
|
static java.lang.String |
READ_ONLY
String for read only label.
|
Constructor and Description |
---|
EditorStatusBar()
Constructs a new
EditorStatusBar instance that is
associated with the specified editor. |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
This is invoked when an action is performed.
|
void |
deinstall(BasicEditorPane editor)
Called when the plugin is being removed from the BasicEditorPane
(for example when the editor is closed.) This is used to notify
plugins that they should unregister any listeners that were
attached.
|
protected static java.lang.String |
getLineColumnText(int line,
int column)
Utility routine for building up the "Line 1 Column 5" text.
|
protected static java.lang.String |
getLineWithTotalColumnText(int line,
int total,
int column)
Utility routine for building up the "Line 1 Column 5" text.
|
protected static java.lang.String |
getOffsetText(java.lang.String template,
int offset)
Utility routine for building up the "Offset 5" text.
|
javax.swing.JComponent[] |
getStatusBarCells()
Fetches the array of cells that make up this status bar.
|
void |
hideFeedback(BasicEditorPane editorPane)
Clears the text feedback message last displayed for the given
editor pane.
|
void |
install(BasicEditorPane editor)
Called when this plugin is being installed into the BasicEditorPane.
|
void |
propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed.
|
void |
showFeedback(BasicEditorPane editorPane,
java.lang.String feedbackMessage)
Displays a text feedback message to the user associated with the
given editor pane.
|
void |
showFeedback(BasicEditorPane editorPane,
java.lang.String feedbackMessage,
int milliSeconds)
Displays a text feedback message to the user associated with the
given editor pane.
|
void |
stateChanged(javax.swing.event.ChangeEvent event)
Invoked when the target of the listener has changed its state.
|
public static final java.lang.String BLANK_MESSAGE
public static final java.lang.String INSERT_MODE
public static final java.lang.String OVERWRITE_MODE
public static final java.lang.String LINE_COLUMN
public static final java.lang.String LINE_WITH_TOTAL_COLUMN
public static final java.lang.String OFFSET
public static final java.lang.String EOL_MACINTOSH
public static final java.lang.String EOL_UNIX
public static final java.lang.String EOL_WINDOWS
public static final java.lang.String MODIFIED
public static final java.lang.String READ_ONLY
public static final java.lang.String PROTECTED
public static final java.lang.String[] INSERT_OVERWRITE_CELL_STRINGS
public static final java.lang.String[] EOL_CELL_STRINGS
public static final java.lang.String[] MODIFIED_CELL_STRINGS
public static final java.lang.String[] LINE_NUMBER_CELL_STRINGS
public static final java.lang.String[] LINE_NUMBER_WITH_TOTAL_CELL_STRINGS
public static final java.lang.String[] OFFSET_CELL_STRINGS
public EditorStatusBar()
EditorStatusBar
instance that is
associated with the specified editor.public void install(BasicEditorPane editor)
install
in interface EditorPlugin
editor
- the editor panepublic void deinstall(BasicEditorPane editor)
deinstall
in interface EditorPlugin
editor
- the editor panepublic void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
event
- A PropertyChangeEvent object describing the event source
and the property that has changed.public void stateChanged(javax.swing.event.ChangeEvent event)
stateChanged
in interface javax.swing.event.ChangeListener
event
- the change eventpublic void showFeedback(BasicEditorPane editorPane, java.lang.String feedbackMessage)
showFeedback
in interface FeedbackManager
editorPane
- the editor pane the message is associated withfeedbackMessage
- the message to displaypublic void showFeedback(BasicEditorPane editorPane, java.lang.String feedbackMessage, int milliSeconds)
showFeedback
in interface FeedbackManager
editorPane
- the editor pane the message is associated withfeedbackMessage
- the message to displaymilliSeconds
- the length of time to display the messagepublic void hideFeedback(BasicEditorPane editorPane)
hideFeedback
in interface FeedbackManager
editorPane
- the editor pane the last message was associated withpublic void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed
in interface java.awt.event.ActionListener
event
- the action eventpublic javax.swing.JComponent[] getStatusBarCells()
protected static java.lang.String getLineColumnText(int line, int column)
line
- the line numbercolumn
- the column numberprotected static java.lang.String getLineWithTotalColumnText(int line, int total, int column)
line
- the line numbertotal
- the total number of lines in the editorcolumn
- the column numberprotected static java.lang.String getOffsetText(java.lang.String template, int offset)
template
- the template for the text, i.e.,
"Offset {0}"offset
- the offset number