/**
   * Used to display the argument ontology tree so an element can be selected
   *
   * @param display - points back to the display
   * @param type - the type of the element being selected to move around the tree
   */
  public SelectRationaleElement_Treeview(Display display, RationaleElementType type) {

    this.eleType = type;
    ourDisplay = display;
    shell = new Shell(display, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
    shell.setText("Select Rationale Element");
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    gridLayout.makeColumnsEqualWidth = true;
    shell.setLayout(gridLayout);

    new Label(shell, SWT.NONE).setText("");
    new Label(shell, SWT.NONE).setText("");
    ontologyTree = new Tree(shell, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);

    root = new TreeItem(ontologyTree, SWT.NONE);

    if (type == RationaleElementType.ALTERNATIVE) {
      root.setText("Decision");
      populateTree(root, "NotNull", RationaleElementType.DECISION, true);
    }
    if (type == RationaleElementType.REQUIREMENT) {
      root.setText(type.toString());
      populateTree(root, "NotNull", type, true);
    }

    GridData gridData =
        new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 3;
    gridData.heightHint = ontologyTree.getItemHeight() * 15;
    ontologyTree.setLayoutData(gridData);

    new Label(shell, SWT.NONE).setText("");

    Button findB = new Button(shell, SWT.PUSH);
    findB.setText("Select");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    gridData.horizontalIndent = 5;
    findB.setLayoutData(gridData);
    if (eleType == RationaleElementType.ALTERNATIVE) eleType = RationaleElementType.DECISION;
    findB.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent event) {

            TreeItem[] selected = ontologyTree.getSelection();
            selElement = new RationaleElement();
            selElement = RationaleDB.getRationaleElement(selected[0].getText(), eleType);

            shell.close();
            shell.dispose();
          }
        });

    Button cancelB = new Button(shell, SWT.PUSH);
    cancelB.setText("Cancel");
    GridData gridData2 =
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    gridData2.horizontalIndent = 5;
    cancelB.setLayoutData(gridData2);
    cancelB.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent event) {
            selElement = null;
            shell.close();
            shell.dispose();
          }
        });

    // We want the buttons to be of equal size...
    findB.setSize(cancelB.getSize());

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }