IBM Rational Performance Tester SDK

com.ibm.rational.common.test.editor.framework
Class ModelStateManager

java.lang.Object
  extended by com.ibm.rational.common.test.editor.framework.ModelStateManager

public final class ModelStateManager
extends Object

ModelStateManager

This class contains several static methods for managing state of model objects. These states are used primarily for conveying visual feedback to user. States are: temporary, new, modified and arror. When model element's state is set, in some cases (for example, for modified state, all element's parents are also marked as modified Many of these methods are called internally, when model elements are added to a test or modified. Clients y call these methods as needed, however in most cases, they should not need to.


Constructor Summary
ModelStateManager()
           
 
Method Summary
protected  void finalize()
           
static Color getBackground(Object element)
          Returns modified background color based on the presense of various type.
static IMarker getError(CBActionElement element, String errorId)
           
static CBActionElement[] getErrorChildren(CBActionElement element)
           
static IMarker[] getErrors(CBActionElement element)
          Returns errors associated with this element.
static Font getFont(Object element, Font originalFont)
          Returns modified font for the argument element based on the presense of various attributes.
static Color getForeground(Object element)
          Returns modified foreground color for element based on the presense of various states.
static Image getImage(Object object, Image baseImage, ExtLabelProvider provider)
           
static StyledString.Styler getSearhMatchStyler()
           
static boolean hasError(CBActionElement element)
          Checks if the element has error state.
static boolean isModified(CBActionElement element)
          Checks if the element has modified state.
static boolean isNew(CBActionElement element)
          Checks if the element has new state.
static boolean isStatusTemp(CBActionElement element, TestEditor editor)
          Checks for temp status on the object.
static void setError(CBActionElement element, TestEditor editor, IMarker errorMarker)
          Sets error state.
static Object setStatusModified(CBActionElement element, Object context, TestEditor editor)
          Sets modified state on the model element.
static Object setStatusModified(CBActionElement element, Object context, TestEditor editor, boolean updateChildrenToo, boolean updateParent)
          Sets modified state on the model element.
static Object setStatusModified(CBTest test, Object context, TestEditor editor)
           
static void setStatusNew(CBActionElement element, TestEditor editor)
          Set new state on model element.
static void setStatusTemp(CBActionElement element, TestEditor editor)
          Sets temp status on model element.
static void setStatusTemp(CBActionElement element, TestEditor editor, boolean updateEditor)
          Sets temp status on model element.
static int unsetAllErrors(TestEditor editor)
          Unsets all errors in he Test Editor.
static void unsetError(CBActionElement element, TestEditor editor, IMarker errorMarker)
          Removes error state from model element.
static void unsetErrors(CBActionElement element, TestEditor editor)
           
static void unsetStatusModified(CBActionElement element, Object context, TestEditor editor)
          Unsets modified state on model element.
static void unsetStatusNew(CBActionElement element, Object context, TestEditor editor)
          Clears new status.
static void unsetStatusTemp(CBActionElement element, TestEditor editor)
          Unsets temp status.
static void unsetStatusTemp(CBActionElement element, TestEditor editor, boolean updateEditor)
          Unsets temp status.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelStateManager

public ModelStateManager()
Method Detail

setError

public static void setError(CBActionElement element,
                            TestEditor editor,
                            IMarker errorMarker)
Sets error state.

Parameters:
element - CBActionElement
editor - TestEditor
errorMarker - IMarker created by MarkerUtil.
See Also:
MarkerUtil

unsetErrors

public static void unsetErrors(CBActionElement element,
                               TestEditor editor)

unsetError

public static void unsetError(CBActionElement element,
                              TestEditor editor,
                              IMarker errorMarker)
Removes error state from model element.

Parameters:
element - CBModelElement
editor - TestEditor
errorMarker - IMarker. Marker must have been created using MarkerUtil and passed to setError method.
See Also:
ModelStateManager.setError(CBActionElement, TestEditor, IMarker), MarkerUtil.removeMarkers(IMarker[], TestEditor)

setStatusNew

public static void setStatusNew(CBActionElement element,
                                TestEditor editor)
Set new state on model element.

Parameters:
element - CBActionElement
editor - TestEditor

unsetStatusNew

public static void unsetStatusNew(CBActionElement element,
                                  Object context,
                                  TestEditor editor)
Clears new status. Typically called after test editor is being saved.

Parameters:
element - CBActionElement
context - unused
editor - TestEditor
See Also:
ModelStateManager.setStatusNew(CBActionElement, TestEditor)

setStatusTemp

public static void setStatusTemp(CBActionElement element,
                                 TestEditor editor)
Sets temp status on model element. Objects with temp status are displayed using grey color and italic font. These objects are placed in the model temporary or about to be removed.

Parameters:
element - CBActionElement
editor - TestEditor

setStatusTemp

public static void setStatusTemp(CBActionElement element,
                                 TestEditor editor,
                                 boolean updateEditor)
Sets temp status on model element. Objects with temp status are displayed using grey color and italic font. These objects are placed in the model temporary or about to be removed.

Parameters:
element - CBActionElement
editor - TestEditor
updateEditor - boolean

unsetStatusTemp

public static void unsetStatusTemp(CBActionElement element,
                                   TestEditor editor)
Unsets temp status.

Parameters:
element - CBActionElement
editor - TestEditor
See Also:
ModelStateManager.setStatusTemp(CBActionElement, TestEditor)

unsetStatusTemp

public static void unsetStatusTemp(CBActionElement element,
                                   TestEditor editor,
                                   boolean updateEditor)
Unsets temp status.

Parameters:
element - CBActionElement
editor - TestEditor
updateEditor - boolean
See Also:
ModelStateManager.setStatusTemp(CBActionElement, TestEditor)

isStatusTemp

public static boolean isStatusTemp(CBActionElement element,
                                   TestEditor editor)
Checks for temp status on the object.

Parameters:
element - CBActionElement
editor - TestEditor
Returns:
boolean true object is marked as temp, false otherwise.

setStatusModified

public static Object setStatusModified(CBActionElement element,
                                       Object context,
                                       TestEditor editor)
Sets modified state on the model element. Objects that are modified are displayed using italics font. modified state is unset after a test was saved.

Parameters:
element - CBActionElement
context - Object that can be used to identify modification or null.
editor - TestEditor
Returns:
Object if context argument was not null, same object is returned. otherwise new Date() is returned.

setStatusModified

public static Object setStatusModified(CBActionElement element,
                                       Object context,
                                       TestEditor editor,
                                       boolean updateChildrenToo,
                                       boolean updateParent)
Sets modified state on the model element. Objects that are modified are displayed using italics font. modified state is unset after a test was saved.

Parameters:
element - CBActionElement
context - Object that can be used to identify modification or null.
editor - TestEditor
updateChildrenToo - boolean Sets modified status to all children of the element
updateParent - boolean Set modified status to parent. Only considered if updateChidrenToo==true ; otherwise, the parent is always updated. Pass false to avoid excessive refreshes
Returns:
Object if context argument was not null, same object is returned. otherwise new Date() is returned.

setStatusModified

public static Object setStatusModified(CBTest test,
                                       Object context,
                                       TestEditor editor)

unsetStatusModified

public static void unsetStatusModified(CBActionElement element,
                                       Object context,
                                       TestEditor editor)
Unsets modified state on model element.

Parameters:
element - CBActionElement
context - Object. Same context must be passed to setModifiedStatus. In this version, this argument is unused and reserved.
editor - TestEditor.

getFont

public static Font getFont(Object element,
                           Font originalFont)
Returns modified font for the argument element based on the presense of various attributes.

Parameters:
element - Object element (must be CBActionlEement)
originalFont -
Returns:
Font or null if no special font is needed.
See Also:
IFontProvider.getFont(java.lang.Object)

getForeground

public static Color getForeground(Object element)
Returns modified foreground color for element based on the presense of various states.

Parameters:
element - Object (must be CBActionElement)
Returns:
Color or null.
See Also:
IColorProvider.getForeground(java.lang.Object)

getBackground

public static Color getBackground(Object element)
Returns modified background color based on the presense of various type.

Returns:
Color always returns null
See Also:
IColorProvider.getBackground(java.lang.Object)

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

unsetAllErrors

public static int unsetAllErrors(TestEditor editor)
Unsets all errors in he Test Editor. Typically called by ErrorcheckingJob prior to invocation. Clients should not need to call this method directly.

Parameters:
editor -
Returns:
number of errors cleared.

isNew

public static boolean isNew(CBActionElement element)
Checks if the element has new state.

Parameters:
element - CBActionElement
Returns:
boolean

isModified

public static boolean isModified(CBActionElement element)
Checks if the element has modified state.

Parameters:
element - CBActionElement
Returns:
boolean

hasError

public static boolean hasError(CBActionElement element)
Checks if the element has error state.

Parameters:
element - CBActionElement
Returns:
boolean

getErrors

public static IMarker[] getErrors(CBActionElement element)
Returns errors associated with this element.

Parameters:
element - CBActionElement
Returns:
boolean List. Returns array of IMarkers if there is no errors.

getError

public static IMarker getError(CBActionElement element,
                               String errorId)

getErrorChildren

public static CBActionElement[] getErrorChildren(CBActionElement element)
Parameters:
element -
Returns:
array CBActionElement[] child elements of element that have errors.

getImage

public static Image getImage(Object object,
                             Image baseImage,
                             ExtLabelProvider provider)

getSearhMatchStyler

public static StyledString.Styler getSearhMatchStyler()

IBM Rational Performance Tester SDK

© Copyright IBM Corp. 2012. All rights reserved.