/** * Check that the {@code representation} is correctly removed/present including removed/prevent * from/in the Sirius CrossReferencer. * * @param target the semantic target * @param representation the representation to check * @param expected true if representation have to be found */ private void checkRepresentation( EObject target, DRepresentation representation, boolean expected) { Collection<DRepresentation> representations = Lists.newArrayList(); ECrossReferenceAdapter xref = session.getSemanticCrossReferencer(); for (EStructuralFeature.Setting setting : xref.getInverseReferences(target)) { if (ViewpointPackage.Literals.DREPRESENTATION.isInstance(setting.getEObject()) && setting.getEStructuralFeature() == ViewpointPackage.Literals.DSEMANTIC_DECORATOR__TARGET) { representations.add((DRepresentation) setting.getEObject()); } } assertEquals( "Can " + (expected ? "not " : "") + "find " + DIAGRAM_NAME + " DRepresentation with sirius cross referencer", expected, representations.contains(representation)); representations = DialectManager.INSTANCE.getRepresentations(target, session); assertEquals( "Can " + (expected ? "not " : "") + "find " + DIAGRAM_NAME + " DRepresentation with DialectManager.INSTANCE.getRepresentations", expected, representations.contains(representation)); }
public BindingInfo openBindingEditor(BindingInfo bindingInfo) { DBindingEditor editor = null; final Session session = SessionManager.INSTANCE.getSession(bindingInfo); // Find an editor to open Collection<DRepresentation> representations = DialectManager.INSTANCE.getRepresentations(bindingInfo, session); for (DRepresentation representation : representations) { if (representation instanceof DBindingEditor) { editor = (DBindingEditor) representation; break; } } // Create an editor if needed if (editor == null) { RepresentationDescription representationDescription = getBindingEditorRepresentation(session); if (representationDescription != null) { DRepresentation representation = DialectManager.INSTANCE.createRepresentation( computeBindingEditorName(bindingInfo), bindingInfo, representationDescription, session, new NullProgressMonitor()); if (representation != null && representation instanceof DBindingEditor) { editor = (DBindingEditor) representation; } } } // Open the editor if (editor != null) { UserSession.from(session).openRepresentation(new StructuredSelection(editor)); } return bindingInfo; }