|
JET | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.utep.cs.et.gui.editor.DefaultEditor
public class DefaultEditor
A simple source code editor that support signle document editing and primitive syntax hightligting.
| Nested Class Summary | |
|---|---|
private class |
DefaultEditor.DefaultCaretListener
A caret listener class for the editor. |
private static class |
DefaultEditor.PasteEnablingAction
An action class to represent editing actions that enable the paste action. |
private class |
DefaultEditor.RedoAction
A class representing redo actions. |
private class |
DefaultEditor.UndoAction
A class representing undo actions. |
| Field Summary | |
|---|---|
private static Action |
actCopy
The action for the copy menu. |
private static Action |
actCut
The action for the cut menu. |
private static Action |
actDelete
The action for the Delete menu. |
private static Action |
actPaste
The action for the Paste menu. |
private static DefaultEditor.RedoAction |
actRedo
The action for the Redo menu. |
private static DefaultEditor.UndoAction |
actUndo
The action for the Undo menu. |
private static DefaultEditorKit |
defaultEditorKit
The default editor kit to open and write the document. |
private DocumentListener |
dirtyFlagManager
A document listener to set the dirty flag. |
private boolean |
docModified
The dirty flag indicating whether the document being edited ( doc) was modified or not. |
private SyntaxDocument |
document
The styled document that is the model for the textPane |
private List<FileChangeListener> |
fileChangeListeners
Registered file change listeners. |
private List<LineChangeListener> |
lineChangeListeners
Registered line change listeners. |
private JEditTextArea |
textPane
The place where the text is drawn. |
private static UndoManager |
undoManager
The undo manager that handles undoable edits performed on the editor buffer. |
| Constructor Summary | |
|---|---|
DefaultEditor()
Create a new JML editor. |
|
| Method Summary | |
|---|---|
void |
addFileChangeListener(FileChangeListener l)
Registers the given file change listener. |
void |
addLineChangeListener(LineChangeListener l)
Registers the given line change listener. |
protected JTextPane |
createTextPane(DefaultStyledDocument doc)
Creates a new text pane. |
private void |
disableAll()
Diables all edit actions. |
SyntaxDocument |
document()
Returns the document being edited. |
private CaretListener |
getCaretListener()
Returns the caret listener. |
Action |
getCopy()
Returns the copy action of this editor. |
Action |
getCut()
Returns the cut action of this editor. |
Action |
getDelete()
Returns the action for delete menu item. |
protected ImageIcon |
getIcon(String name)
Returns an image icon whose image is read from the file named name. |
OptionPanel |
getOptionPanel()
Returns the option panel of this editor. |
Action |
getPaste()
Returns the action for paste menu item. |
Action |
getRedo()
Returns the redo action of this editor. |
Action |
getUndo()
Returns the undo action of this editor. |
private UndoManager |
getUndoManager()
Creates and returns an undo manger. |
JComponent |
getView()
Returns the view of this editor. |
void |
highlight(int line)
Highlights the specified line. |
void |
highlight(int line,
int col)
Highlights the specified line and column. |
boolean |
isDirty()
Returns true if there exist any unsaved edits. |
boolean |
newDocument()
Creates a new empty document and returns true if the creation was successful. |
private void |
notifyFileOpened(File file)
Notifies to the registered file change listeners that the given file was opened by this editor. |
private void |
notifyLineChanged(int line,
int column)
Notifies to the registered line change listeners that the caret was moved to the given line and column numbers. |
boolean |
openFile(File file)
Opens the given file file using this editor, and
returns true if the file was successfully opened. |
private void |
resetUndoManager()
Resets the undo manager by discarding all edits and disabling both the undo and the redo actions. |
boolean |
saveFile(File file)
Saves the document of this editor to the given file file, and returns true if it was successfully
saved. |
(package private) void |
setBackground(Color color)
Sets the background color of this editor. |
void |
setCloseViewAction(AbstractAction action)
Given the action that closes this editor's view, provides an appropriate user interface for it, such as a popup menu. |
void |
setDropTarget(DropTarget dropTarget)
Associate a DropTarget with this editor so that the editor receives drops. |
(package private) void |
setFont(Font font)
Sets the font. |
(package private) void |
setForeground(Color color)
Sets the foreground color of this editor. |
(package private) void |
setStyles(SyntaxStyle[] styles)
Sets the syntax styles of this editor. |
private void |
showMessage(String title,
String msg)
Shows a message dialog with the given title and message. |
(package private) void |
updateView()
Updates the view by repaint it. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private JEditTextArea textPane
private SyntaxDocument document
private boolean docModified
doc) was modified or not. If it is true, it means
that there are unsaved changes; otherwise, no such changes
exist.
private static DefaultEditorKit defaultEditorKit
private final DocumentListener dirtyFlagManager
private final List<LineChangeListener> lineChangeListeners
private final List<FileChangeListener> fileChangeListeners
private static Action actCopy
private static Action actCut
private static Action actPaste
private static Action actDelete
private static DefaultEditor.UndoAction actUndo
private static DefaultEditor.RedoAction actRedo
private static UndoManager undoManager
| Constructor Detail |
|---|
public DefaultEditor()
| Method Detail |
|---|
public void setDropTarget(DropTarget dropTarget)
setDropTarget in interface Editorpublic JComponent getView()
getView in interface Editorpublic OptionPanel getOptionPanel()
getOptionPanel in interface Editorpublic void setCloseViewAction(AbstractAction action)
setCloseViewAction in interface Editorpublic boolean isDirty()
isDirty in interface Editorpublic boolean newDocument()
newDocument in interface Editorpublic boolean openFile(File file)
file using this editor, and
returns true if the file was successfully opened. The contents
of the file are read into the editing buffer (i.e., document)
of this editor.
openFile in interface Editorpublic boolean saveFile(File file)
file, and returns true if it was successfully
saved.
saveFile in interface Editor
public void highlight(int line,
int col)
highlight in interface Editorpublic void highlight(int line)
highlight in interface Editorpublic void addFileChangeListener(FileChangeListener l)
addFileChangeListener in interface Editorpublic void addLineChangeListener(LineChangeListener l)
addLineChangeListener in interface Editorpublic Action getCopy()
getCopy in interface EditorgetCaretListener()public Action getCut()
getCut in interface EditorgetCaretListener()public Action getPaste()
getPaste in interface Editorpublic Action getDelete()
getDelete in interface EditorgetCaretListener()public Action getUndo()
getUndo in interface Editorpublic Action getRedo()
getRedo in interface Editorpublic SyntaxDocument document()
protected JTextPane createTextPane(DefaultStyledDocument doc)
void updateView()
void setFont(Font font)
void setForeground(Color color)
void setBackground(Color color)
void setStyles(SyntaxStyle[] styles)
private void notifyLineChanged(int line,
int column)
private void notifyFileOpened(File file)
private void showMessage(String title,
String msg)
private UndoManager getUndoManager()
thr, e.g.,
side-effects of syntax coloring. Initially both the undo and
redo actions are disabled.
private void resetUndoManager()
private CaretListener getCaretListener()
private void disableAll()
protected ImageIcon getIcon(String name)
name. A null is returned if reading the file fails.
|
JET | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||