public void keyPressed(final KeyEvent e) {

    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      // on enter add new unit to workflow
      final JTree tree = (JTree) e.getSource();

      if (tree.getSelectionRows() != null && tree.getSelectionRows().length > 0) {
        // with 'Enter' all selected Units were inserted, therefore used an array
        final int[] selRows = tree.getSelectionRows();

        final TreePath[] selPaths = new TreePath[selRows.length];
        for (int i = 0; i < selRows.length; i++) {
          selPaths[i] = tree.getPathForRow(selRows[i]);
        }

        final Point insertPoint = UnitDelegate.POINT;
        // counts only Units, not Folders
        int realUnitCount = 0;

        for (int i = 0; i < selRows.length; i++) {
          if (selRows[i] != -1 && selPaths[i].getLastPathComponent() instanceof UnitDelegate) {
            final UnitDelegate delegate = ((UnitDelegate) selPaths[i].getLastPathComponent());
            Point point =
                new Point(
                    insertPoint.x + realUnitCount * GraphPanel.GRIDSIZE,
                    insertPoint.y + realUnitCount * GraphPanel.GRIDSIZE);
            GraphControllerManager.getInstance().getController().addNode(delegate, point);

            realUnitCount++;
          }
        }
      }
    }
  }
  public void mouseClicked(final MouseEvent e) {
    if (e.getClickCount() == 2) {
      final JTree tree = (JTree) e.getSource();

      final int selRow = tree.getRowForLocation(e.getX(), e.getY());
      final TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
      if (selRow != -1 && selPath.getLastPathComponent() instanceof UnitDelegate) {
        final UnitDelegate delegate = ((UnitDelegate) selPath.getLastPathComponent());
        Point point = UnitDelegate.POINT;
        GraphControllerManager.getInstance().getController().addNode(delegate, point);
      }
    }
  }