mars.venus.editors.generic
Class GenericTextArea

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JTextArea
                      extended by mars.venus.editors.generic.GenericTextArea
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, MARSTextEditingArea

public class GenericTextArea
extends JTextArea
implements MARSTextEditingArea

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTextArea
JTextArea.AccessibleJTextArea
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
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.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface mars.venus.editors.MARSTextEditingArea
TEXT_FOUND, TEXT_NOT_FOUND, TEXT_REPLACED_FOUND_NEXT, TEXT_REPLACED_NOT_FOUND_NEXT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GenericTextArea(EditPane editPain, JComponent lineNumbers)
           
 
Method Summary
 void discardAllUndoableEdits()
          Tell UndoManager to discard all its collected undoable edits.
 int doFindText(String find, boolean caseSensitive)
          Finds next occurrence of text in a forward search of a string.
 int doReplace(String find, String replace, boolean caseSensitive)
          Finds and replaces next occurrence of text in a string in a forward search.
 int doReplaceAll(String find, String replace, boolean caseSensitive)
          Finds and replaces ALL occurrences of text in a string in a forward search.
 Component getOuterComponent()
           
 UndoManager getUndoManager()
          Returns the undo manager for this editing area
 int nextIndex(String input, String find, int start, boolean caseSensitive)
          Returns next posn of word in text - forward search.
 void redo()
          Redo previous edit
 void setCaretBlinkRate(int rate)
          Set the caret blinking rate in milliseconds.
 void setCaretVisible(boolean vis)
          Control caret visibility
 void setLineHighlightEnabled(boolean highlight)
          Does nothing, but required by the interface.
 void setSelectionVisible(boolean vis)
          Control selection visibility
 void setSourceCode(String s, boolean editable)
          For initalizing the source code when opening an ASM file
 void setText(String s)
          Override inherited setText to temporarily remove UndoableEditListener because this operation is not undoable.
 void undo()
          Undo previous edit
 void updateSyntaxStyles()
          Does nothing, but required by the interface.
 
Methods inherited from class javax.swing.JTextArea
append, createDefaultModel, getAccessibleContext, getColumns, getColumnWidth, getLineCount, getLineEndOffset, getLineOfOffset, getLineStartOffset, getLineWrap, getPreferredScrollableViewportSize, getPreferredSize, getRowHeight, getRows, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getTabSize, getUIClassID, getWrapStyleWord, insert, paramString, replaceRange, setColumns, setFont, setLineWrap, setRows, setTabSize, setWrapStyleWord
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getActions, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDocument, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface mars.venus.editors.MARSTextEditingArea
copy, cut, getCaretPosition, getDocument, getFont, getFontMetrics, getSelectedText, getSelectionEnd, getSelectionStart, getText, grabFocus, paste, replaceSelection, requestFocusInWindow, revalidate, select, selectAll, setBackground, setCaretPosition, setEditable, setEnabled, setFont, setSelectionEnd, setSelectionStart, setTabSize
 

Constructor Detail

GenericTextArea

public GenericTextArea(EditPane editPain,
                       JComponent lineNumbers)
Method Detail

setLineHighlightEnabled

public void setLineHighlightEnabled(boolean highlight)
Does nothing, but required by the interface. This editor does not support highlighting of the line currently being edited.

Specified by:
setLineHighlightEnabled in interface MARSTextEditingArea

updateSyntaxStyles

public void updateSyntaxStyles()
Does nothing, but required by the interface. This editor does not support syntax styling (colors, bold/italic).

Specified by:
updateSyntaxStyles in interface MARSTextEditingArea

setCaretBlinkRate

public void setCaretBlinkRate(int rate)
Set the caret blinking rate in milliseconds. If rate is 0 it will not blink. If negative, do nothing.

Specified by:
setCaretBlinkRate in interface MARSTextEditingArea
Parameters:
rate - blinking rate in milliseconds

getOuterComponent

public Component getOuterComponent()
Specified by:
getOuterComponent in interface MARSTextEditingArea

setSourceCode

public void setSourceCode(String s,
                          boolean editable)
For initalizing the source code when opening an ASM file

Specified by:
setSourceCode in interface MARSTextEditingArea
Parameters:
s - String containing text
editable - set true if code is editable else false

discardAllUndoableEdits

public void discardAllUndoableEdits()
Tell UndoManager to discard all its collected undoable edits.

Specified by:
discardAllUndoableEdits in interface MARSTextEditingArea

setText

public void setText(String s)
Override inherited setText to temporarily remove UndoableEditListener because this operation is not undoable.

Specified by:
setText in interface MARSTextEditingArea
Overrides:
setText in class JTextComponent
Parameters:
s - String with new contents for the editing area. Replaces current content.

setCaretVisible

public void setCaretVisible(boolean vis)
Control caret visibility

Specified by:
setCaretVisible in interface MARSTextEditingArea
Parameters:
vis - true to display caret, false to hide it

setSelectionVisible

public void setSelectionVisible(boolean vis)
Control selection visibility

Specified by:
setSelectionVisible in interface MARSTextEditingArea
Parameters:
vis - true to display selection, false to hide it

getUndoManager

public UndoManager getUndoManager()
Returns the undo manager for this editing area

Specified by:
getUndoManager in interface MARSTextEditingArea
Returns:
the undo manager

undo

public void undo()
Undo previous edit

Specified by:
undo in interface MARSTextEditingArea

redo

public void redo()
Redo previous edit

Specified by:
redo in interface MARSTextEditingArea

doFindText

public int doFindText(String find,
                      boolean caseSensitive)
Finds next occurrence of text in a forward search of a string. Search begins at the current cursor location, and wraps around when the end of the string is reached.

Specified by:
doFindText in interface MARSTextEditingArea
Parameters:
find - the text to locate in the string
caseSensitive - true if search is to be case-sensitive, false otherwise
Returns:
TEXT_FOUND or TEXT_NOT_FOUND, depending on the result.

nextIndex

public int nextIndex(String input,
                     String find,
                     int start,
                     boolean caseSensitive)
Returns next posn of word in text - forward search. If end of string is reached during the search, will wrap around to the beginning one time.

Parameters:
input - the string to search
find - the string to find
start - the character position to start the search
caseSensitive - true for case sensitive. false to ignore case
Returns:
next indexed position of found text or -1 if not found

doReplace

public int doReplace(String find,
                     String replace,
                     boolean caseSensitive)
Finds and replaces next occurrence of text in a string in a forward search. If cursor is initially at end of matching selection, will immediately replace then find and select the next occurrence if any. Otherwise it performs a find operation. The replace can be undone with one undo operation.

Specified by:
doReplace in interface MARSTextEditingArea
Parameters:
find - the text to locate in the string
replace - the text to replace the find text with - if the find text exists
caseSensitive - true for case sensitive. false to ignore case
Returns:
Returns TEXT_FOUND if not initially at end of selected match and matching occurrence is found. Returns TEXT_NOT_FOUND if the text is not matched. Returns TEXT_REPLACED_NOT_FOUND_NEXT if replacement is successful but there are no additional matches. Returns TEXT_REPLACED_FOUND_NEXT if reaplacement is successful and there is at least one additional match.

doReplaceAll

public int doReplaceAll(String find,
                        String replace,
                        boolean caseSensitive)
Finds and replaces ALL occurrences of text in a string in a forward search. All replacements are bundled into one CompoundEdit, so one Undo operation will undo all of them.

Specified by:
doReplaceAll in interface MARSTextEditingArea
Parameters:
find - the text to locate in the string
replace - the text to replace the find text with - if the find text exists
caseSensitive - true for case sensitive. false to ignore case
Returns:
the number of occurrences that were matched and replaced.