Esempio n. 1
0
  private void buildPkgTree(TreeItem root, PackageHierarchy.Folder folder) {
    if (folder.getConfig() != null) {
      root.addItem(loadPackage(folder.getName(), folder.getConfig()));
    } else {
      TreeItem treeItem = new TreeItem(Util.getHeader(images.emptyPackage(), folder.getName()));
      root.addItem(treeItem);

      for (PackageHierarchy.Folder childFolder : folder.getChildren()) {
        buildPkgTree(treeItem, childFolder);
      }
    }
  }
Esempio n. 2
0
  private void buildPkgTree(TreeItem root, PackageHierarchy.Folder fldr) {
    if (fldr.conf != null) {
      root.addItem(loadPackage(fldr.name, fldr.conf));
    } else {
      TreeItem tn = new TreeItem(Util.getHeader(images.emptyPackage(), fldr.name));
      // itemWidgets.put(item, AssetFormats.BUSINESS_RULE_FORMATS[0]);
      root.addItem(tn);

      for (PackageHierarchy.Folder c : fldr.children) {
        buildPkgTree(tn, c);
      }
    }
  }
 private TreeItem add(TreeItem parent, TreeType type) {
   if (type == TreeType.TEXT) {
     return parent.addItem("text");
   } else if (type == TreeType.HTML) {
     TreeItem item = new TreeItem();
     item.setHTML("<h1>html</h1>");
     parent.addItem(item);
     return item;
   } else if (type == TreeType.CHECKBOX) {
     return parent.addItem(new CheckBox("myBox"));
   } else {
     throw new RuntimeException("What?");
   }
 }
Esempio n. 4
0
    private void addTreeItem(JSONObject jsonObject, int index) {

      Node node =
          new Node(
              jsonObject.get("id").isString().stringValue(),
              jsonObject.get("leaf").isBoolean().booleanValue(),
              jsonObject.get("text").isString().stringValue());
      if (node.getText() != null) {
        TreeItem item = new TreeItem();
        item.setText(node.getText());
        item.setUserObject(node);
        if (!node.isLeaf()) item.addItem(""); // Temporarily add an item so we can expand this node

        treeItem.addItem(item);
      }
    }
 /**
  * Constructs a tree item for generic ("Advanced") component blocks for component types that
  * appear in form.
  *
  * @param form only component types that appear in this Form will be included
  * @return tree item for this form
  */
 public TreeItem getGenericComponentsTree(MockForm form) {
   Map<String, String> typesAndIcons = Maps.newHashMap();
   form.collectTypesAndIcons(typesAndIcons);
   TreeItem advanced = new TreeItem(new HTML("<span>" + MESSAGES.anyComponentLabel() + "</span>"));
   List<String> typeList = new ArrayList<String>(typesAndIcons.keySet());
   Collections.sort(typeList);
   for (final String typeName : typeList) {
     TreeItem itemNode =
         new TreeItem(
             new HTML(
                 "<span>"
                     + typesAndIcons.get(typeName)
                     + MESSAGES.textAnyComponentLabel()
                     + TranslationDesignerPallete.getCorrespondingString(typeName)
                     + "</span>"));
     SourceStructureExplorerItem sourceItem =
         new BlockSelectorItem() {
           @Override
           public void onSelected() {
             fireGenericDrawerSelected(typeName);
           }
         };
     itemNode.setUserObject(sourceItem);
     advanced.addItem(itemNode);
   }
   return advanced;
 }
Esempio n. 6
0
  private void buildLessonTree(Response response) {
    TreeItem item = null;
    JsArray<LessonCategoryJS> lessonJSArray = JsonUtils.safeEval(response.getText());

    for (int i = 0; i < lessonJSArray.length(); i++) {
      LessonCategoryJS lessonCategoryJS = lessonJSArray.get(i);
      TreeItem category = new TreeItem();
      category.setText(lessonCategoryJS.getName());

      JsArray<LessonJS> lessons = lessonCategoryJS.getChildren();
      for (int j = 0; j < lessons.length(); j++) {
        LessonJS lesson = lessons.get(j);

        TreeItem lessonItem = new TreeItem();
        Storage sessionStorage = Storage.getSessionStorageIfSupported();
        String lastUrl = sessionStorage.getItem("lastUrl");
        lessonItem.setText(lesson.getText());
        category.addItem(lessonItem);
        lessonsTreeMap.put(lessonItem.getText(), lesson);
        if (lesson.getTechnology().equals(LessonTechnology.GWT.toString())) {
          addLessonToMap(lesson);
        }
        if (lastUrl != null && lastUrl.equals(lesson.getUrl())) {
          item = lessonItem;
          lessonPanel.setSelectedLesson(lesson);
          category.setState(true);
        }
      }
      lessonTree.addItem(category);
    }
    lessonTree.setSelectedItem(item);
  }
  protected void loadChildren(final TreeItem it, final CategoryItem category) {
    for (final CategoryItem child : category.getChildren()) {
      final TreeItem ct = buildTreeItem(child);

      it.addItem(ct);

      if (child.hasChild()) {
        loadChildren(ct, child);
      }
    }
  }
Esempio n. 8
0
  /**
   * A helper method to simplify adding tree items that have attached images. {@link
   * #addImageItem(TreeItem, String) code}
   *
   * @param root the tree item to which the new item will be added.
   * @param title the text associated with this item.
   */
  private static TreeItem addImageItem(
      TreeItem root,
      String title,
      ImageResource imageProto,
      Object userObj,
      String helpText,
      PopupPanel popup) {

    TreeItem item = new CompositeTreeItem(new TreeItemWidget(imageProto, title, popup));
    item.setUserObject(userObj);
    item.setTitle(helpText);
    root.addItem(item);
    return item;
  }
 private void loadItem(VariableSerializable[] vars) {
   for (int j = 0; j < vars.length; j++) {
     // Do not include variables with subset_variable="true" used to denote "selector"
     // variables in in-situ data sets like SOCAT
     // TODO and for now no variables with character string values
     // if ( Util.keep(vars[j].getDSID(), vars[j].getName()) && Util.keep(vars[j].getDSID(),
     // vars[j].getAttributes()) ) {
     TreeItem item = new TreeItem();
     item.setText(vars[j].getName());
     item.setUserObject(vars[j]);
     currentlySelected.addItem(item);
     // }
   }
 }
  public void addChildren(final CategoryItem parent, final String name, final String description) {
    final CategoryItem child = parent.addChildren(name, description);

    final TreeItem parentTree;
    if (getSelectedCategory() == null) {
      parentTree = navTreeWidget.getItem(0);
    } else {
      parentTree = navTreeWidget.getSelectedItem();
    }

    final TreeItem ct = buildTreeItem(child);
    parentTree.addItem(ct);
    parentTree.setState(true);
  }
  protected void buildTree(final Categories categories) {
    final TreeItem root = new TreeItem();
    root.setHTML(AbstractImagePrototype.create(ImageResources.INSTANCE.desc()).getHTML());
    navTreeWidget.addItem(root);

    for (final CategoryItem category : categories) {
      final TreeItem it = buildTreeItem(category);
      root.addItem(it);

      if (category.hasChild()) {
        loadChildren(it, category);
      }
    }

    root.setState(true);
  }
Esempio n. 12
0
  public void updateTreeItems(TreeItem treeItem, List<FileWrapper> list) {
    if (treeItem == null) treeItem = trtmRoot;

    int index = 0, numberOfChildren = treeItem.getChildCount();
    int newIndex = 0, numberOfNewChildren = list.size();
    while (newIndex < numberOfNewChildren && index < numberOfChildren) {
      FileWrapper fileWrapper = list.get(newIndex);
      if (fileWrapper.getKind() != FileType.DIR) {
        break;
      }
      TreeItem child = treeItem.getChild(index);
      int diff = child.getText().compareTo(fileWrapper.getName());
      if (diff < 0) {
        treeItem.removeItem(child);
      } else if (diff > 0) {
        TreeItem trtmNewItem = new TreeItem();
        treeItem.insertItem(index, trtmNewItem);
        trtmNewItem.setText(fileWrapper.getName());
        index++;
        numberOfChildren++;
        newIndex++;
        presenter.getFiles(trtmNewItem, getPath(trtmNewItem));
      } else {
        index++;
        newIndex++;
        presenter.getFiles(child, getPath(child));
      }
    }
    while (newIndex < numberOfNewChildren) {
      FileWrapper fileWrapper = list.get(newIndex++);
      if (fileWrapper.getKind() != FileType.DIR) {
        break;
      }
      TreeItem trtmNewItem = new TreeItem();
      treeItem.addItem(trtmNewItem);
      trtmNewItem.setText(fileWrapper.getName());
      presenter.getFiles(trtmNewItem, getPath(trtmNewItem));
    }
    while (index < numberOfChildren) {
      treeItem.removeItem(treeItem.getChild(index));
      numberOfChildren--;
    }
  }
  /**
   * Create a Dynamic tree. The code comes from the GWT show case :
   * http://gwt.google.com/samples/Showcase/Showcase.html#!CwTree
   *
   * @return
   */
  private Widget createDynamicTree() {
    // Create a new tree
    Tree dynamicTree = new Tree();

    // Add some default tree items
    for (int i = 0; i < 5; i++) {
      TreeItem item = dynamicTree.addItem("Item " + i);

      // Temporarily add an item so we can expand this node
      item.addItem("");
    }

    // Add a handler that automatically generates some children
    dynamicTree.addOpenHandler(
        new OpenHandler<TreeItem>() {
          public void onOpen(OpenEvent<TreeItem> event) {
            TreeItem item = event.getTarget();
            if (item.getChildCount() == 1) {
              // Close the item immediately
              item.setState(false, false);

              // Add a random number of children to the item
              String itemText = item.getText();
              int numChildren = Random.nextInt(5) + 2;
              for (int i = 0; i < numChildren; i++) {
                TreeItem child = item.addItem(itemText + "." + i);
                child.addItem("");
              }

              // Remove the temporary item when we finish loading
              item.getChild(0).remove();

              // Reopen the item
              item.setState(true, false);
            }
          }
        });

    // Return the tree (decorated)
    DecoratorPanel decPanel = new DecoratorPanel();
    decPanel.setWidget(dynamicTree);
    return decPanel;
  }
Esempio n. 14
0
  public void setFullyQualifiedClassNames(final List<String> fullyQualifiedClassNames) {
    if (tree.getItem(0) != null) {
      tree.clear();
    }

    if (fullyQualifiedClassNames != null) {
      for (String type : fullyQualifiedClassNames) {
        final TreeItem it = new TreeItem();
        it.setHTML(
            AbstractImagePrototype.create(DRLTextEditorResources.INSTANCE.images().classImage())
                    .getHTML()
                + "<small>"
                + type
                + "</small>");
        it.setUserObject(new ClassUserObject(type + "( )", type));
        tree.addItem(it);
        it.addItem(Util.toSafeHtml(LAZY_LOAD));
      }
    }
  }
Esempio n. 15
0
        public void onSuccess(List<GWTFolder> result) {
          boolean directAdd = true;

          // If has no childs directly add values is permited
          if (actualItem.getChildCount() > 0) {
            directAdd = false;
            // to prevent remote folder remove it disables all tree branch
            // items and after sequentially activate
            hideAllBranch(actualItem);
          }

          // On refreshing not refreshed the actual item values but must
          // ensure that has childs value is consistent
          if (result.isEmpty()) {
            ((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
          } else {
            ((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
          }

          // Ads folders childs if exists
          for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
            GWTFolder folder = it.next();
            TreeItem folderItem = new TreeItem(folder.getName());
            folderItem.setUserObject(folder);
            folderItem.setStyleName("okm-TreeItem");

            // If has no childs directly add values is permited, else
            // evalues each node to refresh, remove or add
            if (directAdd) {
              evaluesFolderIcon(folderItem);
              actualItem.addItem(folderItem);
            } else {
              // sequentially activate items and refreshes values
              addFolder(actualItem, folderItem);
            }
          }

          actualItem.setState(true);
          evaluesFolderIcon(actualItem);
        }
  protected void addRootNode(final TreeItem rootItem, final TreeItem leafItem) {
    rootItem.getElement().getStyle().setBackgroundColor("#eff3ff"); // $NON-NLS-1$
    rootItem.getElement().getStyle().setMarginBottom(1, Unit.PX);
    rootItem.getElement().getStyle().setPadding(0, Unit.PX);

    if (leafItem != null) {
      rootItem.addItem(leafItem);

      // Defer styling in order to override padding done in:
      // com.google.gwt.user.client.ui.Tree -> showLeafImage
      Scheduler.get()
          .scheduleDeferred(
              new Scheduler.ScheduledCommand() {
                @Override
                public void execute() {
                  leafItem.getElement().getStyle().setBackgroundColor("#ffffff"); // $NON-NLS-1$
                  leafItem.getElement().getStyle().setMarginLeft(20, Unit.PX);
                  leafItem.getElement().getStyle().setPadding(0, Unit.PX);

                  Boolean isLeafEmpty = (Boolean) leafItem.getUserObject();
                  if (isLeafEmpty != null && isLeafEmpty.equals(Boolean.TRUE)) {
                    rootItem
                        .getElement()
                        .getElementsByTagName("td")
                        .getItem(0)
                        .getStyle()
                        .setVisibility(Visibility.HIDDEN); // $NON-NLS-1$
                  }
                  rootItem
                      .getElement()
                      .getElementsByTagName("td")
                      .getItem(1)
                      .getStyle()
                      .setWidth(100, Unit.PCT); // $NON-NLS-1$
                }
              });
    }

    tree.addItem(rootItem);
  }
 /**
  * Constructs a tree item for built-in blocks.
  *
  * @return tree item
  */
 public TreeItem getBuiltInBlocksTree() {
   initBundledImages();
   TreeItem builtinNode =
       new TreeItem(new HTML("<span>" + MESSAGES.builtinBlocksLabel() + "</span>"));
   for (final String drawerName : BUILTIN_DRAWER_NAMES) {
     Image drawerImage = new Image(bundledImages.get(drawerName));
     TreeItem itemNode =
         new TreeItem(
             new HTML("<span>" + drawerImage + getBuiltinDrawerNames(drawerName) + "</span>"));
     SourceStructureExplorerItem sourceItem =
         new BlockSelectorItem() {
           @Override
           public void onSelected() {
             fireBuiltinDrawerSelected(drawerName);
           }
         };
     itemNode.setUserObject(sourceItem);
     builtinNode.addItem(itemNode);
   }
   builtinNode.setState(true);
   return builtinNode;
 }
Esempio n. 18
0
  /**
   * Adds folders to actual item if not exists or refreshes it values
   *
   * @param actualItem The actual item active
   * @param newItem New item to be added, or refreshed
   */
  public void addFolder(TreeItem actualItem, TreeItem newItem) {
    int i = 0;
    boolean found = false;
    int count = actualItem.getChildCount();
    GWTFolder folder;
    GWTFolder newFolder = (GWTFolder) newItem.getUserObject();
    String folderPath = newFolder.getPath();

    for (i = 0; i < count; i++) {
      folder = (GWTFolder) actualItem.getChild(i).getUserObject();
      // If item is found actualizate values
      if ((folder).getPath().equals(folderPath)) {
        found = true;
        actualItem.getChild(i).setVisible(true);
        actualItem.getChild(i).setUserObject(newFolder);
        evaluesFolderIcon(actualItem.getChild(i));
      }
    }

    if (!found) {
      evaluesFolderIcon(newItem);
      actualItem.addItem(newItem);
    }
  }
Esempio n. 19
0
  public void addTag(final String tagInstanceID) {

    ClientTagInstance tagInstance = vTagger.getTagInstance(tagInstanceID);

    Grid grid = new Grid(1, 3);
    Label l = new HTML("#" + tagInstanceID);
    grid.setWidget(0, 0, l);

    PushButton tagRemoveButton = new PushButton("remove");
    // tagRemoveButton.addStyleName("tagger-pushButton");
    grid.setWidget(0, 1, tagRemoveButton);
    HandlerRegistration tagRemoveBtReg =
        tagRemoveButton.addClickHandler(
            new ClickHandler() {

              public void onClick(ClickEvent event) {
                vTagger.removeTagInstance(tagInstanceID);
                hide();
              }
            });
    handlerRegistrations.add(tagRemoveBtReg);

    PushButton tagEditButton = new PushButton("edit");
    // tagEditButton.addStyleName("tagger-pushButton");
    tagEditButton.setEnabled(false);
    grid.setWidget(0, 2, tagEditButton);
    HandlerRegistration tagEditBtReg =
        tagEditButton.addClickHandler(
            new ClickHandler() {

              public void onClick(ClickEvent event) {}
            });
    handlerRegistrations.add(tagEditBtReg);
    root.addItem(grid);
    root.setState(true);
  }
Esempio n. 20
0
  private void initTree() {
    String section_key = "section";
    String subsection_key = "subsection";
    TreeItem root = new TreeItem("Help");
    PlaceRequest rootPlace = new PlaceRequest(NameTokens.helpPage);

    tree.addItem(
            new Hyperlink(
                "Introduction",
                placeManager.buildHistoryToken(rootPlace.with(section_key, "introduction"))))
        .setUserObject("introduction");

    // Phenotypes
    TreeItem phenotypes_item =
        new TreeItem(
            new Hyperlink(
                "Phenotypes",
                placeManager.buildHistoryToken(rootPlace.with(section_key, "phenotypes"))));
    phenotypes_item.setUserObject("phenotypes");
    phenotypes_item
        .addItem(
            new Hyperlink(
                "Uploading Phenotypes",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "phenotypes").with(subsection_key, "upload"))))
        .setUserObject("phenotypes_upload");
    phenotypes_item
        .addItem(
            new Hyperlink(
                "Phenotype Format",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "phenotypes").with(subsection_key, "format"))))
        .setUserObject("phenotypes_format");
    tree.addItem(phenotypes_item);

    // Accessions
    TreeItem accession_item =
        new TreeItem(
            new Hyperlink(
                "Accessions",
                placeManager.buildHistoryToken(rootPlace.with(section_key, "accessions"))));
    accession_item.setUserObject("accessions");
    tree.addItem(accession_item);

    // Analysis
    TreeItem analysis_item =
        new TreeItem(
            new Hyperlink(
                "Analysis",
                placeManager.buildHistoryToken(rootPlace.with(section_key, "analysis"))));
    analysis_item.setUserObject("analysis");
    analysis_item
        .addItem(
            new Hyperlink(
                "Navigation",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "analysis").with(subsection_key, "navigation"))))
        .setUserObject("analysis_navigation");
    analysis_item
        .addItem(
            new Hyperlink(
                "Phenotypes",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "analysis").with(subsection_key, "phenotypes"))))
        .setUserObject("analysis_phenotypes");
    analysis_item
        .addItem(
            new Hyperlink(
                "Datasets",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "analysis").with(subsection_key, "datasets"))))
        .setUserObject("analysis_datasets");
    analysis_item
        .addItem(
            new Hyperlink(
                "Transformations",
                placeManager.buildHistoryToken(
                    rootPlace
                        .with(section_key, "analysis")
                        .with(subsection_key, "transformations"))))
        .setUserObject("analysis_transformations");
    analysis_item
        .addItem(
            new Hyperlink(
                "Results",
                placeManager.buildHistoryToken(
                    rootPlace.with(section_key, "analysis").with(subsection_key, "results"))))
        .setUserObject("analysis_results");
    tree.addItem(analysis_item);

    // Tutorial
    /*TreeItem tutorial_item = new TreeItem(new Hyperlink("Tutorial",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial"))));
    tutorial_item.setUserObject("tutorial");
    tutorial_item.addItem(new Hyperlink("1.) Uploading Phenotypes",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "uploading")))).setUserObject("tutorial_uploading");
    tutorial_item.addItem(new Hyperlink("2.) Creating subset",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "subset")))).setUserObject("tutorial_subset");
    tutorial_item.addItem(new Hyperlink("3.) Changing transformation",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "transformation")))).setUserObject("tutorial_transformation");
    tutorial_item.addItem(new Hyperlink("4.) Running GWAS",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "gwas")))).setUserObject("tutorial_gwas");
    tutorial_item.addItem(new Hyperlink("5.) Viewing Results",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "results")))).setUserObject("tutorial_results");
    tutorial_item.addItem(new Hyperlink("6.) Running Step-Wise GWAS",placeManager.buildHistoryToken(rootPlace.with(section_key, "tutorial").with(subsection_key, "gwas_step")))).setUserObject("tutorial_gwas_step");
    tree.addItem(tutorial_item);*/
    Iterator<TreeItem> iterator = tree.treeItemIterator();
    while (iterator.hasNext()) {
      iterator.next().setState(true, false);
    }
  }
 public void onSuccess(Object result) {
   CategorySerializable[] cats = (CategorySerializable[]) result;
   if (cats != null && cats.length > 0) {
     if (currentlySelected == null) {
       for (int i = 0; i < cats.length; i++) {
         CategorySerializable cat = cats[i];
         String children = cat.getAttributes().get("children");
         boolean empty = false;
         if (children != null && children.equals("none")) empty = true;
         if (applyFilters(cat) && !empty) {
           TreeItem item = new TreeItem();
           item.addItem(
               new SafeHtmlBuilder().appendEscaped(DatasetWidget.LOADING).toSafeHtml());
           InnerItem inner = new InnerItem(cat);
           item.setWidget(inner);
           item.setUserObject(cat);
           addItem(item);
         }
       }
     } else {
       for (int i = 0; i < cats.length; i++) {
         CategorySerializable cat = cats[i];
         if (cat.isCategoryChildren()) {
           String name = cat.getName();
           TreeItem item;
           if (i == 0) {
             item = currentlySelected.getChild(0);
           } else {
             item = new TreeItem();
           }
           item.addItem(
               new SafeHtmlBuilder().appendEscaped(DatasetWidget.LOADING).toSafeHtml());
           InnerItem inner = new InnerItem(cat);
           item.setWidget(inner);
           item.setUserObject(cat);
           if (i > 0) {
             currentlySelected.addItem(item);
           }
         } else if (cat.isVariableChildren()) {
           // Must have variable children...
           TreeItem item = currentlySelected.getChild(0);
           if (cat.hasMultipleDatasets()) {
             DatasetSerializable[] dses = cat.getDatasetSerializableArray();
             DatasetSerializable ds = dses[0];
             VariableSerializable[] vars = ds.getVariablesSerializable();
             currentlySelected.removeItems();
             for (int j = 0; j < dses.length; j++) {
               ds = dses[j];
               vars = ds.getVariablesSerializable();
               loadItem(vars);
             }
           } else {
             DatasetSerializable ds = cat.getDatasetSerializable();
             VariableSerializable[] vars = ds.getVariablesSerializable();
             currentlySelected.removeItems();
             loadItem(vars);
           }
         }
       }
     }
   } else {
     // A category was selected, but it came back empty...
     if (currentlySelected != null) {
       TreeItem item = currentlySelected.getChild(0);
       item.setText("No data sets found.");
     }
   }
   if (saveSelection != null) {
     currentlySelected = saveSelection;
     saveSelection = null;
   }
 }
Esempio n. 22
0
 private void addItem(TreeItem root, ImageResource image, String label) {
   root.addItem(AbstractImagePrototype.create(image).getHTML() + " " + label);
 }
Esempio n. 23
0
  public SurveyWidget(Survey s, Images images, Composite parent) {
    this.survey = s;
    this.images = images;
    this.parent = parent;

    tree = new Tree(images);
    String title = s.getName() + " ";
    SurveyStatus status = survey.getStatus();
    switch (status) {
      case ACTIVE:
        title += "<span style='color:green'>(Active)</span>";
        break;
      case CANCELLED:
        title += "<span style='color:red'>(Cancelled)</span>";
        break;
      case EXPIRED:
        title += "(Expired)";
    }
    rootHTML = imageItemHTML(images.inbox(), title);
    root = new TreeItem(rootHTML);
    tree.addItem(root);

    tree.addSelectionHandler(
        new SelectionHandler<TreeItem>() {

          public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();

            if (promptMap.containsKey(item)) {
              Prompt p = promptMap.get(item);
              Messages.get().displaySurveyInput(p, 0);
            }
          }
        });

    detailsHTML = imageItemHTML(images.drafts(), "Details");
    detailsHTML.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            if (detailsModel == null) {
              JSONRequest request = new JSONRequest();
              request.doFetchURL(
                  AoAPI.SURVEY_DETAILS + survey.getId() + "/", new SurveyDetailsRequester());
            } else {
              DetailsDialog details = new DetailsDialog(detailsModel);
              details.show();
              details.center();
            }
          }
        });

    TreeItem details = new TreeItem(detailsHTML);
    root.addItem(details);

    if (status == SurveyStatus.ACTIVE) {
      cancelHTML = imageItemHTML(images.reject_sm(), "Cancel");
      cancelHTML.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              confirm =
                  new AreYouSureDialog(
                      "Are you sure you want to cancel all future calls for this broadcast?");
              confirm.show();
              confirm.center();

              confirm.addCloseHandler(
                  new CloseHandler<PopupPanel>() {
                    public void onClose(CloseEvent<PopupPanel> event) {
                      if (confirm.isConfirmed()) {
                        JSONRequest request = new JSONRequest();
                        request.doFetchURL(
                            AoAPI.CANCEL_SURVEY + survey.getId() + "/",
                            new CancelSurveyRequester());
                      }
                    }
                  });
            }
          });

      TreeItem cancel = new TreeItem(cancelHTML);
      root.addItem(cancel);
    }
  }