Ejemplo n.º 1
0
 FileLocationComponentImpl(final UploadComponentOptions uploadOptions) {
   this.options = uploadOptions;
   final TreeOptions treeOptions = new TreeOptions();
   final String extension = uploadOptions.getExtension();
   treeOptions.setSelectionType(
       uploadOptions.isAllowMultiple() ? SelectionType.MULTIPlE : SelectionType.SINGLE);
   treeOptions.setInitialItems(locationFactory.getTropixObjectSourceRootItems(null));
   treeOptions.setShowPredicate(
       LocationPredicates.getTropixFileTreeItemPredicate(extension, true));
   treeOptions.setSelectionPredicate(
       LocationPredicates.getTropixFileTreeItemPredicate(extension, false));
   treeComponent = treeComponentFactory.get(treeOptions);
   treeComponent.addSelectionListener(
       new Listener<TreeItem>() {
         public void onEvent(final TreeItem location) {}
       });
   final TreeGrid treeGrid = treeComponent.get();
   treeGrid.setWidth100();
   treeGrid.setHeight100();
   super.setWidget(treeGrid);
 }
Ejemplo n.º 2
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);
  }
  /**
   * Builds up the tree showing the layers
   *
   * @param mapModel The mapModel containing the layerTree
   */
  private void buildTree(MapModel mapModel) {
    treeGrid.setWidth100();
    treeGrid.setHeight100();
    treeGrid.setShowHeader(false);
    tree = new RefreshableTree();
    final TreeNode nodeRoot = new TreeNode("ROOT");
    tree.setRoot(nodeRoot); // invisible ROOT node (ROOT node is required)

    ClientLayerTreeInfo layerTreeInfo = mapModel.getMapInfo().getLayerTree();
    if (layerTreeInfo != null) {
      ClientLayerTreeNodeInfo treeNode = layerTreeInfo.getTreeNode();
      processNode(treeNode, nodeRoot, tree, mapModel, false);
    }

    treeGrid.setData(tree);
    treeGrid.addLeafClickHandler(this);
    treeGrid.addFolderClickHandler(this);

    // -- add event listeners to layers
    for (Layer<?> layer : mapModel.getLayers()) {
      registrations.add(
          layer.addLayerChangedHandler(
              new LayerChangedHandler() {
                public void onLabelChange(LayerLabeledEvent event) {}

                public void onVisibleChange(LayerShownEvent event) {
                  for (TreeNode node : tree.getAllNodes()) {
                    if (node.getName().equals(event.getLayer().getLabel())) {
                      if (node instanceof LayerTreeTreeNode) {
                        ((LayerTreeTreeNode) node).updateIcon();
                      }
                    }
                  }
                }
              }));
    }
  }