net.refractions.udig.catalog.ui
Class CatalogUIPlugin

java.lang.Object
  extended by AbstractUIPlugin
      extended by net.refractions.udig.catalog.ui.CatalogUIPlugin

public class CatalogUIPlugin
extends AbstractUIPlugin

Lifecycle & Resource management for RegistryUI.

The CatalogUIPlugin provides access for shared images descriptors.

Example use of a shared image descriptor:

 ImageRegistry images = CatalogUIPlugin.getDefault().getImageRegistry();
 ImageDescriptor image = images.getDescriptor(ISharedImages.IMG_DATASTORE_OBJ);
 

Implementation Note

The CatalogUIPlugin delegates the following resource management tasks: These resources are intended for use by classes within this plugin.

Author:
Jody Garnett, Refractions Research, Inc

Field Summary
static java.lang.String ICONS_PATH
          Icons path (value "icons/")
static java.lang.String ID
          The id of the plug-in
static java.lang.String PREF_OPEN_DIALOG_DIRECTORY
          Preference store for the last directory open by the file selection dialog
 
Constructor Summary
CatalogUIPlugin()
          The constructor.
 
Method Summary
static MutablePicoContainer getContainer()
          Gets the container for catalog ui.
static MutablePicoContainer getContainer(IResolve handle)
          Gets a container associated with this handle.
static CatalogUIPlugin getDefault()
          Returns the shared instance.
 ImageRegistry getImageRegistry()
           
 ISharedImages getImages()
          Images instance for use with ImageConstants.
static boolean hasCachedTitle(IResolve resolve)
          Returns true if the title to the resolve was cached during a previous run.
static ImageDescriptor icon(IResolve resolve)
           
static ImageDescriptor icon(IResolve resolve, IProgressMonitor monitor)
          Create icon for provided resource, this will block!
static Image image(IResolve resolve)
          Quick and dirty image generated based on ID, this image is shared and should not be disposed.
static boolean isDebugging(java.lang.String trace)
          Performs the Platform.getDebugOption true check on the provided trace
static java.lang.String label(IResolve resource)
          Quick and dirty label generation based on ID.
static void log(java.lang.String message2, java.lang.Throwable t)
          Logs the Throwable in the plugin's log.
 void start(BundleContext context)
          Set up shared images.
 void stop(BundleContext context)
          Cleanup after shared images.
static void storeLabel(IResolve element, java.lang.String text)
           
static java.lang.String title(IResolve resource)
          Retrive title, this is based on associated metadata (aka LayerPointInfo object).
static java.lang.String title(IResolve resource, IProgressMonitor monitor)
          Retrieve title, this is based on associated metadata (aka LayerPointInfo object).
static void trace(java.lang.String message)
           
static void trace(java.lang.String message, java.lang.Throwable e)
          Messages that only engage if getDefault().isDebugging()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final java.lang.String ID
The id of the plug-in

See Also:
Constant Field Values

PREF_OPEN_DIALOG_DIRECTORY

public static final java.lang.String PREF_OPEN_DIALOG_DIRECTORY
Preference store for the last directory open by the file selection dialog

See Also:
Constant Field Values

ICONS_PATH

public static final java.lang.String ICONS_PATH
Icons path (value "icons/")

See Also:
Constant Field Values
Constructor Detail

CatalogUIPlugin

public CatalogUIPlugin()
The constructor.

Method Detail

start

public void start(BundleContext context)
           throws java.lang.Exception
Set up shared images.

Parameters:
context -
Throws:
java.lang.Exception
See Also:
org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)

stop

public void stop(BundleContext context)
          throws java.lang.Exception
Cleanup after shared images.

Parameters:
context -
Throws:
java.lang.Exception
See Also:
org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)

getDefault

public static CatalogUIPlugin getDefault()
Returns the shared instance.

Returns:
CatalogUIPlugin singleton

getImageRegistry

public ImageRegistry getImageRegistry()

getImages

public ISharedImages getImages()
Images instance for use with ImageConstants.

Returns:
Images for use with ImageConstants.

log

public static void log(java.lang.String message2,
                       java.lang.Throwable t)
Logs the Throwable in the plugin's log.

This will be a user visable ERROR iff:

Parameters:
message -
t -

trace

public static void trace(java.lang.String message,
                         java.lang.Throwable e)
Messages that only engage if getDefault().isDebugging()

It is much prefered to do this:


 private static final String RENDERING = "net.refractions.udig.project/render/trace";
 if (ProjectUIPlugin.getDefault().isDebugging() && "true".equalsIgnoreCase(RENDERING)) {
     System.out.println("your message here");
 }
 

Parameters:
message -
e -

trace

public static void trace(java.lang.String message)

isDebugging

public static boolean isDebugging(java.lang.String trace)
Performs the Platform.getDebugOption true check on the provided trace

Note: ProjectUIPlugin.getDefault().isDebugging() must also be on.

Parameters:
trace - currently only RENDER is defined
Returns:
true if -debug is on for this plugin

getContainer

public static MutablePicoContainer getContainer()
Gets the container for catalog ui.

This is used by the IResourceLabel decorator to pass titles, and images between threads.

Returns:
Container assocaited with the catalog ui

getContainer

public static MutablePicoContainer getContainer(IResolve handle)
Gets a container associated with this handle.

As with any container, the contents should not be assumned, etc...

Parameters:
handle -
Returns:
Container associated with display of resolve

label

public static java.lang.String label(IResolve resource)
Quick and dirty label generation based on ID.

This method does not block and can be safely used to by a LabelProvider. This method does not make use of any title information available via an info object (because that would require blocking and be unsafe).

Returns:
Label for provided resource
See Also:
title

image

public static Image image(IResolve resolve)
Quick and dirty image generated based on ID, this image is shared and should not be disposed.

This method does not block and can be safely used to by a LabelProvider. This method does not make use of any information available via an info object (because that would require blocking and be unsafe).

Parameters:
resource -
Returns:
Image representing provided resource
See Also:
glyph

icon

public static ImageDescriptor icon(IResolve resolve)
                            throws java.io.IOException
Throws:
java.io.IOException

icon

public static ImageDescriptor icon(IResolve resolve,
                                   IProgressMonitor monitor)
                            throws java.io.IOException
Create icon for provided resource, this will block!

Parameters:
resource -
Returns:
ImageDescriptor for resource.
Throws:
java.io.IOException

title

public static java.lang.String title(IResolve resource,
                                     IProgressMonitor monitor)
                              throws java.io.IOException
Retrieve title, this is based on associated metadata (aka LayerPointInfo object).

This method is *not* suitable for use with a LabelProvider, only a LabelDecorator that works in its own thread.

Returns:
title, or null if not found (consider use of label( resource )
Throws:
java.io.IOException

title

public static java.lang.String title(IResolve resource)
                              throws java.io.IOException
Retrive title, this is based on associated metadata (aka LayerPointInfo object).

This method is *not* suitable for use with a LabelProvider, only a LabelDecorator that works in its own thread.

Returns:
title, or null if not found (consider use of label( resource )
Throws:
java.io.IOException

hasCachedTitle

public static boolean hasCachedTitle(IResolve resolve)
Returns true if the title to the resolve was cached during a previous run. In this case label(IResolve) will have returned the cached title.

Parameters:
resolve - the resolve to check for a title.
Returns:
true if the title to the resolve was cached during a previous run.

storeLabel

public static void storeLabel(IResolve element,
                              java.lang.String text)
                       throws java.io.IOException
Throws:
java.io.IOException