/** Refreshes changed content nodes */
  private void refreshDataSourceTree() {
    Node selectedNode = getSelectedNode();
    final String[] selectedPath = NodeOp.createPath(selectedNode, em.getRootContext());

    Children rootChildren = em.getRootContext().getChildren();
    Node dataSourcesFilterNode = rootChildren.findChild(DataSourcesNode.NAME);
    if (dataSourcesFilterNode == null) {
      logger.log(
          Level.SEVERE,
          "Cannot find data sources filter node, won't refresh the content tree"); // NON-NLS
      return;
    }
    OriginalNode imagesNodeOrig = dataSourcesFilterNode.getLookup().lookup(OriginalNode.class);

    if (imagesNodeOrig == null) {
      logger.log(
          Level.SEVERE, "Cannot find data sources node, won't refresh the content tree"); // NON-NLS
      return;
    }

    Node imagesNode = imagesNodeOrig.getNode();

    RootContentChildren contentRootChildren = (RootContentChildren) imagesNode.getChildren();
    contentRootChildren.refreshContentKeys();

    // final TreeView tree = getTree();
    // tree.expandNode(imagesNode);

    setSelectedNode(selectedPath, DataSourcesNode.NAME);
  }
  private void updateHistory(Node[] selectedNodes) {
    if (selectedNodes.length == 0) {
      return;
    }

    Node selectedNode = selectedNodes[0];
    String selectedNodeName = selectedNode.getName();

    /* get the previous entry to make sure we don't duplicate it.
     * Motivation for this is also that if we used the back button,
     * then we already added the 'current' node to 'back' and we will
     * detect that and not reset the forward list.
     */
    String[] currentLast = backList.peekLast();
    String lastNodeName = null;
    if (currentLast != null) {
      lastNodeName = currentLast[currentLast.length - 1];
    }

    if (currentLast == null || !selectedNodeName.equals(lastNodeName)) {
      // add to the list if the last if not the same as current
      final String[] selectedPath = NodeOp.createPath(selectedNode, em.getRootContext());
      backList.addLast(selectedPath); // add the node to the "backList"
      if (backList.size() > 1) {
        backButton.setEnabled(true);
      } else {
        backButton.setEnabled(false);
      }

      forwardList.clear(); // clear the "forwardList"
      forwardButton.setEnabled(false); // disable the forward Button
    }
  }