示例#1
0
  /**
   * Update our child entries. This implementation tries to reuse child entries if possible (if the
   * id of the new descriptor matches the descriptor id of the old entry).
   */
  private void refreshChildEntries() {
    if (childEntries == null) // no children to refresh
    return;
    // get the current descriptors
    List descriptors = computeMergedPropertyDescriptors();
    // cache old entries by their descriptor id
    Map entryCache = new HashMap(childEntries.length * 2 + 1);
    for (int i = 0; i < childEntries.length; i++) {
      entryCache.put(childEntries[i].getDescriptor().getId(), childEntries[i]);
    } // create a list of entries to dispose
    List entriesToDispose = new ArrayList(Arrays.asList(childEntries));
    // rebuild child entries using old when possible
    childEntries = new PropertySheetEntry[descriptors.size()];
    boolean entriesChanged = descriptors.size() != entryCache.size();
    for (int i = 0; i < descriptors.size(); i++) {
      IPropertyDescriptor d = (IPropertyDescriptor) descriptors.get(i);
      // see if we have an entry matching this descriptor
      PropertySheetEntry entry = (PropertySheetEntry) entryCache.get(d.getId());
      if (entry != null) { // reuse old entry
        entry.setDescriptor(d);
        entriesToDispose.remove(entry);
      } else { // create new entry
        entry = new PropertySheetEntry();
        entry.setDescriptor(d);
        entry.setParent(this);
        entry.setPropertySourceProvider(propertySourceProvider);
        entriesChanged = true;
      }
      entry.refreshValues();
      childEntries[i] = entry;
    }

    if (entriesChanged) fireChildEntriesChanged();
    // Dispose of entries which are no longer needed
    for (int i = 0; i < entriesToDispose.size(); i++) {
      ((IPropertySheetEntry) entriesToDispose.get(i)).dispose();
    }
  }
示例#2
0
 /** Create our child entries. */
 private void createChildEntries() {
   // get the current descriptors
   List descriptors = computeMergedPropertyDescriptors();
   // rebuild child entries using old when possible
   childEntries = new PropertySheetEntry[descriptors.size()];
   for (int i = 0; i < descriptors.size(); i++) {
     IPropertyDescriptor d = (IPropertyDescriptor) descriptors.get(i);
     // create new entry
     PropertySheetEntry entry = new PropertySheetEntry();
     entry.setDescriptor(d);
     entry.setParent(this);
     entry.setPropertySourceProvider(propertySourceProvider);
     entry.refreshValues();
     childEntries[i] = entry;
   }
 } /* (non-Javadoc)