/** * 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)); }
/** {@inheritDoc} */ @Override protected void doExecute() { if (representations == null || session == null) { return; } for (final DRepresentation representation : representations) { DialectManager.INSTANCE.copyRepresentation( representation, getName(representation), session, null); } }
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; }
/** * {@inheritDoc} * * @see org.eclipse.sirius.business.api.helper.task.ICommandTask#execute() */ public void execute() { if (semanticElement != null) { try { if (monitor == null) { monitor = new NullProgressMonitor(); } String name = askDiagramName(semanticElement); DialectManager.INSTANCE.createRepresentation( name, semanticElement, description, SessionManager.INSTANCE.getSession(semanticElement), monitor); } catch (final InterruptedException e) { // the user pressed "cancel", let's do nothing } } }
private void cleanDiagramMappingsManagers(final Session session) { final Set<DDiagram> diagramInSession = new HashSet<DDiagram>(); for (final DRepresentation representation : DialectManager.INSTANCE.getAllRepresentations(session)) { if (representation instanceof DDiagram) { diagramInSession.add((DDiagram) representation); } } final Set<DDiagram> keysToRemove = new HashSet<DDiagram>(); for (final DDiagram diagram : diagramMappingsManagers.keySet()) { if (diagramInSession.contains(diagram)) { keysToRemove.add(diagram); } } for (final DDiagram keyToRemove : keysToRemove) { diagramMappingsManagers.remove(keyToRemove); } }
/** * {@inheritDoc} * * @see * org.eclipse.sirius.viewpoint.description.impl.ViewpointImpl#initView(org.eclipse.sirius.viewpoint.DView, * org.eclipse.emf.ecore.EObject) */ @Override public void initView(final EObject model) { DialectManager.INSTANCE.initRepresentations(this, model, new NullProgressMonitor()); }
/** {@inheritDoc} */ @Override public void refresh() { DialectManager.INSTANCE.refresh(this, new NullProgressMonitor()); }