예제 #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);
  }
 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);
  }
    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();
        }
      }
    }