Example usage for java.beans PropertyChangeEvent getOldValue

List of usage examples for java.beans PropertyChangeEvent getOldValue

Introduction

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

Prototype

public Object getOldValue() 

Source Link

Document

Gets the old value for the property, expressed as an Object.

Usage

From source file:org.squidy.designer.zoom.ActionShape.java

@Override
public void initialize() {
    super.initialize();

    if (getProcessable() != null) {
        // Add property change listener that allows to start valve
        // processing this way.
        getProcessable().addStatusChangeListener(Processable.PROPERTY_PROCESSING, new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent evt) {
                firePropertyChange(0, Processable.PROPERTY_PROCESSING, evt.getOldValue(), evt.getNewValue());
            }/* www  . ja  v a  2 s.com*/
        });

        getProcessable().addStatusChangeListener(Processable.STATUS_PROCESSABLE_DELETED,
                new PropertyChangeListener() {

                    public void propertyChange(PropertyChangeEvent evt) {
                        if (Pipe.class.isAssignableFrom(evt.getOldValue().getClass()))
                            return;
                        removeFromParent();
                    }
                });

        getProcessable().addStatusChangeListener(Processable.PROPERTY_FAILURE_PUBLISH,
                new PropertyChangeListener() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see
                     * java.beans.PropertyChangeListener#propertyChange(
                     * java.beans.PropertyChangeEvent)
                     */
                    public void propertyChange(PropertyChangeEvent evt) {
                        Throwable e = (Throwable) evt.getNewValue();
                        publishFailure(e);
                    }
                });

        getProcessable().addStatusChangeListener(Processable.PROPERTY_FAILURE_RESOLVE,
                new PropertyChangeListener() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see
                     * java.beans.PropertyChangeListener#propertyChange(
                     * java.beans.PropertyChangeEvent)
                     */
                    public void propertyChange(PropertyChangeEvent evt) {
                        resolveFailure();

                        // for (Object o : getChildrenReference()) {
                        // if (o instanceof ZoomActionShape) {
                        // ((ZoomActionShape<?>) o).resolveFailure();
                        // }
                        // }
                    }
                });

        getProcessable().addStatusChangeListener(Processable.PROPERTY_NOTIFICATION,
                new PropertyChangeListener() {

                    /*
                     * (non-Javadoc)
                     * 
                     * @see
                     * java.beans.PropertyChangeListener#propertyChange(
                     * java.beans.PropertyChangeEvent)
                     */
                    public void propertyChange(PropertyChangeEvent evt) {
                        publishNotification(new TemporaryNotification(evt.getNewValue().toString()));
                    }
                });
    }
}

From source file:com.github.fritaly.dualcommander.DualCommander.java

@Override
public void propertyChange(PropertyChangeEvent e) {
    if (e.getSource() == preferences) {
        if (logger.isDebugEnabled()) {
            logger.debug(String.format("User preference '%s' changed: '%s' -> '%s'", e.getPropertyName(),
                    e.getOldValue(), e.getNewValue()));
        }//  ww w.  j  a v  a  2 s. co  m

        // The 'show hidden' property changed, need to refresh the active
        // directory browsers
        // TODO Set a flag for the inactive directory browsers to refresh
        // when they get the focus
        this.leftPane.getActiveBrowser().refresh();
        this.rightPane.getActiveBrowser().refresh();
    }
}

From source file:ca.sqlpower.sqlobject.SQLDatabase.java

/**
 * Listens for changes in DBCS properties, and resets this
 * SQLDatabase if a critical property (url, driver, username)
 * changes./* w ww . j a va  2  s.  com*/
 */
public void propertyChange(PropertyChangeEvent e) {
    String pn = e.getPropertyName();
    if ((e.getOldValue() == null && e.getNewValue() != null)
            || (e.getOldValue() != null && e.getNewValue() == null) || (e.getOldValue() != null
                    && e.getNewValue() != null && !e.getOldValue().equals(e.getNewValue()))) {
        if ("url".equals(pn) || "driverClass".equals(pn) || "user".equals(pn)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            reset();
        } else if ("name".equals(pn)) { //$NON-NLS-1$
            firePropertyChange("shortDisplayName", e.getOldValue(), e.getNewValue()); //$NON-NLS-1$
        }
    }
}

From source file:com.haulmont.cuba.web.toolkit.ui.CubaSideMenu.java

@SuppressWarnings("unchecked")
protected void menuItemPropertyChanged(PropertyChangeEvent event) {
    if (event.getPropertyName() == null) {
        return;/*from w  ww .  j  av a2 s  .c  o m*/
    }

    if (!structureChanged && MENU_ITEM_BADGE_TEXT.equals(event.getPropertyName())) {
        badgeUpdates.add((MenuItem) event.getSource());
        markAsDirty();
    }

    if (MENU_ITEM_CHILDREN.equals(event.getPropertyName())) {
        List<MenuItem> oldItems = (List<MenuItem>) event.getOldValue();
        List<MenuItem> newItems = (List<MenuItem>) event.getNewValue();

        if (oldItems != null) {
            for (MenuItem oldItem : oldItems) {
                oldItem.removePropertyChangeListener(itemsPropertyChangeListener);
            }
        }
        if (newItems != null) {
            for (MenuItem newItem : newItems) {
                newItem.addPropertyChangeListener(itemsPropertyChangeListener);
            }
        }
    }

    switch (event.getPropertyName()) {
    case MENU_ITEM_CAPTION:
    case MENU_ITEM_DESCRIPTION:
    case MENU_ITEM_ICON:
    case MENU_ITEM_CHILDREN:
    case MENU_ITEM_STYLE_NAME:
    case MENU_ITEM_VISIBLE:
    case MENU_ITEM_ENABLED:
    case MENU_ITEM_CAPTION_AS_HTML:
    case MENU_ITEM_CUBA_ID:
    case MENU_ITEM_EXPANDED:
        markMenuStructureAsDirty();
        break;
    }
}

From source file:ca.sqlpower.dao.SPPersisterListener.java

public void propertyChanged(PropertyChangeEvent evt) {
    SPObject source = (SPObject) evt.getSource();
    String uuid = source.getUUID();
    String propertyName = evt.getPropertyName();
    Object oldValue = evt.getOldValue();
    Object newValue = evt.getNewValue();

    try {//from w  w w. j  a  v a  2  s .  co  m
        if (!PersisterHelperFinder.findPersister(source.getClass()).getPersistedProperties()
                .contains(propertyName)) {
            logger.debug(
                    "Tried to persist a property that shouldn't be. Ignoring the property: " + propertyName);
            return;
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    if (!((SPObject) evt.getSource()).getRunnableDispatcher().isForegroundThread()) {
        throw new RuntimeException("Property change " + evt + " not fired on the foreground.");
    }

    Object oldBasicType = converter.convertToBasicType(oldValue);
    Object newBasicType = converter.convertToBasicType(newValue);

    PersistedSPOProperty property = null;
    for (PersistedSPOProperty p : persistedProperties.get(uuid)) {
        if (p.getPropertyName().equals(propertyName)) {
            property = p;
            break;
        }
    }
    if (property != null) {
        boolean valuesMatch;
        if (property.getNewValue() == null) {
            valuesMatch = oldBasicType == null;
        } else {
            // Check that the old property's new value is equal to the new change's old value.
            // Also, accept the change if it is the same as the last one.
            valuesMatch = property.getNewValue().equals(oldBasicType)
                    || (property.getOldValue().equals(oldBasicType)
                            && property.getNewValue().equals(newBasicType));
        }
        if (!valuesMatch) {
            try {
                throw new RuntimeException("Multiple property changes do not follow after each other properly. "
                        + "Property " + property.getPropertyName() + ", on object " + source + " of type "
                        + source.getClass() + ", Old " + oldBasicType + ", new " + property.getNewValue());
            } finally {
                this.rollback();
            }
        }
    }

    if (wouldEcho()) {
        //The persisted property was changed by a persist call received from the server.
        //The property is removed from the persist calls as it now matchs what is
        //in the server.
        persistedProperties.remove(uuid, property);
        return;
    }

    transactionStarted(TransactionEvent.createStartTransactionEvent(this,
            "Creating start transaction event from propertyChange on object "
                    + evt.getSource().getClass().getSimpleName() + " and property name "
                    + evt.getPropertyName()));

    //Not persisting non-settable properties.
    //TODO A method in the persister helpers would make more sense than
    //using reflection here.
    PropertyDescriptor propertyDescriptor;
    try {
        propertyDescriptor = PropertyUtils.getPropertyDescriptor(source, propertyName);
    } catch (Exception ex) {
        this.rollback();
        throw new RuntimeException(ex);
    }

    if (propertyDescriptor == null || propertyDescriptor.getWriteMethod() == null) {
        transactionEnded(TransactionEvent.createEndTransactionEvent(this));
        return;
    }

    DataType typeForClass = PersisterUtils.getDataType(newValue == null ? Void.class : newValue.getClass());

    boolean unconditional = false;
    if (property != null) {
        // Hang on to the old value
        oldBasicType = property.getOldValue();
        // If an object was created, and unconditional properties are being sent,
        // this will maintain that flag in the event of additional property changes
        // to the same property in the same transaction.
        unconditional = property.isUnconditional();
        persistedProperties.remove(uuid, property);
    }
    logger.debug("persistProperty(" + uuid + ", " + propertyName + ", " + typeForClass.name() + ", " + oldValue
            + ", " + newValue + ")");
    persistedProperties.put(uuid, new PersistedSPOProperty(uuid, propertyName, typeForClass, oldBasicType,
            newBasicType, unconditional));

    this.transactionEnded(TransactionEvent.createEndTransactionEvent(this));
}

From source file:com.googlecode.vfsjfilechooser2.plaf.basic.BasicVFSDirectoryModel.java

/**
 *
 * @param e//w  ww  . j ava  2 s  .c o m
 */
public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if ((prop.equals(VFSJFileChooserConstants.DIRECTORY_CHANGED_PROPERTY))
            || (prop.equals(VFSJFileChooserConstants.FILE_VIEW_CHANGED_PROPERTY))
            || (prop.equals(VFSJFileChooserConstants.FILE_FILTER_CHANGED_PROPERTY))
            || (prop.equals(VFSJFileChooserConstants.FILE_HIDING_CHANGED_PROPERTY))
            || (prop.equals(VFSJFileChooserConstants.FILE_SELECTION_MODE_CHANGED_PROPERTY))) {
        validateFileCache();
    } else if ("UI".equals(prop)) {
        Object old = e.getOldValue();

        if (old instanceof BasicVFSFileChooserUI) {
            BasicVFSFileChooserUI ui = (BasicVFSFileChooserUI) old;
            BasicVFSDirectoryModel model = ui.getModel();

            if (model != null) {
                model.invalidateFileCache();
            }
        }
    } else if ("JFileChooserDialogIsClosingProperty".equals(prop)) {
        invalidateFileCache();
    }
}

From source file:org.jitsi.android.gui.call.VideoCallActivity.java

/**
 * Invoked by {@link #callConferenceListener} to notify this instance about
 * an <tt>EventObject</tt> related to the <tt>CallConference</tt> depicted
 * by this <tt>CallPanel</tt>, the <tt>Call</tt>s participating in it,
 * the <tt>CallPeer</tt>s associated with them, the
 * <tt>ConferenceMember</tt>s participating in any telephony conferences
 * organized by them, etc. In other words, notifies this instance about
 * any change which may cause an update to be required so that this view
 * i.e. <tt>CallPanel</tt> depicts the current state of its model i.e.
 * {@link #callConference}.//  w ww.j av a  2s  .  com
 *
 * @param ev the <tt>EventObject</tt> this instance is being notified
 * about.
 */
private void onCallConferenceEventObject(EventObject ev) {
    /*
     * The main task is to invoke updateViewFromModel() in order to make
     * sure that this view depicts the current state of its model.
     */

    try {
        /*
         * However, we seem to be keeping track of the duration of the call
         * (i.e. the telephony conference) in the user interface. Stop the
         * Timer which ticks the duration of the call as soon as the
         * telephony conference depicted by this instance appears to have
         * ended. The situation will very likely occur when a Call is
         * removed from the telephony conference or a CallPeer is removed
         * from a Call.
         */
        boolean tryStopCallTimer = false;

        if (ev instanceof CallPeerEvent) {
            tryStopCallTimer = (CallPeerEvent.CALL_PEER_REMOVED == ((CallPeerEvent) ev).getEventID());
        } else if (ev instanceof PropertyChangeEvent) {
            PropertyChangeEvent pcev = (PropertyChangeEvent) ev;

            tryStopCallTimer = (CallConference.CALLS.equals(pcev) && (pcev.getOldValue() instanceof Call)
                    && (pcev.getNewValue() == null));
        }

        if (tryStopCallTimer && (callConference.isEnded() || callConference.getCallPeerCount() == 0)) {
            stopCallTimer();
            doFinishActivity();
        }
    } finally {
        updateViewFromModel(ev);
    }
}

From source file:org.datavyu.controllers.component.MixerController.java

@Override
public void propertyChange(final PropertyChangeEvent evt) {

    if (evt.getSource() == mixerModel.getViewportModel()) {
        final ViewportState oldViewport = (evt.getOldValue() instanceof ViewportState)
                ? (ViewportState) evt.getOldValue()
                : null;//from www.  j  a  va 2  s . c o m
        final ViewportState newViewport = (evt.getNewValue() instanceof ViewportState)
                ? (ViewportState) evt.getNewValue()
                : null;
        handleViewportChanged(oldViewport, newViewport);
    }
}

From source file:net.sourceforge.vulcan.core.support.StateManagerImpl.java

public void start() throws StoreException {
    try {//ww w  .  j av a 2s  .com
        writeLock.lock();

        config = configurationStore.loadConfiguration();

        applyPluginConfigurations();

        final BuildManagerConfigDto buildManagerConfig = config.getBuildManagerConfig();

        buildManagerConfig.addPropertyChangeListener("enabled", new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                final Object newValue = evt.getNewValue();
                if (!evt.getOldValue().equals(newValue)) {
                    if (Boolean.TRUE.equals(newValue)) {
                        startSchedulers();
                    } else {
                        stopSchedulers();
                    }
                }
            }
        });
        buildManager.init(buildManagerConfig);

        running = true;

        if (buildManagerConfig.isEnabled()) {
            startSchedulers();
        }

        startBuildDaemons();

        eventHandler.reportEvent(new InfoEvent(this, "messages.startup"));
    } finally {
        writeLock.unlock();
    }
}

From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java

private void doAccessoryChanged(PropertyChangeEvent e) {
    if (getAccessoryPanel() != null) {
        if (e.getOldValue() != null) {
            getAccessoryPanel().remove((JComponent) e.getOldValue());
        }//w  w w.  j a  va 2s.com

        JComponent accessory = (JComponent) e.getNewValue();

        if (accessory != null) {
            getAccessoryPanel().add(accessory, BorderLayout.CENTER);
        }
    }
}