Java 类org.eclipse.gef.commands.CommandStackEventListener 实例源码

项目:gef-gwt    文件:UndoablePropertySheetPage.java   
/**
 * Constructs a new {@link UndoablePropertySheetPage}.
 * 
 * @param commandStack
 *            The {@link CommandStack} shared with the editor.
 * @param undoAction
 *            The global action handler to be registered for undo
 *            operations.
 * @param redoAction
 *            The global action handler to be registered for redo
 *            operations.
 */
public UndoablePropertySheetPage(final CommandStack commandStack,
        IAction undoAction, IAction redoAction) {
    this.undoHandler = undoAction;
    this.redoHandler = redoAction;
    this.commandStack = commandStack;
    this.commandStackEventListener = new CommandStackEventListener() {

        public void stackChanged(CommandStackEvent event) {
            if (event.getDetail() == CommandStack.PRE_UNDO
                    || event.getDetail() == CommandStack.PRE_REDO) {
                // ensure the property sheet entry looses its current edit
                // state, otherwise it may revert the undo/redo operation
                // within valueChanged when the editor is activated again.
                refresh();
            }
        }
    };
    commandStack.addCommandStackEventListener(commandStackEventListener);
    setRootEntry(new UndoablePropertySheetEntry(commandStack));
}
项目:NEXCORE-UML-Modeler    文件:UMLDiagramCommandStack.java   
/**
 * @see org.eclipse.gef.commands.CommandStack#addCommandStackEventListener(org.eclipse.gef.commands.CommandStackEventListener)
 */
@Override
public void addCommandStackEventListener(CommandStackEventListener listener) {
    if (!commandStackEventListenerList.contains(listener)) {
        commandStackEventListenerList.add(listener);
    }
    super.addCommandStackEventListener(listener);
}