Exemplo n.º 1
0
  /** @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object) */
  @Override
  public boolean hasChildren(Object object) {

    boolean hasChildren = false;

    if (object instanceof EmuViewerNode) {
      EmuViewerNode nodeObject = (EmuViewerNode) object;

      // The node has children if its children collection is bigger than 0
      // in size
      hasChildren = (nodeObject.getChildren().size() > 0);

    } else {
      warn("Tried to test if an object that is not an emulation tree node has children");
    }

    return hasChildren;
  }
Exemplo n.º 2
0
  /** @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object) */
  @Override
  public Object[] getChildren(Object parent) {

    Set<EmuViewerNode> childrenCollection;
    Object[] returnArray;

    if (parent instanceof EmuViewerNode) {
      // Firstly, try to retrieve the parent's children by means of the
      // appropriate method
      EmuViewerNode parentNode = (EmuViewerNode) parent;

      childrenCollection = parentNode.getChildren();

      // If the provided element is an emulator root node, it is needed to
      // test if the
      // intermediate nodes were already created (they are not created in
      // the first request).
      // If they were not created, assure that when the content framework
      // requests, the
      // intermediate nodes will be found.
      //
      // This procedure guarantees that once an emulator is started, it
      // has the intermediate
      // nodes constructed even if no emulation is being performed.
      if (parentNode instanceof EmuViewerRootNode) {
        String host = ((EmuViewerRootNode) parentNode).getEmulatorIdentifier();
        for (EmuViewerNode child : childrenCollection) {
          if (child.getChildren().size() == 0) {

            addChildrenToLeafParentNode(child, host);
          }
        }
      }

      // Creating the array of elements to be returned
      returnArray = childrenCollection.toArray(new EmuViewerNode[childrenCollection.size()]);

    } else {
      warn("Tried to get children of an object that is not an emulation tree node");
      returnArray = new Object[0];
    }

    return returnArray;
  }
Exemplo n.º 3
0
  /** @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(Object) */
  @Override
  public Object getParent(Object element) {

    Object parent = null;

    if (element instanceof EmuViewerNode) {
      EmuViewerNode nodeElement = (EmuViewerNode) element;

      if (nodeElement instanceof EmuViewerRootNode) {
        // The IViewSite object is the parent of the whole tree
        parent = treeParent;
      } else {
        parent = nodeElement.getParent();
      }
    } else {
      warn("Tried to get parent of an object that is not an emulation tree node");
    }

    return parent;
  }