Class SourceTextPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class SourceTextPanel extends JPanel

The Source text Panel.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
See Also:
  • Field Details

    • DEBUG

      private static final boolean DEBUG
      DEBUG on/off
      See Also:
    • lineNumbers

      private JTextPane lineNumbers
      The line number side-panel.
    • styleScrollPane

      private JScrollPane styleScrollPane
      The ScrollPane
    • styleRegular

      private Style styleRegular
      Style
    • styleKeyword

      private Style styleKeyword
      Style
    • styleComment

      private Style styleComment
      Style
    • styleConstant

      private Style styleConstant
      Style
    • styleLineNumber

      private Style styleLineNumber
      Style
    • popupMenu

      private JPopupMenu popupMenu
      The popup Menu.
    • doc

      private StyledDocument doc
      The StyledDocument.
    • editTextPane

      JTextPane editTextPane
      Editable text pane with undo/redo history.
    • lang

      Current language.
    • sourceFile

      File sourceFile
      The source file.
    • AUTO_REFRESH

      boolean AUTO_REFRESH
      Signals auto refresh.
    • undoManager

      private UndoManager undoManager
      The undo manager.
    • fileChanged

      boolean fileChanged
      Indicates that the source file has changed.
    • refreshNeeded

      boolean refreshNeeded
      Indicates that refresh is needed.
    • undoListener

      private UndoableEditListener undoListener
      The UndoableEditListener.
    • mouseListener

      MouseListener mouseListener
      The MouseListener.
    • documentListener

      DocumentListener documentListener
      The DocumentListener.
  • Constructor Details

    • SourceTextPanel

      SourceTextPanel(File sourceFile, SimulaEditor.Language lang, JPopupMenu popupMenu)
      Create a new SourceTextPanel.
      Parameters:
      sourceFile - the source file
      lang - the language
      popupMenu - the popupMenu
  • Method Details

    • getUndoManager

      UndoManager getUndoManager()
      Returns the undo manager.
      Returns:
      the undo manager
    • fillTextPane

      void fillTextPane(Reader reader, int caretPosition)
      Fill the text pane with text from the source file reader.
      Parameters:
      reader - the source file reader
      caretPosition - argument
    • fillTextPane

      private void fillTextPane(int caretPosition, DefaultScanner preScanner)
      Fill the text pane with text delivered from the scanner.
      Parameters:
      caretPosition - the caretPosition after the operations
      preScanner - the scanner to use
    • doRefresh

      void doRefresh()
      Do refresh action.
    • edLineNumber

      private String edLineNumber(int n)
      Utility: Edit right justified line number string.
      Parameters:
      n - the length of line number field
      Returns:
      the resulting line number string
    • countExtraControlCharacters

      private int countExtraControlCharacters(String s, int pos)
      Utility: Count extra control characters in the given string
      Parameters:
      s - the given string
      pos - limitin position in s
      Returns:
      the resulting number of control characters
    • getStyle

      private Style getStyle(Token.StyleCode code)
      Utility: Get Style
      Parameters:
      code - style code
      Returns:
      the resuting Style
    • addStylesToDocument

      private void addStylesToDocument(StyledDocument doc)
      Add Styles to the document.
      Parameters:
      doc - the document
    • toString

      public String toString()
      Overrides:
      toString in class Component