本文整理汇总了Java中java.beans.PropertyChangeSupport.firePropertyChange方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyChangeSupport.firePropertyChange方法的具体用法?Java PropertyChangeSupport.firePropertyChange怎么用?Java PropertyChangeSupport.firePropertyChange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.PropertyChangeSupport
的用法示例。
在下文中一共展示了PropertyChangeSupport.firePropertyChange方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
public static void main(String[] args) {
TestEquals one = new TestEquals(1);
TestEquals two = new TestEquals(2);
Object source = TestEquals.class;
PropertyChangeSupport pcs = new PropertyChangeSupport(source);
pcs.addPropertyChangeListener(PROPERTY, one);
pcs.addPropertyChangeListener(PROPERTY, two);
PropertyChangeEvent event = new PropertyChangeEvent(source, PROPERTY, one, two);
pcs.firePropertyChange(event);
test(one, two, 1); // only one check
pcs.firePropertyChange(PROPERTY, one, two);
test(one, two, 2); // because it invokes firePropertyChange(PropertyChangeEvent)
pcs.fireIndexedPropertyChange(PROPERTY, 1, one, two);
test(one, two, 2); // because it invokes firePropertyChange(PropertyChangeEvent)
}
示例2: MissingNbInstallationProblemProvider
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
public MissingNbInstallationProblemProvider(Project prj) {
pchs = new PropertyChangeSupport(this);
project = prj;
propertyListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (OpenProjects.PROPERTY_OPEN_PROJECTS.equals(evt.getPropertyName()) && OpenProjects.getDefault().isProjectOpen(project)) {
pchs.firePropertyChange(PROP_PROBLEMS, null, null);
}
if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) {
pchs.firePropertyChange(PROP_PROBLEMS, null, null);
}
}
};
weak = WeakListeners.propertyChange(propertyListener, this);
}
示例3: firePropertyChange
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
@Override
public void firePropertyChange(final PropertyChangeEvent evt) {
Object oldValue = evt.getOldValue();
Object newValue = evt.getNewValue();
String propertyName = evt.getPropertyName();
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
Runnable updater = new Runnable() {
public void run() {
PropertyChangeSupport pcs = (PropertyChangeSupport)
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
if (null != pcs) {
pcs.firePropertyChange(evt);
}
}
};
final AppContext currentAppContext = AppContext.getAppContext();
for (AppContext appContext : AppContext.getAppContexts()) {
if (null == appContext || appContext.isDisposed()) {
continue;
}
if (currentAppContext == appContext) {
updater.run();
} else {
final PeerEvent e = new PeerEvent(source, updater, PeerEvent.ULTIMATE_PRIORITY_EVENT);
SunToolkit.postEvent(appContext, e);
}
}
}
示例4: processEvent
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
static void processEvent(XoaEvent event) {
LOG.entering(CLASS_NAME, "dispatchEventToXoa", event);
LOG.log(Level.FINEST, "SOA --> XOA: {1}", event);
Integer handlerId = event.getHandlerId();
if (handlerId == null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Null handlerId");
}
return;
}
String eventType = event.getKind().toString();
Object[] params = event.getParams();
Object[] args = { handlerId, eventType, params };
PropertyChangeSupport xop = getCrossOriginProxy(handlerId);
if (xop == null) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Null xop for handler " + handlerId);
}
return;
}
xop.firePropertyChange(SOA_MESSAGE, null, args);
}
示例5: put
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
public @Override Object put(Object key, Object value) {
if (key == PropertyChangeSupport.class && value instanceof PropertyChangeSupport) {
pcs = (PropertyChangeSupport) value;
}
Object old = null;
boolean usePlainPut = true;
if (key != null) {
Object val = super.get(key);
if (val instanceof BaseDocument_PropertyHandler) {
old = ((BaseDocument_PropertyHandler) val).setValue(value);
usePlainPut = false;
}
}
if (usePlainPut) {
old = super.put(key, value);
}
if (key instanceof String) {
if (pcs != null) {
pcs.firePropertyChange((String) key, old, value);
}
}
return old;
}
示例6: firePropertyChange
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
/** Fire a property change event to all listeners.
* @param name the name of the property
* @param oldValue the old value
* @param newValue the new value
*/
// not final - SystemOption overrides it, e.g.
protected void firePropertyChange(String name, Object oldValue, Object newValue) {
PropertyChangeSupport supp = (PropertyChangeSupport) getProperty(PROP_SUPPORT);
if (supp != null) {
supp.firePropertyChange(name, oldValue, newValue);
}
}
示例7: updateState
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
void updateState(ActionMap prev, ActionMap now, boolean fire) {
if (key == null) {
return;
}
boolean prevEnabled = false;
if (prev != null) {
Action prevAction = prev.get(key);
if (prevAction != null) {
prevEnabled = fire && prevAction.isEnabled();
prevAction.removePropertyChangeListener(weakL);
}
}
if (now != null) {
Action nowAction = now.get(key);
boolean nowEnabled;
if (nowAction != null) {
nowAction.addPropertyChangeListener(weakL);
nowEnabled = nowAction.isEnabled();
} else {
nowEnabled = fallback != null && fallback.isEnabled();
}
PropertyChangeSupport sup = fire ? support : null;
if (sup != null && nowEnabled != prevEnabled) {
sup.firePropertyChange("enabled", prevEnabled, !prevEnabled); // NOI18N
}
}
}
示例8: updateState
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
void updateState() {
PropertyChangeSupport s;
synchronized (this) {
s = support;
}
boolean prev = previousEnabled;
if (s != null && prev != isEnabled()) {
s.firePropertyChange("enabled", Boolean.valueOf(prev), Boolean.valueOf(!prev)); // NOI18N
}
}
示例9: firePropertyChange
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
/**
* Support for reporting bound property changes for Object properties.
* This method can be called when a bound property has changed and it will
* send the appropriate PropertyChangeEvent to any registered
* PropertyChangeListeners.
*
* @param propertyName the property whose value has changed
* @param oldValue the property's previous value
* @param newValue the property's new value
*/
protected void firePropertyChange(String propertyName,
Object oldValue, Object newValue) {
PropertyChangeSupport changeSupport;
synchronized (getObjectLock()) {
changeSupport = this.changeSupport;
}
if (changeSupport == null ||
(oldValue != null && newValue != null && oldValue.equals(newValue))) {
return;
}
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
示例10: firePropertyChange
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
/**
* Fires a PropertyChangeEvent in response to a change in a bound property.
* The event will be delivered to all registered PropertyChangeListeners.
* No event will be delivered if oldValue and newValue are the same.
*
* @param propertyName the name of the property that has changed
* @param oldValue the property's previous value
* @param newValue the property's new value
*/
protected void firePropertyChange(String propertyName, Object oldValue,
Object newValue)
{
if (oldValue == newValue) {
return;
}
PropertyChangeSupport changeSupport = this.changeSupport;
if (changeSupport != null) {
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
}
示例11: main
import java.beans.PropertyChangeSupport; //导入方法依赖的package包/类
public static void main(String[] args) {
PropertyChangeSupport pcs = new PropertyChangeSupport(TestListeners.class);
pcs.addPropertyChangeListener(new TestListeners(0));
pcs.addPropertyChangeListener(NAME, new TestListeners(2));
pcs.addPropertyChangeListener(new TestListeners(1));
pcs.addPropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));
current = 0;
pcs.firePropertyChange(NAME, 0, 1);
if (current != 4)
throw new Error("Expected 4 listeners, but called " + current);
current = 0;
pcs.firePropertyChange(NONE, 1, 0);
if (current != 2)
throw new Error("Expected 2 listeners, but called " + current);
PropertyChangeListener[] all = pcs.getPropertyChangeListeners();
if (all.length != 4)
throw new Error("Expected 4 listeners, but contained " + all.length);
PropertyChangeListener[] named = pcs.getPropertyChangeListeners(NAME);
if (named.length != 2)
throw new Error("Expected 2 named listeners, but contained " + named.length);
PropertyChangeListener[] other = pcs.getPropertyChangeListeners(NONE);
if (other.length != 0)
throw new Error("Expected 0 other listeners, but contained " + other.length);
pcs.removePropertyChangeListener(new TestListeners(0));
pcs.removePropertyChangeListener(new TestListeners(1));
pcs.removePropertyChangeListener(NAME, new TestListeners(2));
pcs.removePropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3)));
all = pcs.getPropertyChangeListeners();
if (all.length != 0)
throw new Error("Expected 4 listeners, but contained " + all.length);
named = pcs.getPropertyChangeListeners(NAME);
if (named.length != 0)
throw new Error("Expected 2 named listeners, but contained " + named.length);
other = pcs.getPropertyChangeListeners(NONE);
if (other.length != 0)
throw new Error("Expected 0 other listeners, but contained " + other.length);
}