com.novell.application.console.snapin
Class AbstractToolBarMenuSnapin

java.lang.Object
  |
  +--com.novell.application.console.snapin.AbstractToolBarMenuSnapin
All Implemented Interfaces:
MenuSnapin, Snapin, ToolBarSnapin

public abstract class AbstractToolBarMenuSnapin
extends java.lang.Object
implements ToolBarSnapin, MenuSnapin

Provides a simplified method of creating simple toolbar and menu snap-ins.

The AbstractToolBarMenuSnapin class is a simple implementation of the MenuSnapin and ToolBarSnapin interfaces. Methods from both of these interfaces are implemented in the AbstractToolBarMenuSnapin class. You can then extend this abstract class, deriving its methods, to create specialized menu and toolbar items without having to implement all the methods yourself. The AbstractToolBarMenuSnapin class will create a snap-in that will place a single menu item in the shell's main menu as well as a button in the toolbar.

NOTE: You cannot use the AbstractToolBarMenuSnapin class to create and register a PopupMenuSnapin item. This is not a supported implementation.

See Also:
ToolBarSnapin

Field Summary
protected  javax.swing.JMenuItem menuItem
          The menu item that will be placed in the main menu.
protected  Shell shell
          Shell instance used to interact with the ConsoleOne shell.
protected  java.awt.Component toolBarItem
          The Component that will be placed on the toolbar.
 
Constructor Summary
AbstractToolBarMenuSnapin()
           
 
Method Summary
abstract  void execute()
          Called when the toolbar button is pressed or the menu item is selected.
abstract  javax.swing.Icon getIcon()
          Returns the icon to be displayed in the toolbar button.
 java.lang.String getMenuLocation()
          Returns the location of this menu item in the menu hierarchy.
 char getMenuMnemonic()
          Deprecated. As of ConsoleOne version 1.2, use an ampersand (&) in the string returned from getMenuName() to specify the mnemonic.
abstract  java.lang.String getMenuName()
          Returns the language-dependent translated menu display name as a String to be placed in the menu item.
abstract  java.lang.String getSnapinDescription()
          Returns the description of the snap-in.
abstract  java.lang.String getSnapinName()
          Returns the localized name of the snap-in.
 java.lang.String getToolTip()
          Returns the localized string to be placed in the tool tip that will be displayed with the toolbar item.
 boolean initAbstractSnapin(InitSnapinInfo info)
          Initializes the class that extends the AbstractToolBarMenuSnapin class.
 void setEnabled(boolean cond)
          Enables or disables the toolbar button and menu item.
 void shutdownAbstractSnapin()
          Shuts down the participating snap-in that extends the AbstractToolBarMenuSnapin class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

toolBarItem

protected java.awt.Component toolBarItem
The Component that will be placed on the toolbar.

This item is handled by AbstractToolBarMenuSnapin. Participating Snap-ins do not have to create it or interact with it themselves, unless that is desired.


menuItem

protected javax.swing.JMenuItem menuItem
The menu item that will be placed in the main menu.

This menu item is handled by AbstractToolBarMenuSnapin. Snap-ins do not have to create it or interact with it themselves, unless they desire.


shell

protected Shell shell
Shell instance used to interact with the ConsoleOne shell.

The shell instance is set in initSnapin(). Subclasses should use this variable to make shell calls.

See Also:
Snapin.initSnapin(com.novell.application.console.snapin.InitSnapinInfo)
Constructor Detail

AbstractToolBarMenuSnapin

public AbstractToolBarMenuSnapin()
Method Detail

getSnapinName

public abstract java.lang.String getSnapinName()
Returns the localized name of the snap-in.

The getSnapinName() method returns the name for the selected snap-in. The shell displays the name you provide together with all the snap-ins of a given type. The user is then allowed to select which snap-ins should be set as active in the current configuration.

Returns:
The translated string object containing the name of the snap-in.
See Also:
Snapin.getSnapinName()

getSnapinDescription

public abstract java.lang.String getSnapinDescription()
Returns the description of the snap-in.

The getSnapinDescription() method returns the description of the selected snap-in. The shell displays the description you provide in the configurator's description area. The description should be kept brief and concise.

Returns:
The translated string object containing the description of the snap-in.
See Also:
Snapin.getSnapinDescription()

initAbstractSnapin

public boolean initAbstractSnapin(InitSnapinInfo info)
Initializes the class that extends the AbstractToolBarMenuSnapin class.

Implement in the extending snap-in if there is anything that needs to be initialized when the snap-in is created.

Parameters:
info - Contains data the snap-in may use for initialization, such as references to the shell and the snap-in type, and may contain a reference to snap-in context data.
Returns:
A boolean set to true if the snap-in is able to successfully complete initialization, or false if initialization fails.
See Also:
Snapin.initSnapin(com.novell.application.console.snapin.InitSnapinInfo)

shutdownAbstractSnapin

public void shutdownAbstractSnapin()
Shuts down the participating snap-in that extends the AbstractToolBarMenuSnapin class.

Implement in the extending snap-in if there is anything that needs to be cleaned up when the snap-in is destroyed. It will be called from this class's shutdownSnapin() method before it performs any necessary clean up.

See Also:
Snapin.shutdownSnapin()

getMenuLocation

public java.lang.String getMenuLocation()
Returns the location of this menu item in the menu hierarchy.

The default is to place the snap-in menu under the tools menu. Derived classes can override this to place the menu item in another location.

Specified by:
getMenuLocation in interface MenuSnapin
Returns:
The location in the menu hierarchy for the snap-in menu item.
See Also:
MenuSnapin.getMenuLocation()

execute

public abstract void execute()
Called when the toolbar button is pressed or the menu item is selected.

The following example will print a message when the toolbar button is pressed or the menu item is selected.

     public void execute()
     {
         System.out.println("Snapin selected");
     }
 

getIcon

public abstract javax.swing.Icon getIcon()
Returns the icon to be displayed in the toolbar button.

The recommended image size is 24 x 24 pixels. The following example code snippet shows how to place an image from a resource bundle in the toolbar button.

     public Icon getIcon()
     {
        ResourceBundle myBundle = ResourceBundle.getBundle("MyBundle");
        Image image = (Image) myBundle.getObject("ToolbarButtonImage");
        return new imageIcon(image);
     }
 
Returns:
The Icon to be used in the toolbar button.

getMenuName

public abstract java.lang.String getMenuName()
Returns the language-dependent translated menu display name as a String to be placed in the menu item. Place an ampersand (&) before the character that is to be used as the mnemonic. This method might be implemented as in the following example:
     public String getMenuName()
     {
         return "E&xample Tool";
     }
 
Returns:
The menu item text as a String.

getToolTip

public java.lang.String getToolTip()
Returns the localized string to be placed in the tool tip that will be displayed with the toolbar item.

The getToolTip() method might be implemented as in the following example:

     public String getToolTip()
     {
         return "Tool Tip";
     }
 
Returns:
The tool tip text of the toolbar button.

getMenuMnemonic

public char getMenuMnemonic()
Deprecated. As of ConsoleOne version 1.2, use an ampersand (&) in the string returned from getMenuName() to specify the mnemonic.

setEnabled

public void setEnabled(boolean cond)
Enables or disables the toolbar button and menu item.

Snap-ins can call this at any time to enable and disable this snap-in tool.

Parameters:
cond - Boolean set to true to enable the tool, or false to disable it.


API Documentation Copyright © 1998-2003 Novell, Inc. All rights reserved.
ConsoleOne is a registered trademark of Novell Inc.
Generated December 9 2003 1727.