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)); }
/** * Initialize listening on adding/removing server so it is * possible to add/remove property sheets */ private void initListeners() { ddListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); Object oldValue = evt.getOldValue(); Object newValue = evt.getNewValue(); if (SunDescriptorDataObject.PROP_DOCUMENT_DTD.equals(propertyName)) { firePropertyChange(PROPERTY_DOCUMENT_TYPE, oldValue, newValue); } else if (DataObject.PROP_VALID.equals(propertyName) && Boolean.TRUE.equals(newValue)) { removePropertyChangeListener(SunDescriptorDataNode.this.ddListener); } else if (XmlMultiViewDataObject.PROP_DOCUMENT_VALID.equals(propertyName)) { setIconBase(Boolean.TRUE.equals(newValue)); } else if (Node.PROP_PROPERTY_SETS.equals(propertyName)) { firePropertySetsChange(null, null); } else if (XmlMultiViewDataObject.PROP_SAX_ERROR.equals(propertyName)) { fireShortDescriptionChange((String) oldValue, (String) newValue); } } }; getDataObject().addPropertyChangeListener(ddListener); }
private void attachTo(DataObject dataObject) { if (dataObject != null) { LOG.log(Level.FINEST, "attaching {0} to {1}", new Object[]{System.identityHashCode(this), dataObject}); dataObject.removePropertyChangeListener(this); dataObject.addPropertyChangeListener(this); NativeFileItemSet set = dataObject.getLookup().lookup(NativeFileItemSet.class); if (set != null) { set.add(this); } } lastDataObject = dataObject; }
@SuppressWarnings("LeakingThisInConstructor") public DataObjectListener(final DataObject dobj) { this.dobj = dobj; this.fobj = dobj.getPrimaryFile(); wlistener = WeakListeners.propertyChange(this, dobj); this.dobj.addPropertyChangeListener(wlistener); }
public void annotate (Line.Set set, Lookup lookup) { final FileObject fo = lookup.lookup(FileObject.class); if (fo != null) { final DataObject dobj = lookup.lookup(DataObject.class); if (dobj != null) { PropertyChangeListener pchl = new PropertyChangeListener() { /** annotate renamed files. */ public void propertyChange(PropertyChangeEvent evt) { if (DataObject.PROP_PRIMARY_FILE.equals(evt.getPropertyName())) { FileObject newFO = dobj.getPrimaryFile(); annotate(newFO); } } }; dobj.addPropertyChangeListener(WeakListeners.propertyChange(pchl, dobj)); synchronized (this) { if (dataObjectListeners == null) { dataObjectListeners = new HashSet<PropertyChangeListener>(); } // Prevent from GC. dataObjectListeners.add(pchl); } } annotate(fo); } }
dobj.addPropertyChangeListener(WeakListeners.propertyChange(pchl, dobj)); synchronized (this) { if (dataObjectListeners == null) {
dobj.addPropertyChangeListener(WeakListeners.propertyChange(pchl, dobj)); synchronized (this) { if (dataObjectListeners == null) {
/** * Set a data object to associate this node with. Whenever the node is asked for a cookie it * doesn't hold, it will delegate the question to the associated data object. * <p> * NOTE: the caller MUST call setDataObject(null) on this node when done * with it to free up resources! * @param dataObject the data object to associate with the node */ private void setDataObject(DataObject dataObject) { if (this.dataObject != dataObject) { // if (this.dataObject != null) // this.dataObject.removePropertyChangeListener(pListener); this.dataObject = dataObject; if (this.dataObject != null) { pListener = new PListener(); this.dataObject.addPropertyChangeListener(WeakListeners.propertyChange(pListener, this.dataObject)); } else { pListener = null; } } }
private static Lookup createLookup(final DataObject dobj) { final InstanceContent ic = new InstanceContent(); Lookup l = new AbstractLookup(ic); dobj.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent ev) { String propName = ev.getPropertyName(); if (propName == null || propName == DataObject.PROP_PRIMARY_FILE) { updateLookup(dobj, ic); } } }); updateLookup(dobj,ic); return l; }
/** * Construct an FacesPageUnit from existing java and markup units * * @param junit * @param cl * @param pkgname * @param rootPackage * @param container * @param pgunit */ public FacesPageUnit(JavaUnit junit, ClassLoader cl, String pkgname, Model model, String rootPackage, FacesContainer container, MarkupUnit pgunit) { super(junit, cl, pkgname, model, rootPackage, container); this.pgunit = pgunit; viewRoot = container.newViewRoot(); //Trace.enableTraceCategory("insync.faces"); // Storing the dataObject such that we can remove the property change listener later in destroy // order of destroy may mean that the page unit no longer can get access to its data object pageUnitDataObject = pgunit.getDataObject(); pageUnitDataObject.addPropertyChangeListener(this); }
o.addPropertyChangeListener (origL); original = o;
private static StorageItem createItem(Storage owner, long origINode, DataObject dao, CloneableOpenSupport origCOS) { FileObject primaryFile = dao.getPrimaryFile(); StorageItem out = new COSRedirectorImpl.StorageItem(owner, origINode, dao, primaryFile, origCOS); dao.addPropertyChangeListener(out); primaryFile.addFileChangeListener(out); return out; }
private void handleInvalidDataObjectImpl(DataObject invalidDO) { invalidDO.removePropertyChangeListener(wlistener); if (fobj.isValid()) { // file object still exists try to find new data object try { DataObject dobjNew = DataObject.find(fobj); synchronized (DataObjectListener.this) { if (dobjNew == dobj) { return; } dobj = dobjNew; dobj.addPropertyChangeListener(wlistener); } assignDocumentListener(dobjNew); resetState(true, false, -1, -1, false); } catch (DataObjectNotFoundException e) { //Ignore - invalidated after fobj.isValid () was called } catch (IOException ex) { // should not occur Exceptions.printStackTrace(ex); } } } }
/** * WebappConfiguration initialization. This method should be called before * this class is being used. * * @param contextXml context.xml file. */ private void init(File contextXml) { //this.contextXml = contextXml; try { getContext(); } catch (ConfigurationException e) { LOGGER.log(Level.FINE, null, e); } if (contextDataObject == null) { try { contextDataObject = DataObject.find(FileUtil.toFileObject(FileUtil.normalizeFile(contextXml))); contextDataObject.addPropertyChangeListener(this); } catch(DataObjectNotFoundException donfe) { LOGGER.log(Level.FINE, null, donfe); } } }
/** * Creates a new instance of WarDeploymentConfiguration */ public WarDeploymentConfiguration(J2eeModule j2eeModule, JBPluginUtils.Version version) { super(j2eeModule, version); jbossWebFile = j2eeModule.getDeploymentConfigurationFile("WEB-INF/jboss-web.xml"); // NOI18N getJbossWeb(); if (deploymentDescriptorDO == null) { try { deploymentDescriptorDO = deploymentDescriptorDO.find(FileUtil.toFileObject(jbossWebFile)); deploymentDescriptorDO.addPropertyChangeListener(this); } catch(DataObjectNotFoundException donfe) { Exceptions.printStackTrace(donfe); } } }
/** * Creates a new instance of EjbDeploymentConfiguration */ public EjbDeploymentConfiguration(J2eeModule j2eeModule, JBPluginUtils.Version version) { super(j2eeModule, version); this.jbossFile = j2eeModule.getDeploymentConfigurationFile("META-INF/jboss.xml"); // NOI18N; getJboss(); if (deploymentDescriptorDO == null) { try { deploymentDescriptorDO = deploymentDescriptorDO.find(FileUtil.toFileObject(jbossFile)); deploymentDescriptorDO.addPropertyChangeListener(this); } catch(DataObjectNotFoundException donfe) { Exceptions.printStackTrace(donfe); } } // TODO: rewrite // EjbJar ejbJar = (EjbJar) j2eeModule.getMetadataModel(J2eeModule.EJBJAR_XML); // if (ejbJar != null) { // ejbJar.addPropertyChangeListener(this); // } }
/** Creates a new instance of CarDeploymentConfiguration */ public CarDeploymentConfiguration(J2eeModule j2eeModule, JBPluginUtils.Version version) { super(j2eeModule, version); jbossClientFile = j2eeModule.getDeploymentConfigurationFile("META-INF/jboss-client.xml"); // NOI18N getJbossClient(); if (deploymentDescriptorDO == null) { try { deploymentDescriptorDO = deploymentDescriptorDO.find(FileUtil.toFileObject(jbossClientFile)); deploymentDescriptorDO.addPropertyChangeListener(this); } catch(DataObjectNotFoundException donfe) { Exceptions.printStackTrace(donfe); } } // TODO: rewrite // AppClient appClient = (AppClient) j2eeModule.getMetadataModel(J2eeModule.CLIENT_XML); // if (appClient != null) { // appClient.addPropertyChangeListener(this); // } }
while (true) { DataObject candidate = null; f.addPropertyChangeListener(WeakListeners.propertyChange(this, f)); for (DataObject kid : ((DataFolder) f).getChildren()) { if (!filter.acceptDataObject(kid)) {
/** Create a data node for a given data object. * The provided children object will be used to hold all child nodes. * The name is always set to the base name of the primary file; * the display name may instead be set to the base name with extension. * @param obj object to work with * @param ch children container for the node * @see #getShowFileExtensions */ public DataNode (DataObject obj, Children ch) { super (ch); this.obj = obj; propL = new PropL (); obj.addPropertyChangeListener (org.openide.util.WeakListeners.propertyChange (propL, obj)); super.setName (obj.getName ()); updateDisplayName (); }
private void init() { obj.addPropertyChangeListener(org.openide.util.WeakListeners.propertyChange(this, obj));