I have the .uml file which contains the UML state machine, transitions and states. I managed to put a marker on the objects in this .uml file, but cannot put a marker on their graphical representation located in a .aird file. This is the code I use to put markers :
public static void addMarker(EObject eObj, String message, String location, int severity) throws CoreException{
Resource resource = eObj.eResource();
String uri = EcoreUtil.getURI(eObj).toString();
String platformString = resource.getURI().toPlatformString(true);
IResource iresource = ResourcesPlugin.getWorkspace().getRoot().findMember(platformString);
IMarker imarker = iresource.createMarker(EValidator.MARKER);
imarker.setAttribute(IMarker.SEVERITY, severity);
imarker.setAttribute(IMarker.LOCATION, location);
imarker.setAttribute(EValidator.URI_ATTRIBUTE, uri);
imarker.setAttribute(IMarker.MESSAGE, message);
}
This is the code I use to find the graphical representation :
for(DView dview : SessionManager.INSTANCE.getSession(eObj).getOwnedViews()){
if(dview.getViewpoint().getName().equals("Design")){
for(DRepresentation drep : dview.getOwnedRepresentations()){
for(DRepresentationElement drepElem : drep.getOwnedRepresentationElements()){
if(drepElem.getTarget() == st.getSrcTransition().getTransition()){
MarkerUtil.addMarker(drepElem, message, location, severity);
}
}
}
}
}
When I try to go to the marker of the graphical representation of a transition, it highlights the state machine. Below are the URIs of a transition :
platform:/resource/TestSuite/default.uml#_igwUwDFJEealS5qn_7gKFw platform:/resource/TestSuite/representations.aird#_igwUwTFJEealS5qn_7gKFw