本文整理汇总了Java中org.netbeans.jemmy.operators.JEditorPaneOperator.pushKey方法的典型用法代码示例。如果您正苦于以下问题:Java JEditorPaneOperator.pushKey方法的具体用法?Java JEditorPaneOperator.pushKey怎么用?Java JEditorPaneOperator.pushKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.jemmy.operators.JEditorPaneOperator
的用法示例。
在下文中一共展示了JEditorPaneOperator.pushKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cutCopyViaStrokes
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
protected void cutCopyViaStrokes(JEditorPaneOperator txtOper, int key, int mod){
Transferable oldClipValue = txtOper.getToolkit().getSystemClipboard().getContents(txtOper);
String oldVal = getClipBoardContent(oldClipValue);
log("");
log("oldClipValue:"+oldVal);
txtOper.requestFocus();
txtOper.pushKey(key, mod);
// give max WAIT_MAX_MILIS_FOR_CLIPBOARD milis for clipboard to change
boolean success = waitMaxMilisForValue(WAIT_MAX_MILIS_FOR_CLIPBOARD, getClipboardResolver(txtOper, key, mod, oldVal), Boolean.FALSE);
if (success == false){
// give it one more chance. maybe selection was not ready at the time of
// copying
log("!!!! ONCE AGAIN");
txtOper.pushKey(key, mod);
// give max WAIT_MAX_MILIS_FOR_CLIPBOARD milis for clipboard to change
waitMaxMilisForValue(WAIT_MAX_MILIS_FOR_CLIPBOARD, getClipboardResolver(txtOper, key, mod, oldVal), Boolean.FALSE);
}
}
示例2: setEditorState
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
public void setEditorState(EditorOperator editor, String goldenFile, int caretLine, int caretColumn) {
JEditorPaneOperator txtOper = editor.txtEditorPane();
StringBuilder fileData = new StringBuilder(1000);
try {
BufferedReader reader = new BufferedReader(new FileReader(getGoldenFile(goldenFile)));
char[] buf = new char[1024];
int numRead;
while ((numRead = reader.read(buf)) != -1) {
fileData.append(buf, 0, numRead);
}
} catch (IOException ex) {
fail(ex);
}
txtOper.removeAll();
txtOper.setText(fileData.toString());
txtOper.pushKey(KeyEvent.VK_BACK_SPACE); // replace the last NL...
editor.setCaretPosition(caretLine, caretColumn);
}
示例3: testLBrace
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
public void testLBrace(){
openDefaultProject();
openDefaultSampleFile();
try {
EditorOperator editor = getDefaultSampleEditorOperator();
// 1. move to adequate place
editor.setCaretPosition(6, 20);
// 2. hit Enter
JEditorPaneOperator txtOper = editor.txtEditorPane();
txtOper.pushKey(KeyEvent.VK_ENTER);
// Compare document content to golden file
compareReferenceFiles(txtOper.getDocument());
} finally {
closeFileWithDiscard();
}
}
示例4: testSpace
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
/** Testing problem of issue #68992 */
public void testSpace(){
openDefaultProject();
openDefaultSampleFile();
try {
EditorOperator editor = getDefaultSampleEditorOperator();
// 1. move to adequate place
editor.setCaretPosition(6, 22);
// 2. hit Enter
JEditorPaneOperator txtOper = editor.txtEditorPane();
txtOper.pushKey(KeyEvent.VK_ENTER);
// Compare document content to golden file
compareReferenceFiles(txtOper.getDocument());
} finally {
closeFileWithDiscard();
}
}
示例5: testComment
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
public void testComment(){
openDefaultProject();
openDefaultSampleFile();
try {
EditorOperator editor = getDefaultSampleEditorOperator();
// 1. move to adequate place
editor.setCaretPosition(6, 36);
// 2. hit Enter
JEditorPaneOperator txtOper = editor.txtEditorPane();
txtOper.pushKey(KeyEvent.VK_ENTER);
// Compare document content to golden file
compareReferenceFiles(txtOper.getDocument());
} finally {
closeFileWithDiscard();
}
}
示例6: cutCopyViaStrokes
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
protected void cutCopyViaStrokes(JEditorPaneOperator txtOper, int key, int mod){
Transferable oldClipValue = txtOper.getToolkit().getSystemClipboard().getContents(txtOper);
log("");
log("oldClipValue:"+oldClipValue);
txtOper.pushKey(key, mod);
// give max WAIT_MAX_MILIS_FOR_CLIPBOARD milis for clipboard to change
boolean success = waitMaxMilisForValue(WAIT_MAX_MILIS_FOR_CLIPBOARD, getClipboardResolver(txtOper, oldClipValue), Boolean.FALSE);
if (success == false){
// give it one more chance. maybe selection was not ready at the time of
// copying
log("!!!! ONCE AGAIN");
txtOper.pushKey(key, mod);
// give max WAIT_MAX_MILIS_FOR_CLIPBOARD milis for clipboard to change
waitMaxMilisForValue(WAIT_MAX_MILIS_FOR_CLIPBOARD, getClipboardResolver(txtOper, oldClipValue), Boolean.FALSE);
}
}
示例7: collapseFoldAtCaretPosition
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
protected void collapseFoldAtCaretPosition(EditorOperator editor, int line, int column){
System.out.println("Collapsing");
// 1. move to adequate place
editor.setCaretPosition(line, column);
// 2. hit CTRL -
JEditorPaneOperator txtOper = editor.txtEditorPane();
txtOper.pushKey(KeyEvent.VK_SUBTRACT, KeyEvent.CTRL_DOWN_MASK);
JTextComponentOperator text = new JTextComponentOperator(editor);
JTextComponent target = (JTextComponent)text.getSource();
// give max 500 milis to fold to collapse
waitMaxMilisForValue(500, getResolver(target), Boolean.TRUE);
}
示例8: testSmartEnter
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
public void testSmartEnter(){
openDefaultProject();
openDefaultSampleFile();
try {
EditorOperator editor = getDefaultSampleEditorOperator();
// 1. move to adequate place
editor.setCaretPosition(5, 28);
// 2. hit Enter
JEditorPaneOperator txtOper = editor.txtEditorPane();
txtOper.pushKey(KeyEvent.VK_ENTER);
// Compare document content to golden file
compareReferenceFiles(txtOper.getDocument());
} finally {
closeFileWithDiscard();
}
}
示例9: testBookmarkMove
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
public void testBookmarkMove() {
int bookmarkLine = 14;
int lineToDelete = 12;
openDefaultProject();
Node node = new Node(new SourcePackagesNode(getDefaultProjectName()),
"org.netbeans.test.bookmarks.BookmarksPersistenceTest|testBookmarkMove.java"); // NOI18N
new OpenAction().perform(node);
EditorOperator editorOper = new EditorOperator("testBookmarkMove.java");
try {
JEditorPaneOperator txtOper = editorOper.txtEditorPane();
Document doc = txtOper.getDocument();
editorOper.setCaretPosition(getLineOffset(doc, bookmarkLine));
txtOper.pushKey(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
editorOper.setCaretPosition(getLineOffset(doc, lineToDelete));
txtOper.pushKey(KeyEvent.VK_E, KeyEvent.CTRL_MASK);
doc = txtOper.getDocument();
BookmarkList bml = BookmarkList.get(doc);
checkBookmarksAtLines(bml, new int[]{bookmarkLine - 1});
} finally {
editorOper.closeDiscardAll();
}
}
示例10: getClipboardResolver
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
protected ValueResolver getClipboardResolver(final JEditorPaneOperator txtOper, final int key, final int mod, final String oldVal){
ValueResolver clipboardValueResolver = new ValueResolver(){
public Object getValue(){
txtOper.pushKey(key, mod);
Transferable newClipValue = txtOper.getToolkit().getSystemClipboard().getContents(txtOper);
String newVal = getClipBoardContent(newClipValue);
log("newClipValue:"+newVal);
return (newVal.equals(oldVal)) ? Boolean.TRUE : Boolean.FALSE;
}
};
return clipboardValueResolver;
}
示例11: expandFoldAtCaretPosition
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
protected void expandFoldAtCaretPosition(EditorOperator editor, int line, int column){
// 1. move to adequate place
editor.setCaretPosition(line, column);
// 2. hit CTRL +
JEditorPaneOperator txtOper = editor.txtEditorPane();
txtOper.pushKey(KeyEvent.VK_ADD, KeyEvent.CTRL_DOWN_MASK);
JTextComponentOperator text = new JTextComponentOperator(editor);
JTextComponent target = (JTextComponent)text.getSource();
// give max 500 milis to fold to expand
waitMaxMilisForValue(500, getResolver(target), Boolean.FALSE);
}
示例12: collapseAllFolds
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
protected void collapseAllFolds(EditorOperator editor){
// hit CTRL Shift -
JEditorPaneOperator txtOper = editor.txtEditorPane();
txtOper.pushKey(KeyEvent.VK_SUBTRACT, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
// wait a while
try {
Thread.currentThread().sleep(COLLAPSE_EXPAND_DELAY);
} catch (InterruptedException ex) {
}
}
示例13: expandAllFolds
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
protected void expandAllFolds(EditorOperator editor){
// hit CTRL Shift +
JEditorPaneOperator txtOper = editor.txtEditorPane();
txtOper.pushKey(KeyEvent.VK_ADD, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
// wait a while
try {
Thread.currentThread().sleep(COLLAPSE_EXPAND_DELAY);
} catch (InterruptedException ex) {
}
}
示例14: testNextBookmark
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
public void testNextBookmark() {
int[] bookmarkLines = new int[]{9, 10, 11};
int[] expectedLines = new int[]{9, 10, 11, 9};
openDefaultProject();
Node node = new Node(new SourcePackagesNode(getDefaultProjectName()),
"org.netbeans.test.bookmarks.BookmarksPersistenceTest|testNextBookmark.java"); // NOI18N
new OpenAction().perform(node);
EditorOperator editorOper = new EditorOperator("testNextBookmark.java");
try {
JEditorPaneOperator txtOper = editorOper.txtEditorPane();
Document doc = txtOper.getDocument();
for (int i = 0; i < bookmarkLines.length; i++) {
editorOper.setCaretPosition(bookmarkLines[i] + 1, 1);
txtOper.pushKey(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
}
editorOper.setCaretPosition(getLineOffset(doc, 2));
for (int i = 0; i < expectedLines.length; i++) {
txtOper.pushKey(KeyEvent.VK_PERIOD, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
int actLine = getLineIndex(doc, txtOper.getCaretPosition());
int j = expectedLines[i];
assertEquals("Caret is at bad location", j, actLine);
}
} finally {
editorOper.closeDiscardAll();
}
}
示例15: testPreviousBookmark
import org.netbeans.jemmy.operators.JEditorPaneOperator; //导入方法依赖的package包/类
public void testPreviousBookmark() {
int[] bookmarkLines = new int[]{9, 10, 11};
int[] expectedLines = new int[]{11, 10, 9, 11};
openDefaultProject();
Node node = new Node(new SourcePackagesNode(getDefaultProjectName()),
"org.netbeans.test.bookmarks.BookmarksPersistenceTest|testPreviousBookmark.java"); // NOI18N
new OpenAction().perform(node);
EditorOperator editorOper = new EditorOperator("testPreviousBookmark.java");
try {
JEditorPaneOperator txtOper = editorOper.txtEditorPane();
Document doc = txtOper.getDocument();
for (int i = 0; i < bookmarkLines.length; i++) {
editorOper.setCaretPosition(bookmarkLines[i] + 1, 1);
txtOper.pushKey(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
}
editorOper.setCaretPosition(getLineOffset(doc, 14));
for (int i = 0; i < expectedLines.length; i++) {
txtOper.pushKey(KeyEvent.VK_COMMA, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
int j = expectedLines[i];
int actLine = getLineIndex(doc, txtOper.getCaretPosition());
assertEquals("Caret is at bad location", j, actLine);
}
} finally {
editorOper.closeDiscardAll();
}
}