Пример #1
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);
  }
Пример #2
0
  private TreeGrid createTreeSelector() {
    TreeGrid treeGrid = new TreeGrid();
    treeGrid.setCanSort(false);
    treeGrid.setDataSource(RelationDataSource.getInstance());
    TreeGridField parentId = new TreeGridField(RelationDataSource.FIELD_PARENT);
    TreeGridField label =
        new TreeGridField(
            RelationDataSource.FIELD_LABEL, i18n.DigitalObjectSearchView_ListHeaderLabel_Title());
    TreeGridField model =
        new TreeGridField(
            RelationDataSource.FIELD_MODEL,
            i18n.DigitalObjectSearchView_ListHeaderModel_Title(),
            150);
    model.setAlign(Alignment.CENTER);
    TreeGridField pid =
        new TreeGridField(
            RelationDataSource.FIELD_PID, i18n.DigitalObjectSearchView_ListHeaderPid_Title(), 100);
    pid.setAlign(Alignment.CENTER);
    TreeGridField created =
        new TreeGridField(
            RelationDataSource.FIELD_CREATED,
            i18n.DigitalObjectSearchView_ListHeaderCreated_Title(),
            100);
    created.setAlign(Alignment.CENTER);
    TreeGridField modified =
        new TreeGridField(
            RelationDataSource.FIELD_MODIFIED,
            i18n.DigitalObjectSearchView_ListHeaderModified_Title(),
            100);
    modified.setAlign(Alignment.CENTER);
    TreeGridField owner =
        new TreeGridField(
            RelationDataSource.FIELD_OWNER,
            i18n.DigitalObjectSearchView_ListHeaderOwner_Title(),
            100);
    TreeGridField export =
        new TreeGridField(
            SearchDataSource.FIELD_EXPORT,
            i18n.DigitalObjectSearchView_ListHeaderExport_Title(),
            100);
    export.setCellFormatter(
        new CellFormatter() {

          @Override
          public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
            return value == null || "0".equals(value)
                ? i18nSmartGwt.dialog_NoButtonTitle()
                : i18nSmartGwt.dialog_YesButtonTitle();
          }
        });
    treeGrid.setFields(parentId, label, model, pid, created, modified, owner, export);
    treeGrid.setTitleField(RelationDataSource.FIELD_LABEL);
    treeGrid.setShowConnectors(true);
    treeGrid.setEmptyMessage(i18n.DigitalObjectTreeView_EmptySelection_Msg());
    treeGrid.setAlternateRecordStyles(true);
    treeGrid.setSelectionType(SelectionStyle.SINGLE);
    treeGrid.setContextMenu(Actions.createMenu());
    treeGrid.addDataArrivedHandler(
        new DataArrivedHandler() {

          @Override
          public void onDataArrived(DataArrivedEvent event) {
            selectAndExpandRootNode(event);
          }
        });
    return treeGrid;
  }