za.co.bluesphere.sens.internal.ui
Class Policy

java.lang.Object
  extended by za.co.bluesphere.sens.internal.ui.Policy

public class Policy
extends java.lang.Object

Internationlization convience methods, with specific help for actions and monitors.

The following binding methods are of interest:

Example use:


 label.setText( Policy.bind( "SearchView.searchLabel" );
 label.setTooltipText( Policy.bind( "SearchView.searchTooltip" );
 

With the following entires in messages.properties:

 SearchView.searchLabel=Search:
 Searchview.searchTooltip=Search for diagram
 

Please visit initAction for more details on how to set up message.properties for effective use of Actions.

Externalize Stirng Wizard

You can use the Source > ExternalizeStrings wizard targeted against this class with the following settings:

  1. Accesor class: Policy
  2. Press "Configure..." button to Configure Accessor Class
  3. Resource bundle accessor class:
  4. Property file location and name:

Do not use the "Messages" class the ExternalizeWizard is willing to create for you! If you use this Policy class your Plugin can free up your resources at the correct time.

Use with Plug-n

Your plug-in needs to call the Policy lifecycle methods:

Author:
Jody

Field Summary
protected static java.util.ResourceBundle bundle
          The resource bundle to get strings from.
 
Constructor Summary
Policy()
           
 
Method Summary
static java.lang.String bind(java.lang.String key)
          Gets a string from the resource bundle.
static java.lang.String bind(java.lang.String id, java.lang.Object binding)
          Lookup the message with the given ID in this catalog and bind its substitution locations with the given string.
static java.lang.String bind(java.lang.String key, java.lang.Object[] args)
          Gets a string from the resource bundle and binds it with the given arguments.
static java.lang.String bind(java.lang.String id, java.lang.Object binding1, java.lang.Object binding2)
          Lookup the message with the given ID in this catalog and bind its substitution locations with the given strings.
static java.lang.String bind(java.lang.String id, java.lang.Object binding1, java.lang.Object binding2, java.lang.Object binding3)
          Lookup the message with the given ID in this catalog and bind its substitution locations with the given strings.
static java.lang.String bind(java.lang.String key, java.util.ResourceBundle b)
          Gets a string from the resource bundle.
static void checkCanceled(org.eclipse.core.runtime.IProgressMonitor monitor)
          Checks if the progress monitor is canceled.
static void cleanup()
          TODO summary sentence for cleanup ...
static java.util.ResourceBundle getBundle()
          Gets a ResourceBundle.
static void initAction(org.eclipse.jface.action.IAction a, java.lang.String id)
          Initialize the given Action from a ResourceBundle.
static void localize(java.lang.String bundleName)
          Creates a NLS catalog for the given locale.
static org.eclipse.core.runtime.IProgressMonitor monitorFor(org.eclipse.core.runtime.IProgressMonitor monitor)
          Returns a monitor for the given monitor
static org.eclipse.core.runtime.IProgressMonitor subMonitorFor(org.eclipse.core.runtime.IProgressMonitor monitor, int ticks)
          Sets up IProgressMonitor for the current locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bundle

protected static java.util.ResourceBundle bundle
The resource bundle to get strings from.

Constructor Detail

Policy

public Policy()
Method Detail

localize

public static void localize(java.lang.String bundleName)
Creates a NLS catalog for the given locale.

Parameters:
bundleName - the name of the bundle

cleanup

public static void cleanup()
TODO summary sentence for cleanup ...


bind

public static java.lang.String bind(java.lang.String id,
                                    java.lang.Object binding)
Lookup the message with the given ID in this catalog and bind its substitution locations with the given string.

Parameters:
id - the id to look up
binding - the string to bind to the result
Returns:
the bound string

bind

public static java.lang.String bind(java.lang.String id,
                                    java.lang.Object binding1,
                                    java.lang.Object binding2)
Lookup the message with the given ID in this catalog and bind its substitution locations with the given strings.

Parameters:
id - the id to look up
binding1 - the first string to bind to the result
binding2 - the second string to bind to the result
Returns:
the bound string

bind

public static java.lang.String bind(java.lang.String id,
                                    java.lang.Object binding1,
                                    java.lang.Object binding2,
                                    java.lang.Object binding3)
Lookup the message with the given ID in this catalog and bind its substitution locations with the given strings.

Parameters:
id - the id to look up
binding1 - the first string to bind to the result
binding2 - the second string to bind to the result
binding3 - the third string to bind to the result
Returns:
the bound string

bind

public static java.lang.String bind(java.lang.String key,
                                    java.util.ResourceBundle b)
Gets a string from the resource bundle. We don't want to crash because of a missing String. Returns the key if not found.

Parameters:
key - the id to look up
b - the ResourceBundle to get the key from.
Returns:
the string with the given key

bind

public static java.lang.String bind(java.lang.String key)
Gets a string from the resource bundle. We don't want to crash because of a missing String. Returns the key if not found.

Parameters:
key - the id to look up
Returns:
the string with the given key

bind

public static java.lang.String bind(java.lang.String key,
                                    java.lang.Object[] args)
Gets a string from the resource bundle and binds it with the given arguments. If the key is not found, return the key.

Parameters:
key - the id to look up
args - the strings to bind to the result
Returns:
the bound string

initAction

public static void initAction(org.eclipse.jface.action.IAction a,
                              java.lang.String id)
Initialize the given Action from a ResourceBundle.

Makes use of the following keys:


checkCanceled

public static void checkCanceled(org.eclipse.core.runtime.IProgressMonitor monitor)
Checks if the progress monitor is canceled.

Parameters:
monitor - the monitor to check for cancellation
Throws:
org.eclipse.core.runtime.OperationCanceledException - if the monitor is canceled

monitorFor

public static org.eclipse.core.runtime.IProgressMonitor monitorFor(org.eclipse.core.runtime.IProgressMonitor monitor)
Returns a monitor for the given monitor

Parameters:
monitor - the monitor to return a monitor for
Returns:
a monitor for the given monitor

subMonitorFor

public static org.eclipse.core.runtime.IProgressMonitor subMonitorFor(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                                      int ticks)
Sets up IProgressMonitor for the current locale.

Parameters:
monitor -
ticks -
Returns:
IProgressMonitor

getBundle

public static java.util.ResourceBundle getBundle()
Gets a ResourceBundle.

Returns:
ResourceBundle