public class EditorOperator extends TopComponentOperator
EditorOperator.txtEditorPane()
. For example, call
txtEditorPane().changeCaretPosition(int)
instead of
EditorOperator.setCaretPosition(int)
. Usage:
EditorOperator eo = new EditorOperator(filename); eo.setCaretPositionToLine(10); eo.insert("// My new comment\n"); eo.select("// My new comment"); eo.deleteLine(10); eo.getToolbarButton("Toggle Bookmark").push(); // discard changes and close eo.close(false); // save changes and close eo.close(true); // try to close all opened documents (confirmation dialog may appear) eo.closeAllDocuments(); // close all opened documents and discard all changes eo.closeDiscardAll();
Modifier and Type | Class and Description |
---|---|
static class |
EditorOperator.EditorSubchooser
SubChooser to determine Editor TopComponent
Used in findTopComponent method.
|
org.netbeans.jemmy.operators.JComponentOperator.JComponentByTipFinder, org.netbeans.jemmy.operators.JComponentOperator.JComponentFinder
org.netbeans.jemmy.operators.ContainerOperator.ContainerFinder
org.netbeans.jemmy.operators.Operator.ComponentVisualizer, org.netbeans.jemmy.operators.Operator.DefaultPathParser, org.netbeans.jemmy.operators.Operator.DefaultStringComparator, org.netbeans.jemmy.operators.Operator.Finder, org.netbeans.jemmy.operators.Operator.MapAction, org.netbeans.jemmy.operators.Operator.MapBooleanAction, org.netbeans.jemmy.operators.Operator.MapByteAction, org.netbeans.jemmy.operators.Operator.MapCharacterAction, org.netbeans.jemmy.operators.Operator.MapDoubleAction, org.netbeans.jemmy.operators.Operator.MapFloatAction, org.netbeans.jemmy.operators.Operator.MapIntegerAction, org.netbeans.jemmy.operators.Operator.MapLongAction, org.netbeans.jemmy.operators.Operator.MapVoidAction, org.netbeans.jemmy.operators.Operator.NoBlockingAction, org.netbeans.jemmy.operators.Operator.PathParser, org.netbeans.jemmy.operators.Operator.StringComparator
A11Y_DATA, A11Y_DESCRIPTION_DPROP, A11Y_NAME_DPROP, TOOLTIP_TEXT_DPROP
HEIGHT_DPROP, IS_SHOWING_DPROP, IS_VISIBLE_DPROP, NAME_DPROP, WIDTH_DPROP, X_DPROP, Y_DPROP
CLASS_DPROP, TO_STRING_DPROP
Constructor and Description |
---|
EditorOperator(org.netbeans.jemmy.operators.ContainerOperator contOper,
String filename)
Waits for first open editor with given name in specified container.
|
EditorOperator(org.netbeans.jemmy.operators.ContainerOperator contOper,
String filename,
int index)
Waits for index-th opened editor with given name in specified container.
|
EditorOperator(JComponent editorComponent)
Creates new operator instance for given component.
|
EditorOperator(String filename)
Waits for the first opened editor with given name.
|
EditorOperator(String filename,
int index)
Waits for index-th opened editor with given name.
|
Modifier and Type | Method and Description |
---|---|
void |
clickForPopup()
Click for popup on JEditorPane component.
|
void |
close(boolean save)
Closes this editor by IDE API call and depending on given flag
it saves or discards changes.
|
static void |
closeDiscardAll()
Closes all opened documents and discards all changes by IDE API calls.
|
void |
collapseFold()
Collapses fold at cursor position using CTRL+'-'.
|
void |
collapseFold(int lineNumber)
Collapses fold at specified line using CTRL+'-'.
|
boolean |
contains(String text)
Checks if editor window contains text specified as parameter text.
|
void |
delete(int length)
Deletes given number of characters from current caret possition.
|
void |
delete(int offset,
int length)
Deletes given number of characters from specified possition.
|
void |
delete(int lineNumber,
int column1,
int column2)
Deletes characters between column1 and column2 (both are included)
on the specified line.
|
void |
deleteLine(int line)
Delete specified line.
|
void |
expandFold()
Expands fold at specified line using CTRL+'+'.
|
void |
expandFold(int lineNumber)
Expands fold at specified line using CTRL+'+'.
|
Object[] |
getAnnotations()
Gets all annotations for current editor (Document).
|
Object[] |
getAnnotations(int lineNumber)
Gets an array of annotations attached to given line.
|
static String |
getAnnotationShortDescription(Object annotation)
Returns a short description of annotation.
|
static String |
getAnnotationType(Object annotation)
Returns a string uniquely identifying annotation.
|
int |
getLineNumber()
Returns current line number.
|
String |
getText()
Gets text from the currently opened Editor window.
|
String |
getText(int lineNumber)
Gets text from specified line.
|
org.netbeans.jemmy.operators.AbstractButtonOperator |
getToolbarButton(int index)
Return AbstractButtonOperator representing index-th toolbar button within
the Source Editor.
|
org.netbeans.jemmy.operators.AbstractButtonOperator |
getToolbarButton(String buttonTooltip)
Return AbstractButtonOperator representing a toolbar button found by given
tooltip within the Source Editor.
|
void |
insert(String text)
Inserts text to current position.
|
void |
insert(String text,
int lineNumber,
int column)
Inserts text to position specified by line number and column.
|
boolean |
isCollapsed()
Returns true if fold at cursor position is collapsed, false if it is
expanded.
|
boolean |
isCollapsed(int lineNumber)
Returns true if fold at specified line is collapsed, false if it is
expanded.
|
org.netbeans.jemmy.operators.JLabelOperator |
lblInputMode()
Returns operator of label showing current input mode (INS/OVR -
insert/overwrite).
|
org.netbeans.jemmy.operators.JLabelOperator |
lblRowColumn()
Returns operator of label showing current row and column at the left
corner of the Source Editor window.
|
org.netbeans.jemmy.operators.JLabelOperator |
lblStatusBar()
Returns operator of status bar at the bottom of the Source Editor.
|
void |
pushDownArrowKey()
Pushes Down key (KeyEvent.VK_DOWN)
|
void |
pushEndKey()
Pushes End key (KeyEvent.VK_END)
|
void |
pushHomeKey()
Pushes Home key (KeyEvent.VK_HOME)
|
void |
pushKey(int keyCode)
Pushes key of requested key code.
|
void |
pushKey(int keyCode,
int modifiers)
Pushes key of requested key code.
|
void |
pushTabKey()
Pushes Tab key (KeyEvent.VK_TAB)
|
void |
pushUpArrowKey()
Pushes Up key (KeyEvent.VK_UP)
|
void |
replace(String oldText,
String newText)
Replaces first occurrence of oldText by newText.
|
void |
replace(String oldText,
String newText,
int index)
Replaced index-th occurrence of oldText by newText.
|
void |
save()
Saves content of this Editor by API.
|
void |
select(int lineNumber)
Selects whole line specified by its number.
|
void |
select(int line1,
int line2)
Selects text between line1 and line2 (both are included).
|
void |
select(int lineNumber,
int column1,
int column2)
Selects text in specified line on position defined by column1
and column2 (both are included).
|
void |
select(String text)
Selects first occurrence of given text.
|
void |
select(String text,
int index)
Selects index-th occurrence of given text.
|
void |
setCaretPosition(int position)
Sets caret to desired position.
|
void |
setCaretPosition(int lineNumber,
int column)
Sets caret position to specified line and column
|
void |
setCaretPosition(String text,
boolean before)
Sets caret position before or after first occurrence of given string.
|
void |
setCaretPosition(String text,
int index,
boolean before)
Sets caret position before or after index-th occurrence of given string.
|
void |
setCaretPositionRelative(int relativeMove)
Sets caret position relatively to current position.
|
void |
setCaretPositionToEndOfLine(int lineNumber)
Sets caret position to the end of specified line.
|
void |
setCaretPositionToLine(int lineNumber)
Sets caret position to the beginning of specified line.
|
org.netbeans.jemmy.operators.JEditorPaneOperator |
txtEditorPane()
Returns operator of currently shown editor pane.
|
void |
typeKey(char keyChar)
Types one char.
|
void |
typeKey(char keyChar,
int modifiers)
Types one char.
|
void |
typeKey(int keyCode,
char keyChar,
int modifiers)
Types one char.
|
void |
verify()
Performs verification by accessing all sub-components
|
void |
waitCollapsed()
Waits for fold at cursor position is collapsed.
|
void |
waitExpanded()
Waits for fold at cursor position is expanded.
|
void |
waitFolding()
Waits for code folding initialization.
|
void |
waitModified(boolean modified)
Waits for given modified state of edited source.
|
attachTo, attachTo, cloneDocument, close, closeAllDocuments, closeDiscard, closeWindow, findParentTopComponent, findTabbedAdapter, findTabDisplayer, findTopComponent, findTopComponent, isModified, isOpened, makeComponentVisible, maximize, pushMenuOnTab, restore, setUnmodified, waitClosed, waitTopComponent, waitTopComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, createToolTip, findJComponent, findJComponent, findJComponent, findJComponent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getAutoscrolls, getBorder, getCenterXForClick, getCenterYForClick, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDump, getInsets, getNextFocusableComponent, getOutput, getRegisteredKeyStrokes, getRootPane, getTimeouts, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVisibleRect, getWindowContainerOperator, grabFocus, isFocusCycleRoot, isManagingFocus, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, requestDefaultFocus, resetKeyboardActions, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setOutput, setPreferredSize, setRequestFocusEnabled, setTimeouts, setToolTipText, showToolTip, unregisterKeyboardAction, updateUI, waitJComponent, waitJComponent, waitJComponent, waitJComponent, waitToolTip
add, add, add, add, add, addContainerListener, createSubOperator, createSubOperator, findComponentAt, findComponentAt, findContainer, findContainer, findContainer, findContainer, findContainerUnder, findContainerUnder, findSubComponent, findSubComponent, getComponent, getComponentCount, getComponents, getInsets, getLayout, isAncestorOf, paintComponents, printComponents, remove, remove, removeAll, removeContainerListener, setLayout, waitContainer, waitContainer, waitContainer, waitContainer, waitSubComponent, waitSubComponent
activateWindow, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, checkImage, checkImage, clickForPopup, clickForPopup, clickForPopup, clickMouse, clickMouse, clickMouse, clickMouse, clickMouse, clickMouse, clickMouse, contains, contains, copyEnvironment, createImage, createImage, dispatchEvent, doLayout, dragMouse, dragMouse, dragMouse, dragNDrop, dragNDrop, dragNDrop, enableInputMethods, enterMouse, exitMouse, findComponent, findComponent, findComponents, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getCenterX, getCenterY, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getContainer, getContainers, getCursor, getDropTarget, getEventDispatcher, getFocus, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, getSize, getSize, getSource, getToolkit, getTreeLock, getWidth, getWindow, getX, getY, hasFocus, imageUpdate, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, list, list, list, list, list, moveMouse, paint, paintAll, prepareImage, prepareImage, pressKey, pressKey, pressMouse, pressMouse, print, printAll, releaseKey, releaseKey, releaseMouse, releaseMouse, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, transferFocus, typedKey, update, validate, waitComponent, waitComponent, waitComponent, waitComponent, waitComponentEnabled, waitComponentShowing, waitComponentVisible, waitHasFocus, wtComponentEnabled
addOperatorPackage, addToDump, addToDump, createOperator, getCharBindingMap, getCharKey, getCharModifiers, getCharsKeys, getCharsKeys, getCharsModifiers, getCharsModifiers, getComparator, getDefaultComponentVisualizer, getDefaultMouseButton, getDefaultPathParser, getDefaultStringComparator, getDefaultVerification, getEnvironmentOperator, getParentPath, getParentPath, getPathParser, getPopupMouseButton, getProperties, getQueueTool, getVerification, getVisualizer, isCaptionEqual, isCaptionEqual, isCaptionEqual, lockQueue, parseString, parseString, printDump, produceNoBlocking, produceNoBlocking, produceTimeRestricted, produceTimeRestricted, runMapping, runMapping, runMapping, runMapping, runMapping, runMapping, runMapping, runMapping, runMapping, setCharBindingMap, setComparator, setDefaultComponentVisualizer, setDefaultPathParser, setDefaultStringComparator, setDefaultVerification, setPathParser, setProperties, setVerification, setVisualizer, toStringSource, unlockAndThrow, unlockQueue, waitState
public EditorOperator(String filename)
filename
- name of file showed in the editor (it used to be label of tab)public EditorOperator(String filename, int index)
filename
- name of file showed in the editor (it used to be label of tab)index
- index of editor to be findpublic EditorOperator(org.netbeans.jemmy.operators.ContainerOperator contOper, String filename)
contOper
- container where to searchfilename
- name of file showed in the editor (it used to be label of tab)public EditorOperator(JComponent editorComponent)
editorComponent
- instance of editorpublic EditorOperator(org.netbeans.jemmy.operators.ContainerOperator contOper, String filename, int index)
contOper
- container where to searchfilename
- name of file showed in the editor (it used to be label of tab)index
- index of editor to be findpublic static void closeDiscardAll()
public void close(boolean save)
save
- true - save changes, false - discard changespublic org.netbeans.jemmy.operators.JEditorPaneOperator txtEditorPane()
public org.netbeans.jemmy.operators.JLabelOperator lblRowColumn()
public org.netbeans.jemmy.operators.JLabelOperator lblInputMode()
public org.netbeans.jemmy.operators.JLabelOperator lblStatusBar()
public String getText()
public String getText(int lineNumber)
lineNumber
- number of line (beggining from 1)public boolean contains(String text)
text
- text to compare topublic void select(int lineNumber)
lineNumber
- number of line (beggining from 1)public void select(int line1, int line2)
line1
- number of line where to begin (beggining from 1)line2
- number of line where to finish (beggining from 1)public void select(int lineNumber, int column1, int column2)
lineNumber
- number of line (beggining from 1)column1
- column position where selection starts (beggining from 1)column2
- column position where selection ends (beggining from 1)public void select(String text, int index)
text
- text to be selectedindex
- index of text occurrence (first occurrence has index 0)EditorOperator.select(String)
public void select(String text)
text
- text to be selectedEditorOperator.select(String, int)
public void replace(String oldText, String newText)
oldText
- text to be replacednewText
- text to write insteadpublic void replace(String oldText, String newText, int index)
oldText
- text to be replacednewText
- text to write insteadindex
- index of oldText occurrence (first occurrence has index 0)public void insert(String text)
text
- a string to be insertedpublic void insert(String text, int lineNumber, int column)
text
- a string to be insertedlineNumber
- number of line (beggining from 1)column
- column position (beggining from 1)public void delete(int offset, int length)
offset
- position inside document (0 means the beginning)length
- number of characters to be deletedpublic void delete(int length)
length
- number of characters to be deletedpublic void deleteLine(int line)
line
- number of line (beggining from 1)public void delete(int lineNumber, int column1, int column2)
lineNumber
- number of line (beggining from 1)column1
- column position where to start deleting (beggining from 1)column2
- column position where to stop deleting (beggining from 1)public int getLineNumber()
public void typeKey(char keyChar)
typeKey
in class org.netbeans.jemmy.operators.ComponentOperator
keyChar
- key charpublic void typeKey(char keyChar, int modifiers)
typeKey
in class org.netbeans.jemmy.operators.ComponentOperator
keyChar
- key charmodifiers
- modifierspublic void typeKey(int keyCode, char keyChar, int modifiers)
typeKey
in class org.netbeans.jemmy.operators.ComponentOperator
keyCode
- key codekeyChar
- key charmodifiers
- modifierspublic void pushKey(int keyCode, int modifiers)
pushKey
in class org.netbeans.jemmy.operators.ComponentOperator
keyCode
- key codemodifiers
- modifierspublic void pushKey(int keyCode)
pushKey
in class org.netbeans.jemmy.operators.ComponentOperator
keyCode
- key codepublic void pushHomeKey()
public void pushEndKey()
public void pushTabKey()
public void pushDownArrowKey()
public void pushUpArrowKey()
public void setCaretPositionRelative(int relativeMove)
relativeMove
- count of charaters to move caretpublic void setCaretPositionToLine(int lineNumber)
lineNumber
- number of line (beggining from 1)public void setCaretPositionToEndOfLine(int lineNumber)
lineNumber
- number of line (beggining from 1)public void setCaretPosition(int lineNumber, int column)
lineNumber
- line number where to set caretcolumn
- column where to set caret (1 means beginning of the row)public void setCaretPosition(int position)
position
- a position to set caret to (number of characters from
the beggining of the file - 0 means beginning of the file).public void setCaretPosition(String text, int index, boolean before)
text
- text to be searchedindex
- index of text occurrence (first occurrence has index 0)before
- if true put caret before text, otherwise after.public void setCaretPosition(String text, boolean before)
text
- text to be searchedbefore
- if true put caret before text, otherwise after.public Object[] getAnnotations(int lineNumber)
lineNumber
- number of line (beggining from 1)EditorOperator.getAnnotationShortDescription(java.lang.Object)
,
EditorOperator.getAnnotationType(java.lang.Object)
public Object[] getAnnotations()
EditorOperator.getAnnotationShortDescription(java.lang.Object)
,
EditorOperator.getAnnotationType(java.lang.Object)
public static String getAnnotationType(Object annotation)
annotation
- instance of org.openide.text.AnnotationEditorOperator.getAnnotations()
,
EditorOperator.getAnnotations(int)
public static String getAnnotationShortDescription(Object annotation)
annotation
- instance of org.openide.text.Annotationpublic org.netbeans.jemmy.operators.AbstractButtonOperator getToolbarButton(String buttonTooltip)
buttonTooltip
- tooltip of toolbar buttonpublic org.netbeans.jemmy.operators.AbstractButtonOperator getToolbarButton(int index)
index
- index of toolbar button to findpublic void waitFolding()
public void waitCollapsed()
public void waitExpanded()
public void collapseFold()
public void collapseFold(int lineNumber)
lineNumber
- number of line (starts at 1)public void expandFold()
public void expandFold(int lineNumber)
lineNumber
- number of line (starts at 1)public boolean isCollapsed()
public boolean isCollapsed(int lineNumber)
lineNumber
- number of line (starts at 1)public void waitModified(boolean modified)
modified
- boolean true waits for file state change to modified, false for change to
unmodified (saved).
Throws TimeoutExpiredException when EditorOperator.WaitModifiedTimeout expires.public void save()
save
in class TopComponentOperator
public void clickForPopup()
clickForPopup
in class org.netbeans.jemmy.operators.ComponentOperator
public void verify()