@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);
  }
Пример #2
0
  public void unlink(AgeAbstractClassImprint parent, AgeAbstractClassImprint child) {
    Tree data = getData();

    Collection<ImprintTreeNode> ndColl = nodeMap.get(child);

    Iterator<ImprintTreeNode> iter = ndColl.iterator();

    ListGridRecord selNode = getSelectedRecord();

    ListGridRecord toSelect = null;
    boolean needReselect = false;

    while (iter.hasNext()) {
      ImprintTreeNode node = iter.next();

      if (((ImprintTreeNode) data.getParent(node)).getClassImprint() == parent) {
        if (node == selNode) {
          needReselect = true;
          selectRecord(selNode, false);
        }

        data.remove(node);
        iter.remove();
      } else if (toSelect == null) toSelect = node;
    }

    if (needReselect && toSelect != null) selectRecord(toSelect);
  }
Пример #3
0
  ClassTreePanel(String title, AgeAbstractClassImprint root, Direction dir, NodeCreator nc) {
    direction = dir;
    nodeCreator = nc;

    //  if( title!=null )
    //  {
    //   setGroupTitle(title);
    ////   setShowHeader(title!=null);
    ////   setFields( new TreeGridField(title,title) );
    //  }

    setShowHeader(false);
    setShowConnectors(true);
    setShowRoot(false);
    setTitleField("Name");

    Tree data = new Tree();
    data.setModelType(TreeModelType.CHILDREN);
    setData(data);

    TreeNode rootNode = new TreeNode("Root");
    data.setRoot(rootNode);

    //  if( mod == null )
    //  {
    //   ClassTreeNode classRoot =  new ClassTreeNode("AgeClass");
    //   classRoot.setIcon("../images/icons/class/abstract.png");
    //
    //   rootNode.setChildren( new TreeNode[] { classRoot } );
    //  }
    //  else
    //  {
    //   setModel(root);
    //  }
    if (root != null) setRoot(root);

    addSelectionChangedHandler(
        new SelectionChangedHandler() {
          @Override
          public void onSelectionChanged(SelectionEvent event) {
            ImprintTreeNode ctn = (ImprintTreeNode) event.getRecord();

            Collection<ImprintTreeNode> coll = nodeMap.get(ctn.getClassImprint());

            if (coll.size() == 1) return;

            for (ImprintTreeNode othnd : coll) {
              if (othnd != ctn) {
                othnd.set_baseStyle(event.getState() ? "sameClassHighlite treeCell" : "treeCell");
              }
            }

            redraw();
          }
        });
  }
Пример #4
0
 private void selectAndExpandRootNode(DataArrivedEvent event) {
   // first event contains parent node that is root node of TreeGrid
   //  and it is a synthetic node without attributes
   TreeNode parentNode = event.getParentNode();
   Tree tree = treeSelector.getTree();
   TreeNode[] children = tree.getChildren(parentNode);
   if (children.length > 0 && children[0].getAttribute(RelationDataSource.FIELD_PARENT) == null) {
     // select real root node and expand it
     TreeNode realRootNode = children[0];
     treeSelector.selectRecord(realRootNode);
     tree.openFolder(realRootNode);
   }
 }
  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") + ":&nbsp;" + 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;
  }
Пример #6
0
  /** @return */
  private TreeNode getInboxTreeNode() {

    Tree treeData = this.tree.getData();
    TreeNode[] nodes = treeData.getChildren(treeData.getRoot());
    if (nodes != null && nodes.length > 0) {
      if (GWTUtil.getGwtFolder(nodes[0]) instanceof GWTMailbox) {
        nodes = treeData.getChildren(nodes[0]);
      }

      for (TreeNode node : nodes) {
        GWTMailFolder folder = (GWTMailFolder) GWTUtil.getGwtFolder(node);
        if (folder.isInbox()) {
          return (TreeNode) node;
        }
      }
    }
    return null;
  }
  /**
   * Processes a treeNode (add it to the TreeGrid)
   *
   * @param treeNode The treeNode to process
   * @param nodeRoot The root node to which the treeNode has te be added
   * @param tree The tree to which the node has to be added
   * @param mapModel map model
   * @param refresh True if the tree is refreshed (causing it to keep its expanded state)
   */
  private void processNode(
      final ClientLayerTreeNodeInfo treeNode,
      final TreeNode nodeRoot,
      final Tree tree,
      final MapModel mapModel,
      final boolean refresh) {
    if (null != treeNode) {
      String treeNodeLabel = treeNode.getLabel();
      final TreeNode node = new TreeNode(treeNodeLabel);

      tree.add(node, nodeRoot);

      // (final leafs)
      for (ClientLayerInfo info : treeNode.getLayers()) {
        Layer<?> layer = mapModel.getLayer(info.getId());
        tree.add(new LayerTreeTreeNode(this.tree, layer), node);
      }

      // treeNodes
      List<ClientLayerTreeNodeInfo> children = treeNode.getTreeNodes();
      for (ClientLayerTreeNodeInfo newNode : children) {
        processNode(newNode, node, tree, mapModel, refresh);
      }

      // expand tree nodes
      // when not refreshing expand them like configured
      // when refreshing expand them as before the refresh
      boolean isTreeNodeExpanded = treeNode.isExpanded();
      if (!refresh) {
        if (isTreeNodeExpanded) {
          tree.openFolder(node);
        }
      } else {
        // TODO close previously opened tree nodes, close others
      }
    }
  }
Пример #8
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);
  }
Пример #9
0
  public void setRoot(AgeAbstractClassImprint root) {
    Tree data = getData();

    if (root == null) {
      data.getRoot().setChildren(new TreeNode[0]);
      data.setRoot(data.getRoot());
      return;
    }

    TreeNode rootNode = data.getRoot();

    ImprintTreeNode clsRoot = nodeCreator.create(root);

    createTreeStructure(root, clsRoot);

    rootNode.setChildren(new TreeNode[] {clsRoot});

    data.setRoot(rootNode);

    data.openAll();
  }
  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;
  }
Пример #11
0
  public void onModuleLoad() {

    topTabSet = new TabSet();
    topTabSet.setTabBarPosition(Side.TOP);
    topTabSet.setWidth(1024);
    topTabSet.setHeight(768);
    topTabSet.setTabBarThickness(50);

    Tab tTab1 = new Tab("Menu", "assets/mainMenu.png");
    Img tImg1 = new Img("pieces/48/pawn_blue.png", 96, 96);

    topTabSet.addTab(tTab1);

    Tab lTab1 = new Tab();
    lTab1.setIcon("pieces/16/pawn_blue.png", 16);
    Img lImg1 = new Img("pieces/48/pawn_blue.png", 48, 48);
    lTab1.setPane(lImg1);

    HLayout buttons = new HLayout();
    buttons.setMembersMargin(15);

    VLayout vLayout = new VLayout();
    vLayout.setMembersMargin(15);
    vLayout.addMember(topTabSet);
    vLayout.addMember(buttons);
    // vLayout.addMember(leftTabSet);
    vLayout.setHeight("*");

    vLayout.draw();

    final HLayout hLayout = new HLayout();
    hLayout.setWidth100();
    hLayout.setHeight100();
    hLayout.setLayoutMargin(20);

    // tree menu
    TreeGrid tree = new TreeGrid();
    tree.setShowConnectors(true);
    tree.setShowResizeBar(true);

    Tree dataTree = new Tree();
    dataTree.setModelType(TreeModelType.CHILDREN);
    dataTree.setRoot(
        new TreeNode(
            "root",
            new TreeNode("Aluno"),
            new TreeNode("Funcionario"),
            new TreeNode("Contato"),
            new TreeNode("Veiculo"),
            new TreeNode("Disciplina")));

    tree.setData(dataTree);

    TreeGridField fieldTree = new TreeGridField("Navegacao");
    fieldTree.setCellFormatter(
        new CellFormatter() {
          public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
            return record.getAttribute("name");
          }
        });
    tree.setFields(fieldTree);

    // layout esquerda
    SectionStack leftSideLayout = new SectionStack();
    leftSideLayout.setWidth(200);
    leftSideLayout.setShowResizeBar(true);
    leftSideLayout.setVisibilityMode(VisibilityMode.MULTIPLE);
    leftSideLayout.setAnimateSections(true);

    leftSideLayout.setMembers(tree);

    // UIs
    final AlunoUI alunoUI = new AlunoUI();
    final FuncionarioUI funcionarioUI = new FuncionarioUI();
    final ContatoUI contatoUI = new ContatoUI();
    final VeiculoUI veiculoUI = new VeiculoUI();
    final DisciplinaUI disciplinaUI = new DisciplinaUI();

    // layout direita
    final SectionStack rightSideLayout = new SectionStack();
    rightSideLayout.setVisibilityMode(VisibilityMode.MULTIPLE);
    rightSideLayout.setAnimateSections(true);

    grid = alunoUI.getGrid();
    formBotoes = alunoUI.getFormBotoes();
    menuItens = new DynamicForm();
    menuItens.setWidth(100);
    menuItens.setAlign(Alignment.RIGHT);

    ButtonItem aluno = new ButtonItem("Aluno");
    aluno.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            newTabCustomAluno("Aluno");
          }
        });

    ButtonItem disc = new ButtonItem("Disciplina");
    disc.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            newTabCustomDisciplina("Disciplina");
          }
        });

    ButtonItem curso = new ButtonItem("Curso");
    curso.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            newTabCustomCurso("Curso");
          }
        });

    ButtonItem matric = new ButtonItem("Matricula");
    matric.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            newTabCustomMatricula("Matricula");
          }
        });

    menuItens.setFields(aluno, disc, curso, matric);

    rightSideLayout.setMembers(menuItens);
    rightSideLayout.setWidth(200);
    // seleciona tree
    tree.addNodeClickHandler(
        new NodeClickHandler() {
          public void onNodeClick(NodeClickEvent event) {
            String node = event.getNode().getAttribute("name");
            if (node.equals("Aluno")) {
              // rightSideLayout.removeMembers(formBotoes,grid);
              // Tab tab = new Tab(node);
              newTabCustomAluno(node);
            } else {
              if (node.equals("Disciplina")) {
                newTabCustomDisciplina(node);
              } else {
                if (node.equals("Curso")) {
                  //	newTabCustom(node);
                } else {
                  if (node.equals("Matricula")) {
                    //	newTabCustom(node);
                  } else {
                    if (node.equals("Disciplina")) {
                      rightSideLayout.removeMembers(formBotoes, grid);
                      grid = disciplinaUI.getGrid();
                      formBotoes = disciplinaUI.getFormBotoes();
                      rightSideLayout.setMembers(formBotoes, grid);
                    }
                  }
                }
              }
            }
          }
        });

    // hLayout

    hLayout.addMember(leftSideLayout);
    hLayout.addMember(rightSideLayout);
    hLayout.draw();

    tTab1.setPane(hLayout);
  }