Search in sources :

Example 1 with DDiagram

use of org.eclipse.sirius.diagram.DDiagram in project Palladio-Editors-Sirius by PalladioSimulator.

the class SemanticElementsValidateAction method getFileToMark.

/*
     * The marker should reference the main aird file, to be sure to load all the user session when clicking on the marker
     * if the corresponding session is closed (referenced analysis cases or CDO for which the main aird is local file with
     * information concerning the server).
     * @was-generated NOT
     */
private static IFile getFileToMark(DiagramEditPart diagramEditPart, View view) {
    Resource targetResource = view.eResource();
    if (diagramEditPart instanceof IDDiagramEditPart) {
        Option<DDiagram> ddiagram = ((IDDiagramEditPart) diagramEditPart).resolveDDiagram();
        Session session = ddiagram.some() && ddiagram.get() instanceof DSemanticDiagram ? SessionManager.INSTANCE.getSession(((DSemanticDiagram) ddiagram.get()).getTarget()) : null;
        if (session != null) {
            targetResource = session.getSessionResource();
        }
    }
    IFile target = targetResource != null ? WorkspaceSynchronizer.getFile(targetResource) : null;
    return target;
}
Also used : DSemanticDiagram(org.eclipse.sirius.diagram.DSemanticDiagram) IFile(org.eclipse.core.resources.IFile) DDiagram(org.eclipse.sirius.diagram.DDiagram) IDDiagramEditPart(org.eclipse.sirius.diagram.ui.edit.api.part.IDDiagramEditPart) Resource(org.eclipse.emf.ecore.resource.Resource) Session(org.eclipse.sirius.business.api.session.Session)

Example 2 with DDiagram

use of org.eclipse.sirius.diagram.DDiagram in project Palladio-Editors-Sirius by PalladioSimulator.

the class SemanticElementsValidateAction method getDSemanticDecorator.

private static DSemanticDecorator getDSemanticDecorator(EObject element, DiagramEditPart diagramEditPart) {
    DSemanticDecorator dSemanticDecorator = null;
    if (!(element instanceof DSemanticDecorator)) {
        Collection<EObject> xrefs = new EObjectQuery(element).getInverseReferences(ViewpointPackage.Literals.DSEMANTIC_DECORATOR__TARGET);
        if (xrefs.isEmpty() && element.eContainer() != null) {
            xrefs = new EObjectQuery(element.eContainer()).getInverseReferences(ViewpointPackage.Literals.DSEMANTIC_DECORATOR__TARGET);
        }
        DDiagram dDiagram = (DDiagram) diagramEditPart.getDiagramView().getElement();
        for (EObject eObject : xrefs) {
            if (eObject == dDiagram || eObject instanceof DSemanticDecorator && EcoreUtil.isAncestor(dDiagram, eObject)) {
                dSemanticDecorator = (DSemanticDecorator) eObject;
                break;
            }
        }
    } else {
        dSemanticDecorator = (DSemanticDecorator) element;
    }
    return dSemanticDecorator;
}
Also used : DSemanticDecorator(org.eclipse.sirius.viewpoint.DSemanticDecorator) EObjectQuery(org.eclipse.sirius.diagram.business.api.query.EObjectQuery) DDiagram(org.eclipse.sirius.diagram.DDiagram) EObject(org.eclipse.emf.ecore.EObject)

Example 3 with DDiagram

use of org.eclipse.sirius.diagram.DDiagram in project Palladio-Editors-Sirius by PalladioSimulator.

the class SemanticElementsValidateAction method getDRepresentationDescriptorURIFromDiagram.

private static String getDRepresentationDescriptorURIFromDiagram(Object object) {
    String diagramDescriptorUri = null;
    if (object instanceof Diagram) {
        Optional<DRepresentationDescriptor> optional = Optional.of((Diagram) object).map(View::getElement).filter(DDiagram.class::isInstance).map(d -> {
            DRepresentationQuery query = new DRepresentationQuery((DDiagram) d);
            return query.getRepresentationDescriptor();
        });
        if (optional.isPresent()) {
            final URI uri = EcoreUtil.getURI(optional.get());
            diagramDescriptorUri = uri.toString();
        }
    }
    return diagramDescriptorUri;
}
Also used : DRepresentationQuery(org.eclipse.sirius.business.api.query.DRepresentationQuery) View(org.eclipse.gmf.runtime.notation.View) URI(org.eclipse.emf.common.util.URI) DRepresentationDescriptor(org.eclipse.sirius.viewpoint.DRepresentationDescriptor) DDiagram(org.eclipse.sirius.diagram.DDiagram) DSemanticDiagram(org.eclipse.sirius.diagram.DSemanticDiagram) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Aggregations

DDiagram (org.eclipse.sirius.diagram.DDiagram)3 DSemanticDiagram (org.eclipse.sirius.diagram.DSemanticDiagram)2 IFile (org.eclipse.core.resources.IFile)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 Diagram (org.eclipse.gmf.runtime.notation.Diagram)1 View (org.eclipse.gmf.runtime.notation.View)1 DRepresentationQuery (org.eclipse.sirius.business.api.query.DRepresentationQuery)1 Session (org.eclipse.sirius.business.api.session.Session)1 EObjectQuery (org.eclipse.sirius.diagram.business.api.query.EObjectQuery)1 IDDiagramEditPart (org.eclipse.sirius.diagram.ui.edit.api.part.IDDiagramEditPart)1 DRepresentationDescriptor (org.eclipse.sirius.viewpoint.DRepresentationDescriptor)1 DSemanticDecorator (org.eclipse.sirius.viewpoint.DSemanticDecorator)1