/* (non-Javadoc)
  * @see org.eclipse.jface.viewers.ITreeViewerListener#treeCollapsed(org.eclipse.jface.viewers.TreeExpansionEvent)
  */
 public void treeCollapsed(final TreeExpansionEvent event) {
   Object element = event.getElement();
   if ((element instanceof IGridContainer) && ((IGridContainer) element).isLazy()) {
     IGridContainer container = (IGridContainer) element;
     this.progressNodes.remove(container);
     container.setDirty();
     try {
       container.deleteAll();
     } catch (ProblemException pExc) {
       Activator.logException(pExc);
     }
   }
 }
  /**
   * Get the children of the specified container. If the container is lazy and dirty the returned
   * array will contain only one element, i.e. a {@link ProgressRunner} that is used to monitor the
   * progress of the children fetching operation that will be started immediately by this method.
   *
   * @param container The container from which to fetch the children.
   * @return An array containing either the list of children or a {@link ProgressRunner} object.
   */
  protected Object[] getChildren(final IGridContainer container) {

    Object[] children = null;

    if (container.isLazy() && container.isDirty()) {

      ProgressTreeNode monitor = this.progressNodes.get(container);

      if (monitor == null) {

        FetchChildrenJob fetcher =
            new FetchChildrenJob(container, this.treeViewer.getControl().getShell());
        monitor = new ProgressTreeNode(this.treeViewer);
        this.progressNodes.put(container, monitor);
        fetcher.setExternalMonitor(monitor);
        fetcher.setSystem(true);
        fetcher.schedule();
      }

      children = new Object[] {monitor};

    } else {

      this.progressNodes.remove(container);

      try {
        IGridElement[] childElements = container.getChildren(null);
        List<IGridElement> visibleChildren = new ArrayList<IGridElement>();
        for (IGridElement child : childElements) {
          if (!child.isHidden()) {
            visibleChildren.add(child);
          }
        }
        children = visibleChildren.toArray(new IGridElement[visibleChildren.size()]);
      } catch (ProblemException pExc) {
        if (this.treeViewer != null) {
          Shell shell = this.treeViewer.getControl().getShell();
          ProblemDialog.openProblem(
              shell,
              Messages.getString("GridModelContentProvider.problem_title"), // $NON-NLS-1$
              Messages.getString("GridModelContentProvider.problem_text")
                  + container.getName(), // $NON-NLS-1$
              pExc);
        } else {
          Activator.logException(pExc);
        }
      }
    }

    return children;
  }
Пример #3
0
 /**
  * Helper method to get the VO in which this CE is located, without assuming a fixed grid tree
  * structure.
  *
  * @return the {@link IVirtualOrganization} this CE belongs to.
  */
 private IVirtualOrganization getVO() {
   IVirtualOrganization result = null;
   IGridProject project = getProject();
   if (project != null) {
     result = project.getVO();
   } else {
     // Go up in the hierarchy until we find the VO
     IGridContainer container = getParent();
     while (container != null) {
       if (container instanceof IVirtualOrganization) {
         result = (IVirtualOrganization) container;
         break;
       }
       container = container.getParent();
     }
   }
   return result;
 }