Search in sources :

Example 1 with DiagramElementPredicates

use of org.osate.ge.internal.diagram.runtime.DiagramElementPredicates in project osate2 by osate.

the class SelectAllConnectionsHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
    if (!(activeEditor instanceof InternalDiagramEditor)) {
        throw new RuntimeException("Unexpected editor: " + activeEditor);
    }
    final InternalDiagramEditor editor = (InternalDiagramEditor) activeEditor;
    final List<DiagramElement> connectionDiagramElements = editor.getDiagram().getAllDiagramNodes().filter(dn -> dn instanceof DiagramElement).map(DiagramElement.class::cast).filter(DiagramElementPredicates::isConnection).collect(Collectors.toList());
    editor.selectDiagramNodes(connectionDiagramElements);
    return null;
}
Also used : InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) List(java.util.List) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) AbstractHandler(org.eclipse.core.commands.AbstractHandler) ExecutionException(org.eclipse.core.commands.ExecutionException) DiagramElementPredicates(org.osate.ge.internal.diagram.runtime.DiagramElementPredicates) Collectors(java.util.stream.Collectors) IEditorPart(org.eclipse.ui.IEditorPart) HandlerUtil(org.eclipse.ui.handlers.HandlerUtil) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

List (java.util.List)1 Collectors (java.util.stream.Collectors)1 AbstractHandler (org.eclipse.core.commands.AbstractHandler)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IEditorPart (org.eclipse.ui.IEditorPart)1 HandlerUtil (org.eclipse.ui.handlers.HandlerUtil)1 DiagramElement (org.osate.ge.internal.diagram.runtime.DiagramElement)1 DiagramElementPredicates (org.osate.ge.internal.diagram.runtime.DiagramElementPredicates)1 InternalDiagramEditor (org.osate.ge.internal.ui.editor.InternalDiagramEditor)1