List of usage examples for java.beans PropertyVetoException PropertyVetoException
public PropertyVetoException(String mess, PropertyChangeEvent evt)
From source file:Main.java
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { Object oldValue = evt.getOldValue(); Object newValue = evt.getNewValue(); boolean veto = false; if (veto) {/*from w w w . j a v a 2 s . c om*/ throw new PropertyVetoException("the reason for the veto", evt); } }
From source file:Main.java
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { Component oldComp = (Component) evt.getOldValue(); Component newComp = (Component) evt.getNewValue(); if ("focusOwner".equals(evt.getPropertyName())) { if (oldComp == null) { System.out.println(newComp.getName()); } else {/*from w w w . ja v a 2 s . c om*/ System.out.println(oldComp.getName()); } } else if ("focusedWindow".equals(evt.getPropertyName())) { if (oldComp == null) { System.out.println(newComp.getName()); } else { System.out.println(oldComp.getName()); } } boolean vetoFocusChange = false; if (vetoFocusChange) { throw new PropertyVetoException("message", evt); } }
From source file:Main.java
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { String eventName = evt.getPropertyName(); if (eventName.equalsIgnoreCase("interest")) { double interest = ((Double) evt.getNewValue()).doubleValue(); if (interest > 20.00) { throw new PropertyVetoException("Interest must be below 20.00", evt); }/*from w ww . ja v a 2 s . c om*/ System.out.println("Interest applied = " + interest); } }
From source file:com.anrisoftware.prefdialog.appdialogs.registerdialog.ApprovalActionListener.java
@Override public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { Status status = (Status) evt.getNewValue(); if (status == Status.APPROVED) { if (isBlank(dialog.getName())) { throw new PropertyVetoException(name_not_set_message.toString(), evt); }// w w w .ja v a 2 s .c om if (isBlank(dialog.getCode())) { throw new PropertyVetoException(code_not_set_message.toString(), evt); } } }
From source file:ca.uhn.hunit.test.TestImpl.java
public void setName(String theName) throws PropertyVetoException { if (StringUtils.equals(myName, theName)) { return;//from www .j av a2 s. c om } if (StringUtils.isEmpty(theName)) { throw new PropertyVetoException(Strings.getInstance().getString("test.name.empty"), null); } if (myBattery.getTestNames().contains(theName)) { throw new PropertyVetoException(Strings.getInstance().getString("test.name.duplicate"), null); } String oldValue = myName; fireVetoableChange(NAME_PROPERTY, oldValue, theName); myName = theName; firePropertyChange(NAME_PROPERTY, oldValue, theName); }
From source file:ca.uhn.hunit.msg.Hl7V2MessageImpl.java
@Override public void setSourceMessage(String theMessage) throws PropertyVetoException { theMessage = StringUtils.defaultString(theMessage); String original = mySourceMessage; String sourceMessage = theMessage.trim(); String text = sourceMessage.replaceAll("(\\r|\\n)+", "\r"); PipeParser parser = new PipeParser(); parser.setValidationContext(new ValidationContextImpl()); Message parsedMessage;/*from w w w . j a va 2 s . c om*/ try { // Parse and re-encode to strip out any inconsistancies in the message (extra blank fields at the end of segments, etc) parsedMessage = parser.parse(text); text = parser.encode(parsedMessage); } catch (EncodingNotSupportedException e) { throw new PropertyVetoException(e.getMessage(), null); } catch (HL7Exception e) { throw new PropertyVetoException(e.getMessage(), null); } sourceMessage = text.replaceAll("\\r", "\r\n"); myParsedMessage = parsedMessage; myText = text; mySourceMessage = sourceMessage; firePropertyChange(SOURCE_MESSAGE_PROPERTY, original, text); }
From source file:ca.uhn.hunit.event.AbstractEvent.java
public void setInterfaceId(String theInterfaceId) throws PropertyVetoException { AbstractInterface newInterface;/* w w w . j av a 2s . c om*/ try { newInterface = getBattery().getInterface(theInterfaceId); } catch (ConfigurationException ex) { throw new PropertyVetoException(ex.getMessage(), null); } String oldValue = myInterface.getId(); fireVetoableChange(INTERFACE_ID_PROPERTY, oldValue, theInterfaceId); this.myInterface = newInterface; firePropertyChange(INTERFACE_ID_PROPERTY, oldValue, theInterfaceId); }
From source file:gda.gui.text.parameter.EpicsPanelParameterListener.java
/** * @param e// ww w .ja v a2 s .co m * @throws PropertyVetoException */ public void vetoableChangeinNewThread(PropertyChangeEvent e) throws PropertyVetoException { Object source = e.getSource(); if (source == null) throw new IllegalArgumentException("ParametersPanelListener.propertyChange - source == null "); if (source instanceof ParametersPanelBuilder.ParameterChangeEventSource) { Object newObject = e.getNewValue(); if ((newObject == null) || !(newObject instanceof Double)) { throw new IllegalArgumentException( "ParametersPanelListener.propertyChange - (newObject == null ) || !(newObject instanceof Limited) "); } if (epicsChannel != null) { try { Double newVal = (Double) newObject; if (converter != null) newVal = converter.convertValue(newVal); if (lastSuccessfullySentValue == null || (lastSuccessfullySentValue.compareTo(newVal) != 0)) { epicsChannel.setValue(newVal); lastSuccessfullySentValue = newVal; } } catch (DeviceException expt) { logger.error(expt.getMessage()); throw new PropertyVetoException(expt.getMessage(), e); } } else { throw new IllegalArgumentException("EpicsPanelParameterListener: epicsChannel == null"); } } }
From source file:InternalFrameTest.java
/** * Creates an internal frame on the desktop. * @param c the component to display in the internal frame * @param t the title of the internal frame. *//*from w w w .jav a 2 s. c o m*/ public void createInternalFrame(Component c, String t) { final JInternalFrame iframe = new JInternalFrame(t, true, // resizable true, // closable true, // maximizable true); // iconifiable iframe.add(c, BorderLayout.CENTER); desktop.add(iframe); iframe.setFrameIcon(new ImageIcon("document.gif")); // add listener to confirm frame closing iframe.addVetoableChangeListener(new VetoableChangeListener() { public void vetoableChange(PropertyChangeEvent event) throws PropertyVetoException { String name = event.getPropertyName(); Object value = event.getNewValue(); // we only want to check attempts to close a frame if (name.equals("closed") && value.equals(true)) { // ask user if it is ok to close int result = JOptionPane.showInternalConfirmDialog(iframe, "OK to close?", "Select an Option", JOptionPane.YES_NO_OPTION); // if the user doesn't agree, veto the close if (result != JOptionPane.YES_OPTION) throw new PropertyVetoException("User canceled close", event); } } }); // position frame int width = desktop.getWidth() / 2; int height = desktop.getHeight() / 2; iframe.reshape(nextFrameX, nextFrameY, width, height); iframe.show(); // select the frame--might be vetoed try { iframe.setSelected(true); } catch (PropertyVetoException e) { } frameDistance = iframe.getHeight() - iframe.getContentPane().getHeight(); // compute placement for next frame nextFrameX += frameDistance; nextFrameY += frameDistance; if (nextFrameX + width > desktop.getWidth()) nextFrameX = 0; if (nextFrameY + height > desktop.getHeight()) nextFrameY = 0; }
From source file:ca.uhn.hunit.iface.AbstractInterface.java
public void setId(String theId) throws PropertyVetoException { if (StringUtils.equals(theId, myId)) { return;// w w w.j av a2s. co m } if (StringUtils.isEmpty(theId)) { throw new PropertyVetoException(Strings.getInstance().getString("interface.id.empty"), null); } if (myBattery.getInterfaceIds().contains(theId)) { throw new PropertyVetoException(Strings.getInstance().getString("interface.id.duplicate"), null); } String oldValue = myId; firePropertyChange(INTERFACE_ID_PROPERTY, oldValue, theId); myId = theId; }