@Override public boolean isGenerateMementos() { // TODO: This shouldn't depend on the current project, but for now // just make sure it's defined and that we have an undo manager Project p = ProjectManager.getManager().getCurrentProject(); return super.isGenerateMementos() && p != null && p.getUndoManager() != null; }
private ProjectActions() { super(); undoAction = new ActionUndo( Translator.localize("action.undo"), ResourceLoaderWrapper.lookupIcon("Undo")); undoAction.setEnabled(false); redoAction = new ActionRedo( Translator.localize("action.redo"), ResourceLoaderWrapper.lookupIcon("Redo")); redoAction.setEnabled(false); TargetManager.getInstance().addTargetListener(this); Project p = ProjectManager.getManager().getCurrentProject(); if (p != null) { p.getUndoManager().addPropertyChangeListener(this); } }
/** * @param memento the GEF memento * @see org.tigris.gef.undo.UndoManager#addMemento(org.tigris.gef.undo.Memento) */ @Override public void addMemento(final Memento memento) { // TODO: This shouldn't be referencing the current project. Instead // the appropriate UndoManager should have already been retrieved from // the correct project. Project p = ProjectManager.getManager().getCurrentProject(); if (p != null) { org.argouml.kernel.UndoManager undo = p.getUndoManager(); if (undo != null) { if (startChain) { // TODO i18n: GEF needs to pass us back the description // of what is being done. undo.startInteraction("Diagram Interaction"); } // TODO: I presume this would fix issue 5250 - but // GEF would need to be adapted: // if (!(memento instanceof SelectionMemento)) undo.addCommand(new DiagramCommand(memento)); startChain = false; } } }