List of usage examples for javax.swing.undo CannotUndoException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:ca.sqlpower.object.undo.PropertyChangeEdit.java
/** * Sets the value of the property to be the old value *//*from ww w. j av a 2s. 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; } }