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 Project: openstock Author: lcmeyer37 File: Crosshair.java License: 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 #2
Source Project: netbeans Author: apache File: ClassPathProviderImpl.java License: 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 #3
Source Project: openjdk-8-source Author: keerath File: TestEquals.java License: 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 #4
Source Project: NBANDROID-V2 Author: NBANDROIDTEAM File: LogReader.java License: 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 #5
Source Project: SIMVA-SoS Author: SESoS File: Crosshair.java License: 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 #6
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: TestEquals.java License: 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 #7
Source Project: jdk8u-jdk Author: lambdalab-mirror File: TestEquals.java License: 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 Project: netbeans Author: apache File: KeyBindingSettingsImpl.java License: 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 #9
Source Project: spark-sdk-android Author: particle-iot File: BridgeUtil.java License: 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 #10
Source Project: pentaho-reporting Author: pentaho File: KettleQueryEntry.java License: GNU Lesser General Public License v2.1 | 5 votes |
public KettleQueryEntry( final String aName ) { this.propertyChangeSupport = new PropertyChangeSupport( this ); this.name = aName; this.arguments = new FormulaArgument[ 0 ]; this.parameters = new FormulaParameter[ 0 ]; this.stopOnErrors = true; }
Example #11
Source Project: openjdk-8 Author: bpupadhyaya File: Toolkit.java License: 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 #12
Source Project: jdk1.8-source-analysis Author: raysonfang File: Toolkit.java License: Apache License 2.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 #13
Source Project: jdk1.8-source-analysis Author: raysonfang File: Toolkit.java License: Apache License 2.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 #14
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: Toolkit.java License: 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 #15
Source Project: jdk-1.7-annotated Author: ZhaoX File: Toolkit.java License: Apache License 2.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 #16
Source Project: dragonwell8_jdk Author: alibaba File: KeyboardFocusManager.java License: 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 #17
Source Project: netbeans Author: apache File: JAXWSLightSupport.java License: Apache License 2.0 | 5 votes |
private JAXWSLightSupport(JAXWSLightSupportImpl impl) { if (impl == null) { throw new IllegalArgumentException(); } this.impl = impl; propertyChangeSupport = new PropertyChangeSupport(this); myLock = new ReentrantReadWriteLock(); myReadLock = myLock.readLock(); myWriteLoick = myLock.writeLock(); }
Example #18
Source Project: material-ui-swing Author: atarw File: MaterialComponentField.java License: MIT License | 5 votes |
public MaterialComponentField(boolean drawLine) { super(); this.drawLine = drawLine; this.focusListenerColorLine = new FocusListenerColorLine(); this.propertyChangeListener = new MaterialPropertyChangeListener(); this.propertyChangeSupport = new PropertyChangeSupport(this); }
Example #19
Source Project: SIMVA-SoS Author: SESoS File: Crosshair.java License: 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 #20
Source Project: visualvm Author: oracle File: ApplicationDescriptor.java License: 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 #21
Source Project: ghidra Author: NationalSecurityAgency File: PluginTool.java License: 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 #22
Source Project: netbeans Author: apache File: SharedClassObject.java License: 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 #23
Source Project: TencentKona-8 Author: Tencent File: Toolkit.java License: 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 #24
Source Project: TencentKona-8 Author: Tencent File: Toolkit.java License: 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 #25
Source Project: hottub Author: dsrg-uoft File: Toolkit.java License: 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 #26
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Toolkit.java License: 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 #27
Source Project: netbeans Author: apache File: SharedClassObject.java License: 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 #28
Source Project: Jupiter Author: andrescv File: DirWatcher.java License: 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 #29
Source Project: netbeans Author: apache File: BaseDocument.java License: 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 #30
Source Project: TencentKona-8 Author: Tencent File: TestSerialization.java License: 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); }