コード例 #1
0
 @Override
 protected void showSearchedObjectsInTree(
     List<? extends ModelWrapper<?>> searchedObjects, boolean doubleClick) {
   for (ModelWrapper<?> searchedObject : searchedObjects) {
     List<AbstractAdapterBase> nodeRes =
         rootNode.search(searchedObject.getClass(), searchedObject.getId());
     if (nodeRes.size() == 0) {
       searchedNode.addSearchObject(searchedObject, searchedObject.getId());
       SpecimenTransitView.addToNode(searchedNode, searchedObject);
     }
   }
   if (searchedObjects.size() == 1) {
     ModelWrapper<?> searchedWrap = searchedObjects.get(0);
     List<AbstractAdapterBase> nodeRes =
         rootNode.search(searchedWrap.getClass(), searchedWrap.getId());
     if (nodeRes.size() > 0) nodeRes.get(0).performDoubleClick();
   } else {
     searchedNode.performExpand();
     BgcPlugin.openMessage(
         Messages.SpecimenTransitView_res_dialog_title,
         NLS.bind(Messages.SpecimenTransitView_found_multiple_msg, searchedObjects.size()));
   }
 }
コード例 #2
0
  @Override
  public void performExpand() {
    List<ModelWrapper<?>> alreadyHasListener = new ArrayList<ModelWrapper<?>>();
    try {
      for (AbstractAdapterBase child : getChildren()) {
        if (child instanceof AdapterBase) {
          ModelWrapper<?> childWrapper = ((AdapterBase) child).getModelObject();
          if (childWrapper != null) {
            childWrapper.reload();
          }
        }
        List<AbstractAdapterBase> subChildren =
            new ArrayList<AbstractAdapterBase>(child.getChildren());
        List<AbstractAdapterBase> toRemove = new ArrayList<AbstractAdapterBase>();
        for (AbstractAdapterBase subChild : subChildren) {
          ModelWrapper<?> wrapper = null;
          if (subChild instanceof AdapterBase) {
            Object subChildObj = ((AdapterBase) subChild).getModelObject();
            if (subChildObj instanceof ModelWrapper) {
              wrapper = (ModelWrapper<?>) subChildObj;
              // wrapper.reload();
              // FIXME: using reload here breaks a lot of stuff,
              // why?
            }
          }
          Integer subChildId = subChild.getId();
          if (!searchedObjectIds.contains(subChildId)) {
            toRemove.add(subChild);
          } else {
            // subChild.rebuild();
            if (wrapper != null) {
              alreadyHasListener.add(wrapper);
            }
          }
        }
        for (AbstractAdapterBase subChild : toRemove) child.removeChild(subChild);
      }
      // add searched objects is not yet there
      for (final Object o : searchedObjects) {
        if (o instanceof ModelWrapper) {
          ModelWrapper<?> w = (ModelWrapper<?>) o;
          if (!alreadyHasListener.contains(w)) {
            w.addWrapperListener(
                new WrapperListenerAdapter() {
                  @Override
                  public void deleted(WrapperEvent event) {
                    searchedObjects.remove(o);
                    performExpand();
                  }
                });
          }
        }
        addNode(o);
      }

      if (!keepDirectLeafChild) {
        // remove sub children without any children
        List<AbstractAdapterBase> children = new ArrayList<AbstractAdapterBase>(getChildren());
        for (AbstractAdapterBase child : children) {
          if (!(child instanceof DispatchAdapter) && child.getChildren().size() == 0) {
            removeChild(child);
          }
        }
      }
    } catch (final RemoteAccessException exp) {
      BgcPlugin.openRemoteAccessErrorMessage(exp);
    } catch (Exception e) {
      logger.error("Error while refreshing searched elements", e); // $NON-NLS-1$
    }
  }