Java 2 Platform
v1.3

edu.umich.visualsoar.ruleeditor
Class RuleEditor

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JInternalFrame
                          |
                          +--edu.umich.visualsoar.ruleeditor.RuleEditor
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class RuleEditor
extends javax.swing.JInternalFrame

This is the rule editor window

See Also:
Serialized Form

Nested Class Summary
(package private)  class RuleEditor.BackupThread
           
(package private)  class RuleEditor.CheckProductionsAction
           
(package private)  class RuleEditor.CloseAction
          Closes the current window
(package private)  class RuleEditor.CloseListener
          This class is meant to catch if the user closes an internal frame without saving the file, it prompts them to save, or discard the file or cancel the close
(package private)  class RuleEditor.CommentOutAction
          This class comments (puts a # in the first position for every line) for the currently selected text of the text area
(package private)  class RuleEditor.FindAction
           
(package private)  class RuleEditor.FindAgainAction
           
(package private)  class RuleEditor.FindAndReplaceAction
           
(package private)  class RuleEditor.IgnoreSyntaxColorUndoManager
           
(package private)  class RuleEditor.InsertTemplateAction
          This class puts the instantiated template in the text area.
(package private)  class RuleEditor.InsertTextFromFileAction
           
(package private)  class RuleEditor.RedoAction
           
(package private)  class RuleEditor.ReplaceAction
           
(package private)  class RuleEditor.ReplaceAllAction
           
(package private)  class RuleEditor.ReplaceAndFindAgainAction
           
(package private)  class RuleEditor.RevertToSavedAction
          reverts the editor's contents to it's last saved state
(package private)  class RuleEditor.SaveAction
          Gets the currently selected rule editor and tells it to save itself
(package private)  class RuleEditor.SendExciseProductionToSoarAction
           
(package private)  class RuleEditor.SendFileToSoarAction
           
(package private)  class RuleEditor.SendMatchesToSoarAction
           
(package private)  class RuleEditor.SendProductionToSoarAction
           
(package private)  class RuleEditor.TabCompleteAction
           
(package private)  class RuleEditor.UncommentOutAction
          This class uncomments (takes out the # in the first position for every line) from the currently selected text of the text area.
(package private)  class RuleEditor.UndoAction
           
 
Nested classes inherited from class javax.swing.JInternalFrame
javax.swing.JInternalFrame.AccessibleJInternalFrame, javax.swing.JInternalFrame.JDesktopIcon
 
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  edu.umich.visualsoar.operatorwindow.OperatorNode associatedNode
           
private  RuleEditor.BackupThread backupThread
           
private  boolean change
           
private  javax.swing.Action checkProductionsAction
           
private  javax.swing.Action closeAction
           
private  javax.swing.Action commentOutAction
           
private  javax.swing.Action copyAction
           
private  javax.swing.Action cutAction
           
private  edu.umich.visualsoar.ruleeditor.EditorPane editorPane
           
private  java.lang.String fileName
           
private  javax.swing.Action findAction
           
private  RuleEditor.FindAgainAction findAgainAction
           
private  javax.swing.Action findAndReplaceAction
           
private  boolean findForward
           
private  java.lang.String findString
           
private  javax.swing.Action insertTextFromFileAction
           
private  javax.swing.JLabel lineNumberLabel
           
private  boolean matchCase
           
private  javax.swing.JLabel modifiedLabel
           
private  javax.swing.Action pasteAction
           
private  javax.swing.Action redoAction
           
private  RuleEditor.ReplaceAction replaceAction
           
private  RuleEditor.ReplaceAllAction replaceAllAction
           
private  RuleEditor.ReplaceAndFindAgainAction replaceAndFindAgainAction
           
private  java.lang.String replaceString
           
private  javax.swing.Action revertToSavedAction
           
private  javax.swing.Action saveAction
           
private  javax.swing.Action sendExciseProductionToSoarAction
           
private  javax.swing.Action sendFileToSoarAction
           
private  javax.swing.Action sendMatchesToSoarAction
           
private  javax.swing.Action sendProductionToSoarAction
           
private  javax.swing.Action tabCompleteAction
           
private  javax.swing.Action uncommentOutAction
           
private  javax.swing.Action undoAction
           
private  javax.swing.undo.UndoManager undoManager
           
private  boolean wrapSearch
           
 
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
 
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 javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
RuleEditor(java.io.File inFileName)
          Constructs a new JInternalFrame, sets its size and adds the editor pane to it.
RuleEditor(java.io.File inFileName, edu.umich.visualsoar.operatorwindow.OperatorNode inNode)
          Constructs a new JInternalFrame, sets its size and adds the editor pane to it
 
Method Summary
private  void adjustKeymap()
           
 void colorSyntax()
          Recolors the syntax to reflect a color preference change
 void fileRenamed(java.lang.String newFileName)
          The file underneath of us has been renamed
 void find()
          Looks for the passed string in the document, if it is searching forward, then it searches for and instance of the string after the caret and selects it, if it is searching backwards then it selects the text either before the caret or before the start of the selection
private  boolean findBackward()
          Finds the a string in the document before the caret or before the selection point, if it finds it, it selects it
private  boolean findForward()
          Finds the a string in the document past the caret, if it finds it, it selects it
 boolean findResult()
          Similiar to void find(), but returns result of search as boolean
 java.lang.String getAllText()
           
private  void getData(java.io.File fn)
          A helper function to read in the data from a file into the editorPane so we don't have catch it in the constructor
 java.lang.String getFile()
           
 edu.umich.visualsoar.operatorwindow.OperatorNode getNode()
          Returns the node this rule editor is associated with
 int getNumberOfLines()
           
 java.lang.String GetProductionNameUnderCaret()
           
 java.lang.String GetProductionStringUnderCaret()
           
 void hideCaret()
          Hides the caret for the editor window
private  void initEditMenu(javax.swing.JMenuBar menuBar)
           
private  void initFileMenu(javax.swing.JMenuBar menuBar)
           
private  void initLayout()
          This lays out the Rule Editor according to specifications
private  void initMenuBar()
          Initializes the menubar according to specifications
private  void initMenuBarExternFile()
           
private  void initSearchMenu(javax.swing.JMenuBar menuBar)
           
private  void initSoarMenu(javax.swing.JMenuBar menuBar)
           
private  void initSoarRuntimeMenu(javax.swing.JMenuBar menuBar)
           
private  void makeValidForParser()
          In order for the file to be valid for the parser there must be a newline following
 java.util.Vector parseProductions()
           
private  void registerDocumentListeners()
           
 void replace()
          Takes the selected text within the editorPane checks to see if that is the string that we are looking for, if it is then it replaces it and selects the new text
 void replaceAll()
          Replaces all instances (before/after) the caret with the specified string
 void revert()
          Reverts the contents of the editor to it's saved copy
 void setFindReplaceData(java.lang.String find, java.lang.Boolean forward, java.lang.Boolean caseSensitive, java.lang.Boolean wrap)
           
 void setFindReplaceData(java.lang.String find, java.lang.String replace, java.lang.Boolean forward, java.lang.Boolean caseSensitive, java.lang.Boolean wrap)
           
 void setLine(int lineNum)
          Sets the current line number in the editorPane, puts the caret at the beginning of the line, and requests focus
 void write()
          Writes the data in the editing window out to disk, the file that it writes to is the same as it was at construction
 
Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, dispose, doDefaultCloseAction, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, show, toBack, toFront, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

associatedNode

private edu.umich.visualsoar.operatorwindow.OperatorNode associatedNode

editorPane

private edu.umich.visualsoar.ruleeditor.EditorPane editorPane

undoManager

private javax.swing.undo.UndoManager undoManager

fileName

private java.lang.String fileName

change

private boolean change

lineNumberLabel

private javax.swing.JLabel lineNumberLabel

modifiedLabel

private javax.swing.JLabel modifiedLabel

findString

private java.lang.String findString

replaceString

private java.lang.String replaceString

findForward

private boolean findForward

matchCase

private boolean matchCase

wrapSearch

private boolean wrapSearch

saveAction

private javax.swing.Action saveAction

revertToSavedAction

private javax.swing.Action revertToSavedAction

closeAction

private javax.swing.Action closeAction

undoAction

private javax.swing.Action undoAction

redoAction

private javax.swing.Action redoAction

cutAction

private javax.swing.Action cutAction

copyAction

private javax.swing.Action copyAction

pasteAction

private javax.swing.Action pasteAction

insertTextFromFileAction

private javax.swing.Action insertTextFromFileAction

commentOutAction

private javax.swing.Action commentOutAction

uncommentOutAction

private javax.swing.Action uncommentOutAction

findAction

private javax.swing.Action findAction

findAgainAction

private RuleEditor.FindAgainAction findAgainAction

replaceAction

private RuleEditor.ReplaceAction replaceAction

replaceAndFindAgainAction

private RuleEditor.ReplaceAndFindAgainAction replaceAndFindAgainAction

replaceAllAction

private RuleEditor.ReplaceAllAction replaceAllAction

findAndReplaceAction

private javax.swing.Action findAndReplaceAction

checkProductionsAction

private javax.swing.Action checkProductionsAction

tabCompleteAction

private javax.swing.Action tabCompleteAction

sendProductionToSoarAction

private javax.swing.Action sendProductionToSoarAction

sendFileToSoarAction

private javax.swing.Action sendFileToSoarAction

sendMatchesToSoarAction

private javax.swing.Action sendMatchesToSoarAction

sendExciseProductionToSoarAction

private javax.swing.Action sendExciseProductionToSoarAction

backupThread

private RuleEditor.BackupThread backupThread
Constructor Detail

RuleEditor

public RuleEditor(java.io.File inFileName,
                  edu.umich.visualsoar.operatorwindow.OperatorNode inNode)
           throws java.io.IOException
Constructs a new JInternalFrame, sets its size and adds the editor pane to it


RuleEditor

public RuleEditor(java.io.File inFileName)
           throws java.io.IOException
Constructs a new JInternalFrame, sets its size and adds the editor pane to it. This constructor is for opening external files not associated with the project.

Method Detail

registerDocumentListeners

private void registerDocumentListeners()

adjustKeymap

private void adjustKeymap()

getData

private void getData(java.io.File fn)
              throws java.io.IOException
A helper function to read in the data from a file into the editorPane so we don't have catch it in the constructor

Parameters:
fn - the file name
java.io.IOException

setLine

public void setLine(int lineNum)
Sets the current line number in the editorPane, puts the caret at the beginning of the line, and requests focus

Parameters:
lineNum - the desired lineNum to go to

getNumberOfLines

public int getNumberOfLines()

getNode

public edu.umich.visualsoar.operatorwindow.OperatorNode getNode()
Returns the node this rule editor is associated with

Returns:
the associated node

findForward

private boolean findForward()
Finds the a string in the document past the caret, if it finds it, it selects it

Returns:
whether or not it found the string

findBackward

private boolean findBackward()
Finds the a string in the document before the caret or before the selection point, if it finds it, it selects it

Returns:
whether or not it found the string

getAllText

public java.lang.String getAllText()

setFindReplaceData

public void setFindReplaceData(java.lang.String find,
                               java.lang.Boolean forward,
                               java.lang.Boolean caseSensitive,
                               java.lang.Boolean wrap)

setFindReplaceData

public void setFindReplaceData(java.lang.String find,
                               java.lang.String replace,
                               java.lang.Boolean forward,
                               java.lang.Boolean caseSensitive,
                               java.lang.Boolean wrap)

GetProductionStringUnderCaret

public java.lang.String GetProductionStringUnderCaret()

GetProductionNameUnderCaret

public java.lang.String GetProductionNameUnderCaret()

find

public void find()
Looks for the passed string in the document, if it is searching forward, then it searches for and instance of the string after the caret and selects it, if it is searching backwards then it selects the text either before the caret or before the start of the selection


findResult

public boolean findResult()
Similiar to void find(), but returns result of search as boolean


replace

public void replace()
Takes the selected text within the editorPane checks to see if that is the string that we are looking for, if it is then it replaces it and selects the new text


replaceAll

public void replaceAll()
Replaces all instances (before/after) the caret with the specified string


write

public void write()
           throws java.io.IOException
Writes the data in the editing window out to disk, the file that it writes to is the same as it was at construction

Throws:
java.io.IOException - if there is a disk error

makeValidForParser

private void makeValidForParser()
In order for the file to be valid for the parser there must be a newline following


revert

public void revert()
            throws java.io.IOException
Reverts the contents of the editor to it's saved copy

java.io.IOException

hideCaret

public void hideCaret()
Hides the caret for the editor window


getFile

public java.lang.String getFile()
Returns:
returns the file that this window is associated with

parseProductions

public java.util.Vector parseProductions()
                                  throws ParseException
ParseException

colorSyntax

public void colorSyntax()
Recolors the syntax to reflect a color preference change


fileRenamed

public void fileRenamed(java.lang.String newFileName)
The file underneath of us has been renamed

Parameters:
newFileName - what the new name is

initLayout

private void initLayout()
This lays out the Rule Editor according to specifications


initMenuBar

private void initMenuBar()
Initializes the menubar according to specifications


initMenuBarExternFile

private void initMenuBarExternFile()

initFileMenu

private void initFileMenu(javax.swing.JMenuBar menuBar)

initEditMenu

private void initEditMenu(javax.swing.JMenuBar menuBar)

initSearchMenu

private void initSearchMenu(javax.swing.JMenuBar menuBar)

initSoarMenu

private void initSoarMenu(javax.swing.JMenuBar menuBar)

initSoarRuntimeMenu

private void initSoarRuntimeMenu(javax.swing.JMenuBar menuBar)

Java 2 Platform
v1.3