/*
** Luxor - XML User Interface Language (XUL) Toolkit
** Copyright (c) 2001, 2002 by Gerald Bauer
**
** This program is free software.
**
** You may redistribute it and/or modify it under the terms of the GNU
** General Public License as published by the Free Software Foundation.
** Version 2 of the license should be included with this distribution in
** the file LICENSE, as well as License.html. If the license is not
** included with this distribution, you may find a copy at the FSF web
** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
**
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
** REDISTRIBUTION OF THIS SOFTWARE.
**
*/

package luxor.core;

import java.util.*;
import org.jdom.*;
import luxor.core.box.*;
import luxor.core.data.*;
import luxor.core.grid.*;
import luxor.core.input.*;
import luxor.core.menu.*;
import luxor.core.misc.*;
import luxor.core.portal.*;
import luxor.core.tab.*;
import luxor.core.table.*;
import luxor.core.toolbar.*;
import luxor.status.*;
import luxor.*;

public class XulDef extends XulContainer
{
   static Logger T = Logger.getLogger( XulDef.class );

   private XulManager _manager;


   XulDef( Element element, XulManager manager )
   {
      super( element );
      _manager = manager;
   }


   public void add( XulNode node )
   {
      if( node instanceof ToolBarDef )
         _manager.addToolBarDef( ( ToolBarDef ) node );
      else if( node instanceof KeySetDef )
      {
         // merge all keys into a single lookup table
         // KeySet forwards key to XulManager
         // therefore, we don't need to do anything here
      }
      else if( node instanceof BoxDef )
         _manager.addBoxDef( ( XulBox ) node );
      else if( node instanceof GroupBoxDef )
         _manager.addBoxDef( ( XulBox ) node );
      else if( node instanceof TabBoxDef )
         _manager.addBoxDef( ( XulBox ) node );
      else if( node instanceof GridDef )
         _manager.addBoxDef( ( XulBox ) node );
      else if( node instanceof TableDef )
         _manager.addBoxDef( ( XulBox ) node );
      else if( node instanceof KeyDef )
         _manager.addKey( ( KeyDef ) node );
      else if( node instanceof MenuBarDef )
         _manager.addMenuBarDef( ( MenuBarDef ) node );
      else if( node instanceof PopupDef )
         _manager.addPopupDef( ( PopupDef ) node );
      else if( node instanceof IconDef )
         _manager.addIconDef( ( IconDef ) node );
      else if( node instanceof ListDef )
         _manager.addListDef( ( ListDef ) node );
      else if( node instanceof MapDef )
         _manager.addMapDef( ( MapDef ) node );
      else if( node instanceof AnimDef )
         _manager.addAnimDef( ( AnimDef ) node );
      else if( node instanceof PortalDef )
         _manager.addPortalDef( ( PortalDef ) node );
      else if( node instanceof CommandDef )
         _manager.addCommandDef( ( CommandDef ) node );
      else if( node instanceof PreDef )
         _manager.addPreDef( ( PreDef ) node );
      else
         Xul.error( "unsupported element type '" + node.getElementName() + "'" );
   }
}