Exemplo n.º 1
0
 /**
  * When the 'close all tabs' button is clicked.<br>
  * 1. Get a list of all open 'Tab'.<br>
  * 2. Iterate through it and close the Tab if it's not the Dashboard.<br>
  * 3. The Dashboard itself is modified after creating to not closable.<br>
  *
  * @throws IOException
  * @throws InterruptedException
  * @author Stephan Gerth
  */
 public void onClick$btnCloseAllTabs() throws IOException, InterruptedException {
   List<AbstractComponent> list = tabsIndexCenter.getChildren();
   try {
     while (!list.isEmpty()) {
       // get the sum of all Tab
       int i = list.size();
       // close all tabs, beginning with the last
       // because Dashboard is all times the first
       if (list.get(i - 1) instanceof Tab) {
         if (StringUtils.equals(((Tab) list.get(i - 1)).getId(), "tab_menu_Item_Home")) {
           break;
         } else {
           ((Tab) list.get(i - 1)).onClose();
         }
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
     MensajeMultilinea.show(e.toString(), Constants.MENSAJE_TIPO_ERROR);
   }
 }
Exemplo n.º 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());
    }
  }