Search in sources :

Example 1 with OverridingMethodsMustInvokeSuper

use of javax.annotation.OverridingMethodsMustInvokeSuper in project JMRI by JMRI.

the class AbstractNamedBean method dispose.

@Override
@OverridingMethodsMustInvokeSuper
public void dispose() {
    PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
    for (PropertyChangeListener l : listeners) {
        pcs.removePropertyChangeListener(l);
        register.remove(l);
        listenerRefs.remove(l);
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper)

Example 2 with OverridingMethodsMustInvokeSuper

use of javax.annotation.OverridingMethodsMustInvokeSuper in project JMRI by JMRI.

the class AbstractManager method vetoableChange.

@Override
@OverridingMethodsMustInvokeSuper
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
    if ("CanDelete".equals(evt.getPropertyName())) {
        //IN18N
        StringBuilder message = new StringBuilder();
        message.append(Bundle.getMessage("VetoFoundIn", getBeanTypeHandled())).append("<ul>");
        boolean found = false;
        for (NamedBean nb : _tsys.values()) {
            try {
                nb.vetoableChange(evt);
            } catch (PropertyVetoException e) {
                if (e.getPropertyChangeEvent().getPropertyName().equals("DoNotDelete")) {
                    //IN18N
                    throw e;
                }
                found = true;
                message.append("<li>").append(e.getMessage()).append("</li>");
            }
        }
        message.append("</ul>").append(Bundle.getMessage("VetoWillBeRemovedFrom", getBeanTypeHandled()));
        if (found) {
            throw new PropertyVetoException(message.toString(), evt);
        }
    } else {
        for (NamedBean nb : _tsys.values()) {
            try {
                nb.vetoableChange(evt);
            } catch (PropertyVetoException e) {
                throw e;
            }
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) NamedBean(jmri.NamedBean) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper)

Example 3 with OverridingMethodsMustInvokeSuper

use of javax.annotation.OverridingMethodsMustInvokeSuper in project JMRI by JMRI.

the class AbstractManager method registerSelf.

/**
     * By default, register this manager to store as configuration information.
     * Override to change that.
     *
     */
@OverridingMethodsMustInvokeSuper
protected void registerSelf() {
    log.debug("registerSelf for config of type {}", getClass());
    ConfigureManager cm = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
    if (cm != null) {
        cm.registerConfig(this, getXMLOrder());
        log.debug("registering for config of type {}", getClass());
    }
}
Also used : ConfigureManager(jmri.ConfigureManager) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper)

Example 4 with OverridingMethodsMustInvokeSuper

use of javax.annotation.OverridingMethodsMustInvokeSuper in project JMRI by JMRI.

the class AbstractManager method dispose.

@Override
@OverridingMethodsMustInvokeSuper
public void dispose() {
    ConfigureManager cm = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
    if (cm != null) {
        cm.deregister(this);
    }
    _tsys.clear();
    _tuser.clear();
}
Also used : ConfigureManager(jmri.ConfigureManager) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper)

Example 5 with OverridingMethodsMustInvokeSuper

use of javax.annotation.OverridingMethodsMustInvokeSuper in project JMRI by JMRI.

the class AbstractManager method propertyChange.

/**
     * The PropertyChangeListener interface in this class is intended to keep
     * track of user name changes to individual NamedBeans. It is not completely
     * implemented yet. In particular, listeners are not added to newly
     * registered objects.
     *
     * @param e the event
     */
@Override
@OverridingMethodsMustInvokeSuper
public void propertyChange(PropertyChangeEvent e) {
    if (e.getPropertyName().equals("UserName")) {
        // previous user name
        String old = (String) e.getOldValue();
        // current user name
        String now = (String) e.getNewValue();
        NamedBean t = (NamedBean) e.getSource();
        if (old != null) {
            // remove old name for this bean
            _tuser.remove(old);
        }
        if (now != null) {
            // was there previously a bean with the new name?
            if (_tuser.get(now) != null && _tuser.get(now) != t) {
                // If so, clear. Note that this is not a "move" operation
                _tuser.get(now).setUserName(null);
            }
            // put new name for this bean
            _tuser.put(now, t);
        }
        //called DisplayListName, as DisplayName might get used at some point by a NamedBean
        //IN18N
        firePropertyChange("DisplayListName", old, now);
    }
}
Also used : NamedBean(jmri.NamedBean) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper)

Aggregations

OverridingMethodsMustInvokeSuper (javax.annotation.OverridingMethodsMustInvokeSuper)5 ConfigureManager (jmri.ConfigureManager)2 NamedBean (jmri.NamedBean)2 PropertyChangeListener (java.beans.PropertyChangeListener)1 PropertyVetoException (java.beans.PropertyVetoException)1