de.cau.cs.kieler.ksbase.ui.test
Class ModelObjectTester

java.lang.Object
  extended by org.eclipse.core.expressions.PropertyTester
      extended by de.cau.cs.kieler.ksbase.ui.test.ModelObjectTester
All Implemented Interfaces:
IPropertyTester

public class ModelObjectTester
extends PropertyTester

A property tester which checks if a selected diagram object matches a given model element.

Rating proposed yellow
(2009-12-15)

Constructor Summary
ModelObjectTester()
           
 
Method Summary
static boolean evaluateTransformation(EditorTransformationSettings editor, String transformation, String[] parameterTypes, List<EObject> parameter, boolean execute)
          Evaluates the given transformation.
 boolean test(Object receiver, String property, Object[] args, Object expectedValue)
          Test method called by the eclipse menu framework when checking for menu visibility.
 
Methods inherited from class org.eclipse.core.expressions.PropertyTester
handles, instantiate, internalCreateDescriptor, internalInitialize, isDeclaringPluginActive, isInstantiated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelObjectTester

public ModelObjectTester()
Method Detail

test

public boolean test(Object receiver,
                    String property,
                    Object[] args,
                    Object expectedValue)
Test method called by the eclipse menu framework when checking for menu visibility. This is kind of hacky, because we are ignoring the given items and using the PlatformUI class to get the current selection object. This results in multiple calls for all selected objects but it is working fast enough. Maybe this can be improved somehow.

Parameters:
receiver - The receiver object
property - The property to check
args - The arguments, in this case this has to be the array[Editor,Transformation]
expectedValue - The expected value
Returns:
True if all selected objects are matching to the current selection.

evaluateTransformation

public static boolean evaluateTransformation(EditorTransformationSettings editor,
                                             String transformation,
                                             String[] parameterTypes,
                                             List<EObject> parameter,
                                             boolean execute)
Evaluates the given transformation.

Parameters:
editor - The editor to use
transformation - The transformation to validate
parameterTypes - The parameter types
parameter - The parameter values
execute - Should the transformation actually be executed?
Returns:
True If the transformation could be initialized and if the execute parameter is set, the transformation returned true.