java.beans.PropertyChangeSupport Java Examples
The following examples show how to use
java.beans.PropertyChangeSupport.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BridgeUtil.java From spark-sdk-android with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: Crosshair.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Creates a new crosshair value with the specified value and line style. * * @param value the value. * @param paint the line paint (<code>null</code> not permitted). * @param stroke the line stroke (<code>null</code> not permitted). */ public Crosshair(double value, Paint paint, Stroke stroke) { ParamChecks.nullNotPermitted(paint, "paint"); ParamChecks.nullNotPermitted(stroke, "stroke"); this.visible = true; this.value = value; this.paint = paint; this.stroke = stroke; this.labelVisible = false; this.labelGenerator = new StandardCrosshairLabelGenerator(); this.labelAnchor = RectangleAnchor.BOTTOM_LEFT; this.labelXOffset = 3.0; this.labelYOffset = 3.0; this.labelFont = new Font("Tahoma", Font.PLAIN, 12); this.labelPaint = Color.black; this.labelBackgroundPaint = new Color(0, 0, 255, 63); this.labelOutlineVisible = true; this.labelOutlinePaint = Color.black; this.labelOutlineStroke = new BasicStroke(0.5f); this.pcs = new PropertyChangeSupport(this); }
Example #3
Source File: ClassPathProviderImpl.java From netbeans with Apache License 2.0 | 6 votes |
SourceLevelSelector( @NonNull final PropertyEvaluator eval, @NonNull final String sourceLevelPropName, @NonNull final List<? extends Supplier<? extends ClassPath>> cpFactories) { Parameters.notNull("eval", eval); //NOI18N Parameters.notNull("sourceLevelPropName", sourceLevelPropName); //NOI18N Parameters.notNull("cpFactories", cpFactories); //NOI18N if (cpFactories.size() != 2) { throw new IllegalArgumentException("Invalid classpaths: " + cpFactories); //NOI18N } for (Supplier<?> f : cpFactories) { if (f == null) { throw new NullPointerException("Classpaths contain null: " + cpFactories); //NOI18N } } this.eval = eval; this.sourceLevelPropName = sourceLevelPropName; this.cpfs = cpFactories; this.listeners = new PropertyChangeSupport(this); this.cps = new ClassPath[2]; this.eval.addPropertyChangeListener(WeakListeners.propertyChange(this, this.eval)); }
Example #4
Source File: TestEquals.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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) }
Example #5
Source File: LogReader.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
public LogReader() { changeSupport = new PropertyChangeSupport(this); listeners = new HashSet<>(); adb = AndroidSdkProvider.getAdb(); checkReadingStatusTimer = new Timer(); checkReadingStatusTimer.schedule(new TimerTask() { @Override public void run() { try { if (!shouldBeReading) { return; } if (!deviceReallyConnected()) { infoMessage("Trying to reconnect to the device in " + checkingPeriod / 1000 + " seconds."); startReading(); } } catch (Exception e) { LOG.log(Level.SEVERE, "Unexpected exception on reconnecting the device.", e); } } }, checkingPeriod, checkingPeriod); }
Example #6
Source File: Crosshair.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Creates a new crosshair value with the specified value and line style. * * @param value the value. * @param paint the line paint (<code>null</code> not permitted). * @param stroke the line stroke (<code>null</code> not permitted). */ public Crosshair(double value, Paint paint, Stroke stroke) { ParamChecks.nullNotPermitted(paint, "paint"); ParamChecks.nullNotPermitted(stroke, "stroke"); this.visible = true; this.value = value; this.paint = paint; this.stroke = stroke; this.labelVisible = false; this.labelGenerator = new StandardCrosshairLabelGenerator(); this.labelAnchor = RectangleAnchor.BOTTOM_LEFT; this.labelXOffset = 3.0; this.labelYOffset = 3.0; this.labelFont = new Font("Tahoma", Font.PLAIN, 12); this.labelPaint = Color.black; this.labelBackgroundPaint = new Color(0, 0, 255, 63); this.labelOutlineVisible = true; this.labelOutlinePaint = Color.black; this.labelOutlineStroke = new BasicStroke(0.5f); this.pcs = new PropertyChangeSupport(this); }
Example #7
Source File: TestEquals.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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) }
Example #8
Source File: TestEquals.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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) }
Example #9
Source File: KeyBindingSettingsImpl.java From netbeans with Apache License 2.0 | 6 votes |
/** * Construction prohibited for API clients. */ private KeyBindingSettingsImpl (MimePath mimePath) { this.mimePath = mimePath; pcs = new PropertyChangeSupport (this); // init logging String myClassName = KeyBindingSettingsImpl.class.getName (); String value = System.getProperty(myClassName); if (value != null) { if (!value.equals("true")) { logActionName = System.getProperty(myClassName); } } else if (mimePath.size() == 1) { logActionName = System.getProperty(myClassName + '.' + mimePath.getMimeType(0)); } }
Example #10
Source File: KeyboardFocusManager.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example #11
Source File: KeyboardFocusManager.java From Java8CN with Apache License 2.0 | 5 votes |
/** * 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); } }
Example #12
Source File: Crosshair.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); this.labelPaint = SerialUtilities.readPaint(stream); this.labelBackgroundPaint = SerialUtilities.readPaint(stream); this.labelOutlineStroke = SerialUtilities.readStroke(stream); this.labelOutlinePaint = SerialUtilities.readPaint(stream); this.pcs = new PropertyChangeSupport(this); }
Example #13
Source File: Toolkit.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@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); } } }
Example #14
Source File: ApplicationDescriptor.java From visualvm with GNU General Public License v2.0 | 5 votes |
@Override public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if (ApplicationType.PROPERTY_NAME.equals(propertyName)) { Application application = getDataSource(); // Name already customized by the user, do not change it if (resolveName(application, null) != null) return; if (supportsRename()) { // Descriptor supports renaming, use setName(), sync name setName((String)evt.getNewValue()); name = ApplicationDescriptor.super.getName(); } else { // Descriptor doesn't support renaming, set name for overriden getName() String oldName = name; name = formatName(createGenericName(application, type.getName())); PropertyChangeSupport pcs = ApplicationDescriptor.this.getChangeSupport(); pcs.firePropertyChange(PROPERTY_NAME, oldName, name); } } else if (ApplicationType.PROPERTY_ICON.equals(propertyName)) { setIcon((Image)evt.getNewValue()); } else if (ApplicationType.PROPERTY_DESCRIPTION.equals(propertyName)) { setDescription((String)evt.getNewValue()); } else if (ApplicationType.PROPERTY_VERSION.equals(propertyName)) { // Not supported by ApplicationDescriptor } }
Example #15
Source File: PluginTool.java From ghidra with Apache License 2.0 | 5 votes |
public PluginTool(Project project, ProjectManager projectManager, ToolServices toolServices, String name, boolean isDockable, boolean hasStatus, boolean isModal) { this.project = project; this.projectManager = projectManager; this.toolServices = toolServices; propertyChangeMgr = new PropertyChangeSupport(this); optionsMgr = new OptionsManager(this); winMgr = createDockingWindowManager(isDockable, hasStatus, isModal); toolActions = new ToolActions(this, new ActionToGuiHelper(winMgr)); taskMgr = new ToolTaskManager(this); setToolOptionsHelpLocation(); winMgr.addStatusItem(taskMgr.getMonitorComponent(), false, true); winMgr.removeStatusItem(taskMgr.getMonitorComponent()); eventMgr = new EventManager(this); serviceMgr = new ServiceManager(); installServices(); pluginMgr = new PluginManager(this, serviceMgr); dialogMgr = new DialogManager(this); initActions(); initOptions(); setToolName(name); PluginToolMacQuitHandler.install(this); PluginToolMacAboutHandler.install(winMgr); installHomeButton(); }
Example #16
Source File: Series.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a new series with the specified key and description. * * @param key the series key (<code>null</code> NOT permitted). * @param description the series description (<code>null</code> permitted). */ protected Series(Comparable key, String description) { ParamChecks.nullNotPermitted(key, "key"); this.key = key; this.description = description; this.listeners = new EventListenerList(); this.propertyChangeSupport = new PropertyChangeSupport(this); this.vetoableChangeSupport = new VetoableChangeSupport(this); this.notify = true; }
Example #17
Source File: SharedClassObject.java From netbeans with Apache License 2.0 | 5 votes |
/** Adds the specified property change listener to receive property * change events from this object. * @param l the property change listener */ public final void addPropertyChangeListener(PropertyChangeListener l) { boolean noListener; synchronized (getLock()) { // System.out.println ("added listener: " + l + " to: " + getClass ()); // NOI18N PropertyChangeSupport supp = (PropertyChangeSupport) getProperty(PROP_SUPPORT); if (supp == null) { // System.out.println ("Creating support"); // NOI18N putProperty(PROP_SUPPORT, supp = new PropertyChangeSupport(this)); } noListener = !supp.hasListeners(null); supp.addPropertyChangeListener(l); } if (noListener) { addNotifySuper = false; addNotify(); if (!addNotifySuper) { // [PENDING] theoretical race condition for this warning if listeners are added // and removed very quickly from two threads, I guess, and addNotify() impl is slow String msg = "You must call super.addNotify() from " + getClass().getName() + ".addNotify()"; // NOI18N err.warning(msg); } } }
Example #18
Source File: Toolkit.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { return pcs.getPropertyChangeListeners(propertyName); } else { return new PropertyChangeListener[0]; } }
Example #19
Source File: Toolkit.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { pcs.removePropertyChangeListener(listener); } }
Example #20
Source File: Toolkit.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public synchronized void removePropertyChangeListener( String propertyName, PropertyChangeListener listener) { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { pcs.removePropertyChangeListener(propertyName, listener); } }
Example #21
Source File: Toolkit.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public synchronized void removePropertyChangeListener( String propertyName, PropertyChangeListener listener) { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { pcs.removePropertyChangeListener(propertyName, listener); } }
Example #22
Source File: Toolkit.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static PropertyChangeSupport createPropertyChangeSupport(Toolkit toolkit) { if (toolkit instanceof SunToolkit || toolkit instanceof HeadlessToolkit) { return new DesktopPropertyChangeSupport(toolkit); } else { return new PropertyChangeSupport(toolkit); } }
Example #23
Source File: SharedClassObject.java From netbeans with Apache License 2.0 | 5 votes |
/** 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); } }
Example #24
Source File: DirWatcher.java From Jupiter with GNU General Public License v3.0 | 5 votes |
/** * Creates a new directory watcher. * * @param observer watcher observer * @throws IOException if an I/O error occurs */ private DirWatcher(PropertyChangeListener observer) throws IOException { watcher = FileSystems.getDefault().newWatchService(); keys = new HashMap<>(); pcs = new PropertyChangeSupport(this); pcs.addPropertyChangeListener(observer); }
Example #25
Source File: RevisionDialogController.java From netbeans with Apache License 2.0 | 5 votes |
private RevisionDialogController (File repository, File[] roots) { infoPanelController = new RevisionInfoPanelController(repository); this.panel = new RevisionDialog(infoPanelController.getPanel()); this.repository = repository; this.roots = roots; this.support = new PropertyChangeSupport(this); this.t = new Timer(500, this); t.stop(); infoPanelController.loadInfo(revisionString = panel.revisionField.getText()); attachListeners(); }
Example #26
Source File: BaseDocument.java From netbeans with Apache License 2.0 | 5 votes |
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; }
Example #27
Source File: TestSerialization.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeSupport pcs) { PropertyChangeListener[] namedListeners = pcs.getPropertyChangeListeners(NAME); check(namedListeners, 1); check(namedListeners[0], 1); PropertyChangeListener[] allListeners = pcs.getPropertyChangeListeners(); check(allListeners, 2); check(allListeners[0], 0); check(allListeners[1], 1, NAME); }
Example #28
Source File: RecentProjects.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a new instance of RecentProjects */ private RecentProjects() { pch = new PropertyChangeSupport(this); OpenProjectList.getDefault().addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(OpenProjectList.PROPERTY_RECENT_PROJECTS)) { pch.firePropertyChange(new PropertyChangeEvent(RecentProjects.class, PROP_RECENT_PROJECT_INFO, null, null)); } } }); }
Example #29
Source File: Bean.java From LGoodDatePicker with MIT License | 5 votes |
/** * Support for reporting bound property changes for boolean 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 final void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { PropertyChangeSupport aChangeSupport = this.changeSupport; if (aChangeSupport == null) { return; } aChangeSupport.firePropertyChange(propertyName, oldValue, newValue); }
Example #30
Source File: Toolkit.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public synchronized PropertyChangeListener[] getPropertyChangeListeners() { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { return pcs.getPropertyChangeListeners(); } else { return new PropertyChangeListener[0]; } }