protected void initialize() { super.initialize(); this.components = new IdentityHashMap(); this.collections = new IdentityHashMap(); this.componentListener = this.buildComponentListener(); this.size = 0; }
/** @see CollectionValueModelWrapper#engageModel() */ protected void engageModel() { super.engageModel(); // synch our cache *after* we start listening to the wrapped collection, // since its value might change when a listener is added; // the following will trigger the firing of a number of unnecessary events // (since we don't have any listeners yet), // but it reduces the amount of duplicate code this.addComponentSources((Iterator) this.collectionHolder.getValue()); }
/** @see CollectionValueModelWrapper#disengageModel() */ protected void disengageModel() { super.disengageModel(); // stop listening to the components... for (Iterator stream = this.components.values().iterator(); stream.hasNext(); ) { ((CollectionValueModel) stream.next()) .removeCollectionChangeListener(ValueModel.VALUE, this.componentListener); } // ...and clear the cache this.components.clear(); this.collections.clear(); this.size = 0; }