Package clips.report.panels

Source Code of clips.report.panels.PanelWinthSubTabs

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package clips.report.panels;

import cli_fmw.delegate.DelegateLine2;
import cli_fmw.main.ClipsException;
import cli_fmw.main.OpenCloseSensitive;
import cli_fmw.main.PageContainer;
import cli_fmw.main.PageException;
import cli_fmw.main.PageGeneric;
import cli_fmw.utils.MessageBox;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author finder
*/

abstract public class PanelWinthSubTabs extends PageGeneric implements OpenCloseSensitive {
//  static final long                      serialVersionUID = 1L;

  ArrayList<PageGeneric>            subTabs = new ArrayList<PageGeneric>();

  public PanelWinthSubTabs(PageContainer container) throws ClipsException {
    super(container);
  }

  protected PageContainer getPagesContainer(){
    return getContainer();
  }

  protected void addSubTab(PageGeneric tab){
    PageGeneric        after = this;
    if (subTabs.size() > 0) {
      after = subTabs.get(subTabs.size() - 1);
    }
    subTabs.add(tab);
    if (tab instanceof OpenCloseSensitive) {
      ((OpenCloseSensitive) tab).beforeOpen();
    }
    try {
      getPagesContainer().addNewPage(tab, after);
    } catch (PageException ex) {
      MessageBox.showException(ex);
    }
  }

  protected void removeSubTab(PageGeneric tab){
    for (PageGeneric pageGeneric : subTabs) {
      if (tab == pageGeneric){
        if (pageGeneric instanceof OpenCloseSensitive) {
          ((OpenCloseSensitive) pageGeneric).beforeClose();
        }
        try {
          getPagesContainer().removePage(pageGeneric, true);
        }
        catch (PageException ex) {
          MessageBox.showException(ex);
        }
        return;
      }
    }
  }

  protected void clearAllSubPage(){
    for (PageGeneric pageGeneric : subTabs) {
      if (pageGeneric instanceof OpenCloseSensitive) {
        ((OpenCloseSensitive) pageGeneric).beforeClose();
      }
    }
    for (PageGeneric pageGeneric : subTabs) {
      try {
        getPagesContainer().removePage(pageGeneric, true);
      }
      catch (PageException ex) {
        MessageBox.showException(ex);
      }
    }
    subTabs.clear();
  }

  @Override
  public void beforeClose() {
    clearAllSubPage();
  }

  @Override
  public void beforeOpen() {
  }
}
TOP

Related Classes of clips.report.panels.PanelWinthSubTabs

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.