コード例 #1
0
 public void removeSelected() {
   final CategoryItem parent =
       ((CategoryItem) navTreeWidget.getSelectedItem().getUserObject()).getParent();
   if (parent != null) {
     parent.removeChildren(getSelectedCategory().getName());
   } else {
     categories.removeChildren(getSelectedCategory().getName());
   }
   navTreeWidget.getSelectedItem().remove();
 }
コード例 #2
0
  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);
      }
    }
  }
コード例 #3
0
  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);
  }
コード例 #4
0
 private String getTitle(CategoryItem categoryItem) {
   if (categoryItem == null) {
     return Constants.INSTANCE.CreateANewTopLevelCategory();
   } else {
     return Constants.INSTANCE.CreateNewCategoryUnder0(categoryItem.getName());
   }
 }
コード例 #5
0
  public TreeItem buildTreeItem(final CategoryItem category) {
    final TreeItem it = new TreeItem();
    it.setHTML(
        AbstractImagePrototype.create(ImageResources.INSTANCE.categorySmall()).getHTML()
            + h(category.getName()));
    it.setUserObject(category);

    return it;
  }
コード例 #6
0
  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);
  }
コード例 #7
0
    void ok() {

      if ("".equals(this.name.getText())) {
        ErrorPopup.showMessage(Constants.INSTANCE.CanNotHaveAnEmptyCategoryName());
      } else {
        if (parent.contains(name.getText())) {
          ErrorPopup.showMessage(Constants.INSTANCE.CategoryWasNotSuccessfullyCreated());
        } else {
          isDirty = true;
          explorer.addChildren(parent, name.getText(), description.getText());
          hide();
        }
      }
    }