/** @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; }
/** @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; }