com.novell.application.console.snapin
Interface DisplayIconSnapin

All Superinterfaces:
Snapin

public interface DisplayIconSnapin
extends Snapin

Provides the icons associated with a specified ObjectEntry or ObjectType.

Snap-ins must implement this interface to provide the icons for a specified ObjectEntry or object type. Two types of getDisplayIcon() method are provided: One associated with a specified ObjectEntry, and the other associated with a specified namespace and object type. The icon for the object is displayed next to the display name for the object.


Method Summary
 boolean doesIconChangePerEntry(ObjectType type)
          Returns a boolean indicating if the icon can change depending on the ObjectEntry of the specified ObjectType.
 javax.swing.Icon getDisplayIcon(ObjectEntry entry)
          Returns the snap-in icon associated with the specified ObjectEntry in the tree.
 javax.swing.Icon getDisplayIcon(java.lang.String namespace, java.lang.String type)
          Returns the snap-in icon associated with the specified namespace and object type.
 
Methods inherited from interface com.novell.application.console.snapin.Snapin
getSnapinDescription, getSnapinName, initSnapin, shutdownSnapin
 

Method Detail

getDisplayIcon

public javax.swing.Icon getDisplayIcon(java.lang.String namespace,
                                       java.lang.String type)
Returns the snap-in icon associated with the specified namespace and object type.

You must return the icon (image) associated with the ObjectType that has the same name as the passed in 'type' String parameter. This should be the generic icon for that ObjectType. This method is called by ConsoleOne in response to a Shell.getDisplayIcon(String namespace, String type) call.

You can return null if there is no icon being provided and you want the default icon to be used. A default icon is returned for the specified entry type only if no other registered snap-in has been defined that provides an icon for that type of entry. Otherwise, a search of all available snap-ins is conducted. The first one that provides an icon for the specified entry is used to return the display icon.

Following is an example of the getDisplayIcon(namespace, type) implementation:


    public Icon getDisplayIcon(String namespace, String type)
    {
        Icon icon = (Icon) icons.get(type);
        if(icon == null)
        {
            Image i = null;
            String path = "/com/novell/sample/snapins/filesystem/images/";
            path += type + ".gif";
            URL url = getClass().getResource(path);
            if(url != null)
            {
                i = Toolkit.getDefaultToolkit().getImage(url);
                icon = new ImageIcon(i);
                icons.put(type, icon);
            }
            else
            {
                System.err.println("Image loading URL is null in
                                   ZipNamespaceDisplay::getDisplayIcon");
            }
        }
        return icon;
    }
 
Parameters:
namespace - The namespace of the object type for the desired display icon.
type - The name of the ObjectType for which to get the icon.
Returns:
The icon to be displayed, or null if no icon is being provided.
See Also:
DisplayNameSnapin.getDisplayName(java.lang.String, java.lang.String), Shell.getDisplayIcon(java.lang.String, java.lang.String)

getDisplayIcon

public javax.swing.Icon getDisplayIcon(ObjectEntry entry)
Returns the snap-in icon associated with the specified ObjectEntry in the tree.

You should return the icon (image) that the shell will use to display the specified ObjectEntry in the tree or view. You can return NULL if this snap-in does not have the icon and you want the default icon to be used. A default icon is returned for the specified ObjectEntry only if no other registered snap-in has been defined that provides an icon for that ObjectEntry. Otherwise, a search of all available snap-ins is conducted. The first one that provides an icon for the specified entry is used to return the display icon.

Following is an example of the getDisplayIcon(entry) implementation:


    public Icon getDisplayIcon(ObjectEntry entry)
    {
        return getDisplayIcon(entry.getObjectType().getNamespace()
            .getUniqueID(), entry.getObjectType().getName());
    }
 
Parameters:
entry - The specified ObjectEntry for which to get the icon that will be displayed in the tree or view.
Returns:
The icon to be displayed, or null if no icon is being provided.
See Also:
DisplayNameSnapin.getDisplayName(com.novell.application.console.snapin.ObjectEntry), Shell.getDisplayIcon(com.novell.application.console.snapin.ObjectEntry)

doesIconChangePerEntry

public boolean doesIconChangePerEntry(ObjectType type)
Returns a boolean indicating if the icon can change depending on the ObjectEntry of the specified ObjectType.

If the same icon is always returned for a particular ObjectType, return false. If the icon can change depending on the ObjectEntry of the given ObjectType then return true. This way ConsoleOne can cache the icon, when possible, and use the same icon for all objects of the given type.

Following is an example of the doesIconChangePerEntry(type) implementation:


    public boolean doesIconChangePerEntry(ObjectType type)
    {
        return false;
    }
 
Parameters:
type - The ObjectType that is being queried for the icon information.
Returns:
A boolean set to true if the icon can change depending on the ObjectEntry of the given type, or false if the same icon is always returned for a particular ObjectType.


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