List of usage examples for java.beans PropertyChangeEvent getOldValue
public Object getOldValue()
From source file:org.eclipse.php.composer.api.entities.AbstractJsonObject.java
private void installListener(final String property, JsonEntity entity) { if (entity != null) { listeners.put(property, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { firePropertyChange(property + "." + evt.getPropertyName(), evt.getOldValue(), //$NON-NLS-1$ evt.getNewValue()); }/* ww w .j a v a 2s.c o m*/ }); entity.addPropertyChangeListener(listeners.get(property)); } }
From source file:de.bstreit.java.springaop.test.observablebean.PropertyChangeSupportTest.java
private void checkPropChangeEvent(final String fieldName, final Object oldValue, Object newValue) { final PropertyChangeEvent propChangeEvent = propChangeEvents.get(propChangeEventIdx++); assertEquals(fieldName, propChangeEvent.getPropertyName()); assertEquals(oldValue, propChangeEvent.getOldValue()); assertEquals(newValue, propChangeEvent.getNewValue()); }
From source file:org.jcurl.core.helpers.PropertyChangeSupport.java
/** * Fire a property change event to all of the listeners. * <p>/*from w w w .j a va2 s .co m*/ * This method is called by all the fire methods to perform the firing of * the events. * </p> * <p> * The firing will go to the listeners that are registered for the specific * property as well as general purpose listeners. * </p> * <p> * If the old and new values for the event are the same, by the * <tt>equals()</tt> method, the event will not be fired. * </p> * * @param event * The event to fire to the listeners. */ public void firePropertyChange(final PropertyChangeEvent event) { validateNamedProperty(event.getPropertyName()); { final Object a = event.getOldValue(); final Object b = event.getNewValue(); if (a != null && a.equals(b) || a == null && b == null) return; } // if (event.getOldValue() == null) { // if (event.getOldValue() == null) { // return; // } // } else if (event.getOldValue().equals(event.getNewValue())) { // 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:org.opencastproject.staticfiles.impl.StaticFileServiceImpl.java
@Override public String storeFile(String filename, InputStream inputStream) throws IOException { notNull(filename, "filename"); notNull(inputStream, "inputStream"); final String uuid = UUID.randomUUID().toString(); final String org = securityService.getOrganization().getId(); Path file = getTemporaryStorageDir(org).resolve(Paths.get(uuid, filename)); try (ProgressInputStream progressInputStream = new ProgressInputStream(inputStream)) { progressInputStream.addPropertyChangeListener(new PropertyChangeListener() { @Override//from w ww.jav a 2s . c o m public void propertyChange(PropertyChangeEvent evt) { long totalNumBytesRead = (Long) evt.getNewValue(); long oldTotalNumBytesRead = (Long) evt.getOldValue(); staticFileStatistics.add(totalNumBytesRead - oldTotalNumBytesRead); } }); Files.createDirectories(file.getParent()); Files.copy(progressInputStream, file); } catch (IOException e) { logger.error("Unable to save file '{}' to {} because: {}", new Object[] { filename, file, ExceptionUtils.getStackTrace(e) }); throw e; } return uuid; }
From source file:de.fhg.fokus.hss.model.Impu.java
/** * Method to change property// w w w . j a v a2s . c o m * @param evt Property change event */ public void propertyChange(PropertyChangeEvent evt) { super.propertyChange(evt); if (evt.getPropertyName().equals("userStatus") && (evt.getOldValue() != null)) { changeUserState = true; if ((evt.getNewValue().equals(USER_STATUS_NOT_REGISTERED)) && (evt.getOldValue() != null)) { deregistered = true; } } else if (evt.getPropertyName().equals("svp") && (evt.getOldValue() != null)) { this.changedSVP = true; } else if (evt.getPropertyName().equals("barringIndication") && (evt.getOldValue() != null)) { this.changedBarring = true; } }
From source file:de.fhg.igd.swingrcp.ActionAdapter.java
/** * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) *//* w w w . j a v a 2 s. c o m*/ @Override public void propertyChange(final PropertyChangeEvent evt) { // propagate property change event // -> enabled if (evt.getPropertyName().equals("enabled")) display.asyncExec(new Runnable() { @Override public void run() { firePropertyChange(Action.ENABLED, evt.getOldValue(), evt.getNewValue()); } }); }
From source file:EnrollFingerprint.Verify.java
/** * Creates new form Enroll//ww w . ja v a2 s .c om */ public Verify() { initComponents(); //updateStatus(); // Event listener actived when fingerprint template is ready this.addPropertyChangeListener(TEMPLATE_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getNewValue() == evt.getOldValue()) { return; } if (template != null) { JOptionPane.showMessageDialog(Verify.this, "La huella capturada esta lista para ser guardada.", "Captura y Registro de huellas", JOptionPane.INFORMATION_MESSAGE); } } }); }
From source file:de.fhg.fokus.hss.model.Impi.java
/** * Method to change property/*from ww w.j a va 2 s . c o m*/ * @param evt Property change event */ public void propertyChange(PropertyChangeEvent evt) { super.propertyChange(evt); if ((evt.getPropertyName().equals("scscfName")) && (evt.getOldValue() != null)) { this.changeScscfName = true; } }
From source file:fi.elfcloud.client.dialog.UploadDialog.java
@Override public void propertyChange(PropertyChangeEvent evt) { int value;/*from w ww .j a v a 2s . c o m*/ if ("totalNumBytesRead" == evt.getPropertyName()) { //$NON-NLS-1$ task.progress += (Long) evt.getNewValue() - (Long) evt.getOldValue(); value = (int) ((task.progress.doubleValue() / task.totalLength.doubleValue()) * 100); progressBar.setValue(value); setTitle(Messages.getString("UploadDialog.window_title_uploading_1") + task.filesSent //$NON-NLS-1$ + Messages.getString("UploadDialog.window_title_uploading_2") + task.fileCount + " - " //$NON-NLS-1$//$NON-NLS-2$ + Integer.toString(value) + "%"); //$NON-NLS-1$ } if ("progress" == evt.getPropertyName()) { //$NON-NLS-1$ int progress = (Integer) evt.getNewValue(); progressBar.setValue(progress); setTitle(Messages.getString("UploadDialog.window_title_uploading_1") + task.filesSent //$NON-NLS-1$ + Messages.getString("UploadDialog.window_title_uploading_2") + task.fileCount + " - " //$NON-NLS-1$//$NON-NLS-2$ + Integer.toString(progress) + "%"); //$NON-NLS-1$ } }
From source file:EnrollFingerprint.Enroll.java
/** * Creates new form Enroll//from w w w. j a v a2 s. c om */ public Enroll() { initComponents(); updateStatus(); // Event listener actived when fingerprint template is ready this.addPropertyChangeListener(TEMPLATE_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { btnSave.setEnabled(template != null); if (evt.getNewValue() == evt.getOldValue()) { return; } if (template != null) { JOptionPane.showMessageDialog(Enroll.this, "La huella capturada esta lista para ser guardada.", "Captura y Registro de huellas", JOptionPane.INFORMATION_MESSAGE); } } }); }