我有 .uml 文件,其中包含 UML 状态机、转换和状态。我设法在这个 .uml 文件中的对象上放置了一个标记,但不能在它们位于 .aird 文件中的图形表示上放置一个标记。这是我用来放置标记的代码:
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);
}
这是我用来查找图形表示的代码:
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);
}
}
}
}
}
当我尝试转到转换图形表示的标记时,它会突出显示状态机。以下是转换的 URI:
平台:/resource/TestSuite/default.uml#_igwUwDFJEealS5qn_7gKFw 平台:/resource/TestSuite/representations.aird#_igwUwTFJEealS5qn_7gKFw