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);
}
;
}
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;
}
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;
}
Aggregations