Example usage for javax.swing.undo CannotUndoException CannotUndoException

List of usage examples for javax.swing.undo CannotUndoException CannotUndoException

Introduction

In this page you can find the example usage for javax.swing.undo CannotUndoException CannotUndoException.

Prototype

CannotUndoException

Source Link

Usage

From source file:ca.sqlpower.object.undo.PropertyChangeEdit.java

/**
 * Sets the value of the property to be the old value
 *///from   ww  w . ja  v  a  2 s  .c o  m
@Override
public void undo() throws CannotUndoException {
    logger.debug("Undoing Property change: Setting " + sourceEvent.getPropertyName() + " from "
            + sourceEvent.getNewValue() + " to " + sourceEvent.getOldValue());
    super.undo();
    try {
        final PropertyDescriptor propertyDescriptor = PropertyUtils
                .getPropertyDescriptor(sourceEvent.getSource(), sourceEvent.getPropertyName());
        logger.debug("Found property descriptor " + propertyDescriptor);
        if (logger.isDebugEnabled()) {
            PropertyDescriptor[] propertyDescriptors = PropertyUtils
                    .getPropertyDescriptors(sourceEvent.getSource());
            logger.debug("Descriptor has write method " + propertyDescriptor.getWriteMethod());
        }
        Method setter = PropertyUtils.getWriteMethod(propertyDescriptor);
        logger.info("Found setter: " + setter.getName());
        setter.invoke(sourceEvent.getSource(), sourceEvent.getOldValue());

    } catch (Exception ex) {
        CannotUndoException wrapper = new CannotUndoException();
        wrapper.initCause(ex);
        throw wrapper;
    }
}

From source file:ffx.algorithms.MolecularDynamics.java

public void revertState() {
    if (dynamicsState == null) {
        throw new CannotUndoException();
    }
    dynamicsState.restore();
}