Search in sources :

Example 1 with AgeDiagramProvider

use of org.osate.ge.internal.AgeDiagramProvider in project osate2 by osate.

the class DefaultDiagramService method getReferences.

@Override
public ReferenceCollection getReferences(final Set<IProject> relevantProjects, final Set<CanonicalBusinessObjectReference> originalCanonicalReferences) {
    final InternalReferencesToUpdate references = new InternalReferencesToUpdate();
    Display.getDefault().syncExec(() -> {
        // Create updateable reference for open diagrams
        for (final InternalDiagramEditor editor : getOpenEditorsMap(relevantProjects).values()) {
            final AgeDiagramProvider diagramProvider = editor.getAdapter(AgeDiagramProvider.class);
            if (diagramProvider == null) {
                continue;
            }
            final AgeDiagram diagram = diagramProvider.getAgeDiagram();
            if (diagram == null) {
                continue;
            }
            // Update the diagram immediately. This is intended to ensure the diagram doesn't have any proxies
            editor.updateNowIfModelHasChanged();
            final CanonicalBusinessObjectReference diagramContextRef = diagram.getConfiguration().getContextBoReference();
            if (diagramContextRef != null && originalCanonicalReferences.contains(diagramContextRef)) {
                references.addReference(editor, diagramContextRef, new OpenDiagramContextReference(diagram));
            }
            // Get references from the diagram elements
            getRuntimeReferencesFromChildren(editor, diagram, originalCanonicalReferences, references);
        }
        // Create updateable references for saved diagrams
        savedDiagramIndex.getDiagramsByContexts(relevantProjects.stream(), originalCanonicalReferences).forEach(e -> references.addReference(e.getDiagramFile(), e.getContext(), new SavedDiagramContextReference()));
        savedDiagramIndex.getDiagramElementUrisByReferences(relevantProjects.stream(), originalCanonicalReferences).forEach(e -> references.addReference(e.diagramFile, e.reference, new SavedDiagramElementReference(e.diagramElementUri)));
    });
    return references;
}
Also used : InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference) AgeDiagramProvider(org.osate.ge.internal.AgeDiagramProvider)

Aggregations

CanonicalBusinessObjectReference (org.osate.ge.CanonicalBusinessObjectReference)1 AgeDiagramProvider (org.osate.ge.internal.AgeDiagramProvider)1 AgeDiagram (org.osate.ge.internal.diagram.runtime.AgeDiagram)1 InternalDiagramEditor (org.osate.ge.internal.ui.editor.InternalDiagramEditor)1