List of usage examples for java.beans PropertyChangeEvent getOldValue
public Object getOldValue()
From source file:org.springframework.beans.AbstractVetoableChangeListener.java
/** * Implementation of VetoableChangeListener. * Will attempt to locate the appropriate validator method and invoke it. * Will do nothing if there is no validation method for this property. *//*from w ww. ja v a 2 s . com*/ public final void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException { if (logger.isDebugEnabled()) logger.debug( "VetoableChangeEvent: old value=[" + e.getOldValue() + "] new value=[" + e.getNewValue() + "]"); Method method = (Method) validationMethodHash.get(e.getPropertyName()); if (method != null) { try { logger.debug("Using validator method: " + method); Object val = e.getNewValue(); method.invoke(this, new Object[] { val, e }); } catch (IllegalAccessException ex) { logger.warn("Can't validate: Method isn't accessible"); } catch (InvocationTargetException ex) { // This is what we're looking for: the subclass's // validator method vetoed the property change event // We know that the exception must be of the correct type (unless // it's a runtime exception) as we checked the declared exceptions of the // validator method in this class's constructor. // If it IS a runtime exception, we just rethrow it, to encourage the // author of the subclass to write robust code... if (ex.getTargetException() instanceof RuntimeException) throw (RuntimeException) ex.getTargetException(); PropertyVetoException pex = (PropertyVetoException) ex.getTargetException(); throw pex; } } // if there was a validator method for this property else { logger.debug("No validation method for property: " + e.getPropertyName()); } }
From source file:org.jcurl.demo.tactics.CurlerSwingBean.java
public void propertyChange(final PropertyChangeEvent evt) { log.warn("Unconsumed event '" + evt.getPropertyName() + "' from " + evt.getSource().getClass().getName() + ": " + evt.getOldValue() + " -> " + evt.getNewValue()); }
From source file:net.sf.maltcms.chromaui.project.spi.nodes.DescriptorNode.java
@Override public void propertyChange(PropertyChangeEvent pce) { if (pce.getPropertyName().equals(PROP_NAME) || pce.getPropertyName().equals(IDescriptor.PROP_NAME)) { fireNameChange((String) pce.getOldValue(), (String) pce.getNewValue()); }//from w ww. ja v a 2 s . c o m if (pce.getPropertyName().equals(PROP_DISPLAY_NAME) || pce.getPropertyName().equals(IDescriptor.PROP_DISPLAYNAME)) { fireDisplayNameChange((String) pce.getOldValue(), (String) pce.getNewValue()); } if (pce.getPropertyName().equals(PROP_SHORT_DESCRIPTION) || pce.getPropertyName().equals(IDescriptor.PROP_SHORTDESCRIPTION)) { fireShortDescriptionChange((String) pce.getOldValue(), (String) pce.getNewValue()); } if (pce.getPropertyName().equals(PROP_ICON)) { fireIconChange(); } if (pce.getPropertyName().equals(PROP_OPENED_ICON)) { fireOpenedIconChange(); } if (pce.getPropertyName().equals(IColorizableDescriptor.PROP_COLOR)) { fireIconChange(); fireOpenedIconChange(); } }
From source file:joachimeichborn.geotag.model.Geocoding.java
@Override public void propertyChange(final PropertyChangeEvent aEvent) { propertyChangeSupport.firePropertyChange(aEvent.getPropertyName(), aEvent.getOldValue(), aEvent.getNewValue());// www. j ava2s . c o m }
From source file:org.eclipse.php.composer.api.entities.JsonEntity.java
protected void listen() { try {/*from www. ja va 2 s .c o m*/ for (Field field : getFields(this.getClass())) { if (JsonCollection.class.isAssignableFrom(field.getType())) { final String prop = getFieldName(field); final JsonEntity sender = this; if (listening.contains(prop)) { continue; } field.setAccessible(true); JsonEntity obj = (JsonEntity) field.get(this); if (obj != null) { obj.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { firePropertyChange(prop + "." + e.getPropertyName(), e.getOldValue(), //$NON-NLS-1$ e.getNewValue()); // append to sort order - use reflection if (sender instanceof AbstractJsonObject) { try { Method mtd = JsonEntity.class.getDeclaredMethod("appendSortOrder", //$NON-NLS-1$ String.class); mtd.setAccessible(true); mtd.invoke(sender, prop); } catch (Exception e1) { e1.printStackTrace(); } } } }); listening.add(prop); } } } } catch (Exception e) { log.error(e); } }
From source file:de.unentscheidbar.validation.swing.trigger.DocumentChangeTrigger.java
@Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() instanceof JComponent) { JComponent src = (JComponent) evt.getSource(); forgetDocument((Document) evt.getOldValue(), src); observeDocument(src);//from ww w .ja v a2s. co m } else { /* JComponent correctly reports itself as the event source, so this should never happen */ throw new IllegalStateException("Received a PropertyChangeEvent with unexpected source type: " + ClassUtils.getSimpleName(evt.getSource(), "NULL")); } }
From source file:mulavito.gui.components.LayerDataPanel.java
public LayerDataPanel(FloatingTabbedPane owner) { super("Layer Data", owner); textArea = new JTextArea(defaultText); textArea.setEditable(false);//from ww w. j a va 2s .co m textArea.setCaretPosition(0); // Scroll up the text area. JScrollPane textPane = new JScrollPane(textArea); add(textPane, BorderLayout.CENTER); // updates the data mouseListener = new MouseAdapter() { @SuppressWarnings("unchecked") @Override public void mouseEntered(MouseEvent e) { if (e.getSource() instanceof LayerViewer<?, ?>) { LayerViewer<V, E> vv = (LayerViewer<V, E>) e.getSource(); showData(vv.getLayer()); } } @Override public void mouseExited(MouseEvent e) { showData(null); } }; // adds/removes focus listeners on layers graphPanelListener = new PropertyChangeListener() { @SuppressWarnings("unchecked") @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("Viewers")) { if (evt.getOldValue() instanceof LayerViewer<?, ?> && evt.getNewValue() == null) { // GraphPanel#removeLayer ((LayerViewer<?, ?>) evt.getOldValue()).removeMouseListener(mouseListener); } else if (evt.getOldValue() instanceof List<?>) { System.out.println("Replace"); for (LayerViewer<?, ?> vv : ((List<LayerViewer<?, ?>>) evt.getOldValue())) vv.removeMouseListener(mouseListener); } if (evt.getNewValue() instanceof LayerViewer<?, ?> && evt.getOldValue() == null) { // GraphPanel#addLayer ((LayerViewer<?, ?>) evt.getNewValue()).addMouseListener(mouseListener); } else if (evt.getNewValue() instanceof List<?>) { // New Layer List on start up for (LayerViewer<?, ?> vv : ((List<LayerViewer<?, ?>>) evt.getNewValue())) vv.addMouseListener(mouseListener); } showData(current); } } }; }
From source file:org.jcurl.core.api.PropertyChangeSupport.java
public void firePropertyChange(final PropertyChangeEvent event) { // log.debug(event); validateNamedProperty(event.getPropertyName()); {/*from ww w . j av a2 s. c o m*/ final Object a = event.getOldValue(); final Object b = event.getNewValue(); if (a != null && a.equals(b) || a == null && b == null) return; } // validated that an event must be thrown; now throw it. synchronized (listenerMap) { // First gets the list of listeners and stores them in strong // references by copying them into a new set. final Set<PropertyChangeListener> targets = new HashSet<PropertyChangeListener>( listenerMap.get(ALL_PROPERTIES)); targets.addAll(listenerMap.get(event.getPropertyName())); for (final PropertyChangeListener element : targets) element.propertyChange(event); } }
From source file:wsattacker.sso.openid.attacker.server.OpenIdServer.java
@Override public void propertyChange(PropertyChangeEvent pce) { String propertyName = pce.getPropertyName(); Object newValue = pce.getNewValue(); Object oldValue = pce.getOldValue(); switch (propertyName) { case OpenIdServerConfiguration.PROP_HTMLCONFIGURATION: HtmlDiscoveryConfiguration oldHtmlConfig = (HtmlDiscoveryConfiguration) oldValue; HtmlDiscoveryConfiguration newHtmlConfig = (HtmlDiscoveryConfiguration) newValue; LOG.info("Changed HTML Discovery Configuration"); oldHtmlConfig.removePropertyChangeListener(this); newHtmlConfig.addPropertyChangeListener(this); processor.setHtmlConfiguration(newHtmlConfig); break;/* ww w . ja va2 s.co m*/ case OpenIdServerConfiguration.PROP_XRDSCONFIGURATION: XrdsConfiguration oldConfig = (XrdsConfiguration) oldValue; XrdsConfiguration newConfig = (XrdsConfiguration) newValue; LOG.info("Changed XRDS Configuration"); oldConfig.removePropertyChangeListener(this); newConfig.addPropertyChangeListener(this); processor.setXrdsConfiguration(newConfig); processor.setEndpoint(newConfig.getBaseUrl()); break; case XrdsConfiguration.PROP_BASEURL: LOG.info(String.format("Changed Endpoint URI from '%s' to '%s'", oldValue, newValue)); processor.setEndpoint((String) pce.getNewValue()); break; case OpenIdServerConfiguration.PROP_ASSOCIATIONEXPIRATIONINSECONDS: LOG.info(String.format("Changed Association expiration time from %ss to %ss", oldValue, newValue)); processor.setExpiresIn((int) pce.getNewValue()); break; case OpenIdServerConfiguration.PROP_VALIDUSER: LOG.info("Changed valid user!"); processor.setValidUser((User) newValue); break; case OpenIdServerConfiguration.PROP_ASSOCIATIONPREFIX: LOG.info(String.format("Association Prefix changed from '%s' to '%s'", oldValue, newValue)); store.setAssociationPrefix((String) newValue); break; default: break; } }
From source file:org.cubictest.ui.sections.ParameterisationSection.java
public void propertyChange(PropertyChangeEvent event) { if (event.getOldValue() instanceof ParameterList) { ((ParameterList) event.getOldValue()).removePropertyChangeListener(this); }//from www . j a va 2s . c om if (event.getNewValue() instanceof ParameterList) { ((ParameterList) event.getNewValue()).removePropertyChangeListener(this); } refresh(); }