|
|||||||||
| 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 BuTextPane

java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JEditorPane
javax.swing.JTextPane
com.memoire.bu.BuTextPane
- 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 BuTextPane
- extends javax.swing.JTextPane
- implements javax.swing.event.UndoableEditListener, javax.swing.event.DocumentListener, BuTextComponentInterface
- extends javax.swing.JTextPane
This component extends a JTextPane. 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.JEditorPane |
javax.swing.JEditorPane.AccessibleJEditorPane, javax.swing.JEditorPane.AccessibleJEditorPaneHTML, javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport |
| 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 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.JEditorPane |
|
| 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 | |
BuTextPane()
|
|
| 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. |
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 |
colorize(BuCommonInterface _app)
|
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. |
int |
getLength()
Return the lentgh of the text in the pane. |
int |
getLineEndOffset(int _n)
|
int |
getLineStartOffset(int _n)
This is just to reduce code size of other classes. |
boolean |
getOperation()
Return true if we can use the setChanged() method, false otherwise. |
java.awt.Dimension |
getPreferredScrollableViewportSize()
|
java.awt.Dimension |
getPreferredSize()
Returns the preferred size for the JEditorPane. |
boolean |
getScrollableTracksViewportHeight()
Returns true when a Viewport should force the height of
this component to match the viewport height. |
boolean |
getScrollableTracksViewportWidth()
Returns true when a Viewport should force the width of
this component to match the viewport width. |
java.lang.String |
getSyntax()
|
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 pane content has changed, false otherwise. |
boolean |
isEmpty()
Return true if pane is empty, false otherwise. |
boolean |
isNew()
Return true if current text is new, false otherwise. |
void |
newFile()
Set a new file. |
void |
open(java.lang.String path)
Called to load a new file in the text pane. |
void |
paint(java.awt.Graphics _g)
Paint the component. |
void |
paintComponent(java.awt.Graphics _g)
Paint the component's body. |
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 |
setBorder(javax.swing.border.Border b)
Set the value of the JComponent.border> JComponent.border 55 property. |
void |
setCaretPosition(int _pos)
Sets the caret to a new position. |
void |
setDirty()
Called when the content of the pane has changed. |
void |
setSyntax(java.lang.String _syntax)
|
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 pane 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
currentFile
private java.lang.String currentFile
anchor
private int anchor
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 |
BuTextPane
public BuTextPane()
| 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.
setBorder
public void setBorder(javax.swing.border.Border b)
- Description copied from class:
javax.swing.JComponent - Set the value of the JComponent.border>
JComponent.border55 property.
select
public void select()
duplicate
public void duplicate()
go
public void go(int _line)
- Specified by:
goin interfaceBuTextComponentInterface
paintComponent
public void paintComponent(java.awt.Graphics _g)
- Description copied from class:
javax.swing.JComponent - Paint the component's body. This usually means calling ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)>
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)55 on the JComponent.ui>JComponent.ui55 property of the component, if it is non-null. You may override this if you wish to customize the component's body-painting behavior. The component's body is painted first, before the border and children.
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
- Description copied from class:
javax.swing.JEditorPane - Returns
truewhen a Viewport should force the width of this component to match the viewport width. This is implemented to returntruewhen the parent is an instance of JViewport and the viewport width > the UI's minimum width.- Specified by:
getScrollableTracksViewportWidthin interfacejavax.swing.Scrollable
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()
- Description copied from class:
javax.swing.JEditorPane - Returns
truewhen a Viewport should force the height of this component to match the viewport height. This is implemented to returntruewhen the parent is an instance of JViewport and the viewport height > the UI's minimum height.- Specified by:
getScrollableTracksViewportHeightin interfacejavax.swing.Scrollable
getPreferredScrollableViewportSize
public java.awt.Dimension getPreferredScrollableViewportSize()
- Specified by:
getPreferredScrollableViewportSizein interfacejavax.swing.Scrollable
getPreferredSize
public java.awt.Dimension getPreferredSize()
- Description copied from class:
javax.swing.JEditorPane - Returns the preferred size for the JEditorPane. This is implemented to
return the super's preferred size, unless one of
JEditorPane.getScrollableTracksViewportHeight()>
JEditorPane.getScrollableTracksViewportHeight()55 or JEditorPane.getScrollableTracksViewportWidth()>JEditorPane.getScrollableTracksViewportWidth()55 returnstrue, in which case the preferred width and/or height is replaced by the UI's minimum size.
setCaretPosition
public void setCaretPosition(int _pos)
- Description copied from class:
javax.swing.text.JTextComponent - Sets the caret to a new position.
getSyntax
public java.lang.String getSyntax()
setSyntax
public void setSyntax(java.lang.String _syntax)
colorize
public void colorize(BuCommonInterface _app)
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.
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 _n)
- This is just to reduce code size of other classes.
getLineEndOffset
public int getLineEndOffset(int _n)
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 pane 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 pane.
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 pane is empty, false otherwise.
isDirty
public boolean isDirty()
- Return true if pane content has changed, false otherwise.
setDirty
public void setDirty()
- Called when the content of the pane 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 pane.
- 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.
|
|||||||||
| Home >> All >> com >> memoire >> [ bu overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC