// Sample code file: ChatRoomPageSnapin.java

// Warning: This code has been marked up for HTML

/*
   Copyright (c) 2000 Novell, Inc.  All Rights Reserved.

   THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES. 
   USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE AGREEMENT 
   ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS THIS WORK. 
   PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO DEVELOPER A 
   ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE CODE IN ITS 
   PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS TO MARKET, 
   DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF DEVELOPER'S 
   PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR DEVELOPER'S 
   CUSTOMERS WITH RESPECT TO THIS CODE. 
*/
 


package com.novell.Chat;

import java.awt.*;
import java.util.ResourceBundle;

// ConsoleOne imports
import com.novell.application.console.snapin.*;
import com.novell.application.console.snapin.context.*;
import com.novell.application.console.snapin.scope.*;

// NDSNamespace and common library imports
import com.novell.admin.ns.nds.*;
import com.novell.admin.common.snapins.*;


/**
 * This is the Page that is displayed in the property book for all Chat Room Objects.
 */
public class ChatRoomPageSnapin implements PageSnapin, AttributeHandler
{
    /**
     * Snapin Information
     */
    private final String tabName = Chat.chatRes.getString("General Tab");
    private final String menuName = Chat.chatRes.getString("Information Tab");
   
    /**
     * The page for this snapin
    **/
    private ChatRoomPage page;
    
    /**
     * The InitSnapinInfo received by the snapin at initSnapin().
     */
    InitSnapinInfo snapinInfo = null;
   
        /**
    * Snapin interface implementation
    *
    * @param   info  The InitSnapinInfo object passed by ConsoleOne.
    *
    * @return true if initialized correctly, false otherwise.  If false is
    *         returned, the snapin will be discarded by ConsoleOne.
    */
        public boolean initSnapin(InitSnapinInfo snapinInfo)
    {        
        this.snapinInfo = snapinInfo;

        return true;
   }
   
    
   /**
    * Snapin Interface implementation.
    *
    * @return           The Snapin Name
    */
   public String getSnapinName()
   {
      return Chat.chatRes.getString("ChatRoomPageSnapin_Name");
   }

   /**
    * Snapin Interface implementation.
    *
    * @return           The description of the snapin
    */
   public String getSnapinDescription()
   {
      return Chat.chatRes.getString("ChatRoomPageSnapin_Description");
   }
   
   
   /**
    * Snapin Interface implementation, called when snapin shutsdown.
    */
   public void shutdownSnapin()
   {
     
   }
   
   /**
    * PageSnapin interface implementation.
    *
    * @return  The ChatRoomPage object
    */
   public Component getPage()
   {
      page = new ChatRoomPage(this, snapinInfo);
      return page;
   }
   
   /**
    * PageSnapin Interface implementation.
    *
    * @return           The tab to place on the PropertyBook for this snapin.
    */
   public String getTabName()
   {
     return tabName;
   }

   /**
    * PageSnapin Interface implementation.
    *
    * @return           The tab ID.
    */
   public String getTabID()
   {
     return tabName;
   }

   /**
    * PageSnapin Interface implementation.
    *
    * @return           The unique menu name in case more than one page has the save Tab name.
    */
   public String getMenuName()
   {
     return menuName;
   }
   
   /**
    * Called just before the page is set as the current page.  Here we just call into
    * our GUI page.
    *
    * @param   I-isFirstTimeShown   true, if first time page is shown, false otherwise.
    */
   public void setActive(boolean isFirstTimeShown)
   {
      page.setActive(isFirstTimeShown);
   }
   
   /**
    * Called just before the page loses the focus.  Calls into our GUI page.
    *
    * @return  true, if ok to leave this page, false otherwise.
    */   
   public boolean killActive()
   {
      return page.killActive();
   }   
   
   /**
    * Launches context sensitive help.  
    */
   public void showHelp()
   {
     // shell.launchHelp("novellndsadmin", "help");
   }
   
   /**
    * PageSnapin Interface implementation.
    *
    * @return           True, our snapin does have help.
    */
   public boolean hasHelp()
   {
     return false;
   }

   /**
    * PageSnapin Interface implementation.
    *
    * @return   true.  We validate data in killActive.  If you want to validate
    *             data only when the ok or apply buttons are pressed then this is
    *             where you would do it.
    */
   public boolean canSave()
   {
     return false;
   }
   
   /**
    * PageSnapin Interface implementation. Note that this does NOT call page's saveData().  This is 
    * because saveData() for the panel was called in killActive() routine of the panel.
    *
    * This does the actual write to NDS.
    *
    * @return   true always since we don't save on the page.
    */
   public boolean saveData()
   {         
          return true;
   }
   
   /**
    * AttributeHandler interface implementation.  This is an optional 
    * interface to tell the PropertyBook what attributes you are handling.  
    * If you do not implement this interface, then the "Other" page is 
    * allowed to edit these attributes.
    *
    * @return  String[] with attribute names that this page is editing.
    */ 
   public String[] getHandledAttributeNames()
   {
      String[] attributes = new String[4];
      attributes[0] = Chat.ATTRIBUTE_IP;
      attributes[1] = Chat.ATTRIBUTE_OWNER;
      attributes[2] = Chat.ATTRIBUTE_PORT;
      attributes[3] = Chat.ATTRIBUTE_USERLIST;
      return attributes;
   }
  
}