net.refractions.udig.catalog
Class CatalogPlugin

java.lang.Object
  extended by Plugin
      extended by net.refractions.udig.catalog.CatalogPlugin

public class CatalogPlugin
extends Plugin

The main plugin class to be used in the desktop.


Field Summary
static java.lang.String ID
           
 
Constructor Summary
CatalogPlugin()
          The constructor.
 
Method Summary
static void addListener(IResolveChangeListener listener)
          Add a catalog listener for changed to this catalog.
 ICatalog[] getCatalogs()
           
static CatalogPlugin getDefault()
          Returns the shared instance.
 ICatalog getLocalCatalog()
           
 IPreferenceStore getPreferenceStore()
          Returns the preference store for this UI plug-in.
 IResolveManager getResolveManager()
           
 java.util.ResourceBundle getResourceBundle()
          Returns the plugin's resource bundle,
static java.lang.String getResourceString(java.lang.String key)
          Returns the string from the plugin's resource bundle, or 'key' if not found.
 IServiceFactory getServiceFactory()
           
static boolean isDebugging(java.lang.String trace)
          Performs the Platform.getDebugOption true check on the provided trace
static java.net.URL locateURL(java.lang.Object data)
          Attempts to turn data into a URL.
static void log(java.lang.String message2, java.lang.Throwable t)
          Logs the Throwable in the plugin's log.
static void removeListener(IResolveChangeListener listener)
          Remove a catalog listener that was interested in this catalog.
 void restoreFromPreferences()
           
 void start(BundleContext context)
          This method is called upon plug-in activation
 void stop(BundleContext context)
          Cleanup after shared images.
 void storeToPreferences(IProgressMonitor monitor)
           
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
See Also:
Constant Field Values
Constructor Detail

CatalogPlugin

public CatalogPlugin()
The constructor. See start(BundleContext) for the initialization of the plugin.

Method Detail

start

public void start(BundleContext context)
           throws java.lang.Exception
This method is called upon plug-in activation

Throws:
java.lang.Exception

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)

restoreFromPreferences

public void restoreFromPreferences()
                            throws BackingStoreException,
                                   java.net.MalformedURLException
Throws:
BackingStoreException
java.net.MalformedURLException

storeToPreferences

public void storeToPreferences(IProgressMonitor monitor)
                        throws BackingStoreException,
                               java.io.IOException
Throws:
BackingStoreException
java.io.IOException

getDefault

public static CatalogPlugin getDefault()
Returns the shared instance.


addListener

public static void addListener(IResolveChangeListener listener)
Add a catalog listener for changed to this catalog.

Parameters:
listener -

removeListener

public static void removeListener(IResolveChangeListener listener)
Remove a catalog listener that was interested in this catalog.

Parameters:
listener -

getResourceString

public static java.lang.String getResourceString(java.lang.String key)
Returns the string from the plugin's resource bundle, or 'key' if not found.


getResourceBundle

public java.util.ResourceBundle getResourceBundle()
Returns the plugin's resource bundle,


getCatalogs

public ICatalog[] getCatalogs()
Returns:
Returns the catalogs found ... local one is slot[0]. TODO hook the extension point up.

getLocalCatalog

public ICatalog getLocalCatalog()
Returns:
the local catalog. Equivalent to getCatalogs()[0]

getServiceFactory

public IServiceFactory getServiceFactory()
Returns:
Returns the serviceFactory.

locateURL

public static java.net.URL locateURL(java.lang.Object data)
Attempts to turn data into a URL. If data is an array or Collection, it will return the first successful URL it can find. This is a utility method. Feel free to move it to another class. In the future, it might be nice to have it return a List of the URLs it found, not just the first one.

Parameters:
data -
Returns:
a URL if it can find one, or null otherwise

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:


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");
 }


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.

  • Trace.RENDER - trace rendering progress

Parameters:
trace - currently only RENDER is defined

getPreferenceStore

public IPreferenceStore getPreferenceStore()
Returns the preference store for this UI plug-in. This preference store is used to hold persistent settings for this plug-in in the context of a workbench. Some of these settings will be user controlled, whereas others may be internal setting that are never exposed to the user.

If an error occurs reading the preference store, an empty preference store is quietly created, initialized with defaults, and returned.

NOTE: As of Eclipse 3.1 this method is no longer referring to the core runtime compatibility layer and so plug-ins relying on Plugin#initializeDefaultPreferences will have to access the compatibility layer themselves.

Returns:
the preference store

getResolveManager

public IResolveManager getResolveManager()