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)
}
java类java.beans.PropertyChangeSupport的实例源码
TestEquals.java 文件源码
项目:openjdk-jdk10
阅读 23
收藏 0
点赞 0
评论 0
ForwardingLibraryImplementation.java 文件源码
项目:incubator-netbeans
阅读 15
收藏 0
点赞 0
评论 0
/**
* Creates a new {@link ForwardingLibraryImplementation}.
* @param delegate the delegate
*/
public ForwardingLibraryImplementation(@NonNull final LibraryImplementation delegate) {
Parameters.notNull("delegate", delegate); //NOI18N
this.delegate = delegate;
this.support = new PropertyChangeSupport(this);
this.listener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
ForwardingLibraryImplementation.this.support.firePropertyChange(
evt.getPropertyName(),
evt.getOldValue(),
evt.getNewValue());
}
};
this.delegate.addPropertyChangeListener(WeakListeners.propertyChange(
this.listener,
this.delegate));
}
OpenProjectList.java 文件源码
项目:incubator-netbeans
阅读 16
收藏 0
点赞 0
评论 0
OpenProjectList() {
LOAD = new LoadOpenProjects(0);
openProjects = new ArrayList<Project>();
openProjectsModuleInfos = new HashMap<ModuleInfo, List<Project>>();
infoListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evn) {
if (ModuleInfo.PROP_ENABLED.equals(evn.getPropertyName())) {
checkModuleInfo((ModuleInfo)evn.getSource());
}
}
};
pchSupport = new PropertyChangeSupport( this );
recentProjects = new RecentProjectList(10); // #47134
recentTemplates = new ArrayList<String>();
projectGroupSupport = new ArrayList<ProjectGroupChangeListener>();
}
MapDataAdapter.java 文件源码
项目:FxTreeMap
阅读 16
收藏 0
点赞 0
评论 0
/**
* Creates a new MapDataAdapter from the given list of objects.
*
* @param dataCollectionName the name given to the objects group
* @param dataObjects list containing data to be aggregated as children
* @param valueFunction the function used to calculated the objects value
* @param nameFunction the function used to get the objects name
*/
public MapDataAdapter(String dataCollectionName, List<T> dataObjects, DataValueFunction<T> valueFunction, DataNameFunction<T> nameFunction) {
if (dataObjects == null) {
throw new IllegalArgumentException("dataObjects should not be null");
}
if (valueFunction == null) {
throw new IllegalArgumentException(VALUE_F_NULL_MESSAGE);
}
propertyChangeSupport = new PropertyChangeSupport(MapDataAdapter.this);
dataType = DataType.NODE;
name = dataCollectionName;
dataValueFunction = valueFunction;
dataNameFunction = nameFunction;
dataObject = null;
dataAdapters = new LinkedList<>();
dataObjectList = new LinkedList<>(dataObjects);
dataObjectList.forEach(o -> dataAdapters.add(new MapDataAdapter<>(o, valueFunction, nameFunction)));
recalculate();
lastNotifiedValue = value;
}
ProgressFrame.java 文件源码
项目:incubator-netbeans
阅读 35
收藏 0
点赞 0
评论 0
/** Creates new form ProgressFrame */
public ProgressFrame() {
propertySupport = new PropertyChangeSupport(this);
initComponents ();
this.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_ProgressFrameTabA11yDesc")); // NOI18N
okButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CancelButtonA11yDesc")); // NOI18N
progressHandle = ProgressHandleFactory.createHandle(null);
progressComponent = ProgressHandleFactory.createProgressComponent(progressHandle);
progressPanel.add(progressComponent);
progressHandle.start();
javax.swing.ImageIcon ideIcon = new javax.swing.ImageIcon("/org/netbeans/core/resources/frames/ide.gif"); //NOI18N
setIconImage(ideIcon.getImage());
java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(380, 150);
setLocation(dim.width/2 - 190, dim.height/2 - 80);
}
JPDADebuggerImpl.java 文件源码
项目:incubator-netbeans
阅读 17
收藏 0
点赞 0
评论 0
public JPDADebuggerImpl (ContextProvider lookupProvider) {
this.lookupProvider = lookupProvider;
Properties p = Properties.getDefault().getProperties("debugger.options.JPDA");
int stepResume = p.getInt("StepResume", (SINGLE_THREAD_STEPPING) ? 1 : 0);
suspend = (stepResume == 1) ? SUSPEND_EVENT_THREAD : SUSPEND_ALL;
pcs = new PropertyChangeSupport (this);
List l = lookupProvider.lookup (null, DebuggerEngineProvider.class);
int i, k = l.size ();
for (i = 0; i < k; i++) {
if (l.get (i) instanceof JavaEngineProvider) {
javaEngineProvider = (JavaEngineProvider) l.get (i);
}
}
if (javaEngineProvider == null) {
throw new IllegalArgumentException
("JavaEngineProvider have to be used to start JPDADebugger!");
}
languages = new HashSet<String>();
languages.add ("Java");
threadsTranslation = ObjectTranslation.createThreadTranslation(this);
localsTranslation = ObjectTranslation.createLocalsTranslation(this);
this.expressionPool = new ExpressionPool();
io = new DebuggerConsoleIO(this, lookupProvider);
}
MainProjectManager.java 文件源码
项目:incubator-netbeans
阅读 16
收藏 0
点赞 0
评论 0
@java.lang.SuppressWarnings("LeakingThisInConstructor")
private MainProjectManager () {
pcs = new PropertyChangeSupport (this);
a = ProjectSensitiveActions.projectSensitiveAction (
this, "x", null
);
OpenProjects.getDefault().addPropertyChangeListener(this);
currentProject = new WeakReference<Project>(OpenProjects.getDefault().getMainProject());
isMainProject = currentProject.get() != null;
a.addPropertyChangeListener(this); // I'm listening on it so that I get enable() called.
SwingUtilities.invokeLater(new Runnable() {
public @Override void run() {
a.isEnabled();
}
});
}
AbstractNbTaskWrapper.java 文件源码
项目:incubator-netbeans
阅读 16
收藏 0
点赞 0
评论 0
/** PRIVATE TASK ATTRIBUTES **/
public AbstractNbTaskWrapper (NbTask task) {
this.task = task;
this.repositoryDataRef = new SoftReference<TaskData>(null);
support = new PropertyChangeSupport(this);
repositoryTaskDataLoaderTask = RP.create(new Runnable() {
@Override
public void run () {
loadRepositoryTaskData();
}
});
MylynSupport mylynSupp = MylynSupport.getInstance();
taskDataListener = new TaskDataListenerImpl();
mylynSupp.addTaskDataListener(WeakListeners.create(TaskDataListener.class, taskDataListener, mylynSupp));
taskListener = new TaskListenerImpl();
task.addNbTaskListener(WeakListeners.create(NbTaskListener.class, taskListener, mylynSupp));
}
TestEquals.java 文件源码
项目:jdk8u-jdk
阅读 21
收藏 0
点赞 0
评论 0
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)
}
OutputNode.java 文件源码
项目:VISNode
阅读 18
收藏 0
点赞 0
评论 0
/**
* Creates a new output node
*/
public OutputNode() {
this.connector = new NodeConnector(this);
propertyChangeSupport = new PropertyChangeSupport(this);
listenerList = new EventListenerList();
img = null;
}
FxMapModel.java 文件源码
项目:FxTreeMap
阅读 13
收藏 0
点赞 0
评论 0
public FxMapModel(FxTreeMap treeMap, MapData mapData, double width, double height) {
modelData = mapData;
mapItems = new LinkedList<>();
propertyChangeSupport = new PropertyChangeSupport(FxMapModel.this);
propertyChangeSupport.addPropertyChangeListener(treeMap);
style = new TreeMapStyle();
style.removePropertyChangeListener(FxMapModel.this);
totalArea = width * height;
modelData.getChildrenData().forEach(d -> {
FxMapItem mapItem = new FxMapItem(FxMapModel.this, d);
mapItems.add(mapItem);
});
modelData.addPropertyChangeListener(this::handleModelChange);
}
MockPropertyChangeListenerTest.java 文件源码
项目:incubator-netbeans
阅读 15
收藏 0
点赞 0
评论 0
@Override
protected void setUp() throws Exception {
super.setUp();
source = new Object();
pcs = new PropertyChangeSupport(source);
l = new MockPropertyChangeListener();
pcs.addPropertyChangeListener(l);
}
KeyboardFocusManager.java 文件源码
项目:jdk8u-jdk
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
Component.java 文件源码
项目:OpenJSharp
阅读 21
收藏 0
点赞 0
评论 0
/**
* 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);
}
KeyboardFocusManager.java 文件源码
项目:OpenJSharp
阅读 20
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
SharedClassObject.java 文件源码
项目:incubator-netbeans
阅读 17
收藏 0
点赞 0
评论 0
/** 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);
}
}
}
SharedClassObject.java 文件源码
项目:incubator-netbeans
阅读 19
收藏 0
点赞 0
评论 0
/**
* Removes the specified property change listener so that it
* no longer receives property change events from this object.
* @param l the property change listener
*/
public final void removePropertyChangeListener(PropertyChangeListener l) {
boolean callRemoved;
synchronized (getLock()) {
PropertyChangeSupport supp = (PropertyChangeSupport) getProperty(PROP_SUPPORT);
if (supp == null) {
return;
}
boolean hasListener = supp.hasListeners(null);
supp.removePropertyChangeListener(l);
callRemoved = hasListener && !supp.hasListeners(null);
}
if (callRemoved) {
putProperty(PROP_SUPPORT, null); // clean the PCS, see #25417
removeNotifySuper = false;
removeNotify();
if (!removeNotifySuper) {
String msg = "You must call super.removeNotify() from " + getClass().getName() + ".removeNotify()"; // NOI18N
err.warning(msg);
}
}
}
Toolkit.java 文件源码
项目:jdk8u-jdk
阅读 30
收藏 0
点赞 0
评论 0
@Override
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
PropertyChangeSupport pcs = (PropertyChangeSupport)
AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY);
if (null != pcs) {
pcs.removePropertyChangeListener(listener);
}
}
GWNode.java 文件源码
项目:gw4e.project
阅读 14
收藏 0
点赞 0
评论 0
public GWNode(UUID uuid,String name,String id) {
this.uuid = uuid;
this.id = id;
this.setName(name);
this.in = new ArrayList<GWLink>();
this.out = new ArrayList<GWLink>();
this.listeners = new PropertyChangeSupport(this);
}
RecentProjects.java 文件源码
项目:incubator-netbeans
阅读 14
收藏 0
点赞 0
评论 0
/**
* 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));
}
}
});
}
PaletteController.java 文件源码
项目:incubator-netbeans
阅读 15
收藏 0
点赞 0
评论 0
/** Create new instance of PaletteController */
PaletteController( Model model, Settings settings ) {
this.model = model;
this.settings = settings;
support = new PropertyChangeSupport( this );
this.model.addModelListener( new ModelListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
if( Model.PROP_SELECTED_ITEM.equals( evt.getPropertyName() ) ) {
Lookup oldValue = null == evt.getOldValue() ? Lookup.EMPTY : ((Item)evt.getOldValue()).getLookup();
Lookup newValue = null == evt.getNewValue() ? Lookup.EMPTY : ((Item)evt.getNewValue()).getLookup();
support.firePropertyChange( PROP_SELECTED_ITEM, oldValue, newValue );
}
}
public void categoriesRemoved(Category[] removedCategories) {
//not interested
}
public void categoriesAdded(Category[] addedCategories) {
//not interested
}
public void categoriesReordered() {
//not interested
}
});
}
ParameterControlPanel.java 文件源码
项目:jaer
阅读 19
收藏 0
点赞 0
评论 0
/** Builds a new panel around the Object f. Any properties of the Object (defined by matching <code>setX/getX</code> methods)
* are added to the panel. If the object implements {@link HasPropertyTooltips} then a tooltip is added for the property if the
* {@link HasPropertyTooltips#getPropertyTooltip(java.lang.String) } returns a non-null String property.
*
* @param obj the object
*/
public ParameterControlPanel(Object obj) {
setClazz(obj);
initComponents();
String cn = getClazz().getClass().getName();
int lastdot = cn.lastIndexOf('.');
String name = cn.substring(lastdot + 1);
setName(name);
titledBorder = new TitledBorder(name);
titledBorder.getBorderInsets(this).set(1, 1, 1, 1);
setBorder(titledBorder);
normalBorder = titledBorder.getBorder();
redLineBorder = BorderFactory.createLineBorder(Color.red);
addIntrospectedControls();
// add(new JPanel()); // to fill vertical space in GridLayout
add(Box.createVerticalGlue()); // to fill space at bottom - not needed
try {
// when clazz fires a property change event, propertyChangeEvent is called here and we refresh all our controls
Method m=obj.getClass().getMethod("getPropertyChangeSupport", (Class[])null);
support=(PropertyChangeSupport)m.invoke(obj, (Object[]) null);
support.addPropertyChangeListener(this);
} catch (Exception ex) {
}
// if(f instanceof PropertyChangeListener){
// ((PropertyChangeListener)f).getPropertyChangeSupport().addPropertyChangeListener(this);
// }
ToolTipManager.sharedInstance().setDismissDelay(10000); // to show tips
revalidate();
}
RevisionInfoPanelController.java 文件源码
项目:incubator-netbeans
阅读 13
收藏 0
点赞 0
评论 0
public RevisionInfoPanelController (File repository) {
this.repository = repository;
this.loadInfoTask = Git.getInstance().getRequestProcessor(null).create(loadInfoWorker);
this.panel = new RevisionInfoPanel();
this.support = new PropertyChangeSupport(this);
resetInfoFields();
}
RepositoryRevision.java 文件源码
项目:incubator-netbeans
阅读 22
收藏 0
点赞 0
评论 0
RepositoryRevision (GitRevisionInfo message, File repositoryRoot, File[] selectionRoots,
Set<GitTag> tags, Set<GitBranch> branches, File dummyFile, String dummyFileRelativePath,
SearchExecutor.Mode mode) {
this.message = message;
this.repositoryRoot = repositoryRoot;
this.selectionRoots = selectionRoots;
this.tags = tags;
this.branches = branches;
support = new PropertyChangeSupport(this);
dummyEvents = new ArrayList<Event>(1);
if (dummyFile != null && dummyFileRelativePath != null) {
dummyEvents.add(new Event(dummyFile, dummyFileRelativePath));
}
this.mode = mode;
}
SearchContext.java 文件源码
项目:powertext
阅读 15
收藏 0
点赞 0
评论 0
@Override
public SearchContext clone() {
try {
SearchContext context = null;
context = (SearchContext)super.clone();
// Don't copy over listeners
context.support = new PropertyChangeSupport(context);
return context;
} catch (CloneNotSupportedException cnse) { // Never happens
throw new RuntimeException("Should never happen", cnse);
}
}
RepositoryRevision.java 文件源码
项目:incubator-netbeans
阅读 28
收藏 0
点赞 0
评论 0
public RepositoryRevision(ISVNLogMessage message, SVNUrl rootUrl, File[] selectionRoots,
Map<String,File> pathToRoot, Map<String, SVNRevision> pegRevisions) {
this.message = message;
this.repositoryRootUrl = rootUrl;
this.selectionRoots = selectionRoots;
support = new PropertyChangeSupport(this);
this.pathToRoot = pathToRoot;
this.pegRevisions = pegRevisions;
initFakeRootEvent();
}
DefaultProjectConvertorServices.java 文件源码
项目:incubator-netbeans
阅读 55
收藏 0
点赞 0
评论 0
ProjectInfo(
@NonNull final Project project,
@NonNull final ProjectConvertor.Result result) {
Parameters.notNull("project", project); //NOI18N
Parameters.notNull("result", result); //NOI18N
this.project = project;
this.result = result;
this.pcs = new PropertyChangeSupport(this);
this.eventSource = project.getLookup().lookupResult(ProjectInformation.class);
this.eventSource.addLookupListener(WeakListeners.create(LookupListener.class, this, eventSource));
}
CreatorBasedLazyFixList.java 文件源码
项目:incubator-netbeans
阅读 15
收藏 0
点赞 0
评论 0
/** Creates a new instance of CreatorBasedLazyFixList */
public CreatorBasedLazyFixList(FileObject file, String diagnosticKey, int offset, Collection<ErrorRule> c, Map<Class, Data> class2Data) {
this.pcs = new PropertyChangeSupport(this);
this.file = file;
this.diagnosticKey = diagnosticKey;
this.offset = offset;
this.c = c;
this.class2Data = class2Data;
this.fixes = Collections.<Fix>emptyList();
}
Toolkit.java 文件源码
项目:openjdk-jdk10
阅读 30
收藏 0
点赞 0
评论 0
private static PropertyChangeSupport createPropertyChangeSupport(Toolkit toolkit) {
if (toolkit instanceof SunToolkit || toolkit instanceof HeadlessToolkit) {
return new DesktopPropertyChangeSupport(toolkit);
} else {
return new PropertyChangeSupport(toolkit);
}
}
Toolkit.java 文件源码
项目:jdk8u-jdk
阅读 26
收藏 0
点赞 0
评论 0
@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];
}
}