Esempio n. 1
0
 private void makeTree(List<String> pageList) {
   for (String pageName : pageList) {
     String[] splits = pageName.split("\\.");
     treeRoot.addItem(splits, 0);
   }
   compactTree();
 }
Esempio n. 2
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);
  }
Esempio n. 3
0
 void addItem(String[] itemPath, int currentIndex) {
   if (currentIndex < itemPath.length) {
     // special case for this tree only, that all the titles should be organised before we start.
     if (nameSameAsLastName(itemPath[currentIndex])) {
       branches.get(branches.size() - 1).addItem(itemPath, ++currentIndex);
     } else {
       String branchName = itemPath[currentIndex];
       String branchFullName = fullName;
       branchFullName += (fullName.length() > 0) ? "." + branchName : branchName;
       TreeItem branch = new TreeItem(branchName, branchFullName);
       branches.add(branch);
       branch.addItem(itemPath, ++currentIndex);
     }
   }
 }