OME
Class ObjectMethod

java.lang.Object
  |
  +--OME.AbstractPluginMethod
        |
        +--OME.ObjectMethod

public abstract class ObjectMethod
extends AbstractPluginMethod

Many PluginMethods operate on ViewObjects. They look for a ViewObject from the context, and if they can't find one there, they will seek one from the user as a parameter. This class encapsulates that behaviour to save the plugin implementor from repeating the same code again and again.


Field Summary
protected  java.lang.String instruction
           
protected  java.lang.String[] instructions
           
protected  java.lang.String name
           
protected  View view
           
 
Constructor Summary
ObjectMethod(View view)
          When no n is supplied, the default is 1.
ObjectMethod(View view, int n)
          The input n determines how many objects are needed by this Method.
 
Method Summary
 void cancelled()
          If the method is cancelled, we must return to the starting state.
 java.lang.String getName()
          Set the name for this method in subclass' constructor.
 void invoke()
          Invoke performs the operation on the method, and then resets the state of the method.
 boolean isEnabled(ViewContext con)
          This method is only enabled if the view has an object associated with it.
protected  boolean isSuitable(ViewObject vo)
          Override this method to perform a suitability test on the object.
protected  boolean isSuitable(ViewObject vo, int n, ViewObject[] collected)
          Override this method to perform a suitability test on the nth object (COUNTING FROM ZERO).
 PluginParameter nextParameter()
          We try to get the object from the context first, if possible, otherwise we ask for an object as a paramter.
protected  void operate(ViewObject vo)
          For objects using 1 object...
protected  void operate(ViewObject[] viewobjects)
          For objects using more than 1 object...
 void passParameter(java.util.Collection c)
          Accept the parameter we just asked for.
protected  void resetMethod()
          Override this method to perform any clean up that shoudl take place after an invocation of cancellation of the method.
 
Methods inherited from class OME.AbstractPluginMethod
getImage, getSubmenu, getSubmenu
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

view

protected View view

name

protected java.lang.String name

instruction

protected java.lang.String instruction

instructions

protected java.lang.String[] instructions
Constructor Detail

ObjectMethod

public ObjectMethod(View view)
When no n is supplied, the default is 1.

ObjectMethod

public ObjectMethod(View view,
                    int n)
The input n determines how many objects are needed by this Method.
Method Detail

nextParameter

public final PluginParameter nextParameter()
We try to get the object from the context first, if possible, otherwise we ask for an object as a paramter. NOTE: objects that are selected by the context are ignored.
Overrides:
nextParameter in class AbstractPluginMethod

passParameter

public final void passParameter(java.util.Collection c)
Accept the parameter we just asked for. Change our state appropriately.
Overrides:
passParameter in class AbstractPluginMethod
Tags copied from class: AbstractPluginMethod
Parameters:
c - a singleton Collection containing the parameter to be passed to this PluginMethod.

cancelled

public final void cancelled()
If the method is cancelled, we must return to the starting state.
Overrides:
cancelled in class AbstractPluginMethod

resetMethod

protected void resetMethod()
Override this method to perform any clean up that shoudl take place after an invocation of cancellation of the method.

invoke

public final void invoke()
Invoke performs the operation on the method, and then resets the state of the method.
Overrides:
invoke in class AbstractPluginMethod

isSuitable

protected boolean isSuitable(ViewObject vo)
Override this method to perform a suitability test on the object. For example, if you only want a link of a certain type, check to see if that's what you`ve got. vo is guaranteed not be null. This method is only called for one-object methods.

isSuitable

protected boolean isSuitable(ViewObject vo,
                             int n,
                             ViewObject[] collected)
Override this method to perform a suitability test on the nth object (COUNTING FROM ZERO). The array of ViewObjects collected before this one is also supplied, but is only guaranteed to be initialized up to index n-1. Leave this method if this is a one-object method, and use the one above.

operate

protected void operate(ViewObject vo)
For objects using 1 object... Override this method to perform the desired operation on the object. vo is guaranteed not be null.

operate

protected void operate(ViewObject[] viewobjects)
For objects using more than 1 object... Override this method to perfrom the desired operation on the given objects. Each entry in viewobjects is guaranteed to be non-null, and the order they are in the array is the order in which they were collected.

getName

public final java.lang.String getName()
Set the name for this method in subclass' constructor.
Overrides:
getName in class AbstractPluginMethod

isEnabled

public final boolean isEnabled(ViewContext con)
This method is only enabled if the view has an object associated with it.
Overrides:
isEnabled in class AbstractPluginMethod
Tags copied from class: AbstractPluginMethod
Parameters:
con - the ViewContext for which this PluginMethod is called.