Java Code Examples for java.beans.PropertyVetoException#getLocalizedMessage()

The following examples show how to use java.beans.PropertyVetoException#getLocalizedMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertyEnv.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * A setter that should be used by the property editor
 * to change the state of the environment.
 * Even the state property is bound, changes made from the editor itself
 * are allowed without restrictions.
 */
public void setState(Object newState) {
    if (getState().equals(newState)) {
        // no change, no fire vetoable and property change
        return;
    }

    try {
        getSupport().fireVetoableChange(PROP_STATE, getState(), newState);
        state = newState;

        // always notify state change
        getChange().firePropertyChange(PROP_STATE, null, newState);
    } catch (PropertyVetoException pve) {
        // and notify the user that the change cannot happen
        String msg = Exceptions.findLocalizedMessage(pve);
        if (msg == null) {
            msg = pve.getLocalizedMessage();
        }
        if (msg != null) {
            DialogDisplayer.getDefault().notify(
                    new NotifyDescriptor.Message(msg, NotifyDescriptor.WARNING_MESSAGE));
        } else { // no message for the user, log the exception the standard way
            PropertyDialogManager.notify(pve);
        }
    }
}
 
Example 2
Source File: MergeDialogComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void save() throws java.io.IOException {
    try {
        MergeDialogComponent.this.fireVetoableChange(PROP_PANEL_SAVE, null, mergePanelRef.get());
    } catch (PropertyVetoException vetoEx) {
        Throwable cause = vetoEx.getCause();
        if (cause instanceof IOException) {
            throw (IOException) cause;
        } else {
            throw new java.io.IOException(vetoEx.getLocalizedMessage());
        }
    }
}