// Sample code file: FilesystemRegistrar.java

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

/*
   Copyright (c) 1997-1999 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.sample.snapins.filesystem;

import java.awt.*;
import java.util.*;
import javax.swing.*;

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

/*
* The Registrar is the class which identifies the snapins which constitute
* a total set of functionality call a Snapin Collection.  The snapins are
* then loaded/activated based on the specified scope as the user navigates
* (or changes state) within the ConsoleOne browser window.  
*
* You should only have one Registrar for each Snapin Collection.  This minimizes
* the snapin registration processing required during ConsoleOne startup 
* (which helps ConsoleOne start up faster).  The getRegistrationItems() call
* should be optimized for speed usually just returning a hard-coded array of
* registration items.

* The order that the snapins are listed in the getRegistrationsItems() call 
* is important since it implies the order the snapins will be loaded/activated
* as the user changes the browser state/context.  Snapins are loaded based first
* on their scope (most specific to most general).  Within a scope, however, the 
* snapins are then loaded in the order specified in the getRegistrationItems array.
*/

public class FilesystemRegistrar implements Registration
{
   /*
    Implementation of the Registration interface for the FileSystem.
   */

   /*
    * Unique identifier definitions.
    * Namespace and Views are assigned a unique identifier in ConsoleOne
    * so that other snapins can be registered to them. 
    */
   private static final String FS_NAMESPACE_UNIQUE_ID = "Novell Sample File System";
   private static final String FS_ZIP_NAMESPACE_UNIQUE_ID = "Novell Sample Zip File System";
   private static final String FS_LISTVIEW_UNIQUE_ID = "Novell Sample List View";

   /**
    This getRegistration() method return an array of RegistrationItems which represent
    the FileSystem snap-ins which should be entered in the Registry upon ConsoleOne startup. 
    
    A RegistrationItem contains information identifying the kind of snapin being
    registered, when ConsoleOne should load or activate it, and where the code which
    implements the snapin is located.
   */
   public RegistrationItem[] getRegistration()
   {

      return new RegistrationItem[]
      {
         // FilesystemStatusBarItem
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_STATUSBARITEM, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemStatusBarItem"),

         // FilesystemAbstractStatusBar
         new RegistrationItem(
            new NamespaceScope(Shell.SNAPIN_STATUSBARITEM, FS_NAMESPACE_UNIQUE_ID),
            "com.novell.sample.snapins.filesystem.FilesystemAbstractStatusBar"),
         new RegistrationItem(
             new MultiSelectNamespaceScope(Shell.SNAPIN_STATUSBARITEM, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemAbstractStatusBar"),

         // FilesystemAbstractToolBarMenu
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_TOOLBARITEM, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemAbstractToolBarMenu"),
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_MENU, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemAbstractToolBarMenu"),

         // FilesystemListView
         new RegistrationItem(
             new NamespaceContainerTypesScope(Shell.SNAPIN_VIEW, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemListView"),

         // FilesystemMainMenu
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_MENU, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemMainMenu"),

         // FilesystemNamespace
         new RegistrationItem(
             new GlobalScope(Shell.SNAPIN_NAMESPACE),
             "com.novell.sample.snapins.filesystem.FilesystemNamespace"),
         new RegistrationItem(
             new NamespaceTreeObjectsScope(Shell.SNAPIN_VIEW, FS_NAMESPACE_UNIQUE_ID),
             Shell.CONSOLE_VIEW_CLASS_NAME),
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_RESULTMODIFIER, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.application.console.consolesnapins.DefaultResultModifierSnapin"),

         // FilesystemNamespaceDisplay
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_DISPLAYICON, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemNamespaceDisplay"),
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_DISPLAYNAME, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemNamespaceDisplay"),

         // FilesystemPage
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_PAGE, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemPage"),

         // FilesystemPopupMenu
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_POPUP_MENU, FS_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemPopupMenu"),

         // FilesystemService
         new RegistrationItem(
             new GlobalScope(Shell.SNAPIN_SERVICE),
             "com.novell.sample.snapins.filesystem.FilesystemService"),

         // FilesystemToolBarItem
         new RegistrationItem(
             new NamespaceViewScope(Shell.SNAPIN_TOOLBARITEM, FS_NAMESPACE_UNIQUE_ID, FS_LISTVIEW_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemToolBarItem",
             new Integer(1)),
         new RegistrationItem(
             new NamespaceViewScope(Shell.SNAPIN_TOOLBARITEM, FS_NAMESPACE_UNIQUE_ID, FS_LISTVIEW_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemToolBarItem",
             new Integer(2)),
         new RegistrationItem(
             new NamespaceViewScope(Shell.SNAPIN_TOOLBARITEM, FS_NAMESPACE_UNIQUE_ID, FS_LISTVIEW_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemToolBarItem",
             new Integer(3)),
         new RegistrationItem(
             new NamespaceViewScope(Shell.SNAPIN_TOOLBARITEM, FS_NAMESPACE_UNIQUE_ID, FS_LISTVIEW_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.FilesystemToolBarItem",
             new Integer(4)),

         // ZipNamespace
         new RegistrationItem(
             new GlobalScope(Shell.SNAPIN_NAMESPACE),
             "com.novell.sample.snapins.filesystem.ZipNamespace"),
         new RegistrationItem(
             new NamespaceTypeScope(Shell.SNAPIN_MAP_OBJECTENTRY, FS_NAMESPACE_UNIQUE_ID, "zip"),
             "com.novell.sample.snapins.filesystem.ZipNamespace"),
         new RegistrationItem(
             new NamespaceTypeScope(Shell.SNAPIN_MAP_OBJECTENTRY, FS_NAMESPACE_UNIQUE_ID, "jar"),
             "com.novell.sample.snapins.filesystem.ZipNamespace"),
         new RegistrationItem(
             new NamespaceTreeObjectsScope(Shell.SNAPIN_VIEW, FS_ZIP_NAMESPACE_UNIQUE_ID),
             Shell.CONSOLE_VIEW_CLASS_NAME),
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_RESULTMODIFIER, FS_ZIP_NAMESPACE_UNIQUE_ID),
             "com.novell.application.console.consolesnapins.DefaultResultModifierSnapin"),

         // ZipNamespaceDisplay
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_DISPLAYICON, FS_ZIP_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.ZipNamespaceDisplay"),
         new RegistrationItem(
             new NamespaceScope(Shell.SNAPIN_DISPLAYNAME, FS_ZIP_NAMESPACE_UNIQUE_ID),
             "com.novell.sample.snapins.filesystem.ZipNamespaceDisplay")
      };
   }

}