JET

edu.utep.cs.jet.gui.editor
Class DefaultEditor

java.lang.Object
  extended by edu.utep.cs.jet.gui.editor.DefaultEditor
All Implemented Interfaces:
Editor
Direct Known Subclasses:
LineNumberedEditor

public class DefaultEditor
extends Object
implements Editor

A simple source code editor that support single document editing and primitive syntax hightligting.

Author:
Yoonsik Cheon

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.
 SyntaxDocument document()
          Returns the document being edited.
 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.
 Action getFind()
          Returns the find action of this editor.
 Action getGoto()
          Returns the goto action of this editor.
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.
 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.
 boolean openFile(File file)
          Opens the given file file using this editor, and returns true if the file was successfully opened.
 boolean saveFile(File file)
          Saves the document of this editor to the given file file, and returns true if it was successfully saved.
 void setDropTarget(DropTarget dropTarget)
          Associate a DropTarget with this editor so that the editor receives drops.
 void setHideViewAction(AbstractAction action)
          Given the action that hides this editor's view, provides an appropriate user interface for it, such as a popup menu.
 void setPopupOptions()
          Set right click pop-up options.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEditor

public DefaultEditor()
Create a new JML editor.

Method Detail

setPopupOptions

public void setPopupOptions()
Set right click pop-up options.


setDropTarget

public void setDropTarget(DropTarget dropTarget)
Associate a DropTarget with this editor so that the editor receives drops.

Specified by:
setDropTarget in interface Editor

getView

public JComponent getView()
Returns the view of this editor.

Specified by:
getView in interface Editor

getOptionPanel

public OptionPanel getOptionPanel()
Returns the option panel of this editor.

Specified by:
getOptionPanel in interface Editor

setHideViewAction

public void setHideViewAction(AbstractAction action)
Given the action that hides this editor's view, provides an appropriate user interface for it, such as a popup menu.

Specified by:
setHideViewAction in interface Editor

isDirty

public boolean isDirty()
Returns true if there exist any unsaved edits.

Specified by:
isDirty in interface Editor

newDocument

public boolean newDocument()
Creates a new empty document and returns true if the creation was successful. The created document is not associated with an external file.

Specified by:
newDocument in interface Editor

openFile

public boolean openFile(File file)
Opens the given 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.

Specified by:
openFile in interface Editor

saveFile

public boolean saveFile(File file)
Saves the document of this editor to the given file file, and returns true if it was successfully saved.

Specified by:
saveFile in interface Editor

highlight

public void highlight(int line,
                      int col)
Highlights the specified line and column.

Specified by:
highlight in interface Editor

highlight

public void highlight(int line)
Highlights the specified line.

Specified by:
highlight in interface Editor

addFileChangeListener

public void addFileChangeListener(FileChangeListener l)
Registers the given file change listener.

Specified by:
addFileChangeListener in interface Editor

addLineChangeListener

public void addLineChangeListener(LineChangeListener l)
Registers the given line change listener.

Specified by:
addLineChangeListener in interface Editor

getCopy

public Action getCopy()
Returns the copy action of this editor. Initially the action is disabled; it is enabled whenever something is selected in the editor.

Specified by:
getCopy in interface Editor
See Also:
getCaretListener()

getCut

public Action getCut()
Returns the cut action of this editor. Initially the action is disabled,; it is enabled whenever something is selected in the editor.

Specified by:
getCut in interface Editor
See Also:
getCaretListener()

getPaste

public Action getPaste()
Returns the action for paste menu item. Initially the action is disabled, and gets enabled whenever something is copied or cut by the editor.

Specified by:
getPaste in interface Editor

getDelete

public Action getDelete()
Returns the action for delete menu item. Initially the action is disabled, and gets enabled whenever something is selected on the editor.

Specified by:
getDelete in interface Editor
See Also:
getCaretListener()

getUndo

public Action getUndo()
Returns the undo action of this editor.

Specified by:
getUndo in interface Editor

getRedo

public Action getRedo()
Returns the redo action of this editor.

Specified by:
getRedo in interface Editor

getFind

public Action getFind()
Returns the find action of this editor.

Specified by:
getFind in interface Editor

getGoto

public Action getGoto()
Returns the goto action of this editor.

Specified by:
getGoto in interface Editor

document

public SyntaxDocument document()
Returns the document being edited.


createTextPane

protected JTextPane createTextPane(DefaultStyledDocument doc)
Creates a new text pane. This is a factory method that can be overridden by subclasses to return a different type of text panes.


getIcon

protected ImageIcon getIcon(String name)
Returns an image icon whose image is read from the file named name. A null is returned if reading the file fails.


JET

JET is Copyright (C) 2005-2008 by The University of Texas at El Paso and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.