public class TextEditor extends JFrame implements ActionListener, ChangeListener, CloseConfirmable, DocumentListener
Based on the powerful SciJava scripting framework and the RSyntaxTextArea library, this text editor lets users script their way to success. Thanks to the Java backend for SciJava scripting, it is even possible to develop Java plugins in the editor.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
TextEditor.AcceleratorTriplet |
class |
TextEditor.Executer
Generic Thread that keeps a starting time stamp, sets the priority to
normal and starts itself.
|
class |
TextEditor.FindClassSourceAndJavadoc |
JFrame.AccessibleJFrameFrame.AccessibleAWTFrameWindow.AccessibleAWTWindow, Window.TypeContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
static String |
AUTO_IMPORT_PREFS |
static ArrayList<Context> |
contexts |
static int |
DEFAULT_WINDOW_HEIGHT |
static int |
DEFAULT_WINDOW_WIDTH |
protected List<TextEditor.AcceleratorTriplet> |
defaultAccelerators |
static ArrayList<TextEditor> |
instances |
static String |
LAST_LANGUAGE |
static String |
MAIN_DIV_LOCATION |
static String |
TAB_DIV_LOCATION |
static String |
TAB_DIV_ORIENTATION |
static String |
WINDOW_HEIGHT |
static String |
WINDOW_WIDTH |
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabledCROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSORBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTDISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSEABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
TextEditor(Context context) |
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(ActionEvent ae) |
void |
addAccelerator(JMenuItem component,
int key,
int modifiers) |
void |
addAccelerator(JMenuItem component,
int key,
int modifiers,
boolean record) |
void |
addAccelerator(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea,
JMenuItem component,
int key,
int modifiers) |
void |
addDefaultAccelerators(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea) |
void |
addImport(String className) |
static void |
addTemplatePath(String path)
Adds a script template path that will be scanned by future TextEditor
instances.
|
JMenuItem |
addToMenu(JMenu menu,
String menuEntry,
int key,
int modifiers) |
void |
changedUpdate(DocumentEvent e) |
void |
checkForOutsideChanges()
Check whether the file was edited outside of this
EditorPane and
ask the user whether to reload. |
void |
chooseTaskToKill()
Query the list of running scripts and provide a dialog to choose one and
kill it.
|
void |
compile() |
boolean |
confirmClose() |
void |
createNewDocument() |
void |
createNewDocument(String title,
String text) |
void |
createNewFromTemplate(File file,
File templateFile)
Open a new editor to edit the given file, with a templateFile if the file
does not exist yet
|
void |
extractSourceJar() |
void |
extractSourceJar(File file) |
boolean |
fileChanged() |
void |
findOrReplace(boolean doReplace) |
ScriptLanguage |
getCurrentLanguage() |
EditorPane |
getEditorPane()
Return the
EditorPane of the currently selected
TextEditorTab. |
EditorPane |
getEditorPane(int index) |
ErrorHandler |
getErrorHandler() |
JTextArea |
getErrorScreen() |
List<TextEditor.Executer> |
getExecutingTasks()
Returns a list of currently executing tasks
|
File |
getFile() |
File |
getFileForBasename(String baseName) |
PlatformService |
getPlatformService() |
String |
getSelectedClassNameOrAsk() |
String |
getSelectedTextOrAsk(String label) |
TextEditorTab |
getTab()
Get the currently selected tab.
|
TextEditorTab |
getTab(int index)
Get tab at provided index.
|
org.fife.ui.rsyntaxtextarea.RSyntaxTextArea |
getTextArea() |
void |
gotoLine() |
void |
gotoLine(int line) |
void |
handleException(Throwable e) |
static void |
handleException(Throwable e,
JTextArea textArea) |
protected boolean |
handleTabsMenu(Object source) |
boolean |
handleUnsavedChanges() |
boolean |
handleUnsavedChanges(boolean beforeCompiling) |
void |
insertUpdate(DocumentEvent e) |
static boolean |
isBinary(File file) |
void |
kill(TextEditor.Executer executer) |
void |
listBookmarks() |
void |
loadPreferences()
Loads the Script Editor layout from persisted storage.
|
void |
loadTemplate(String url)
Loads a template file from the given resource
|
void |
loadTemplate(URL url) |
void |
loadTemplate(URL url,
ScriptLanguage language) |
LogService |
log() |
boolean |
makeJar(boolean includeSources) |
void |
makeJar(File file,
boolean includeSources) |
void |
markCompileEnd() |
void |
markCompileStart() |
void |
markCompileStart(boolean with_timestamp) |
TextEditorTab |
newTab(String content,
String language)
Open a new tab with some content; the languageExtension is like ".java",
".py", etc.
|
boolean |
nextError(boolean forward) |
TextEditorTab |
open(File file) |
void |
openClassOrPackageHelp(String text) |
void |
openHelp(String className) |
void |
openHelp(String className,
boolean withFrames) |
boolean |
reload() |
boolean |
reload(String message) |
void |
removeUpdate(DocumentEvent e) |
void |
runBatch()
Run current script with the batch processor
|
void |
runScript() |
void |
runText()
Run the text in the textArea without compiling it, only if it's not java.
|
void |
runText(boolean selectionOnly) |
boolean |
save() |
boolean |
saveAs() |
void |
saveAs(String path) |
boolean |
saveAs(String path,
boolean askBeforeReplacing) |
void |
saveWindowSizeToPrefs()
Saves the Script Editor layout to persisted storage.
|
void |
setEditorPaneFileName(File file) |
void |
setEditorPaneFileName(String baseName) |
void |
setErrorHandler(ErrorHandler errorHandler) |
void |
setErrorScreen(JTextArea errorScreen) |
void |
setFontSize(float size) |
void |
setIncremental(boolean incremental) |
void |
setTitle(String title) |
void |
stateChanged(ChangeEvent e) |
void |
switchTo(File file) |
void |
switchTo(File file,
int lineNumber) |
void |
switchTo(int index) |
void |
switchTo(String path,
int lineNumber) |
void |
toggleBookmark() |
void |
updateTabAndFontSize(boolean setByLanguage) |
boolean |
write(File file) |
void |
write(String message)
Write a message to the output screen
|
void |
writeError(String message) |
int |
zapGremlins()
Removes invalid characters, shows a dialog.
|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateaddNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setUndecoratedaddPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFrontadd, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetFont, postEventpublic static final String AUTO_IMPORT_PREFS
public static final String WINDOW_HEIGHT
public static final String WINDOW_WIDTH
public static final int DEFAULT_WINDOW_WIDTH
public static final int DEFAULT_WINDOW_HEIGHT
public static final String MAIN_DIV_LOCATION
public static final String TAB_DIV_LOCATION
public static final String TAB_DIV_ORIENTATION
public static final String LAST_LANGUAGE
public static final ArrayList<TextEditor> instances
protected List<TextEditor.AcceleratorTriplet> defaultAccelerators
public TextEditor(Context context)
public LogService log()
public PlatformService getPlatformService()
public JTextArea getErrorScreen()
public void setErrorScreen(JTextArea errorScreen)
public ErrorHandler getErrorHandler()
public void setErrorHandler(ErrorHandler errorHandler)
public void checkForOutsideChanges()
EditorPane and
ask the user whether to reload.public static void addTemplatePath(String path)
path - Resource path to scan for scripts.public void loadPreferences()
saveWindowSizeToPrefs()public void saveWindowSizeToPrefs()
Separated from savePreferences because we always want to save the window size when it's resized, however, we don't want to automatically save the font, tab size, etc. without the user pressing "Save Preferences"
loadPreferences()public final org.fife.ui.rsyntaxtextarea.RSyntaxTextArea getTextArea()
public TextEditorTab getTab()
public TextEditorTab getTab(int index)
index - the index of the tab.TextEditorTab at given index or null.public EditorPane getEditorPane()
EditorPane of the currently selected
TextEditorTab.EditorPane. Never null.public ScriptLanguage getCurrentLanguage()
ScriptLanguage used in the current EditorPane.public void addAccelerator(JMenuItem component, int key, int modifiers)
public void addAccelerator(JMenuItem component, int key, int modifiers, boolean record)
public void addAccelerator(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea,
JMenuItem component,
int key,
int modifiers)
public void addDefaultAccelerators(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
public void loadTemplate(String url)
url - The resource to load.public void loadTemplate(URL url)
public void loadTemplate(URL url, ScriptLanguage language)
public void createNewDocument()
public void createNewFromTemplate(File file, File templateFile)
public boolean fileChanged()
public boolean handleUnsavedChanges()
public boolean handleUnsavedChanges(boolean beforeCompiling)
public void actionPerformed(ActionEvent ae)
actionPerformed in interface ActionListenerprotected boolean handleTabsMenu(Object source)
public void stateChanged(ChangeEvent e)
stateChanged in interface ChangeListenerpublic EditorPane getEditorPane(int index)
public void findOrReplace(boolean doReplace)
public void gotoLine()
public void gotoLine(int line)
throws BadLocationException
BadLocationExceptionpublic void toggleBookmark()
public void listBookmarks()
public boolean reload()
public boolean reload(String message)
public static boolean isBinary(File file)
public TextEditorTab newTab(String content, String language)
public TextEditorTab open(File file)
public boolean saveAs()
public void saveAs(String path)
public boolean saveAs(String path, boolean askBeforeReplacing)
public boolean save()
public boolean write(File file)
public boolean makeJar(boolean includeSources)
public void makeJar(File file, boolean includeSources) throws IOException
IOExceptionpublic void updateTabAndFontSize(boolean setByLanguage)
public void setEditorPaneFileName(String baseName)
public void setEditorPaneFileName(File file)
public List<TextEditor.Executer> getExecutingTasks()
public void kill(TextEditor.Executer executer)
public void chooseTaskToKill()
public void runText()
public void runText(boolean selectionOnly)
public void runBatch()
public void runScript()
public void compile()
public String getSelectedClassNameOrAsk()
public void markCompileStart()
public void markCompileStart(boolean with_timestamp)
public void markCompileEnd()
public boolean nextError(boolean forward)
public void switchTo(String path, int lineNumber) throws IOException
IOExceptionpublic void switchTo(File file, int lineNumber)
public void switchTo(File file)
public void switchTo(int index)
public File getFile()
public void addImport(String className)
public void openHelp(String className)
public void openHelp(String className, boolean withFrames)
className - withFrames - public void openClassOrPackageHelp(String text)
text - Either a classname, or a partial class name, or package name or any part of the fully qualified class name.public void extractSourceJar()
public void extractSourceJar(File file)
public void write(String message)
message - The text to writepublic void writeError(String message)
public void handleException(Throwable e)
public int zapGremlins()
public void setIncremental(boolean incremental)
public boolean confirmClose()
confirmClose in interface CloseConfirmabletrue if the current close operation should continue.public void insertUpdate(DocumentEvent e)
insertUpdate in interface DocumentListenerpublic void removeUpdate(DocumentEvent e)
removeUpdate in interface DocumentListenerpublic void changedUpdate(DocumentEvent e)
changedUpdate in interface DocumentListenerpublic void setFontSize(float size)
Copyright © 2015–2022 SciJava. All rights reserved.