Esempio n. 1
0
  public Panel getAccordionNav() {
    Panel accordion = new Panel();
    accordion.setTitle("Accordion");
    accordion.setLayout(new AccordionLayout(true));

    Store store = getStore();

    Record[] records = store.getRecords();
    for (int i = 0; i < records.length; i++) {
      Record record = records[i];

      String id = record.getAsString("id");
      final String category = record.getAsString("category");
      String title = record.getAsString("title");
      final String iconCls = record.getAsString("iconCls");

      String thumbnail = record.getAsString("thumbnail");
      String qtip = record.getAsString("qtip");

      final ShowcasePanel panel = (ShowcasePanel) record.getAsObject("screen");

      if (category == null) {
        Panel categoryPanel = new Panel();
        categoryPanel.setAutoScroll(true);
        categoryPanel.setLayout(new FitLayout());
        categoryPanel.setId(id + "-acc");
        categoryPanel.setTitle(title);
        categoryPanel.setIconCls(iconCls);
        accordion.add(categoryPanel);
      } else {
        Panel categoryPanel = (Panel) accordion.findByID(category + "-acc");
        TreePanel treePanel = (TreePanel) categoryPanel.findByID(category + "-acc-tree");
        TreeNode root = null;
        if (treePanel == null) {
          treePanel = new TreePanel();
          treePanel.setAutoScroll(true);
          treePanel.setId(category + "-acc-tree");
          treePanel.setRootVisible(false);
          root = new TreeNode();
          treePanel.setRootNode(root);
          categoryPanel.add(treePanel);
        } else {
          root = treePanel.getRootNode();
        }

        TreeNode node = new TreeNode();
        node.setText(title);
        node.setId(id);
        if (iconCls != null) node.setIconCls(iconCls);
        if (qtip != null) node.setTooltip(qtip);
        root.appendChild(node);

        addNodeClickListener(node, panel, iconCls);
      }
    }

    return accordion;
  }
Esempio n. 2
0
  public TreePanel getTreeNav() {
    treePanel = new TreePanel();
    treePanel.setTitle("Tree View");
    treePanel.setId("nav-tree");
    treePanel.setWidth(180);
    treePanel.setCollapsible(true);
    treePanel.setAnimate(true);
    treePanel.setEnableDD(false);
    treePanel.setAutoScroll(true);
    treePanel.setContainerScroll(true);
    treePanel.setRootVisible(false);
    treePanel.setBorder(false);
    treePanel.setTopToolbar(getFilterToolbar());

    TreeNode root = new TreeNode("Showcase Explorer");
    treePanel.setRootNode(root);

    CreditsPanel creditsPanel = new CreditsPanel();

    TreeNode creditsNode = new TreeNode("Credits");
    creditsNode.setIconCls("credits-icon");
    creditsNode.setId("credits");
    root.appendChild(creditsNode);
    addNodeClickListener(creditsNode, creditsPanel, "credits-icon");

    Store store = getStore();

    Record[] records = store.getRecords();
    for (int i = 0; i < records.length; i++) {
      Record record = records[i];

      String id = record.getAsString("id");
      final String category = record.getAsString("category");
      String title = record.getAsString("title");
      final String iconCls = record.getAsString("iconCls");

      String thumbnail = record.getAsString("thumbnail");
      String qtip = record.getAsString("qtip");

      final ShowcasePanel panel = (ShowcasePanel) record.getAsObject("screen");

      TreeNode node = new TreeNode(title);
      node.setId(id);
      if (iconCls != null) node.setIconCls(iconCls);
      if (qtip != null) node.setTooltip(qtip);
      if (category == null || category.equals("")) {
        root.appendChild(node);
      } else {
        Node categoryNode =
            root.findChildBy(
                new NodeTraversalCallback() {
                  public boolean execute(Node node) {
                    return node.getId().equals(category);
                  }
                });

        if (categoryNode != null) {
          categoryNode.appendChild(node);
        }
      }
      addNodeClickListener(node, panel, iconCls);
    }
    treeFilter = new TreeFilter(treePanel);
    treePanel.expandAll();
    return treePanel;
  }