/********************************************************************
 * Copyright © 2004 EDS. All rights reserved
 ********************************************************************/
package gov.vha.edb.rules.web.builder;

//import ilog.webui.dhtml.IlxWComponent;
import ilog.webui.dhtml.IlxWPort;
import ilog.webui.dhtml.components.IlxWMessageList;
//import ilog.webui.dhtml.components.IlxWTabbedPane;
import ilog.rules.webui.*;

import java.io.IOException;
import java.util.ArrayList;

public class MessagePanel extends IlrWCollapsibleComponent {


//  private IlxWTabbedPane pane;
  private static final long serialVersionUID = 3001300982746538377L;
  private IlxWMessageList messageList;
  private ArrayList tabs;
  private WebBuilder builder;

    public MessagePanel(WebBuilder builder) {
      this.builder = builder;
//    pane = new IlxWTabbedPane() {
//      protected String getHtmlTagName(IlxWPort port) {
//        return "div";
//      }
//    };
//    pane.getStyle().set(PROP_WIDTH, "100%");
//    pane.getStyle().set(PROP_HEIGHT, "100%");
      setTitle(this.builder.getMessage("Messages.Messages"));

      tabs = new ArrayList();
      messageList = new IlxWMessageList() {
        private static final long serialVersionUID = 0L;

        protected void printComponent(IlxWPort ilxWPort) throws IOException
        {
          if (isMaximized()) // FUGLY HACK
            super.printComponent(ilxWPort);
        }
      };
      add(messageList);
//    configureLayout();
//    addTab(this.builder.getMessage("Messages.Messages"), messageList);
    }

//  public IlxWTabbedPane getPane() {
//    return pane;
//  }
//
//  public void configureLayout() {
//    safeAdd(pane);
//    removeElementTabs();
//  }
//
//  private void addTab(String title, IlxWComponent component) {
//    for (int i=0; i<tabs.size(); i++) {
//      pane.remove((IlxWComponent)tabs.get(i));
//    }
//    tabs.clear();
//    pane.insertTab(title, null, component, title, 0);
//    tabs.add(component);
//  }

//  private void removeElementTabs() {
//    int size = tabs.size();
//    for (int i=0; i<size; i++) {
//      IlxWComponent c = (IlxWComponent)tabs.get(i);
//      pane.remove(c);
//    }
//    tabs.clear();
//  }

  public IlxWMessageList getMessageList() {
    return messageList;
  }

  /*
  protected void printComponent(IlxWPort port) throws IOException {
    if (pane.getTabCount()>0) {
//      Util.startDiv(port, "width:100%;height:100%");
      pane.print(port);
//      Util.endDiv(port);
    }
  }
  */

  protected void printChildren(IlxWPort port) throws IOException
  {
    /*
    if (pane.getTabCount()>0) {
//      Util.startDiv(port, "width:100%;height:100%");
      pane.print(port);
//      Util.endDiv(port);
    }
    */
    messageList.print(port);
  }
}
