本文整理匯總了Java中org.openide.loaders.DataObject.addPropertyChangeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java DataObject.addPropertyChangeListener方法的具體用法?Java DataObject.addPropertyChangeListener怎麽用?Java DataObject.addPropertyChangeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openide.loaders.DataObject
的用法示例。
在下文中一共展示了DataObject.addPropertyChangeListener方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: stateChanged
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
public void stateChanged(ChangeEvent e) {
Object source = e.getSource();
if (source instanceof Collection) {
FileObject bfo = this.fo;
if (bfo == null) {
return ;
}
for (Object obj : ((Collection) source)) {
DataObject dobj = (DataObject) obj;
FileObject primary = dobj.getPrimaryFile();
if (bfo.equals(primary)) {
synchronized (this) {
dobjRef = new WeakReference<DataObject>(dobj);
dobjwl = WeakListeners.propertyChange(this, dobj);
dobj.addPropertyChangeListener(dobjwl);
if (registryListener != null) {
DataObject.getRegistry().removeChangeListener(registryListener);
registryListener = null;
}
}
break;
}
}
}
}
示例2: createKeys
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override protected boolean createKeys(List<DataObject> keys) {
List<DataObject> files = new ArrayList<DataObject>();
for (DataObject f : folder.getChildren()) {
if (!filter.acceptDataObject(f)) {
continue;
}
if (f instanceof DataFolder) {
while (true) {
DataObject candidate = null;
f.addPropertyChangeListener(WeakListeners.propertyChange(this, f));
for (DataObject kid : ((DataFolder) f).getChildren()) {
if (!filter.acceptDataObject(kid)) {
continue;
}
if (kid instanceof DataFolder) {
if (candidate == null) {
candidate = kid;
} else {
candidate = null;
break;
}
} else {
candidate = null;
break;
}
}
if (candidate != null) {
f = candidate;
} else {
break;
}
}
keys.add(f);
} else {
files.add(f);
}
}
keys.addAll(files);
return true;
}
示例3: DataObjectSource
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
public DataObjectSource(DataObject data) {
this.data = data;
support = new PropertyChangeSupport(this);
propertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if(DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) {
support.firePropertyChange(PROP_MODIFIED, evt.getOldValue(), evt.getNewValue());
}
}
};
data.addPropertyChangeListener(WeakListeners.propertyChange(propertyChangeListener, this.data));
}
示例4: Prov
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
Prov(Document doc, DataObject xml, LayerHandle handle) {
this.doc = doc;
this.xml = xml;
this.handle = handle;
xml.getPrimaryFile().addFileChangeListener(FileUtil.weakFileChangeListener(listener, xml.getPrimaryFile()));
xml.addPropertyChangeListener(WeakListeners.propertyChange(pcl, xml));
task = RP.post(this);
}
示例5: DOEnvLookup
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
private DOEnvLookup (DataObject dobj, InstanceContent ic) {
super (ic);
this.ic = ic;
this.dobj = dobj;
dobj.addPropertyChangeListener(WeakListeners.propertyChange(this, dobj));
updateLookup ();
}
示例6: PropertiesDataNode
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/** Creates data node for a given data object.
* The provided children object will be used to hold all child nodes.
* @param dataObject object to work with
* @param children container for the node
*/
public PropertiesDataNode(DataObject dataObject, Children children, Lookup lookup) {
super(dataObject, children, lookup);
setIconBaseWithExtension("org/netbeans/modules/properties/propertiesObject.png"); // NOI18N
dataObjectListener = new NameUpdater();
dataObject.addPropertyChangeListener(
WeakListeners.propertyChange(dataObjectListener, dataObject));
}
示例7: JavaNode
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/** Create a node for the Java data object using the default children.
* @param jdo the data object to represent
*/
public JavaNode (final DataObject jdo, boolean isJavaSource) {
super (jdo, Children.LEAF);
this.isJavaSource = isJavaSource;
this.isCompiled = new AtomicReference<>();
this.isExecutable = new AtomicReference<>();
this.computedIcon = new AtomicReference<>();
this.computedIconListener = new AtomicReference<>();
this.setIconBaseWithExtension(isJavaSource ? JAVA_ICON_BASE : CLASS_ICON_BASE);
Logger.getLogger("TIMER").log(Level.FINE, "JavaNode", new Object[] {jdo.getPrimaryFile(), this});
if (!jdo.isTemplate()) {
WORKER.post(IconTask.create(this));
if (isJavaSource) {
WORKER.post(new BuildStatusTask(this));
WORKER.post(new ExecutableTask(this));
jdo.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (DataObject.PROP_PRIMARY_FILE.equals(evt.getPropertyName())) {
Logger.getLogger("TIMER").log(Level.FINE, "JavaNode", new Object[]{jdo.getPrimaryFile(), this});
WORKER.post(new Runnable() {
public void run() {
computedIconListener.set(null);
synchronized (JavaNode.this) {
status = null;
executableListener = null;
WORKER.post(new BuildStatusTask(JavaNode.this));
WORKER.post(new ExecutableTask(JavaNode.this));
}
}
});
}
}
});
}
}
}
示例8: fillHibernateConfigurations
import org.openide.loaders.DataObject; //導入方法依賴的package包/類
public void fillHibernateConfigurations(Node[] activatedNodes) {
Node node = activatedNodes[0];
DataObject dO = node.getCookie(DataObject.class);
if (dO instanceof HibernateCfgDataObject) {
dO.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if(DataObject.PROP_VALID.equals(evt.getPropertyName()) && Boolean.FALSE.equals(evt.getNewValue())){
if(SwingUtilities.isEventDispatchThread()){
close();//need to close if corresponding dataobject was invalidated (deleted)
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
close();//need to close if corresponding dataobject was invalidated (deleted)
}
});
}
}
}
});
Project enclosingProject = FileOwnerQuery.getOwner(dO.getPrimaryFile());
env = enclosingProject.getLookup().lookup(HibernateEnvironment.class);
if (env == null) {
logger.warning("HiberEnv is not found in enclosing project.");
return;
}
List<FileObject> configFileObjects = env.getAllHibernateConfigFileObjects();
for (FileObject configFileObject : configFileObjects) {
try {
HibernateCfgDataObject hibernateCfgDataObject = (HibernateCfgDataObject) DataObject.find(configFileObject);
String configName = hibernateCfgDataObject.getHibernateConfiguration().getSessionFactory().getAttributeValue("name"); //NOI18N
if (configName == null || configName.equals("")) {
configName = configFileObject.getName();
}
hibernateConfigMap.put(configName, configFileObject);
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
hibernateConfigurationComboBox.setModel(new DefaultComboBoxModel(hibernateConfigMap.keySet().toArray()));
HibernateConfiguration config = ((HibernateCfgDataObject) dO).getHibernateConfiguration();
String selectedConfigName = config.getSessionFactory().getAttributeValue("name"); //NOI18N
if (selectedConfigName == null || selectedConfigName.equals("")) {
selectedConfigName = dO.getPrimaryFile().getName();
}
hibernateConfigurationComboBox.setSelectedItem(selectedConfigName);
} else {
//TODO Don't know whether this case will actually arise..
}
}