Package org.basex.gui.text
Class TextPanel
- All Implemented Interfaces:
ComponentListener,KeyListener,MouseListener,MouseMotionListener,MouseWheelListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible
- Direct Known Subclasses:
EditorArea
Renders and provides edit capabilities for text.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal TextEditorText editor.final HistoryUndo history.protected SearchBarSearch bar.Fields inherited from class org.basex.gui.layout.BaseXPanel
guiFields inherited from class org.basex.gui.layout.BaseXBack
SEPARATOR_SIZEFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionTextPanel(BaseXWindow win, boolean editable) Default constructor.TextPanel(BaseXWindow win, String text, boolean editable) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidbracket()Jumps to a matching bracket.final voidcomment()Adds or removes a comment.final voidfinal voiderror(int pos) Sets the error marker.final voidformat()Formats the selected text.final SearchBarReturns the search bar.final byte[]getText()Returns the output text.final booleanReturns the editable flag.protected final voidjump(SearchBar.SearchDir dir, boolean select) Jumps to the current, next or previous search string.voidvoidvoidfinal voidfinal voidfinal voidfinal voidfinal voidvoidfinal voidfinal int[]pos()Returns the line and column of the current caret position.final voidRefreshes the layout.protected voidrelease(TextPanel.Action action) Releases a key or mouse.final voidRemoves the error marker.final StringReturns a currently marked string if it does not extend over more than one line.final booleanselected()Tests if text has been selected.final voidsetCaret(int pos) Sets the caret to the specified position.final voidsetEnabled(boolean enabled) final voidfinal voidInstalls a link listener.final voidsetSyntax(org.basex.gui.text.Syntax syntax) Sets a syntax highlighter.protected final voidSets a syntax highlighter, based on the file format.voidsetText(byte[] t) Sets the output text.final voidsetText(byte[] text, int size) Sets the output text.voidSets the output text.final voidsort()Sorts text.final voidCase conversion.Methods inherited from class org.basex.gui.layout.BaseXPanel
componentHidden, componentMoved, componentShown, keyReleasedMethods inherited from class org.basex.gui.layout.BaseXBack
border, border, layout, paintComponentMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
editor
Text editor. -
hist
Undo history. -
search
Search bar.
-
-
Constructor Details
-
TextPanel
Default constructor.- Parameters:
win- parent windoweditable- editable flag
-
TextPanel
Default constructor.- Parameters:
win- parent windowtext- initial texteditable- editable flag
-
-
Method Details
-
setText
Sets the output text.- Parameters:
t- output text
-
setText
public void setText(byte[] t) Sets the output text.- Parameters:
t- output text
-
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 textsize- text size
-
setSyntax
Sets a syntax highlighter, based on the file format.- Parameters:
file- file referenceopened- 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
- Overrides:
setFontin classJComponent
-
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
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:
setEnabledin classJComponent
-
setLinkListener
Installs a link listener.- Parameters:
ll- link listener
-
getSearch
Returns the search bar.- Returns:
- search bar
-
jump
Jumps to the current, next or previous search string.- Parameters:
dir- search directionselect- select hit
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener- Overrides:
mouseEnteredin classBaseXPanel
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener- Overrides:
mouseExitedin classBaseXPanel
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classBaseXPanel
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classBaseXPanel
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener- Overrides:
mouseClickedin classBaseXPanel
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin classBaseXPanel
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classBaseXPanel
-
keyPressed
- Specified by:
keyPressedin interfaceKeyListener- Overrides:
keyPressedin classBaseXPanel
-
keyTyped
- Specified by:
keyTypedin interfaceKeyListener- Overrides:
keyTypedin classBaseXPanel
-
release
Releases a key or mouse. Can be overwritten to react on events.- Parameters:
action- action
-
refreshLayout
Refreshes the layout.- Parameters:
f- used font
-
mouseWheelMoved
- Specified by:
mouseWheelMovedin interfaceMouseWheelListener- Overrides:
mouseWheelMovedin classBaseXPanel
-
componentResized
- Specified by:
componentResizedin interfaceComponentListener- Overrides:
componentResizedin classBaseXPanel
-