Search in sources :

Example 1 with GraphicalEditor

use of org.osate.ge.GraphicalEditor in project AGREE by loonwerks.

the class VariablesView method showInGraphicalView.

private void showInGraphicalView(final InstanceObject io) {
    assert (io != null);
    // Open the graphical editor
    final GraphicalEditorService editorService = Objects.requireNonNull(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(GraphicalEditorService.class), "unable to retrieve Graphical Editor Service");
    final SimulationEngine engine = simulationUiService.getCurrentState().getSimulationEngine();
    if (engine != null && engine.getSystemInstance() != null) {
        final GraphicalEditor editor = editorService.openBusinessObject(engine.getSystemInstance());
        editor.selectDiagramElementsForBusinessObject(io);
    }
    ;
}
Also used : SimulationEngine(edu.uah.rsesc.aadlsimulator.SimulationEngine) GraphicalEditorService(org.osate.ge.services.GraphicalEditorService) GraphicalEditor(org.osate.ge.GraphicalEditor)

Example 2 with GraphicalEditor

use of org.osate.ge.GraphicalEditor in project osate-plugin by sireum.

the class AwasUtil method awasGraphUri2AgeDiagramEditor.

@SuppressWarnings("restriction")
public static Set<AgeEditor> awasGraphUri2AgeDiagramEditor(Set<String> graphs, Boolean isImpleDiagram, SymbolTable st, Resource resource, DiagramService diagramService) {
    List<String> graphFrags = graphs.stream().flatMap(it -> {
        Option<Node> t = SymbolTableHelper.uri2Node(it, st);
        List<String> res = new ArrayList<String>();
        if (t.isDefined() && t.get().auriFrag().isDefined()) {
            res.add(t.get().auriFrag().get());
        }
        return res.stream();
    }).collect(Collectors.toList());
    final List<EObject> cis = graphFrags.stream().map(it -> resource.getResourceSet().getEObject(URI.createURI(it), true)).collect(Collectors.toList());
    Set<AgeEditor> ads = new HashSet<AgeEditor>();
    for (EObject ci : cis) {
        if (ci instanceof ComponentInstance) {
            GraphicalEditor ade = null;
            if (isImpleDiagram) {
                ComponentImplementation cii = InstanceUtil.getComponentImplementation((ComponentInstance) ci, 0, null);
                // AgeDiagramEditor ade = openOrCreateDiagramForBusinessObject(cii, diagramService);
                ade = diagramService.openOrCreateDiagramForBusinessObject(cii, false, false);
            } else {
                ade = diagramService.openOrCreateDiagramForBusinessObject(((ComponentInstance) ci).getSystemInstance(), true, true);
            }
            if (!(ade instanceof AgeEditor)) {
                throw new AgeGefRuntimeException("Unexpected editor type. Editor must be of type " + AgeEditor.class);
            }
            ads.add((AgeEditor) ade);
        }
    }
    return ads;
}
Also used : ComponentInstance(org.osate.aadl2.instance.ComponentInstance) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) Element(org.osate.aadl2.Element) URI(org.eclipse.emf.common.util.URI) Node(org.sireum.awas.ast.Node) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgeGefRuntimeException(org.osate.ge.gef.AgeGefRuntimeException) ResultType(org.sireum.awas.collector.ResultType) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AgeEditor(org.osate.ge.gef.ui.editor.AgeEditor) InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) Collector(org.sireum.awas.awasfacade.Collector) EObjectURIWrapper(org.osate.aadl2.modelsupport.EObjectURIWrapper) InstanceUtil(org.osate.aadl2.instance.util.InstanceUtil) SystemInstance(org.osate.aadl2.instance.SystemInstance) NodeType(org.sireum.awas.flow.NodeType) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) DiagramService(org.osate.ge.internal.services.DiagramService) SymbolTable(org.sireum.awas.symbol.SymbolTable) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Option(scala.Option) Collectors(java.util.stream.Collectors) StyleBuilder(org.osate.ge.graphics.StyleBuilder) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) DiagramReference(org.osate.ge.internal.services.DiagramService.DiagramReference) EditorUtil(org.osate.ge.internal.ui.util.EditorUtil) List(java.util.List) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GraphicalEditor(org.osate.ge.GraphicalEditor) ExecutionMode(org.osate.ge.internal.services.ActionExecutor.ExecutionMode) Resource(org.eclipse.emf.ecore.resource.Resource) SymbolTableHelper(org.sireum.awas.symbol.SymbolTableHelper) InstanceObject(org.osate.aadl2.instance.InstanceObject) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgeEditor(org.osate.ge.gef.ui.editor.AgeEditor) EObject(org.eclipse.emf.ecore.EObject) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Option(scala.Option) ArrayList(java.util.ArrayList) List(java.util.List) AgeGefRuntimeException(org.osate.ge.gef.AgeGefRuntimeException) HashSet(java.util.HashSet) GraphicalEditor(org.osate.ge.GraphicalEditor)

Example 3 with GraphicalEditor

use of org.osate.ge.GraphicalEditor in project osate2 by osate.

the class CreateNewDiagramHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
    if (!(activeEditor instanceof GraphicalEditor)) {
        throw new RuntimeException("Unexpected editor: " + activeEditor);
    }
    // Get diagram and selected BOCs
    final List<BusinessObjectContext> selectedBusinessObjectContexts = AgeHandlerUtil.getSelectedBusinessObjectContexts();
    if (selectedBusinessObjectContexts.size() == 0) {
        throw new RuntimeException("No element selected");
    }
    final Object bo = selectedBusinessObjectContexts.get(0).getBusinessObject();
    final DiagramService diagramService = Objects.requireNonNull(Adapters.adapt(activeEditor, DiagramService.class), "Unable to retrieve diagram service");
    final IFile file = diagramService.createDiagram(bo);
    if (file != null) {
        EditorUtil.openEditor(file, false);
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) IEditorPart(org.eclipse.ui.IEditorPart) DiagramService(org.osate.ge.internal.services.DiagramService) BusinessObjectContext(org.osate.ge.BusinessObjectContext) GraphicalEditor(org.osate.ge.GraphicalEditor)

Aggregations

GraphicalEditor (org.osate.ge.GraphicalEditor)3 DiagramService (org.osate.ge.internal.services.DiagramService)2 SimulationEngine (edu.uah.rsesc.aadlsimulator.SimulationEngine)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 IFile (org.eclipse.core.resources.IFile)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IEditorPart (org.eclipse.ui.IEditorPart)1 ComponentImplementation (org.osate.aadl2.ComponentImplementation)1 Element (org.osate.aadl2.Element)1 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)1 InstanceObject (org.osate.aadl2.instance.InstanceObject)1 SystemInstance (org.osate.aadl2.instance.SystemInstance)1 InstanceUtil (org.osate.aadl2.instance.util.InstanceUtil)1