private void updateItems(final FileInfo parent) {
   if (fDisplay == null) return;
   assert Thread.currentThread() == fDisplay.getThread();
   TreeItem[] items = null;
   boolean expanded = true;
   if (parent.children == null || parent.children_error != null) {
     if (parent == fRootInfo) {
       fileTree.setItemCount(1);
       items = fileTree.getItems();
     } else {
       TreeItem item = findItem(parent);
       if (item == null) return;
       expanded = item.getExpanded();
       item.setItemCount(1);
       items = item.getItems();
     }
     assert items.length == 1;
     items[0].removeAll();
     if (parent.children_pending) {
       items[0].setForeground(fDisplay.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
       items[0].setText("Pending...");
     } else if (parent.children_error != null) {
       String msg = parent.children_error.getMessage();
       if (msg == null) msg = parent.children_error.getClass().getName();
       else msg = msg.replace('\n', ' ');
       items[0].setForeground(fDisplay.getSystemColor(SWT.COLOR_RED));
       items[0].setText(msg);
       items[0].setImage((Image) null);
     } else if (expanded) {
       loadChildren(parent);
       items[0].setForeground(fDisplay.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
       items[0].setText("Pending...");
     } else {
       items[0].setText("");
     }
   } else {
     FileInfo[] arr = parent.children;
     if (parent == fRootInfo) {
       fileTree.setItemCount(arr.length);
       items = fileTree.getItems();
     } else {
       TreeItem item = findItem(parent);
       if (item == null) return;
       expanded = item.getExpanded();
       item.setItemCount(expanded ? arr.length : 1);
       items = item.getItems();
     }
     if (expanded) {
       assert items.length == arr.length;
       for (int i = 0; i < items.length; i++) fillItem(items[i], arr[i]);
       expandSelect();
     } else {
       items[0].setText("");
     }
   }
 }
Example #2
0
  private void closeStackAllFileInfo() {
    Tree tree = this.getMainTree();
    if (tree != null) {
      tree.clearAll(true);
      tree.setItemCount(0);
    }

    clearTable();
    this.displayContent(null);
  }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.swt.widgets.Control#pack(boolean)
  */
 @Override
 public void pack(boolean changed) {
   if (changed) {
     RootContainer root = RootContainer.getRoot(project);
     root.update();
     table.clearAll(true);
     table.setItemCount(0);
     if (tableSelectionListener != null) {
       table.removeSelectionListener(tableSelectionListener);
     }
     setupClasspathInfo(table, root);
     makeChecksConsistentWithChildren();
     expandAll(table.getItems());
     if (tableSelectionListener == null) {
       tableSelectionListener = new TableSelectionListener();
       table.addSelectionListener(tableSelectionListener);
     }
   }
   table.pack(changed);
   super.pack(changed);
 }
 public void setInput(IPeer peer) {
   if (peer == fPeer) {
     return;
   }
   if (fPeer != null) {
     Protocol.invokeAndWait(
         new Runnable() {
           public void run() {
             disconnectPeer();
           }
         });
   }
   fileTree.setItemCount(0);
   fRootInfo.children = null;
   fPeer = peer;
   if (fPeer != null) {
     Protocol.invokeAndWait(
         new Runnable() {
           public void run() {
             connectPeer();
           }
         });
   }
 }