+ Iterator<?> it = ((IStructuredSelection) selection).iterator();
+
+ // as the size method is recursive, we keep track of nodes for which
+ // we already have computed size so that we don't count them twice.
+ // In a first approximation, we assume that the structure selection
+ // keep the nodes ordered.
+ // TODO : enhance that.
+ List<String> importedPathes = new ArrayList<String>();
+ try {
+ nodesIt: while (it.hasNext()) {
+ Object obj = it.next();
+ String curPath;
+ Node node;
+ if (obj instanceof SingleJcrNode) {
+ node = ((SingleJcrNode) obj).getNode();
+ curPath = node.getSession().getWorkspace().getName();
+ curPath += "/" + node.getPath();
+ } else if (obj instanceof WorkspaceNode) {
+ node = ((WorkspaceNode) obj).getRootNode();
+ curPath = node.getSession().getWorkspace().getName();
+ } else
+ // unvalid object type
+ continue nodesIt;
+
+ Iterator<String> itPath = importedPathes.iterator();
+ while (itPath.hasNext()) {
+ String refPath = itPath.next();
+ if (curPath.startsWith(refPath))
+ // Already done : skip node
+ continue nodesIt;
+ }
+ size += JcrUtils.getNodeApproxSize(node);
+ importedPathes.add(curPath);
+ }
+ } catch (Exception e) {
+ ErrorFeedback.show("Cannot Get size of selected node ", e);
+ }