@Override public void undo() throws CannotUndoException { super.undo(); try { Set<QualName> deleted = new HashSet<>(this.newTexts.keySet()); deleted.removeAll(this.oldTexts.keySet()); doDeleteTexts(getResourceKind(), deleted); if (this.oldProps != null) { doPutProperties(this.oldProps); } doPutTexts(getResourceKind(), this.oldTexts); } catch (IOException exc) { throw new CannotUndoException(); } notifyObservers(this); }
public @Override void undo() throws CannotUndoException { atomicLockImpl (); try { TokenHierarchyControl<?> thcInactive = thcInactive(); try { super.undo(); } finally { if (thcInactive != null) { thcInactive.setActive(true); } } } finally { atomicUnlockImpl (); } if (previousEdit != null) { previousEdit.undo(); } }
/** Implements {@code UndoRedo}. Undo an edit. It finds a manager which next undo edit has the highest * time stamp and makes undo on it. * @exception CannotUndoException if it fails */ @Override public synchronized void undo () throws CannotUndoException { PropertiesEditorSupport.UndoRedoStampFlagManager chosenManager = (PropertiesEditorSupport.UndoRedoStampFlagManager)getNextUndo(); if (chosenManager == null) { throw new CannotUndoException(); } else { Object atomicFlag = chosenManager.getAtomicFlagOfEditToBeUndone(); if (atomicFlag == null) {// not linked with other edits as one atomic action chosenManager.undo(); } else { // atomic undo compound from more edits in underlying managers boolean undone; do { // the atomic action can consists from more undo edits from same manager undone = false; for (Iterator<Manager> it = managers.iterator(); it.hasNext(); ) { PropertiesEditorSupport.UndoRedoStampFlagManager manager = (PropertiesEditorSupport.UndoRedoStampFlagManager)it.next(); if(atomicFlag.equals(manager.getAtomicFlagOfEditToBeUndone())) { manager.undo(); undone = true; } } } while(undone); } } }
public void testBasicFailUndo0() throws Exception { StableCompoundEdit cEdit = new StableCompoundEdit(); TestEdit e0 = new TestEdit(true); TestEdit e1 = new TestEdit(); cEdit.addEdit(e0); cEdit.addEdit(e1); NbTestCase.assertFalse("Not ended yet", cEdit.canUndo()); NbTestCase.assertFalse("Not ended yet", cEdit.canRedo()); cEdit.end(); NbTestCase.assertTrue("Expected undoable", cEdit.canUndo()); NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo()); try { cEdit.undo(); fail("Was expecting CannotUndoException exception."); } catch (CannotUndoException ex) { // Expected } NbTestCase.assertTrue("Expected undoable", cEdit.canUndo()); NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo()); NbTestCase.assertTrue("Expected undoable", e0.canUndo()); NbTestCase.assertFalse("Expected non-redoable", e0.canRedo()); NbTestCase.assertTrue("Expected undoable", e1.canUndo()); NbTestCase.assertFalse("Expected non-redoable", e1.canRedo()); }
public void testBasicFailUndo1() throws Exception { StableCompoundEdit cEdit = new StableCompoundEdit(); TestEdit e0 = new TestEdit(); TestEdit e1 = new TestEdit(true); cEdit.addEdit(e0); cEdit.addEdit(e1); NbTestCase.assertFalse("Not ended yet", cEdit.canUndo()); NbTestCase.assertFalse("Not ended yet", cEdit.canRedo()); cEdit.end(); NbTestCase.assertTrue("Expected undoable", cEdit.canUndo()); NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo()); try { cEdit.undo(); fail("Was expecting CannotUndoException exception."); } catch (CannotUndoException ex) { // Expected } NbTestCase.assertTrue("Expected undoable", cEdit.canUndo()); NbTestCase.assertFalse("Expected non-redoable", cEdit.canRedo()); NbTestCase.assertTrue("Expected undoable", e0.canUndo()); NbTestCase.assertFalse("Expected non-redoable", e0.canRedo()); NbTestCase.assertTrue("Expected undoable", e1.canUndo()); NbTestCase.assertFalse("Expected non-redoable", e1.canRedo()); }
public static void undo(Context context, final int count) throws Exception { final Document doc = getDocument(context); final UndoManager undoManager = (UndoManager) doc.getProperty(UndoManager.class); logUndoRedoOp(context, "UNDO", count); invoke(context, new Runnable() { @Override public void run() { try { int cnt = count; while (undoManager.canUndo() && --cnt >= 0) { undoManager.undo(); } } catch (CannotUndoException e) { throw new IllegalStateException(e); } } }); logPostUndoRedoOp(context, count); }
@Override public void undo() { if (!canUndo()) { throw new CannotUndoException(); } MyCompoundEdit u = edits.get(pointer); u.undo(); pointer--; }
@Override public void undo() throws CannotUndoException { super.undo(); // --- Remove the added components -------------- HashSet<NetworkComponent> netComps2Remove = new HashSet<NetworkComponent>(); for (NetworkComponent networkComponentPasted : this.pastedNetworkModel.getNetworkComponents().values()) { String netCompID = networkComponentPasted.getId(); NetworkComponent netCompRemove = this.graphController.getNetworkModel().getNetworkComponent(netCompID); netComps2Remove.add(netCompRemove); this.graphController.removeAgent(networkComponentPasted); } this.graphController.getNetworkModel().removeNetworkComponents(netComps2Remove); NetworkModelNotification notification = new NetworkModelNotification(NetworkModelNotification.NETWORK_MODEL_Component_Removed); notification.setInfoObject(netComps2Remove); this.graphController.notifyObservers(notification); }
@Override public void undo() throws CannotUndoException { try { ignore = true; // take text from position - 1 String planText = history.get(position - 1); // parse it PoshParser parser = new PoshParser(new StringReader(planText)); PoshPlan plan = parser.parsePlan(); // synchronize with the editor tree lapTree.synchronize(plan); if (position > 0) { --position; } } catch (ParseException ex) { throw new CannotUndoException(); } finally { ignore = false; cs.fireChange(); } }
@Override public void undo() throws CannotUndoException { super.undo(); try { boolean layout = getType() == LAYOUT; if (!layout) { Set<QualName> deleted = getNames(this.newGraphs); deleted.removeAll(getNames(this.oldGraphs)); doDeleteGraphs(getResourceKind(), deleted); if (this.oldProps != null) { doPutProperties(this.oldProps); } } doPutGraphs(getResourceKind(), this.oldGraphs, layout); } catch (IOException exc) { throw new CannotUndoException(); } notifyObservers(this); }
@Override public void undo() throws CannotUndoException { super.undo(); boolean b = scene.getUndoRedoEnabled(); scene.setUndoRedoEnabled(false); scene.getModel().getViewChangedEvent().addListener(this); scene.getModel().setData(oldModel); scene.getModel().getViewChangedEvent().removeListener(this); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { scene.setScrollPosition(oldScrollPosition); } }); scene.setUndoRedoEnabled(b); }
public void actionPerformed(ActionEvent e) { try { undo.undo(); } catch (CannotUndoException ex) { System.out.println("Unable to undo: " + ex); ex.printStackTrace(); } update(); redoAction.update(); }
@Override public void undo() throws CannotUndoException { if (edit != null) { edit.end(); } super.undo(); edit = null; }
@Override public void undo() throws CannotUndoException { synchronized(delegates) { for (CompoundUndoManager cm : delegates) { if(cm.hasFocus()) { cm.undo(); return; } } } }
private void undoAtomicEdits() { if (atomicEdits != null && atomicEdits.size() > 0) { atomicEdits.end(); if (atomicEdits.canUndo()) { atomicEdits.undo(); } else { LOG.log(Level.WARNING, "Cannot UNDO: " + atomicEdits.toString() + // NOI18N " Edits: " + atomicEdits.getEdits(), // NOI18N new CannotUndoException()); } atomicEdits = null; } }
public void undo() throws CannotUndoException { GuardedDocument gdoc = (GuardedDocument)getDocument(); boolean origBreak = gdoc.breakGuarded; gdoc.breakGuarded = true; super.undo(); if (!origBreak) { gdoc.breakGuarded = false; } }
public @Override void undo() throws CannotUndoException { super.undo(); if (debugUndo) { /*DEBUG*/System.err.println("UNDO-" + dump()); // NOI18N } undoOrRedo(-length, true); }
@Override public void undo() throws CannotUndoException { JTextComponent focusedComponent = EditorRegistry.focusedComponent(); if (focusedComponent != null) { if (focusedComponent.getDocument() == ces.getDocument()) { //call global undo only for focused component undoManager.undo(session, ces.getDocument()); } } //delegate.undo(); inner.undo(); }
public void undo() throws CannotUndoException { assert (!undone) : "Already undone"; if (undoFail) { undoFailedCount++; throw new CannotUndoException(); } undone = true; }
@Override public void undo() throws CannotUndoException { InstantRefactoringPerformer perf = performer.get(); if (perf != null) { perf.release(true); } }
@Override public void undo() throws CannotUndoException { // JTextComponent focusedComponent = EditorRegistry.focusedComponent(); // if (focusedComponent != null) { // if (focusedComponent.getDocument() == ces.getDocument()) { // //call global undo only for focused component // undoManager.undo(session); // } // } //delegate.undo(); inner.undo(); }
public void undo() throws CannotUndoException { super.undo(); try { insertString(offset, string); // Update the Positions that were in the range removed. if(posRefs != null) { updateUndoPositions(posRefs, offset, length); posRefs = null; } string = null; } catch (BadLocationException bl) { throw new CannotUndoException(); } }
/** Overrides superclass method. Updates time stamp for the edit. */ @Override public synchronized void undo() throws CannotUndoException { UndoableEdit anEdit = editToBeUndone(); if(anEdit != null) { Object atomicFlag = stampFlags.get(anEdit).getAtomicFlag(); // atomic flag remains super.undo(); stampFlags.put(anEdit, new StampFlag(System.currentTimeMillis(), atomicFlag)); } }
@Override public void undo() throws CannotUndoException { InstantRenamePerformer perf = performer.get(); if (perf != null) { perf.release(); } }
@Override public void undo() throws CannotUndoException { boolean undoStartedTransaction = false; boolean needsRefresh = true; try { startTransaction(true, true); //start pseudo transaction for event firing undoStartedTransaction = true; AbstractModel.this.getAccess().prepareForUndoRedo(); super.undo(); AbstractModel.this.getAccess().finishUndoRedo(); endTransaction(); needsRefresh = false; } catch(CannotUndoException ex) { needsRefresh = false; throw ex; } finally { if (undoStartedTransaction && isIntransaction()) { try { endTransaction(true); // do not fire events } catch(Exception e) { Logger.getLogger(getClass().getName()).log(Level.INFO, "Undo error", e); //NOI18N } } if (needsRefresh) { setState(State.NOT_SYNCED); refresh(); } } }
@Override public void undo() throws CannotUndoException { if (!canUndo()) { throw new CannotUndoException(); } statusBits &= ~HAS_BEEN_DONE; // hasBeenDone = false; }
@Override public void redo() { if (!canRedo()) { throw new CannotUndoException(); } pointer++; MyCompoundEdit u = edits.get(pointer); u.redo(); }
@Override public void undo() throws CannotUndoException { super.undo(); if (removal) { insertEdit(this); } else { removeEdit(this); } }
@Override public void undo() throws CannotUndoException { super.undo(); if (mayDifferPairs != null) { for (PositionPair pair : mayDifferPairs) { assert (!pair.mayDiffer) : "Invalid pair: " + pair; // NOI18N pair.mayDiffer = true; } } assert (mayDifferUndoItem == this) : "Invalid mayDifferUndoItem=" + mayDifferUndoItem; mayDifferUndoItem = previousItem; }
@Override public void undo() throws CannotUndoException { if (fireException) { throw new CannotUndoException(); } super.undo(); }
public void undo() throws CannotUndoException { super.undo(); replace(index, childrenAdded.length, childrenRemoved); // Switch childrenAdded with childrenRemoved Element[] tmp = childrenRemoved; childrenRemoved = childrenAdded; childrenAdded = tmp; }
@Override public void undo() throws CannotUndoException { super.undo(); try { model.resetDocument(oldDocument); } catch (RuntimeException ex) { if (oldDocument != model.getCurrentDocument()) { CannotUndoException e = new CannotUndoException(); e.initCause(ex); throw e; } else { throw ex; } } }
@Override public void undo() throws CannotUndoException { if (undoFails) { throw new CannotUndoException(); } undo++; }
@Override public void undo() throws CannotUndoException { super.undo(); if (!inactive) { inactive = true; CodeTemplateInsertHandler handler = (CodeTemplateInsertHandler) doc.getProperty(CT_HANDLER_DOC_PROPERTY); if (handler != null) { handler.release(); } } }
@Override public void undo() throws CannotUndoException { if(delegate != null) { delegate.undo(); } else { UndoRedo.NONE.undo(); } }