|
|||||||||
| Home >> All >> com >> memoire >> [ bu overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.memoire.bu
Class BuTextArea

java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextArea
com.memoire.bu.BuTextArea
- All Implemented Interfaces:
- javax.accessibility.Accessible, BuTextComponentInterface, javax.swing.event.DocumentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.event.UndoableEditListener
- public class BuTextArea
- extends javax.swing.JTextArea
- implements javax.swing.event.UndoableEditListener, javax.swing.event.DocumentListener, BuTextComponentInterface
- extends javax.swing.JTextArea
This component extends a JTextArea, providing methods to undo/redo, find/replace and read/save. This component extends a JTextArea. This component provides its own methods to read and save files (even to zip them).
- Version:
- 1.1
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JTextArea |
javax.swing.JTextArea.AccessibleJTextArea |
| Nested classes inherited from class javax.swing.text.JTextComponent |
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
private int |
anchor
|
private static int |
BUFFER_SIZE
This constant defines the size of the buffer used to read files |
private javax.swing.undo.CompoundEdit |
compoundEdit
|
private java.lang.String |
currentFile
|
private boolean |
dirty
|
private java.lang.String |
fontName
|
private int |
fontSize
|
private int |
fontStyle
|
private boolean |
newText
|
static int |
OPEN
This constant defines an open dialog box. |
private boolean |
operation
|
private com.memoire.re.RE |
regexp
|
static int |
SAVE
This constant defines a save dialog box. |
private javax.swing.undo.UndoManager |
undo
|
| Fields inherited from class javax.swing.JTextArea |
|
| Fields inherited from class javax.swing.text.JTextComponent |
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
BuTextArea()
The constructor add the necessary listeners, set some stuffs (caret color, borers, fonts...). |
|
BuTextArea(int _lines,
int _cols)
|
|
| Method Summary | |
void |
beginCompoundEdit()
Used for ReplaceAll. |
void |
beginOperation()
When an operation has began, setChanged() cannot be called. |
void |
changedUpdate(javax.swing.event.DocumentEvent e)
When a modification is made in the text, we turn the 'to_be_saved' flag to true. |
private void |
changeFont()
Set the new font. |
static java.lang.String |
chooseFile(java.awt.Component owner,
int mode)
Display a file chooser dialog box. |
void |
clean()
Called after having saved or created a new document to ensure the content isn't 'dirty'. |
void |
discard()
Discard all edits contained in the UndoManager. |
void |
duplicate()
|
void |
endCompoundEdit()
See beginCompoundEdit(). |
void |
endOperation()
Calling this will allow the DocumentListener to use setChanged(). |
boolean |
find(java.lang.String searchStr,
int start,
boolean ignoreCase)
Return the result of a string search. |
int |
getAnchor()
Return the anchor position. |
java.lang.String |
getCurrentFile()
Return the full path of the opened file. |
java.lang.String |
getFontName()
Return current font's name |
int |
getFontSize()
Return current font's size |
int |
getFontStyle()
Return current font's style (bold, italic...) |
int |
getLength()
Return the lentgh of the text in the area. |
int |
getLineStartOffset(int off)
This is just to reduce code size of other classes. |
boolean |
getOperation()
Return true if we can use the setChanged() method, false otherwise. |
javax.swing.undo.UndoManager |
getUndo()
Useful for the GUI. |
void |
go(int _line)
|
void |
insertUpdate(javax.swing.event.DocumentEvent e)
When a modification is made in the text, we turn the 'to_be_saved' flag to true. |
boolean |
isDirty()
Return true if area content has changed, false otherwise. |
boolean |
isEmpty()
Return true if area is empty, false otherwise. |
boolean |
isNew()
Return true if current text is new, false otherwise. |
static void |
main(java.lang.String[] argv)
|
void |
newFile()
Set a new file. |
void |
open(java.lang.String path)
Called to load a new file in the text area. |
void |
paint(java.awt.Graphics _g)
Paint the component. |
void |
redo()
redo the last operation |
void |
removeUpdate(javax.swing.event.DocumentEvent e)
When a modification is made in the text, we turn the 'to_be_saved' flag to true. |
boolean |
replace(java.lang.String searchStr,
java.lang.String replaceStr,
int start,
int end,
boolean ignoreCase)
|
boolean |
replaceAll(java.lang.String searchStr,
java.lang.String replaceStr,
int start,
int end,
boolean ignoreCase)
Return the result of a string replace. |
void |
save(java.lang.String file)
Store the text in a specified file. |
void |
saveContent()
Called to save this component's content. |
void |
select()
|
void |
setAnchor(int offset)
Set the anchor postion. |
void |
setDirty()
Called when the content of the area has changed. |
void |
setFontName(java.lang.String name)
Set the font which has to be used. |
void |
setFontSize(int size)
Set the size of the font. |
void |
setFontStyle(int style)
Set the style of the font. |
static void |
showError(java.lang.String message)
Display an error message in a dialog box. |
static void |
showMessage(java.lang.String message)
Display a sample message in a dialog box. |
java.lang.String |
toString()
Return a String representation of this object. |
void |
undo()
undo the last operation |
void |
undoableEditHappened(javax.swing.event.UndoableEditEvent e)
When an undoable event is fired, we add it to the undo/redo list. |
void |
zip(java.lang.String zipFile)
Zip text area content into specified file. |
void |
zipContent()
Called to save current content in specified zip file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.memoire.bu.BuTextComponentInterface |
getCaretPosition, select |
| Field Detail |
OPEN
public static final int OPEN
- This constant defines an open dialog box.
- See Also:
- Constant Field Values
SAVE
public static final int SAVE
- This constant defines a save dialog box.
- See Also:
- Constant Field Values
regexp
private com.memoire.re.RE regexp
compoundEdit
private javax.swing.undo.CompoundEdit compoundEdit
fontName
private java.lang.String fontName
currentFile
private java.lang.String currentFile
anchor
private int anchor
fontSize
private int fontSize
fontStyle
private int fontStyle
dirty
private boolean dirty
newText
private boolean newText
operation
private boolean operation
undo
private javax.swing.undo.UndoManager undo
BUFFER_SIZE
private static final int BUFFER_SIZE
- This constant defines the size of the buffer used to read files
- See Also:
- Constant Field Values
| Constructor Detail |
BuTextArea
public BuTextArea()
- The constructor add the necessary listeners, set some stuffs
(caret color, borers, fonts...).
BuTextArea
public BuTextArea(int _lines,
int _cols)
| Method Detail |
paint
public void paint(java.awt.Graphics _g)
- Description copied from class:
javax.swing.JComponent Paint the component. This is a delicate process, and should only be called from the repaint thread, under control of the javax.swing.RepaintManager. Client code should usually call Component.repaint()>
Component.repaint()55 to trigger painting.The body of the
paintcall involves calling JComponent.paintComponent(java.awt.Graphics)>JComponent.paintComponent(java.awt.Graphics)55 , JComponent.paintBorder(java.awt.Graphics)>JComponent.paintBorder(java.awt.Graphics)55 , and JComponent.paintChildren(java.awt.Graphics)>JComponent.paintChildren(java.awt.Graphics)55 in order. If you want to customize painting behavior, you should override one of these methods rather thanpaint.For more details on the painting sequence, see this article.
select
public void select()
duplicate
public void duplicate()
go
public void go(int _line)
- Specified by:
goin interfaceBuTextComponentInterface
chooseFile
public static java.lang.String chooseFile(java.awt.Component owner, int mode)
- Display a file chooser dialog box.
showMessage
public static void showMessage(java.lang.String message)
- Display a sample message in a dialog box.
showError
public static void showError(java.lang.String message)
- Display an error message in a dialog box.
getFontName
public java.lang.String getFontName()
- Return current font's name
getFontSize
public int getFontSize()
- Return current font's size
getFontStyle
public int getFontStyle()
- Return current font's style (bold, italic...)
setFontName
public void setFontName(java.lang.String name)
- Set the font which has to be used.
setFontSize
public void setFontSize(int size)
- Set the size of the font.
setFontStyle
public void setFontStyle(int style)
- Set the style of the font.
changeFont
private void changeFont()
- Set the new font.
getCurrentFile
public java.lang.String getCurrentFile()
- Return the full path of the opened file.
beginOperation
public void beginOperation()
- When an operation has began, setChanged() cannot be called.
This is very important when we need to insert or remove some
parts of the texte without turning on the 'to_be_saved' flag.
endOperation
public void endOperation()
- Calling this will allow the DocumentListener to use setChanged().
getOperation
public boolean getOperation()
- Return true if we can use the setChanged() method,
false otherwise.
newFile
public void newFile()
- Set a new file. We first ask the user if he'd like to save its
changes (if some have been made).
getLineStartOffset
public int getLineStartOffset(int off)
- This is just to reduce code size of other classes.
zipContent
public void zipContent()
- Called to save current content in specified zip file.
Call zip(String file) but asks user for overwriting if
file already exists.
zip
public void zip(java.lang.String zipFile)
- Zip text area content into specified file.
saveContent
public void saveContent()
- Called to save this component's content.
Call save(String file) but let the user choosing a file name.
In the case the user choosed an existing file, we ask him if
he really wants to overwrite it.
save
public void save(java.lang.String file)
- Store the text in a specified file.
open
public void open(java.lang.String path)
- Called to load a new file in the text area.
Determines which line separator (\n, \r\n...) are used in the
file to open. Convert'em into Swing line separator (\n).
isNew
public boolean isNew()
- Return true if current text is new, false otherwise.
isEmpty
public boolean isEmpty()
- Return true if area is empty, false otherwise.
isDirty
public boolean isDirty()
- Return true if area content has changed, false otherwise.
setDirty
public void setDirty()
- Called when the content of the area has changed.
clean
public void clean()
- Called after having saved or created a new document to ensure
the content isn't 'dirty'.
discard
public void discard()
- Discard all edits contained in the UndoManager.
getUndo
public javax.swing.undo.UndoManager getUndo()
- Useful for the GUI.
undo
public void undo()
- undo the last operation
redo
public void redo()
- redo the last operation
getAnchor
public int getAnchor()
- Return the anchor position.
setAnchor
public void setAnchor(int offset)
- Set the anchor postion.
getLength
public int getLength()
- Return the lentgh of the text in the area.
- Specified by:
getLengthin interfaceBuTextComponentInterface
beginCompoundEdit
public void beginCompoundEdit()
- Used for ReplaceAll.
This merges all text changes made between the beginCompoundEdit()
and the endCompoundEdit() calls into only one undo event.
endCompoundEdit
public void endCompoundEdit()
- See beginCompoundEdit().
find
public boolean find(java.lang.String searchStr, int start, boolean ignoreCase)
- Return the result of a string search.
- Specified by:
findin interfaceBuTextComponentInterface
replace
public boolean replace(java.lang.String searchStr, java.lang.String replaceStr, int start, int end, boolean ignoreCase)
- Specified by:
replacein interfaceBuTextComponentInterface
replaceAll
public boolean replaceAll(java.lang.String searchStr, java.lang.String replaceStr, int start, int end, boolean ignoreCase) throws com.memoire.re.REException
- Return the result of a string replace.
undoableEditHappened
public void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
- When an undoable event is fired, we add it to the undo/redo list.
- Specified by:
undoableEditHappenedin interfacejavax.swing.event.UndoableEditListener
changedUpdate
public void changedUpdate(javax.swing.event.DocumentEvent e)
- When a modification is made in the text, we turn
the 'to_be_saved' flag to true.
- Specified by:
changedUpdatein interfacejavax.swing.event.DocumentListener
insertUpdate
public void insertUpdate(javax.swing.event.DocumentEvent e)
- When a modification is made in the text, we turn
the 'to_be_saved' flag to true.
- Specified by:
insertUpdatein interfacejavax.swing.event.DocumentListener
removeUpdate
public void removeUpdate(javax.swing.event.DocumentEvent e)
- When a modification is made in the text, we turn
the 'to_be_saved' flag to true.
- Specified by:
removeUpdatein interfacejavax.swing.event.DocumentListener
toString
public java.lang.String toString()
- Return a String representation of this object.
main
public static void main(java.lang.String[] argv)
|
|||||||||
| Home >> All >> com >> memoire >> [ bu overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC