Package adams.gui.core
Class AbstractTextAreaPanelWithAdvancedSyntaxHighlighting
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.core.AbstractTextAreaPanelWithAdvancedSyntaxHighlighting
-
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible
- Direct Known Subclasses:
DefaultTextAreaPanelWithAdvancedSyntaxHighlighting,GroovySyntaxEditorPanel,SQLSyntaxEditorPanel,XSLTSyntaxEditorPanel
public abstract class AbstractTextAreaPanelWithAdvancedSyntaxHighlighting extends BasePanel
Panel with syntax highlighting usingRSyntaxTextArea.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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
Fields Modifier and Type Field Description protected HashSet<ChangeListener>m_ChangeListenersthe listeners for modification events.protected Filem_CurrentFilethe current file.protected TextFileChooserm_FileChooserfor saving the content.protected booleanm_IgnoreChangeswhether to ignore changes.protected Stringm_LastFindthe last search string used.protected booleanm_Modifiedwhether the content was modified.protected org.fife.ui.rtextarea.RTextScrollPanem_ScrollPanethe scroll pane.protected org.fife.ui.rsyntaxtextarea.RSyntaxTextAream_TextAreathe text area.-
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Constructors Constructor Description AbstractTextAreaPanelWithAdvancedSyntaxHighlighting()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddChangeListener(ChangeListener l)Adds the given change listener to its internal list.booleancanCopy()Checks whether text can be copied at the moment.booleancanCut()Checks whether text can be cut at the moment.booleancanPaste()Checks whether text can be pasted at the moment.booleancanRedo()Checks whether a redo action is available.booleancanUndo()Checks whether an undo action is available.booleancheckForModified()Returns whether we can proceed with the operation or not, depending on whether the user saved the content or discarded the changes.voidclear()Removes all content.voidcopy()Copies the currently selected text to the clipboard.voidcut()Cuts the currently selected text and places it on the clipboard.voidfind()Initiates a search.voidfindNext()Finds the next occurrence.intgetCaretPosition()Returns the current position of the cursor.StringgetContent()Returns the content to display.DocumentgetDocument()Returns the underlying document of the text area.protected TextFileChoosergetFileChooser()Returns the file chooser and creates it if necessary.StringgetLastFind()Returns the last search string.booleangetLineWrap()Returns the linewrap status.protected abstract StringgetSyntaxStyle()Returns the syntax style to use.org.fife.ui.rsyntaxtextarea.RSyntaxTextAreagetTextArea()Returns the underlying RSyntaxTextArea element.FontgetTextFont()Returns the font currently in use by the text area.protected voidinitGUI()For initializing members.protected voidinitialize()For initializing members.booleanisEditable()Returns whether the text area is editable or not.booleanisModified()Returns whether the content has been modified.protected org.fife.ui.rtextarea.RTextScrollPanenewScrollPane(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)Creates a newRSyntaxTextAreainstance.protected org.fife.ui.rsyntaxtextarea.RSyntaxTextAreanewTextArea()Creates a newRSyntaxTextAreainstance.protected voidnotifyChangeListeners()Sends an event to all change listeners.voidopen()Pops up dialog to open a file.voidopen(File file)Opens the specified file and loads/displays the content, using UTF-8.voidopen(File file, String encoding)Opens the specified file and loads/displays the content.voidpaste()Pastes the text from the clipboard into the document.voidprintText()Pops up a print dialog.voidredo()Performs a redo, if possible.voidremoveChangeListener(ChangeListener l)Removes the given change listener from its internal list.voidsave()Pops up dialog to save the content in a file.protected voidsave(File file)Saves the content under the specified file.voidsaveAs()Pops up dialog to save the content in a file.voidselectAll()Selects all the text.voidselectFont()Pops up a dialog for selecting the font.voidsetCaretPosition(int value)Sets the position of the cursor.voidsetContent(String value)Sets the content to display.voidsetEditable(boolean value)Sets whether the text area is editable or not.voidsetLineWrap(boolean value)Sets the linewrap state.voidsetModified(boolean value)Sets the modified state.voidsetTextFont(Font value)Sets the font of the text area.voidundo()Performs an undo, if possible.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, finishInit, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, 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, 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 Detail
-
m_TextArea
protected org.fife.ui.rsyntaxtextarea.RSyntaxTextArea m_TextArea
the text area.
-
m_ScrollPane
protected org.fife.ui.rtextarea.RTextScrollPane m_ScrollPane
the scroll pane.
-
m_Modified
protected boolean m_Modified
whether the content was modified.
-
m_IgnoreChanges
protected boolean m_IgnoreChanges
whether to ignore changes.
-
m_FileChooser
protected transient TextFileChooser m_FileChooser
for saving the content.
-
m_LastFind
protected String m_LastFind
the last search string used.
-
m_ChangeListeners
protected HashSet<ChangeListener> m_ChangeListeners
the listeners for modification events.
-
m_CurrentFile
protected File m_CurrentFile
the current file.
-
-
Method Detail
-
initialize
protected void initialize()
For initializing members.- Overrides:
initializein classBasePanel
-
getSyntaxStyle
protected abstract String getSyntaxStyle()
Returns the syntax style to use.- Returns:
- style
- See Also:
RSyntaxTextArea
-
newTextArea
protected org.fife.ui.rsyntaxtextarea.RSyntaxTextArea newTextArea()
Creates a newRSyntaxTextAreainstance.- Returns:
- the text area
-
newScrollPane
protected org.fife.ui.rtextarea.RTextScrollPane newScrollPane(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
Creates a newRSyntaxTextAreainstance.- Returns:
- the text area
-
getFileChooser
protected TextFileChooser getFileChooser()
Returns the file chooser and creates it if necessary.
-
setModified
public void setModified(boolean value)
Sets the modified state. If false, all edits are discarded and the last search string reset as well.- Parameters:
value- if true then the content is flagged as modified
-
isModified
public boolean isModified()
Returns whether the content has been modified.- Returns:
- true if the content was modified
-
setContent
public void setContent(String value)
Sets the content to display. Resets the modified state.- Parameters:
value- the text
-
getContent
public String getContent()
Returns the content to display.- Returns:
- the text
-
setEditable
public void setEditable(boolean value)
Sets whether the text area is editable or not.- Parameters:
value- if true then the text will be editable
-
isEditable
public boolean isEditable()
Returns whether the text area is editable or not.- Returns:
- true if the text is editable
-
setTextFont
public void setTextFont(Font value)
Sets the font of the text area.- Parameters:
value- the font to use
-
getTextFont
public Font getTextFont()
Returns the font currently in use by the text area.- Returns:
- the font in use
-
getLastFind
public String getLastFind()
Returns the last search string.- Returns:
- the last search string, can be null if no search performed yet
-
getTextArea
public org.fife.ui.rsyntaxtextarea.RSyntaxTextArea getTextArea()
Returns the underlying RSyntaxTextArea element.- Returns:
- the component
-
getDocument
public Document getDocument()
Returns the underlying document of the text area.- Returns:
- the document
-
setCaretPosition
public void setCaretPosition(int value)
Sets the position of the cursor.- Parameters:
value- the position
-
getCaretPosition
public int getCaretPosition()
Returns the current position of the cursor.- Returns:
- the cursor position
-
setLineWrap
public void setLineWrap(boolean value)
Sets the linewrap state.- Parameters:
value- whether to wrap or not
-
getLineWrap
public boolean getLineWrap()
Returns the linewrap status.- Returns:
- true if linewrap is on
-
checkForModified
public boolean checkForModified()
Returns whether we can proceed with the operation or not, depending on whether the user saved the content or discarded the changes.- Returns:
- true if safe to proceed
-
open
public void open()
Pops up dialog to open a file.
-
open
public void open(File file)
Opens the specified file and loads/displays the content, using UTF-8.- Parameters:
file- the file to load
-
open
public void open(File file, String encoding)
Opens the specified file and loads/displays the content.- Parameters:
file- the file to loadencoding- the encoding to use, use null or empty string for default UTF-8
-
save
public void save()
Pops up dialog to save the content in a file.
-
saveAs
public void saveAs()
Pops up dialog to save the content in a file.
-
save
protected void save(File file)
Saves the content under the specified file.- Parameters:
file- the file to save the content int
-
clear
public void clear()
Removes all content. Does not reset the undos.
-
canUndo
public boolean canUndo()
Checks whether an undo action is available.- Returns:
- true if an undo action is available
-
undo
public void undo()
Performs an undo, if possible.
-
canRedo
public boolean canRedo()
Checks whether a redo action is available.- Returns:
- true if a redo action is available
-
redo
public void redo()
Performs a redo, if possible.
-
canCut
public boolean canCut()
Checks whether text can be cut at the moment.- Returns:
- true if text is available for cutting
-
cut
public void cut()
Cuts the currently selected text and places it on the clipboard.
-
canCopy
public boolean canCopy()
Checks whether text can be copied at the moment.- Returns:
- true if text is available for copying
-
copy
public void copy()
Copies the currently selected text to the clipboard.
-
canPaste
public boolean canPaste()
Checks whether text can be pasted at the moment.- Returns:
- true if text is available for pasting
-
paste
public void paste()
Pastes the text from the clipboard into the document.
-
selectAll
public void selectAll()
Selects all the text.
-
find
public void find()
Initiates a search.
-
findNext
public void findNext()
Finds the next occurrence.
-
printText
public void printText()
Pops up a print dialog.
-
selectFont
public void selectFont()
Pops up a dialog for selecting the font.
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds the given change listener to its internal list.- Parameters:
l- the listener to add
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes the given change listener from its internal list.- Parameters:
l- the listener to remove
-
notifyChangeListeners
protected void notifyChangeListeners()
Sends an event to all change listeners.
-
-