Example usage for javax.swing.undo CannotRedoException initCause

List of usage examples for javax.swing.undo CannotRedoException initCause

Introduction

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

Prototype

public synchronized Throwable initCause(Throwable cause) 

Source Link

Document

Initializes the cause of this throwable to the specified value.

Usage

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

/**
 * Sets the value of the property to be the new value
 *//*from  w  w w .  java 2  s. co  m*/
@Override
public void redo() throws CannotRedoException {
    logger.debug("Undoing Property change: Setting " + sourceEvent.getPropertyName() + " from "
            + sourceEvent.getOldValue() + " to " + sourceEvent.getNewValue());
    super.redo();
    try {
        Method setter = PropertyUtils.getWriteMethod(
                PropertyUtils.getPropertyDescriptor(sourceEvent.getSource(), sourceEvent.getPropertyName()));
        logger.info("Found setter: " + setter.getName());
        setter.invoke(sourceEvent.getSource(), sourceEvent.getNewValue());

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