Пример #1
0
 private Tab addTab(String id, String tabName, EventListener eventListener) {
   Tab tab = new Tab(tabName);
   tab.setId(id);
   tab.setParent(usertabs.getTabs());
   Tabpanel tabpanel = new Tabpanel();
   tabpanel.setParent(usertabs.getTabpanels());
   if (eventListener != null) {
     tab.addEventListener("onSelect", eventListener);
   }
   return tab;
 }
Пример #2
0
  /**
   * Creates a page from a zul-file in a tab in the center area of the borderlayout. Checks if the
   * tab is opened before. If yes than it selects this tab.
   *
   * @param zulFilePathName The ZulFile Name with path.
   * @param tabName The tab name.
   * @throws InterruptedException
   */
  private void showPage(String zulFilePathName, String tabName) throws InterruptedException {

    try {
      // TODO get the parameter for working with tabs from the application
      // params
      final int workWithTabs = 1;
      if (workWithTabs == 1) {
        /* get an instance of the borderlayout defined in the zul-file */
        Borderlayout bl = (Borderlayout) Path.getComponent("/outerIndexWindow/borderlayoutMain");
        /* get an instance of the searched CENTER layout area */
        Center center = bl.getCenter();
        // get the tabs component
        Tabs tabs =
            (Tabs)
                center
                    .getFellow("divCenter")
                    .getFellow("tabBoxIndexCenter")
                    .getFellow("tabsIndexCenter");
        /**
         * Check if the tab is already opened than select them and<br>
         * go out of here. If not than create them.<br>
         */
        Tab checkTab = null;
        try {
          // checkTab = (Tab) tabs.getFellow(tabName);
          checkTab = (Tab) tabs.getFellow("tab_" + tabName.trim());
          checkTab.setSelected(true);
        } catch (final ComponentNotFoundException ex) {
          // Ignore if can not get tab.
        }
        if (checkTab == null) {
          Tab tab = new Tab();
          tab.setId("tab_" + tabName.trim());
          tab.setLabel(tabName.trim());
          tab.setClosable(true);
          tab.setParent(tabs);
          Tabpanels tabpanels =
              (Tabpanels)
                  center
                      .getFellow("divCenter")
                      .getFellow("tabBoxIndexCenter")
                      .getFellow("tabsIndexCenter")
                      .getFellow("tabpanelsBoxIndexCenter");
          Tabpanel tabpanel = new Tabpanel();
          tabpanel.setHeight("100%");
          tabpanel.setStyle("padding: 0px;");
          tabpanel.setParent(tabpanels);
          /**
           * Create the page and put it in the tabs area. If zul-file is not found, detach the
           * created tab
           */
          try {
            Executions.createComponents(zulFilePathName, tabpanel, null);
            tab.setSelected(true);
          } catch (final Exception e) {
            tab.detach();
          }
        }
      } else {
        /* get an instance of the borderlayout defined in the zul-file */
        Borderlayout bl = (Borderlayout) Path.getComponent("/outerIndexWindow/borderlayoutMain");
        /* get an instance of the searched CENTER layout area */
        Center center = bl.getCenter();
        /* clear the center child comps */
        center.getChildren().clear();
        /** create the page and put it in the center layout area */
        Executions.createComponents(zulFilePathName, center, null);
      }

      if (logger.isDebugEnabled()) {
        logger.debug("--> calling zul-file: " + zulFilePathName);
      }
    } catch (final Exception e) {
      Messagebox.show(e.toString());
    }
  }