UTJML

edu.utep.cs.utjml.canica.jmleditor
Class JMLTextPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by edu.utep.cs.utjml.canica.jmleditor.JMLTextPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class JMLTextPane
extends JPanel

This class has the view, model and controller of a Java file. Its main functionalities are to display the Java file, show syntax highlighting, and provide the methods to edit a file.

Author:
Angelica B. Perez, Apr 27, 2006
See Also:
Serialized Form

Nested Class Summary
protected  class JMLTextPane.MyDocumentListener
           
protected  class JMLTextPane.MyUndoableEditListener
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
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
protected  Mainable canica
          the main program
 MenuOptions menuOptions
          the menu options personalized for this document
protected  Lexer syntaxLexer
          The lexer that tells us what colors different words should be.
protected  UndoManager undo
          Manages undo actions to this text pane
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JMLTextPane(StyledDocument doc, File newFile, int index, Mainable canica, Thread colorer)
          Initializes the JMLTextPane, setting its index file, and setting the reference to the status bar of canica.
 
Method Summary
 void focusTextArea()
          It focus the text area
 int getCol()
           
 StyledDocument getDocument()
          It returns the styled document related with this JML TextPane.
 boolean getError()
          Returns true if an error occurred at reading the file
 File getFile()
          Returns the file associated with this textpane
 String getFileName()
          returns the file name associated with this textpane
 int getIndex()
          Returns the index file (control) of this textpane
 int getLine()
           
 JTextPane getTextPane()
          It returns the JTextPane object related with this object.
 void highlightLine(int line)
          Highlights the specified line.
 void highlightLine(int line, int col)
          Highlights the specified line and set the Caret to column position.
 boolean isModified()
          Returns true if there exist unsaved edits.
 void redo()
          Redo the last editing action to the document.
 boolean saveContents()
          Save the actual contents to the actual file
 boolean saveContents(File newFile)
          Save the actual contents of the View to a new file.
 void setFileName(File file)
          Sets a new name to its file
 void undo()
          Undo the last editing action to the document.
 void updateRedoState()
          Enables or disables the redo menu item option to this file, and updates the action name.
 void updateUndoState()
          Enables or disables the undo menu item option to this file, and updates the action name.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, 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, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, 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, addInputMethodListener, 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, getInputMethodRequests, 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, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, 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
 

Field Detail

canica

protected Mainable canica
the main program


syntaxLexer

protected Lexer syntaxLexer
The lexer that tells us what colors different words should be.


menuOptions

public MenuOptions menuOptions
the menu options personalized for this document


undo

protected final UndoManager undo
Manages undo actions to this text pane

Constructor Detail

JMLTextPane

public JMLTextPane(StyledDocument doc,
                   File newFile,
                   int index,
                   Mainable canica,
                   Thread colorer)
Initializes the JMLTextPane, setting its index file, and setting the reference to the status bar of canica.

Parameters:
index - index file
canica - Main program
Method Detail

getDocument

public StyledDocument getDocument()
It returns the styled document related with this JML TextPane.

Returns:
Styled Document

highlightLine

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


highlightLine

public void highlightLine(int line,
                          int col)
Highlights the specified line and set the Caret to column position.


isModified

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


getIndex

public int getIndex()
Returns the index file (control) of this textpane


getFileName

public String getFileName()
returns the file name associated with this textpane


setFileName

public void setFileName(File file)
Sets a new name to its file

Parameters:
file - New file name

getFile

public File getFile()
Returns the file associated with this textpane


getError

public boolean getError()
Returns true if an error occurred at reading the file

Returns:
errorAtReading

focusTextArea

public void focusTextArea()
It focus the text area


getLine

public int getLine()
Returns:
The actual line caret position

getCol

public int getCol()
Returns:
The actual column caret position

getTextPane

public JTextPane getTextPane()
It returns the JTextPane object related with this object.

Returns:
JTextPane object.

saveContents

public boolean saveContents()
Save the actual contents to the actual file

Returns:
True if there where no problems

saveContents

public boolean saveContents(File newFile)
Save the actual contents of the View to a new file.

Parameters:
newFile -
Returns:

undo

public void undo()
Undo the last editing action to the document.


redo

public void redo()
Redo the last editing action to the document.


updateRedoState

public void updateRedoState()
Enables or disables the redo menu item option to this file, and updates the action name.


updateUndoState

public void updateUndoState()
Enables or disables the undo menu item option to this file, and updates the action name.


UTJML

UTJML is Copyright (C) 2004-2006 by 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. This release depends on code from the JML project.