예제 #1
0
  /**
   * Selects and activates a given tab, if possible.
   *
   * @param tab the tab name/identifier to activate
   */
  private void activateTab(final String tab) {
    if (activeTab != null) {
      activeTab.unSelect();
    }

    activeTab = tabs.get(tab);
    activeTab.select();

    tabContents.clear();
    tabContents.add(activeTab.getContents());
  }
예제 #2
0
  /**
   * Insert a tab. Like add a tab only with an index.
   *
   * @param tab the tab.
   * @param index the index.
   */
  public void insertTab(final SimpleTab tab, final int index) {
    if (firstTab == null) {
      firstTab = tab.getIdentifier();
    }
    tabs.put(tab.getIdentifier(), tab);
    tabDropZone.insert(tab, index);

    if (draggable) {
      tab.makeTabDraggable(tabDragController);
    }

    tab.init(key);
  }
예제 #3
0
 /**
  * Switch to a tab by it's unique identifier.
  *
  * @param identifier the tab's identifier.
  */
 public void switchToTab(final String identifier) {
   if (activeTab == null || !activeTab.getIdentifier().equals(identifier)) {
     if (tabs.containsKey(identifier)) {
       activateTab(identifier);
     } else if (firstTab != null) {
       activateTab(firstTab);
     }
   }
 }