Locates the handle for a given resource. @param res the resource for which the handle is sought. @return the Handle for the resource, if it it was found.
(Resource res)
| 430 | * @return the {@link Handle} for the resource, if it it was found. |
| 431 | */ |
| 432 | protected Handle findHandleForResource(Resource res){ |
| 433 | Handle handle = null; |
| 434 | // go through all the nodes |
| 435 | Enumeration<?> nodesEnum = resourcesTreeRoot.breadthFirstEnumeration(); |
| 436 | while(nodesEnum.hasMoreElements() && handle == null) { |
| 437 | Object node = nodesEnum.nextElement(); |
| 438 | if(node instanceof DefaultMutableTreeNode) { |
| 439 | DefaultMutableTreeNode dmtNode = (DefaultMutableTreeNode)node; |
| 440 | if(dmtNode.getUserObject() instanceof Handle) { |
| 441 | if(((Handle)dmtNode.getUserObject()).getTarget() == res) { |
| 442 | handle = (Handle)dmtNode.getUserObject(); |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | return handle; |
| 448 | } |
| 449 | |
| 450 | /** |
| 451 | * Selects a resource if loaded in the system and not invisible. |