org.openide.actions.UndoAction Java Examples
The following examples show how to use
org.openide.actions.UndoAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicOpenFileTest.java From netbeans with Apache License 2.0 | 5 votes |
private void undo() throws Exception { final UndoAction ua = SystemAction.get(UndoAction.class); assertNotNull("Cannot obtain UndoAction", ua); while (ua.isEnabled()) { SwingUtilities.invokeAndWait(new Runnable() { public void run() { ua.performAction(); } }); } }
Example #2
Source File: BasicOpenFileTest.java From netbeans with Apache License 2.0 | 5 votes |
private void undo() throws Exception { final UndoAction ua = SystemAction.get(UndoAction.class); assertNotNull("Cannot obtain UndoAction", ua); while (ua.isEnabled()) { SwingUtilities.invokeAndWait(new Runnable() { public void run() { ua.performAction(); } }); } }
Example #3
Source File: NbEditorKit.java From netbeans with Apache License 2.0 | 5 votes |
protected @Override void updateActions() { addSystemActionMapping(cutAction, javax.swing.text.DefaultEditorKit.cutAction); addSystemActionMapping(copyAction, javax.swing.text.DefaultEditorKit.copyAction); addSystemActionMapping(pasteAction, org.openide.actions.PasteAction.class); // #69077 - DeleteAction now delegates to deleteNextCharAction addSystemActionMapping(deleteNextCharAction, "delete"); addSystemActionMapping(showPopupMenuAction, org.openide.actions.PopupAction.class); addSystemActionMapping(gotoAction, org.openide.actions.GotoAction.class); addSystemActionMapping(undoAction, org.openide.actions.UndoAction.class); addSystemActionMapping(redoAction, org.openide.actions.RedoAction.class); }
Example #4
Source File: NbEditorKit.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void actionPerformed(ActionEvent evt, JTextComponent target) { Document doc = target.getDocument(); if (doc.getProperty(BaseDocument.UNDO_MANAGER_PROP) != null || doc.getProperty(UndoManager.class) != null ) { // Basic way of undo super.actionPerformed(evt, target); } else { // Deleagte to system undo action // Delegate to system undo action UndoAction ua = (UndoAction)SystemAction.get(UndoAction.class); if (ua != null && ua.isEnabled()) { ua.actionPerformed(evt); } } }
Example #5
Source File: CompletionTest.java From netbeans with Apache License 2.0 | 4 votes |
protected void exec(JEditorPane editor, TestStep step) throws Exception { try { BaseDocument doc = (BaseDocument) editor.getDocument(); ref(step.toString()); Caret caret = editor.getCaret(); caret.setDot(step.getOffset() + 1); EditorOperator eo = new EditorOperator(testFileObj.getNameExt()); eo.insert(step.getPrefix()); if (!isJavaScript()) { caret.setDot(step.getCursorPos()); } waitTypingFinished(doc); CompletionJListOperator comp = null; boolean print = false; int counter = 0; while (!print) { ++counter; if (counter > 5) { print = true; } try { comp = CompletionJListOperator.showCompletion(); } catch (JemmyException e) { log("EE: The CC window did not appear"); e.printStackTrace(getLog()); } if (comp != null) { print = dumpCompletion(comp, step, editor, print) || print; waitTypingFinished(doc); CompletionJListOperator.hideAll(); if (!print) {// wait for refresh Thread.sleep(1000); if (!isJavaScript()) { caret.setDot(step.getCursorPos()); } } } else { long time = System.currentTimeMillis(); String screenFile = time + "-screen.png"; log("CompletionJList is null"); log("step: " + step); log("captureScreen:" + screenFile); try { PNGEncoder.captureScreen(getWorkDir().getAbsolutePath() + File.separator + screenFile); } catch (Exception e1) { e1.printStackTrace(getLog()); } } } waitTypingFinished(doc); int rowStart = Utilities.getRowStart(doc, step.getOffset() + 1); int rowEnd = Utilities.getRowEnd(doc, step.getOffset() + 1); String fullResult = doc.getText(new int[]{rowStart, rowEnd}); String result = fullResult.trim(); int removed_whitespaces = fullResult.length() - result.length(); if (!result.equals(step.getResult().trim())) { ref("EE: unexpected CC result:\n< " + result + "\n> " + step.getResult()); } ref("End cursor position = " + (caret.getDot() - removed_whitespaces)); } finally { // undo all changes final UndoAction ua = SystemAction.get(UndoAction.class); assertNotNull("Cannot obtain UndoAction", ua); while (ua.isEnabled()) { runInAWT(new Runnable() { public void run() { ua.performAction(); } }); } } }