Esempio n. 1
0
 private Tab getTab(String id) {
   List children = usertabs.getTabs().getChildren();
   for (Object obj : children) {
     Tab component = (Tab) obj;
     if (component.getId().equals(id)) {
       return component;
     }
   }
   return null;
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 public void onClose() {
   if (onCloseHandler != null) onCloseHandler.onClose(this);
   else {
     Tab tab = this.getLinkedTab();
     Tabbox tabbox = (Tabbox) tab.getTabbox();
     if (tabbox.getSelectedTab() == tab) {
       Tabs tabs = (Tabs) tabbox.getTabs();
       List childs = tabs.getChildren();
       for (int i = 0; i < childs.size(); i++) {
         if (childs.get(i) == tab) {
           if (i > 0) tabbox.setSelectedIndex((i - 1));
           break;
         }
       }
     }
     this.detach();
     tab.detach();
   }
 }
Esempio n. 4
0
 private void closeAllTabs() {
   Tab selectedTab = null;
   for (Object obj : new ArrayList(usertabs.getTabs().getChildren())) {
     Tab tab = ((Tab) obj);
     if (!tab.isSelected()) {
       Components.removeAllChildren(tab.getLinkedPanel());
       tab.close();
     } else {
       selectedTab = tab;
     }
   }
   if (selectedTab != null) {
     selectedTab.close();
   }
 }
  /**
   * 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());
    }
  }