UML Modeling Layer

com.ibm.xtools.uml.msl.internal.redefinition
Class RedefUtil

java.lang.Object
  extended by com.ibm.xtools.uml.msl.internal.redefinition.RedefInternalUtil
      extended by com.ibm.xtools.uml.msl.internal.redefinition.RedefUtil
Direct Known Subclasses:
RedefClassifierUtil, RedefConnectorUtil, RedefPropertyUtil, RedefRegionUtil, RedefStateMachineUtil, RedefStateUtil, RedefTransitionUtil, RedefVertexUtil

public class RedefUtil
extends RedefInternalUtil

Redefinition utilities for structure & state diagrams


Nested Class Summary
static class RedefUtil.ElementWithRedefinitionContext
           
static interface RedefUtil.IRedefintionContextAccessor
           
 
Nested classes/interfaces inherited from class com.ibm.xtools.uml.msl.internal.redefinition.RedefInternalUtil
RedefInternalUtil.ContainmentTester
 
Field Summary
static String CONTEXT_HINT
           
static String EDIT_REQUEST_PARAM_SUPRESS_UI
           
protected static RedefUtil redefUtilInstance
           
static String REFACTORING_ROOT_FRAGMENT_REMOVAL
           
 
Fields inherited from class com.ibm.xtools.uml.msl.internal.redefinition.RedefInternalUtil
defaultContainmentTester, EMPTY_BEHAVIOR_BODY, uml2
 
Constructor Summary
RedefUtil()
           
 
Method Summary
static boolean canRedefine(Element el, EObject contextHint)
          Answers whether the element in question is redefinable in the context of a specialized class
static boolean canRedefine(RedefUtil.ElementWithRedefinitionContext elementWithContext)
          Answers whether the element in question is redefinable in the context of a specialized class
static boolean canReinherit(Element element, EObject contextHint)
           
static boolean canReinheritViewTarget(View view)
           
static void changeRedefinitionRoot(Element newRoot, Element oldRoot)
          Change the root fragment of existing redefinition hierarchy tree from oldRoot to newRoot
static void copyAllRedefinableContent(Element source, Element target)
           
static void copyLocalRedefinableContent(Element source, Element target)
           
static void copySharedContent(Element source, Element target)
           
static Object getAdapterForEditPart(Class key, View view)
           
static List getAffectedFilesFromContextHint(IEditCommandRequest request)
          Returns the affected files list based on the redefinition context hint stored with the request parameters
static List getAllStructuralFeatureContent(Element element, EObject contextHint, EStructuralFeature sf)
           
static StateMachine getContainingStateMachine(EObject eObject)
          Returns containing state machine
static EObject getContextHint(Map parameters)
           
static Map getContextHintMap(EObject hint)
           
static Element getContextualFragment(Element element, EObject contextHint)
          Finds an element that redefines the given element in the given context or the context closest to the given context
static Element getContextualFragment(RedefUtil.ElementWithRedefinitionContext elementWithContext)
           
static Collection getInheritanceTree(Classifier clazz)
           
static List getInheritedContent(EObject element, EReference slot)
          returns inherited content of the given structural feature
static RedefUtil getInstance()
           
static Classifier getLocalContext(EObject element)
          Returns local context for the given element.
static Classifier getLocalContextFromHint(Element element, EObject contextHint)
           
static Classifier getLocalContextFromHint(EObject contextHint)
          Deprecated. Use getLocalContextFromHint(Element element, EObject contextHint) method instead
static Classifier getLocalContextIfExists(EObject element)
          Returns local context for the given element.
static Element getLocalFragment(Element element, EObject contextHint)
           
 RedefinableStructuralFeature[] getRedefinableFeatures()
           
static RedefinableElement getRedefinedElement(Element element)
           
static Element getRedefinedElementOrSuperClass(Element fragment)
           
static Collection getRedefinitions(Element redefElement)
           
static EReference getRedefinitionStructuralFeature(RedefinableElement el)
           
static Collection getRedefinitionTree(RedefinableElement element)
           
static List getReferencesTargets(Collection candidates, EObject contextHint)
          Returns collection of semantic elements that the views should keep as their target.
static Element getReferenceTarget(Element candidate, EObject contextHint)
          Returns semantic element that the view should keep as its target.
static IAdaptable getReferenceTarget(IAdaptable candidate, EObject contextHint)
          Returns semantic element that the view should keep as its target.
static Element getRootFragment(Element element)
          Follows the redefinition chain and returns the first fragment in the chain, the one who does not redefine any other element.
static EStructuralFeature[] getSharedFeatures()
           
static Object getStereotypeValue(Element element, EObject contextHint, String stereotypeName, String valueName)
           
static Collection getSubclasses(Classifier clazz)
           
static Object getValue(EStructuralFeature feature, Element element, EObject contextHint)
          Given an element, redefinition context hint and the feature returns the value object
static boolean isEventBrokerRedefinitionAware()
           
static boolean isExcluded(Element contextualFragment)
           
static boolean isExcluded(Element rootFragment, EObject redefinitionContextHint)
           
static boolean isFragmentRemovalRefactoring(Element element)
           
static boolean isInheritable(Element el, EObject contextHint)
          Answers whether the element in question can be inherited in the given context
static boolean isInherited(Element element, EObject contextHint)
           
static boolean isLocal(Element element, EObject contextHint)
          Returns FALSE if given fragment is owned by a context different from one identified by contextHint argument.
static boolean isRedefinitionContextValid(Classifier elementContext, Classifier contextHintContext)
          Check to see if the context of the element in question is a generalization of the context of contextHint...only then is redefinition valid
static boolean isRedefinitionStructuredFeature(Object sf)
           
static boolean isStereotypePropertyRedefinable(Stereotype stereotype, String propertyName)
          Will return whether this stereotype property is redefinable or not
static boolean isStereotypeValueInherited(Element element, EObject contextHint, String stereotypeName, String valueName)
           
static boolean isUISuppressed(Map params)
          Tests if the parameter map contains the RedefUtil.EDIT_REQUEST_PARAM_SUPRESS_UI parameter
static boolean isUMLRedefinitionStructuralFeature(EReference sf)
           
static boolean isValueLocal(EStructuralFeature feature, Element element, EObject contextHint)
           
static void markFragmentRemovalRefactoring(Element element)
           
static EObject normalizeContextHint(Element semanticElement, EObject contextHint)
           
static Element redefine(Element el, EObject contextHint)
          redefines given redefinable element in the context of a specialized class
static Element redefine(RedefUtil.ElementWithRedefinitionContext elementWithContext)
           
static void reinherit(Element element)
           
static void removeFragment(Element element)
          Remove given root fragment and make the immediate redefining fragments new root ones
static void separate(Element fragment, boolean absorbInheritedContent)
          Detaches given redefining fragment from the fragment it redefines
static void setRedefinition(Element redefining, Element redefined)
          Sets redefinition relationship between two existing fragments
static void setSupressUIParam(Map params, boolean suppress)
          Sets the RedefUtil.EDIT_REQUEST_PARAM_SUPRESS_UI parameter into the parameter map
static Element unexclude(RedefinableElement contextualFragment)
           
 
Methods inherited from class com.ibm.xtools.uml.msl.internal.redefinition.RedefInternalUtil
filterBySF, findBody, findBody, findOwner, findOwner, findSubclasses, findSubclasses, getContainedElement, getContextChain, getExclusionSupport, getRedefSupport, retargetReferences, retargetReferencesDownTheContextChain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

redefUtilInstance

protected static RedefUtil redefUtilInstance

CONTEXT_HINT

public static final String CONTEXT_HINT
See Also:
Constant Field Values

REFACTORING_ROOT_FRAGMENT_REMOVAL

public static final String REFACTORING_ROOT_FRAGMENT_REMOVAL
See Also:
Constant Field Values

EDIT_REQUEST_PARAM_SUPRESS_UI

public static final String EDIT_REQUEST_PARAM_SUPRESS_UI
See Also:
Constant Field Values
Constructor Detail

RedefUtil

public RedefUtil()
Method Detail

getInstance

public static RedefUtil getInstance()

setSupressUIParam

public static void setSupressUIParam(Map params,
                                     boolean suppress)
Sets the RedefUtil.EDIT_REQUEST_PARAM_SUPRESS_UI parameter into the parameter map

Parameters:
params -

isUISuppressed

public static boolean isUISuppressed(Map params)
Tests if the parameter map contains the RedefUtil.EDIT_REQUEST_PARAM_SUPRESS_UI parameter

Parameters:
params -
Returns:
true if the map contains the given parameter

getRedefinableFeatures

public RedefinableStructuralFeature[] getRedefinableFeatures()

isLocal

public static boolean isLocal(Element element,
                              EObject contextHint)
Returns FALSE if given fragment is owned by a context different from one identified by contextHint argument. Returns TRUE otherwise.

Parameters:
element -
contextHint - is an EObject owned directly or indirectly by the redefinition context (StateMachine or Classifier)
Returns:

getRootFragment

public static Element getRootFragment(Element element)
Follows the redefinition chain and returns the first fragment in the chain, the one who does not redefine any other element.

Parameters:
element -
Returns:

getContextualFragment

public static Element getContextualFragment(Element element,
                                            EObject contextHint)
Finds an element that redefines the given element in the given context or the context closest to the given context

Parameters:
element -
contextHint - is an EObject owned directly or indirectly by the redefinition context (StateMachine or Classifier)
Returns:

getContextualFragment

public static Element getContextualFragment(RedefUtil.ElementWithRedefinitionContext elementWithContext)

getLocalFragment

public static Element getLocalFragment(Element element,
                                       EObject contextHint)

isInherited

public static boolean isInherited(Element element,
                                  EObject contextHint)
Parameters:
element - the Element to check if it is inherited in the context derived from the view
view - the View that is used to derive the inheritance context
Returns:
true if the element is inherited, false otherwise.

getContainingStateMachine

public static StateMachine getContainingStateMachine(EObject eObject)
Returns containing state machine

Parameters:
eObject -
Returns:

redefine

public static Element redefine(Element el,
                               EObject contextHint)
redefines given redefinable element in the context of a specialized class

Parameters:
el -
context -
Returns:
a new or existing redefintion

redefine

public static Element redefine(RedefUtil.ElementWithRedefinitionContext elementWithContext)

reinherit

public static void reinherit(Element element)

getRedefinitions

public static Collection getRedefinitions(Element redefElement)

getRedefinedElement

public static RedefinableElement getRedefinedElement(Element element)

getReferenceTarget

public static Element getReferenceTarget(Element candidate,
                                         EObject contextHint)
Returns semantic element that the view should keep as its target.

Parameters:
candidate - the semantic element that view would "normally" use or its redefinition
contextHint - is an EObject owned directly or indirectly by the redefinition context (StateMachine or Classifier)

getReferenceTarget

public static IAdaptable getReferenceTarget(IAdaptable candidate,
                                            EObject contextHint)
Returns semantic element that the view should keep as its target.

Parameters:
candidate - the semantic element that view would "normally" use or its redefinition
contextHint - is an EObject owned directly or indirectly by the redefinition context (StateMachine or Classifier)

getReferencesTargets

public static List getReferencesTargets(Collection candidates,
                                        EObject contextHint)
Returns collection of semantic elements that the views should keep as their target.

Parameters:
candidate - the collection of semantic elements that views would "normally" use or their redefinitions
contextHint - is an EObject owned directly or indirectly by the redefinition context (StateMachine or Classifier)

getLocalContext

public static Classifier getLocalContext(EObject element)
Returns local context for the given element. Throws an exception if one is not found.

Parameters:
element -
Returns:

getLocalContextIfExists

public static Classifier getLocalContextIfExists(EObject element)
Returns local context for the given element.

Parameters:
element -
Returns:
local context or null

getLocalContextFromHint

public static Classifier getLocalContextFromHint(EObject contextHint)
Deprecated. Use getLocalContextFromHint(Element element, EObject contextHint) method instead

Parameters:
contextHint -
Returns:

getLocalContextFromHint

public static Classifier getLocalContextFromHint(Element element,
                                                 EObject contextHint)
Parameters:
element -
contextHint -
Returns:

getRedefinitionTree

public static Collection getRedefinitionTree(RedefinableElement element)
Parameters:
element -
Returns:
the element's redefinition chain with the initial redefined element in the begining

getAdapterForEditPart

public static Object getAdapterForEditPart(Class key,
                                           View view)

canReinheritViewTarget

public static boolean canReinheritViewTarget(View view)
Parameters:
view -
Returns:
TRUE if the model element represented by given View object can be re-inherited in the context represented by given View object

canReinherit

public static boolean canReinherit(Element element,
                                   EObject contextHint)
Parameters:
element -
contextHint -
Returns:
TRUE if given model element can be re-inherited in the context represented by given context hint

isRedefinitionStructuredFeature

public static boolean isRedefinitionStructuredFeature(Object sf)

getContextHint

public static EObject getContextHint(Map parameters)

getAllStructuralFeatureContent

public static List getAllStructuralFeatureContent(Element element,
                                                  EObject contextHint,
                                                  EStructuralFeature sf)

getContextHintMap

public static Map getContextHintMap(EObject hint)

getSubclasses

public static Collection getSubclasses(Classifier clazz)

removeFragment

public static void removeFragment(Element element)
Remove given root fragment and make the immediate redefining fragments new root ones

Parameters:
element -

separate

public static void separate(Element fragment,
                            boolean absorbInheritedContent)
Detaches given redefining fragment from the fragment it redefines

Parameters:
redefiningFragment -

markFragmentRemovalRefactoring

public static void markFragmentRemovalRefactoring(Element element)

isFragmentRemovalRefactoring

public static boolean isFragmentRemovalRefactoring(Element element)

copySharedContent

public static void copySharedContent(Element source,
                                     Element target)

copyLocalRedefinableContent

public static void copyLocalRedefinableContent(Element source,
                                               Element target)

copyAllRedefinableContent

public static void copyAllRedefinableContent(Element source,
                                             Element target)

getRedefinedElementOrSuperClass

public static Element getRedefinedElementOrSuperClass(Element fragment)

getRedefinitionStructuralFeature

public static EReference getRedefinitionStructuralFeature(RedefinableElement el)

normalizeContextHint

public static EObject normalizeContextHint(Element semanticElement,
                                           EObject contextHint)

getStereotypeValue

public static Object getStereotypeValue(Element element,
                                        EObject contextHint,
                                        String stereotypeName,
                                        String valueName)

isStereotypeValueInherited

public static boolean isStereotypeValueInherited(Element element,
                                                 EObject contextHint,
                                                 String stereotypeName,
                                                 String valueName)

isStereotypePropertyRedefinable

public static boolean isStereotypePropertyRedefinable(Stereotype stereotype,
                                                      String propertyName)
Will return whether this stereotype property is redefinable or not

Parameters:
stereotype - - The stereotype applied to the redefinable element
propertyName - - The property of the stereotype to be redefined
Returns:
false if the Stereotype's property has the isLeaf flag set true otherwise

getInheritanceTree

public static Collection getInheritanceTree(Classifier clazz)
Parameters:
clazz -
Returns:
collection of classifers that subclass given classifer directly or indirecty

isUMLRedefinitionStructuralFeature

public static boolean isUMLRedefinitionStructuralFeature(EReference sf)

getValue

public static Object getValue(EStructuralFeature feature,
                              Element element,
                              EObject contextHint)
Given an element, redefinition context hint and the feature returns the value object

Parameters:
feature -
element -
contextHint -
Returns:

isValueLocal

public static boolean isValueLocal(EStructuralFeature feature,
                                   Element element,
                                   EObject contextHint)
Parameters:
feature -
element -
contextHint -
Returns:

isEventBrokerRedefinitionAware

public static boolean isEventBrokerRedefinitionAware()
Returns:
true if the currently instantiated event broker is redefinition-aware

getSharedFeatures

public static EStructuralFeature[] getSharedFeatures()
Returns:
array of structural features representing shared (inheritable, but not redefinable) properties of redefinable elements

canRedefine

public static boolean canRedefine(Element el,
                                  EObject contextHint)
Answers whether the element in question is redefinable in the context of a specialized class

Parameters:
el -
contextHint -
Returns:

isInheritable

public static boolean isInheritable(Element el,
                                    EObject contextHint)
Answers whether the element in question can be inherited in the given context

Parameters:
el -
contextHint -
Returns:

canRedefine

public static boolean canRedefine(RedefUtil.ElementWithRedefinitionContext elementWithContext)
Answers whether the element in question is redefinable in the context of a specialized class

Parameters:
elementWithContext -
Returns:

isRedefinitionContextValid

public static boolean isRedefinitionContextValid(Classifier elementContext,
                                                 Classifier contextHintContext)
Check to see if the context of the element in question is a generalization of the context of contextHint...only then is redefinition valid

Parameters:
elementContext -
contextHintContext -
Returns:

changeRedefinitionRoot

public static void changeRedefinitionRoot(Element newRoot,
                                          Element oldRoot)
Change the root fragment of existing redefinition hierarchy tree from oldRoot to newRoot

Parameters:
newRedefintionRoot -
oldRedefinitionRoot -

getInheritedContent

public static List getInheritedContent(EObject element,
                                       EReference slot)
returns inherited content of the given structural feature

Parameters:
element -
slot -
Returns:

setRedefinition

public static void setRedefinition(Element redefining,
                                   Element redefined)
Sets redefinition relationship between two existing fragments

Parameters:
redefining -
redefined -

isExcluded

public static boolean isExcluded(Element contextualFragment)

isExcluded

public static boolean isExcluded(Element rootFragment,
                                 EObject redefinitionContextHint)

unexclude

public static Element unexclude(RedefinableElement contextualFragment)

getAffectedFilesFromContextHint

public static List getAffectedFilesFromContextHint(IEditCommandRequest request)
Returns the affected files list based on the redefinition context hint stored with the request parameters

Parameters:
request -
Returns:
the list of the affected files or NULL if one cannot be derived from the request

UML Modeling Layer

© Copyright IBM Corp. 2009. All rights reserved.