Class TextPanel

All Implemented Interfaces:
ComponentListener, KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
EditorArea

public class TextPanel extends BaseXPanel
Renders and provides edit capabilities for text.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
See Also:
  • Field Details

    • editor

      public final TextEditor editor
      Text editor.
    • hist

      public final History hist
      Undo history.
  • Constructor Details

    • TextPanel

      public TextPanel(BaseXWindow win, boolean editable)
      Default constructor.
      Parameters:
      win - parent window
      editable - editable flag
    • TextPanel

      public TextPanel(BaseXWindow win, String text, boolean editable)
      Default constructor.
      Parameters:
      win - parent window
      text - initial text
      editable - editable flag
  • Method Details

    • setText

      public void setText(String t)
      Sets the output text.
      Parameters:
      t - output text
    • setText

      public void setText(byte[] t)
      Sets the output text.
      Parameters:
      t - output text
    • searchString

      public final String searchString()
      Returns a currently marked string if it does not extend over more than one line.
      Returns:
      search string
    • pos

      public final int[] pos()
      Returns the line and column of the current caret position.
      Returns:
      line/column
    • setText

      public final void setText(byte[] text, int size)
      Sets the output text.
      Parameters:
      text - output text
      size - text size
    • setSyntax

      protected final void setSyntax(IO file, boolean opened)
      Sets a syntax highlighter, based on the file format.
      Parameters:
      file - file reference
      opened - indicates if file was opened from disk
    • isEditable

      public final boolean isEditable()
      Returns the editable flag.
      Returns:
      boolean result
    • setSyntax

      public final void setSyntax(org.basex.gui.text.Syntax syntax)
      Sets a syntax highlighter.
      Parameters:
      syntax - syntax reference
    • setCaret

      public final void setCaret(int pos)
      Sets the caret to the specified position. A text selection will be removed.
      Parameters:
      pos - caret position
    • getText

      public final byte[] getText()
      Returns the output text.
      Returns:
      output text
    • selected

      public final boolean selected()
      Tests if text has been selected.
      Returns:
      result of check
    • setFont

      public final void setFont(Font f)
      Overrides:
      setFont in class JComponent
    • resetError

      public final void resetError()
      Removes the error marker.
    • error

      public final void error(int pos)
      Sets the error marker.
      Parameters:
      pos - start of optional error mark
    • comment

      public final void comment()
      Adds or removes a comment.
    • toCase

      public final void toCase(TextEditor.Case cs)
      Case conversion.
      Parameters:
      cs - case type
    • bracket

      public final void bracket()
      Jumps to a matching bracket.
    • sort

      public final void sort()
      Sorts text.
    • format

      public final void format()
      Formats the selected text.
    • setEnabled

      public final void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent
    • setLinkListener

      public final void setLinkListener(LinkListener ll)
      Installs a link listener.
      Parameters:
      ll - link listener
    • getSearch

      public final SearchBar getSearch()
      Returns the search bar.
      Returns:
      search bar
    • jump

      protected final void jump(SearchBar.SearchDir dir, boolean select)
      Jumps to the current, next or previous search string.
      Parameters:
      dir - search direction
      select - select hit
    • mouseEntered

      public final void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
      Overrides:
      mouseEntered in class BaseXPanel
    • mouseExited

      public final void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
      Overrides:
      mouseExited in class BaseXPanel
    • mouseMoved

      public final void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
      Overrides:
      mouseMoved in class BaseXPanel
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
      Overrides:
      mouseReleased in class BaseXPanel
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
      Overrides:
      mouseClicked in class BaseXPanel
    • mouseDragged

      public final void mouseDragged(MouseEvent e)
      Specified by:
      mouseDragged in interface MouseMotionListener
      Overrides:
      mouseDragged in class BaseXPanel
    • mousePressed

      public final void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
      Overrides:
      mousePressed in class BaseXPanel
    • keyPressed

      public void keyPressed(KeyEvent e)
      Specified by:
      keyPressed in interface KeyListener
      Overrides:
      keyPressed in class BaseXPanel
    • keyTyped

      public void keyTyped(KeyEvent e)
      Specified by:
      keyTyped in interface KeyListener
      Overrides:
      keyTyped in class BaseXPanel
    • release

      protected void release(TextPanel.Action action)
      Releases a key or mouse. Can be overwritten to react on events.
      Parameters:
      action - action
    • refreshLayout

      public final void refreshLayout(Font f)
      Refreshes the layout.
      Parameters:
      f - used font
    • mouseWheelMoved

      public final void mouseWheelMoved(MouseWheelEvent e)
      Specified by:
      mouseWheelMoved in interface MouseWheelListener
      Overrides:
      mouseWheelMoved in class BaseXPanel
    • componentResized

      public final void componentResized(ComponentEvent e)
      Specified by:
      componentResized in interface ComponentListener
      Overrides:
      componentResized in class BaseXPanel