javax.swing.undo.CannotRedoException Java Examples
The following examples show how to use
javax.swing.undo.CannotRedoException.
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: DocumentTesting.java From netbeans with Apache License 2.0 | 6 votes |
public static void redo(Context context, final int count) throws Exception { final Document doc = getDocument(context); final UndoManager undoManager = (UndoManager) doc.getProperty(UndoManager.class); logUndoRedoOp(context, "REDO", count); invoke(context, new Runnable() { @Override public void run() { try { int cnt = count; while (undoManager.canRedo() && --cnt >= 0) { undoManager.redo(); } } catch (CannotRedoException e) { throw new IllegalStateException(e); } } }); logPostUndoRedoOp(context, count); }
Example #2
Source File: BringToFrontAction.java From openAGV with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(java.awt.event.ActionEvent e) { final DrawingView view = getView(); final LinkedList<Figure> figures = new LinkedList<>(view.getSelectedFigures()); bringToFront(view, figures); fireUndoableEditHappened(new AbstractUndoableEdit() { @Override public String getPresentationName() { return ResourceBundleUtil.getBundle(TOOLBAR_PATH).getString("bringToFrontAction.undo.presentationName"); } @Override public void redo() throws CannotRedoException { super.redo(); BringToFrontAction.bringToFront(view, figures); } @Override public void undo() throws CannotUndoException { super.undo(); SendToBackAction.sendToBack(view, figures); } }); }
Example #3
Source File: SendToBackAction.java From openAGV with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(java.awt.event.ActionEvent e) { final DrawingView view = getView(); final LinkedList<Figure> figures = new LinkedList<>(view.getSelectedFigures()); sendToBack(view, figures); fireUndoableEditHappened(new AbstractUndoableEdit() { @Override public String getPresentationName() { return ResourceBundleUtil.getBundle(TOOLBAR_PATH).getString("sendToBackAction.undo.presentationName"); } @Override public void redo() throws CannotRedoException { super.redo(); SendToBackAction.sendToBack(view, figures); } @Override public void undo() throws CannotUndoException { super.undo(); BringToFrontAction.bringToFront(view, figures); } }); }
Example #4
Source File: BaseDocument.java From netbeans with Apache License 2.0 | 6 votes |
public @Override void redo() throws CannotRedoException { if (previousEdit != null) { previousEdit.redo(); } atomicLockImpl (); try { TokenHierarchyControl<?> thcInactive = thcInactive(); try { super.redo(); } finally { if (thcInactive != null) { thcInactive.setActive(true); } } } finally { atomicUnlockImpl (); } }
Example #5
Source File: WrapUndoEdit.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void redo() throws CannotRedoException { undoRedoManager.checkLogOp("WrapUndoEdit.redo", this); boolean savepoint = undoRedoManager.isAtSavepoint(); if (savepoint) { undoRedoManager.beforeRedoAtSavepoint(this); } boolean done = false; try { delegate.redo(); done = true; // This will only happen if delegate.redo() does not throw CannotRedoException undoRedoManager.afterRedoCheck(this); } finally { if (!done && savepoint) { undoRedoManager.delegateRedoFailedAtSavepoint(this); } } }
Example #6
Source File: StableCompoundEdit.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void redo() throws CannotRedoException { if (!canRedo()) { throw new CannotRedoException(); } int i = 0; int size = edits.size(); try { for (; i < size; i++) { edits.get(i).redo(); } setStatusBits(HAS_BEEN_DONE); } finally { if (i != size) { // i-th edit's redo failed => undo the ones below while (--i >= 0) { edits.get(i).undo(); } } } }
Example #7
Source File: StableCompoundEdit.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void redo() throws CannotRedoException { if (!canRedo()) { throw new CannotRedoException(); } int i = 0; int size = edits.size(); try { for (; i < size; i++) { edits.get(i).redo(); } setStatusBits(HAS_BEEN_DONE); } finally { if (i != size) { // i-th edit's redo failed => undo the ones below while (--i >= 0) { edits.get(i).undo(); } } } }
Example #8
Source File: PropertiesOpen.java From netbeans with Apache License 2.0 | 6 votes |
/** Implements {@code UndoRedo}. Redo a previously undone edit. It finds a manager which next undo edit has the highest * time stamp and makes undo on it. * @exception CannotRedoException if it fails */ @Override public synchronized void redo () throws CannotRedoException { PropertiesEditorSupport.UndoRedoStampFlagManager chosenManager = (PropertiesEditorSupport.UndoRedoStampFlagManager)getNextRedo(); if (chosenManager == null) { throw new CannotRedoException(); } else { Object atomicFlag = chosenManager.getAtomicFlagOfEditToBeRedone(); if (atomicFlag == null) {// not linked with other edits as one atomic action chosenManager.redo(); } else { // atomic redo compound from more edits in underlying managers boolean redone; do { // the atomic action can consists from more redo edits from same manager redone = false; for (Iterator<Manager> it = managers.iterator(); it.hasNext(); ) { PropertiesEditorSupport.UndoRedoStampFlagManager manager = (PropertiesEditorSupport.UndoRedoStampFlagManager)it.next(); if(atomicFlag.equals(manager.getAtomicFlagOfEditToBeRedone())) { manager.redo(); redone = true; } } } while(redone); } } }
Example #9
Source File: ExpectedDocumentContent.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { super.redo(); if (removal) { removeEdit(this); } else { insertEdit(this); } }
Example #10
Source File: AbstractModel.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { boolean redoStartedTransaction = false; boolean needsRefresh = true; try { startTransaction(true, true); //start pseudo transaction for event firing redoStartedTransaction = true; AbstractModel.this.getAccess().prepareForUndoRedo(); super.redo(); AbstractModel.this.getAccess().finishUndoRedo(); endTransaction(); needsRefresh = false; } catch(CannotRedoException ex) { needsRefresh = false; throw ex; } finally { if (isIntransaction() && redoStartedTransaction) { try { endTransaction(true); // do not fire events } catch(Exception e) { Logger.getLogger(getClass().getName()).log(Level.INFO, "Redo error", e); //NOI18N } } if (needsRefresh) { setState(State.NOT_SYNCED); refresh(); } } }
Example #11
Source File: XDMModelUndoableEdit.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { super.redo(); try { model.resetDocument(newDocument); } catch (RuntimeException ex) { if (newDocument != model.getCurrentDocument()) { CannotRedoException e = new CannotRedoException(); e.initCause(ex); throw e; } else { throw ex; } } }
Example #12
Source File: GapContent.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void redo() throws CannotRedoException { super.redo(); try { insertString(offset, string); string = null; // Update the Positions that were in the range removed. if(posRefs != null) { updateUndoPositions(posRefs, offset, length); posRefs = null; } } catch (BadLocationException bl) { throw new CannotRedoException(); } }
Example #13
Source File: PositionSyncList.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { super.redo(); if (mayDifferPairs != null) { for (PositionPair pair : mayDifferPairs) { assert (pair.mayDiffer) : "Invalid pair: " + pair; // NOI18N pair.mayDiffer = false; } } mayDifferUndoItem = this; }
Example #14
Source File: GapContent.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void redo() throws CannotRedoException { super.redo(); try { string = getString(offset, length); // Get the Positions in the range being removed. posRefs = getPositionsInRange(null, offset, length); remove(offset, length); } catch (BadLocationException bl) { throw new CannotRedoException(); } }
Example #15
Source File: ModRootElement.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { super.redo(); // #145588 - must recompute index according to current modList state index = findModElementIndex(modElement.getStartOffset(), true); run(); }
Example #16
Source File: ContentEdit.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { if (!canRedo()) { throw new CannotRedoException(); } statusBits |= HAS_BEEN_DONE; }
Example #17
Source File: DocumentContent.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void redo() throws CannotRedoException { super.redo(); if (debugUndo) { /*DEBUG*/System.err.println("REDO-" + dump()); // NOI18N } undoOrRedo(length, false); }
Example #18
Source File: UndoRedoSupport.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { synchronized(delegates) { for (CompoundUndoManager cm : delegates) { if(cm.hasFocus()) { cm.redo(); return; } } } }
Example #19
Source File: GuardedDocumentEvent.java From netbeans with Apache License 2.0 | 5 votes |
public void redo() throws CannotRedoException { GuardedDocument gdoc = (GuardedDocument)getDocument(); boolean origBreak = gdoc.breakGuarded; super.redo(); if (!origBreak) { gdoc.breakGuarded = false; } }
Example #20
Source File: IssueTopComponent.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { if(delegate != null) { delegate.redo(); } else { UndoRedo.NONE.redo(); } }
Example #21
Source File: Deadlock207571Test.java From netbeans with Apache License 2.0 | 5 votes |
public void redo() throws CannotRedoException { assert (undone) : "Already redone"; if (redoFail) { throw new CannotRedoException(); } undone = false; }
Example #22
Source File: InstantRefactoringPerformer.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { // JTextComponent focusedComponent = EditorRegistry.focusedComponent(); // if (focusedComponent != null) { // if (focusedComponent.getDocument() == ces.getDocument()) { // //call global undo only for focused component // undoManager.redo(session); // } // } //delegate.redo(); inner.redo(); }
Example #23
Source File: DefaultStyledDocument.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Redoes a change. * * @exception CannotRedoException if the change cannot be redone */ public void redo() throws CannotRedoException { super.redo(); MutableAttributeSet as = (MutableAttributeSet)element .getAttributes(); if(isReplacing) as.removeAttributes(as); as.addAttributes(newAttributes); }
Example #24
Source File: LockingManager.java From constellation with Apache License 2.0 | 5 votes |
@Override public void redo() { if (!canRedo() || !executed.compareAndSet(false, true)) { throw new CannotRedoException(); } new Thread(() -> { // Get the global write lock because we will change the graph globalWriteLock.lock(); try { writeContext.target.setOperationMode(GraphOperationMode.REDO); execute(writeContext.target); writeContext.target.validateKeys(); writeContext.target.setOperationMode(GraphOperationMode.EXECUTE); // Switch the read context to the write context final Context originalReadContext = readContext; readContext = writeContext; originalReadContext.lock.writeLock().lock(); try { originalReadContext.target.setOperationMode(GraphOperationMode.REDO); execute(originalReadContext.target); originalReadContext.target.validateKeys(); originalReadContext.target.setOperationMode(GraphOperationMode.EXECUTE); } finally { originalReadContext.lock.writeLock().unlock(); } // Switch the write context writeContext = originalReadContext; } finally { // Unlock the global write lock so new write requests can begin on the new write context globalWriteLock.unlock(); } }).start(); update(null, null); }
Example #25
Source File: DefaultStyledDocument.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Redoes a change. * * @exception CannotRedoException if the change cannot be redone */ public void redo() throws CannotRedoException { super.redo(); MutableAttributeSet as = (MutableAttributeSet)element .getAttributes(); if(isReplacing) as.removeAttributes(as); as.addAttributes(newAttributes); }
Example #26
Source File: DiagramScene.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void redo() throws CannotRedoException { super.redo(); boolean b = scene.getUndoRedoEnabled(); scene.setUndoRedoEnabled(false); scene.getModel().getViewChangedEvent().addListener(this); scene.getModel().setData(newModel); scene.getModel().getViewChangedEvent().removeListener(this); scene.setUndoRedoEnabled(b); }
Example #27
Source File: GapContent.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void redo() throws CannotRedoException { super.redo(); try { insertString(offset, string); string = null; // Update the Positions that were in the range removed. if(posRefs != null) { updateUndoPositions(posRefs, offset, length); posRefs = null; } } catch (BadLocationException bl) { throw new CannotRedoException(); } }
Example #28
Source File: EditorPaneUndoRedo.java From SikuliX1 with MIT License | 5 votes |
public void actionPerformed(ActionEvent e) { try { undoManager.redo(); } catch (CannotRedoException ex) { // TODO deal with this ex.printStackTrace(); } update(); undoAction.update(); }
Example #29
Source File: DefaultStyledDocument.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Redoes a change. * * @exception CannotRedoException if the change cannot be redone */ public void redo() throws CannotRedoException { super.redo(); MutableAttributeSet as = (MutableAttributeSet)element .getAttributes(); if(isReplacing) as.removeAttributes(as); as.addAttributes(newAttributes); }
Example #30
Source File: DefaultStyledDocument.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Redoes a change. * * @exception CannotRedoException if the change cannot be redone */ public void redo() throws CannotRedoException { super.redo(); MutableAttributeSet as = (MutableAttributeSet)element .getAttributes(); if(isReplacing) as.removeAttributes(as); as.addAttributes(newAttributes); }