我正在使用PropertySheetView組件來可視化和編輯節點的屬性。該視圖應始終反映該對象的最新屬性;如果在另一個進程中對象發生更改,我想以某種方式刷新視圖並查看更新的屬性。NetBeans平臺 - 如何刷新節點的屬性表視圖?
我能夠做到這一點的最好辦法是像下面(利用EventBus庫中的對象發佈和訂閱變化):
public DomainObjectWrapperNode(DomainObject obj) {
super (Children.LEAF, Lookups.singleton(obj));
EventBus.subscribe(DomainObject.class, this);
}
public void onEvent(DomainObject event) {
// Do a check to determine if the updated object is the one wrapped by this node;
// if so fire a property sets change
firePropertySetsChange(null, this.getPropertySets());
}
這工作,但我在滾動的地方紙張刷新時丟失;它將視圖重置爲列表頂部,我必須回滾到刷新操作前的位置。
所以我的問題是,是否有更好的方式來刷新節點的屬性表視圖,特別是我的屬性列表中的位置刷新後不會丟失?
firePropertySetsChange的解決方案來自this thread。