@Override
  public void onSuccess(CComponentTypeRegistry[] result) {
    CComponentTypeNode[] ds = new CComponentTypeNode[result.length];
    int index = 0;
    for (CComponentTypeRegistry registry : result) {
      ds[index++] = new CComponentTypeNode(registry);
      if (PROCESSOR_SECTION_ID.equals(sectionID))
        WebClientController.componentManager.registerProcessor(registry);
      else if (DATASOURCE_SECTION_ID.equals(sectionID))
        WebClientController.componentManager.registerDataSource(registry);
    }
    TreeNode root = new TreeNode("ComponentRoot", ds);

    Tree dataSourceTree = new Tree();
    dataSourceTree.setModelType(TreeModelType.CHILDREN);
    dataSourceTree.setNameProperty(COMPONENT_NAME);
    dataSourceTree.setRoot(root);
    // group tree grid
    TreeGridField connectorsField = new TreeGridField("ComponentField");
    connectorsField.setShowHover(false);
    connectorsField.setCellFormatter(
        new CellFormatter() {
          @Override
          public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
            return record.getAttributeAsString(COMPONENT_NAME);
          }
        });
    treeGrid.setData(dataSourceTree);
    treeGrid.setFields(connectorsField);
  }
  public Canvas getViewPanel() {
    Tree employeeTree = new Tree();
    employeeTree.setModelType(TreeModelType.PARENT);
    employeeTree.setRootValue(1);
    employeeTree.setNameProperty("Name");
    employeeTree.setIdField("EmployeeId");
    employeeTree.setParentIdField("ReportsTo");
    employeeTree.setOpenProperty("isOpen");
    employeeTree.setData(employeeData);

    TreeGridField formattedField = new TreeGridField("Name");
    formattedField.setCellFormatter(
        new CellFormatter() {
          public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
            return record.getAttributeAsString("Job") + ": " + value;
          }
        });

    TreeGrid employeeTreeGrid = new TreeGrid();

    employeeTreeGrid.setWidth(500);
    employeeTreeGrid.setHeight(400);
    employeeTreeGrid.setNodeIcon("icons/16/person.png");
    employeeTreeGrid.setFolderIcon("icons/16/person.png");
    employeeTreeGrid.setCanReorderRecords(true);
    employeeTreeGrid.setCanAcceptDroppedRecords(true);
    employeeTreeGrid.setShowOpenIcons(false);
    employeeTreeGrid.setDropIconSuffix("into");
    employeeTreeGrid.setClosedIconSuffix("");
    employeeTreeGrid.setData(employeeTree);
    employeeTreeGrid.setFields(formattedField);

    return employeeTreeGrid;
  }
Esempio n. 3
0
  public AddressbookTree() {
    super();
    SectionStackSection section = new SectionStackSection();
    section.setCanCollapse(false);
    section.setExpanded(true);
    section.setResizeable(true);

    TreeGrid tree = new TreeGrid();
    tree.setWidth100();
    tree.setHeight100();
    tree.setAnimateFolderTime(100);
    tree.setAnimateFolders(true);
    tree.setAnimateFolderSpeed(1000);
    tree.setShowSortArrow(SortArrow.CORNER);
    tree.setShowAllRecords(true);
    tree.setLoadDataOnDemand(false);
    tree.setCanSort(false);
    tree.setCellHeight(17);
    tree.setShowHeader(false);

    TreeGridField field = new TreeGridField();
    field.setCanFilter(true);
    field.setName("name");
    field.setTitle("<b>SmartGWT Showcase</b>");
    tree.setFields(field);

    Tree treeData = new Tree();
    treeData.setModelType(TreeModelType.PARENT);
    treeData.setNameProperty("name");
    treeData.setOpenProperty("isOpen");
    treeData.setIdField("nodeID");
    treeData.setParentIdField("parentNodeID");
    treeData.setRootValue("root");
    treeData.setData(DemoData.getAddressBookTreeData());

    tree.setData(treeData);
    section.setItems(tree);

    setSections(section);
  }
  public Canvas getViewPanel() {
    Tree employeeTree = new Tree();
    employeeTree.setModelType(TreeModelType.PARENT);
    employeeTree.setIdField("EmployeeId");
    employeeTree.setParentIdField("ReportsTo");
    employeeTree.setNameProperty("Name");
    employeeTree.setRootValue(1);
    employeeTree.setData(employeeData);

    TreeGrid employeeTreeGrid = new TreeGrid();
    employeeTreeGrid.setWidth(500);
    employeeTreeGrid.setHeight(400);
    employeeTreeGrid.setNodeIcon("icons/16/person.png");
    employeeTreeGrid.setFolderIcon("icons/16/person.png");
    employeeTreeGrid.setShowOpenIcons(false);
    employeeTreeGrid.setShowDropIcons(false);
    employeeTreeGrid.setClosedIconSuffix("");
    employeeTreeGrid.setFields(new TreeGridField("Name"));
    employeeTreeGrid.setData(employeeTree);

    employeeTreeGrid.getData().openAll();

    return employeeTreeGrid;
  }