Example usage for java.beans PropertyVetoException PropertyVetoException

List of usage examples for java.beans PropertyVetoException PropertyVetoException

Introduction

In this page you can find the example usage for java.beans PropertyVetoException PropertyVetoException.

Prototype

public PropertyVetoException(String mess, PropertyChangeEvent evt) 

Source Link

Document

Constructs a PropertyVetoException with a detailed message.

Usage

From source file:com.anrisoftware.prefdialog.core.AbstractFieldComponentLogger.java

PropertyVetoException errorTrySetValue(AbstractFieldComponent<?> field, Exception e, Object value,
        String property) {/*from w ww .ja  v a  2  s  . co m*/
    PropertyVetoException ex = new PropertyVetoException(e.getMessage(),
            new PropertyChangeEvent(field, property, null, value));
    log.debug(ERROR_SET_VALUE, value, field, e.getLocalizedMessage());
    return ex;
}

From source file:ca.uhn.hl7v2.testpanel.model.msg.Hl7V2MessageBase.java

@Override
public void setSourceMessage(String theMessage) throws PropertyVetoException {
    theMessage = StringUtils.defaultString(theMessage);

    String original = mySourceMessage;
    if (mySourceMessage != null && mySourceMessage.equals(theMessage)) {
        return;//from   w ww  .j a  v a 2s .  c o m
    }

    String sourceMessage = theMessage.trim();
    String text = sourceMessage.replaceAll("(\\r|\\n)+", "\r");

    updateParser();

    Message parsedMessage;
    try {

        ourLog.info("About to parse message");

        if (myRuntimeProfile != null) {
            Entry profile = determineRuntimeProfile(text);

            if (profile != null) {
                parsedMessage = ConformanceMessage.newInstanceFromStaticDef(
                        profile.getProfileProxy().getProfile().getMessage(), profile.getTablesId());
                parsedMessage.setParser(myParser);
                parsedMessage.parse(text);
            } else {
                parsedMessage = myParser.parse(text);
            }
        } else {
            parsedMessage = myParser.parse(text);
        }

        ourLog.info("Done parsing message");

    } catch (EncodingNotSupportedException e) {
        ourLog.error("Failed to parse message", e);
        throw new PropertyVetoException(e.getMessage(), null);
    } catch (HL7Exception e) {
        ourLog.error("Failed to parse message", e);
        throw new PropertyVetoException(e.getMessage(), null);
    } catch (IOException e) {
        ourLog.error("Failed to parse message", e);
        throw new PropertyVetoException(e.getMessage(), null);
    } catch (ProfileException e) {
        ourLog.error("Failed to parse message", e);
        throw new PropertyVetoException(e.getMessage(), null);
    }

    myParsedMessage = parsedMessage;
    mySourceMessage = sourceMessage;

    recalculateIndexes();

    firePropertyChange(PARSED_MESSAGE_PROPERTY, original, text);
}

From source file:ca.uhn.hunit.iface.AbstractJmsInterfaceImpl.java

public void setConnectionFactoryClass(Class<?> theConnectionFactoryClass) throws PropertyVetoException {
    Class<?> oldValue = theConnectionFactoryClass;

    if (!theConnectionFactoryClass.isAssignableFrom(ConnectionFactory.class)) {
        throw new PropertyVetoException("Must extend " + ConnectionFactory.class, null);
    }//from   w w w . ja v a 2  s .  c  o m

    fireVetoableChange(CONNECTION_FACTORY_CLASS_PROPERTY, oldValue, theConnectionFactoryClass);
    this.myConnectionFactoryClass = theConnectionFactoryClass;
    firePropertyChange(CONNECTION_FACTORY_CLASS_PROPERTY, oldValue, theConnectionFactoryClass);
}

From source file:ca.uhn.hunit.iface.AbstractJmsInterfaceImpl.java

public void setQueueName(String myQueueName) throws PropertyVetoException {
    if (StringUtils.isBlank(myQueueName)) {
        throw new PropertyVetoException(Strings.getInstance().getString("interface.queue.empty"), null);
    }/*from   w ww  . j  a v a 2s.  com*/

    this.myQueueName = myQueueName;
}

From source file:org.jfree.data.time.TimeSeriesCollection.java

/**
 * Receives notification that the key for one of the series in the 
 * collection has changed, and vetos it if the key is already present in 
 * the collection.//from   www  .java 2  s.c  o m
 * 
 * @param e  the event.
 * 
 * @since 1.0.17
 */
@Override
public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException {
    // if it is not the series name, then we have no interest
    if (!"Key".equals(e.getPropertyName())) {
        return;
    }

    // to be defensive, let's check that the source series does in fact
    // belong to this collection
    Series s = (Series) e.getSource();
    if (getSeriesIndex(s.getKey()) == -1) {
        throw new IllegalStateException(
                "Receiving events from a series " + "that does not belong to this collection.");
    }
    // check if the new series name already exists for another series
    Comparable key = (Comparable) e.getNewValue();
    if (getSeriesIndex(key) >= 0) {
        throw new PropertyVetoException("Duplicate key2", e);
    }
}

From source file:org.nuclos.client.ui.collect.CollectController.java

protected void initTab() {
    // prevent that the frame is closed when changes are pending:
    getTab().addVetoableChangeListener(new VetoableChangeListener() {
        @Override/*  www . java  2 s .co  m*/
        public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
            if (evt.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY)) {
                final Boolean bOldValue = (Boolean) evt.getOldValue();
                final Boolean bNewValue = (Boolean) evt.getNewValue();

                if (bOldValue == Boolean.FALSE && bNewValue == Boolean.TRUE) {
                    // We need bFrameMayBeClosed as a member variable here, as it is set in
                    // cmdFrameClosing and must be checked here.
                    // JInternalFrame.setClosed() first sends a frame closing event, then a vetoable change event.
                    // Note that this is totally weird. See JInternalFrame.setClosed()
                    if (!CollectController.this.bFrameMayBeClosed) {
                        throw new PropertyVetoException("do not close", evt);
                    }
                }
            }
        }
    });

    // override close behavior:
    getTab().addMainFrameTabListener(new MainFrameTabAdapter() {
        @Override
        public void tabSelected(MainFrameTab tab) {
            setDefaultButton();
        }

        @Override
        public void tabClosing(MainFrameTab tab, final ResultListener<Boolean> rl) {
            askAndSaveIfNecessary(new ResultListener<Boolean>() {
                @Override
                public void done(Boolean result) {
                    rl.done(Boolean.TRUE.equals(result));
                }
            });
        }

        @Override
        public void tabClosed(MainFrameTab tab) {
            CollectController.this.close();
            tab.removeMainFrameTabListener(this);
        }
    });
}

From source file:org.orbisgis.mapeditor.map.MapEditor.java

/**
 * The user update the scale field/*from  www .  ja  v  a2 s.c om*/
 * @param pce update event
 * @throws PropertyVetoException If the property entered is incorrect
 */
public void onUserSetScaleDenominator(PropertyChangeEvent pce) throws PropertyVetoException {
    long newScale = (Long) pce.getNewValue();
    if (newScale < 1) {
        throw new PropertyVetoException(
                I18N.tr("The value of the scale denominator must be equal or greater than 1"), pce);
    }
    mapControl.getMapTransform().setScaleDenominator(newScale);
}