Java 8 UndoManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 UndoManager class.

This code example shows how to use the following methods:
 
	public static void registerNewUndoManager(JTextComponent jtc) {
		registerNewUndoManager(jtc, jtc.getDocument());
	} 
	public static void registerNewUndoManager(JComponent jtc, Document d) {
		UndoManager undoManager = new UndoManager();
		d.addUndoableEditListener(undoManager);
	    FormUtils.registerUndoRedoActions(jtc, FormUtils.createUndoAction(undoManager, "undo"), FormUtils.createRedoAction(undoManager, "redo"));
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:canUndo, getUndoPresentationName, undo
            setEnabled(false);
        } 
         
        public void actionPerformed(ActionEvent e) {
            try { 
                undo.undo();
            } catch (CannotUndoException ex) {
                System.out.println("Unable to undo: " + ex);
                ex.printStackTrace();
            } 
            updateUndoState(); 
            redoAction.updateRedoState();
        } 
         
        protected void updateUndoState() { 
            if (undo.canUndo()) {
                setEnabled(true);
                putValue(Action.NAME, undo.getUndoPresentationName());
            } else { 
                setEnabled(false);

6
CodeRank
This code example shows how to use the following methods:canRedo, canUndo, redo
		ApplicationContext ctx = AppContext.getContext();	
		BoardEditor editor = EditorUtils.getCurrentActiveEditor();		
		UndoManager undoManager = editor.getUndoManager();
		 
		try {				 
			undoManager.redo();
		} 
		catch (CannotRedoException r) {
			log.warn("Cannot redo.");
		} 
		 
		ctx.getBean(RedoCommand.class).setEnabled(undoManager.canRedo());
		ctx.getBean(UndoCommand.class).setEnabled(undoManager.canUndo());
 
	} 
 
	@Override 
	public void editorChanged(EditorChangedEvent event) {
 
		if (event.getEditor() == null) {
5
CodeRank
This code example shows how to use the following methods:addEdit, canRedo, canUndo
		 
		if (editor.getSelectedItem() != null) {
			if (editor.getSelectedItem() instanceof Rotateable) {
				Rotateable part = (Rotateable) editor.getSelectedItem();
				part.rotateCCW();				
				if (!undoManager.addEdit(new RotateCCWEdit(part))) {
					log.info("Could not add edit : "+this.getClass());
				}								 
				editor.refresh();
			} 
		} 
		 
		ctx.getBean(RedoCommand.class).setEnabled(undoManager.canRedo());
		ctx.getBean(UndoCommand.class).setEnabled(undoManager.canUndo());
		 
	} 
 
	 
} 
5
CodeRank
This code example shows how to use the following methods:addEdit, canRedo, canUndo
				} 
				 
				Rotateable r = (Rotateable) editor.getSelectedItem();
				r.rotateCW();				
								 
				if (!undoManager.addEdit(new RotateCWEdit(r))) {
					log.info("Could not add edit "+this.getClass());
				}				 
				editor.refresh();
			} 
		} 
		 
		ctx.getBean(RedoCommand.class).setEnabled(undoManager.canRedo());
		ctx.getBean(UndoCommand.class).setEnabled(undoManager.canUndo());
		 
	} 
	 
} 
5
CodeRank
This code example shows how to use the following methods:canRedo, canUndo, undo
		UndoManager undoManager = editor.getUndoManager();				
		 
		try { 
			 
			try { 
				undoManager.undo();	
			} 
			catch (CannotUndoException c) {
				JOptionPane.showMessageDialog(win, resources.getResourceByKey("msg.cantundo"), 
												   resources.getResourceByKey("msg.error"),  
												   JOptionPane.ERROR_MESSAGE);		
			} 
						 
		} 
		catch (CannotUndoException e1) {
			log.warn("Cannot undo.");
			e1.printStackTrace();
		} 
		 
		ctx.getBean(RedoCommand.class).setEnabled(undoManager.canRedo());

5
CodeRank
This code example shows how to use the following methods:canRedo, canUndo, redo
 
    @Override 
    public void actionPerformed(ActionEvent actionEvent) {
        PetriNetController controller = applicationController.getActivePetriNetController();
        UndoManager manager = controller.getUndoManager();
        manager.redo();
 
        this.setEnabled(manager.canRedo());
        undoAction.setEnabled(manager.canUndo());
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:canUndo, getUndoPresentationName, undo
        this.redoAction = action;
    } 
 
    public void actionPerformed(ActionEvent e) {
        try { 
            if(undoManager.canUndo())
                undoManager.undo();
        } catch (CannotUndoException ex) {
            ex.printStackTrace();
        } 
        updateUndoState(); 
        redoAction.updateRedoState();
    } 
 
    protected void updateUndoState() { 
        if (undoManager.canUndo()) {
            setEnabled(true);
            putValue(Action.NAME, undoManager.getUndoPresentationName());
        } else { 
            setEnabled(false);

4
CodeRank
This code example shows how to use the following methods:
public class XJUndo { 
 
    protected XJUndoEngine engine;
    protected XJUndoDelegate delegate;
 
    protected UndoManager undoManager = new UndoManager();
    protected XJUndoAction undoAction;
    protected XJRedoAction redoAction;
 
    protected Stack<CustomCompoundEdit> groupEditEvent = new Stack<CustomCompoundEdit>();
 
    protected int enable = 0;
 
    public XJUndo(XJUndoEngine engine, XJUndoDelegate delegate) {
        this.engine = engine;
        this.delegate = delegate;
 
        undoAction = new XJUndoAction(undoManager);
        redoAction = new XJRedoAction(undoManager);
 

4
CodeRank
This code example shows how to use the following methods:canRedo, canUndo, undo
     */ 
    @Override 
    public void actionPerformed(ActionEvent actionEvent) {
        PetriNetController controller = applicationController.getActivePetriNetController();
        UndoManager manager = controller.getUndoManager();
        manager.undo();
 
        this.setEnabled(manager.canUndo());
        if (redoAction != null) {
            redoAction.setEnabled(manager.canRedo());
        } 
    } 
} 
4
CodeRank
See Code Examples for Java 8 UndoManager Methods: