Search in sources :

Example 1 with GefAgeDiagram

use of org.osate.ge.gef.ui.diagram.GefAgeDiagram in project osate2 by osate.

the class AgeEditor method createPartControl.

@Override
public void createPartControl(final Composite parent) {
    // 
    // Create the FX canvas which is an SWT widget for embedding JavaFX content.
    // 
    fxCanvas = new FXCanvas(parent, SWT.NONE);
    fxCanvas.addDisposeListener(e -> {
        fxCanvas.getScene().setRoot(new Group());
        fxCanvas.setScene(null);
    });
    fxCanvas.addPaintListener(paintListener);
    // Suppress SWT key press handling when interaction is active
    fxCanvas.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final org.eclipse.swt.events.KeyEvent e) {
            if (activeInteraction != null) {
                e.doit = false;
            }
        }
    });
    fxCanvas.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            deactivateInteraction();
        }
    });
    // Create the context menu
    contextMenuManager = new MenuManager(MENU_ID, MENU_ID);
    contextMenuManager.setRemoveAllWhenShown(true);
    final Menu contextMenu = contextMenuManager.createContextMenu(fxCanvas);
    fxCanvas.setMenu(contextMenu);
    getEditorSite().registerContextMenu(MENU_ID, contextMenuManager, selectionProvider, true);
    // Create the action executor. It will append an action to activate the editor when undoing and redoing actions.
    actionExecutor = (label, mode, action) -> {
        final boolean reverseActionWasSpecified = actionService.execute(label, mode, action);
        // This will ensure that when the action is undone, the editor will be switched to the one in which the action was performed.
        if (isEditorActive() && reverseActionWasSpecified && !actionService.isActionExecuting() && mode == ExecutionMode.NORMAL) {
            actionService.execute("Activate Editor", ExecutionMode.APPEND_ELSE_HIDE, new ActivateAgeEditorAction(AgeEditor.this));
        }
        fireDirtyPropertyChangeEvent();
        return reverseActionWasSpecified;
    };
    // Initialize the palette model
    final AgeEditorPaletteModel.ImageProvider imageProvider = id -> {
        final RegisteredImage img = extRegistry.getImageMap().get(id);
        if (img == null) {
            return Optional.empty();
        }
        final URI imageUri = URI.createPlatformPluginURI("/" + img.plugin + "/" + img.path, true);
        if (CommonPlugin.asLocalURI(imageUri).isFile()) {
            return Optional.of(new Image(imageUri.toString()));
        } else {
            return Optional.empty();
        }
    };
    Object diagramBo = AgeDiagramUtil.getConfigurationContextBusinessObject(diagram, projectReferenceService);
    if (diagramBo == null) {
        diagramBo = project;
    }
    this.paletteModel = new AgeEditorPaletteModel(extRegistry.getPaletteContributors(), diagramBo, imageProvider);
    // If the palette item changes while an interaction is active, deactivate the interaction.
    this.paletteModel.activeItemProperty().addListener((javafx.beans.value.ChangeListener<SimplePaletteItem>) (observable, oldValue, newValue) -> deactivateInteraction());
    // Initialize the JavaFX nodes based on the diagram
    canvas = new InfiniteCanvas();
    // Set show grid based on preferences
    canvas.setShowGrid(preferenceStore.getBoolean(Preferences.SHOW_GRID));
    final Scene scene = new Scene(new DiagramEditorNode(paletteModel, canvas));
    fxCanvas.setScene(scene);
    gefDiagram = new GefAgeDiagram(diagram, coloringService);
    // Create a wrapper around the diagram's scene node.
    final Group wrapper = new DiagramNodeWrapper(gefDiagram.getSceneNode());
    // Add the wrapper to the canvas
    canvas.getContentGroup().getChildren().add(wrapper);
    gefDiagram.updateDiagramFromSceneGraph(false);
    // Treat the current state of the diagram as clean.
    cleanDiagramChangeNumber = diagram.getCurrentChangeNumber();
    adapterMap.put(LayoutInfoProvider.class, gefDiagram);
    // Create overlays
    overlays = new Overlays(gefDiagram);
    selectionProvider.addSelectionChangedListener(overlays);
    canvas.getScrolledOverlayGroup().getChildren().add(overlays);
    // Perform the initial incremental layout
    diagram.modify("Incremental Layout", m -> DiagramElementLayoutUtil.layoutIncrementally(diagram, m, gefDiagram));
    // Set action executor after initial load. This occurs after the incremental layout to prevent the loading and initial layout from being undoable
    diagram.setActionExecutor(actionExecutor);
    // Refresh the dirty state whenever an operation occurs
    final IOperationHistory history = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
    history.addOperationHistoryListener(operationHistoryListener);
    canvas.setOnScroll(e -> {
        if (e.isControlDown()) {
            // Adjust zoom
            if (e.getDeltaY() < 0.0) {
                zoomOut();
            } else {
                zoomIn();
            }
        } else {
            if (e.isShiftDown()) {
                // Scroll in X direction
                canvas.setHorizontalScrollOffset(canvas.getHorizontalScrollOffset() - e.getDeltaY());
            } else {
                // Scroll
                canvas.setHorizontalScrollOffset(canvas.getHorizontalScrollOffset() - e.getDeltaX());
                canvas.setVerticalScrollOffset(canvas.getVerticalScrollOffset() + e.getDeltaY());
            }
        }
    });
    // 
    // Listeners to handle tooltips
    // 
    canvas.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, e -> {
        if (e.getTarget() instanceof Node && activeInteraction == null && tooltipManager != null && gefDiagram != null) {
            final DiagramElement de = gefDiagram.getDiagramElement((Node) e.getTarget());
            if (de != null) {
                tooltipManager.mouseEnter(de);
            }
        }
    });
    canvas.addEventHandler(MouseEvent.MOUSE_EXITED_TARGET, e -> {
        if (e.getTarget() instanceof Node && activeInteraction == null && tooltipManager != null && gefDiagram != null) {
            final DiagramElement de = gefDiagram.getDiagramElement((Node) e.getTarget());
            if (de != null) {
                tooltipManager.mouseExit(de);
            }
        }
    });
    // 
    // General input handlers
    // 
    // Event handler. Delegates to input event handlers or the active interaction as appropriate
    final EventHandler<? super InputEvent> handleInput = e -> {
        if (activeInteraction == null) {
            // Delegate processing of the event to the input event handlers
            for (final InputEventHandler inputEventHandler : inputEventHandlers) {
                final InputEventHandler.HandledEvent r = inputEventHandler.handleEvent(e);
                if (r != null) {
                    activeInteraction = r.newInteraction;
                    if (activeInteraction != null) {
                        canvas.setCursor(activeInteraction.getCursor());
                        if (tooltipManager != null) {
                            tooltipManager.hideTooltip();
                        }
                    }
                    break;
                }
            }
        } else {
            if (activeInteraction.handleEvent(e) == InteractionState.COMPLETE) {
                deactivateInteraction();
            }
            canvas.setCursor(activeInteraction == null ? null : activeInteraction.getCursor());
        }
    };
    // Handle mouse button presses
    canvas.addEventFilter(MouseEvent.MOUSE_PRESSED, handleInput);
    canvas.addEventFilter(MouseEvent.MOUSE_DRAGGED, handleInput);
    canvas.addEventFilter(MouseEvent.MOUSE_RELEASED, handleInput);
    scene.addEventFilter(KeyEvent.KEY_PRESSED, handleInput);
    canvas.addEventFilter(MouseEvent.MOUSE_MOVED, e -> {
        if (activeInteraction == null) {
            Cursor cursor = Cursor.DEFAULT;
            for (final InputEventHandler inputEventHandler : inputEventHandlers) {
                final Cursor overrideCursor = inputEventHandler.getCursor(e);
                if (overrideCursor != null) {
                    cursor = overrideCursor;
                    break;
                }
            }
            canvas.setCursor(cursor);
        }
        handleInput.handle(e);
    });
    // Create input event handlers
    inputEventHandlers.add(new OpenPropertiesViewInputEventHandler(this));
    inputEventHandlers.add(new ResizeInputEventHandler(this));
    inputEventHandlers.add(new MarqueeSelectInputEventHandler(this));
    inputEventHandlers.add(new MoveConnectionPointTool(this));
    inputEventHandlers.add(new RenameInputEventHandler(this));
    inputEventHandlers.add(new SelectInputEventHandler(this));
    inputEventHandlers.add(new MoveInputEventHandler(this));
    inputEventHandlers.add(new PaletteCommandInputEventHandler(this));
}
Also used : DiagramModifier(org.osate.ge.internal.diagram.runtime.DiagramModifier) Tool(org.osate.ge.internal.ui.tools.Tool) CoreException(org.eclipse.core.runtime.CoreException) FocusEvent(org.eclipse.swt.events.FocusEvent) DiagramElementLayoutUtil(org.osate.ge.internal.diagram.runtime.layout.DiagramElementLayoutUtil) InteractionState(org.osate.ge.gef.ui.editor.Interaction.InteractionState) BusinessObjectContext(org.osate.ge.BusinessObjectContext) DefaultQueryService(org.osate.ge.services.impl.DefaultQueryService) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) Map(java.util.Map) CommonPlugin(org.eclipse.emf.common.CommonPlugin) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) StatusManager(org.eclipse.ui.statushandlers.StatusManager) ProjectProvider(org.osate.ge.internal.services.ProjectProvider) Transform(javafx.scene.transform.Transform) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) GefAgeDiagram(org.osate.ge.gef.ui.diagram.GefAgeDiagram) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ChangeListener(org.osate.ge.internal.services.ModelChangeNotifier.ChangeListener) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) MenuManager(org.eclipse.jface.action.MenuManager) Status(org.eclipse.core.runtime.Status) Rectangle(javafx.scene.shape.Rectangle) AgeGefUiPlugin(org.osate.ge.gef.ui.AgeGefUiPlugin) KeyEvent(javafx.scene.input.KeyEvent) UiService(org.osate.ge.internal.services.UiService) Group(javafx.scene.Group) IContentOutlinePage(org.eclipse.ui.views.contentoutline.IContentOutlinePage) IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) IOperationHistoryListener(org.eclipse.core.commands.operations.IOperationHistoryListener) ReferenceService(org.osate.ge.internal.services.ReferenceService) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) Overlays(org.osate.ge.gef.ui.editor.overlays.Overlays) SWT(org.eclipse.swt.SWT) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) EditorPart(org.eclipse.ui.part.EditorPart) AgeDiagramProvider(org.osate.ge.internal.AgeDiagramProvider) DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) Bounds(javafx.geometry.Bounds) PaintListener(org.eclipse.swt.events.PaintListener) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) URI(org.eclipse.emf.common.util.URI) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ExtensionRegistryService(org.osate.ge.internal.services.ExtensionRegistryService) ListenerList(org.eclipse.core.runtime.ListenerList) IEditorSite(org.eclipse.ui.IEditorSite) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IPropertySheetPage(org.eclipse.ui.views.properties.IPropertySheetPage) ArrayList(java.util.ArrayList) IFileEditorInput(org.eclipse.ui.IFileEditorInput) ModelChangeNotifier(org.osate.ge.internal.services.ModelChangeNotifier) AgeContentOutlinePage(org.osate.ge.internal.ui.editor.AgeContentOutlinePage) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) ITabbedPropertySheetPageContributor(org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor) IProject(org.eclipse.core.resources.IProject) IResourceDelta(org.eclipse.core.resources.IResourceDelta) ReferenceResolutionService(org.osate.ge.services.ReferenceResolutionService) IFile(org.eclipse.core.resources.IFile) BusinessObjectTreeUpdater(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectTreeUpdater) FXCanvas(javafx.embed.swt.FXCanvas) Color(javafx.scene.paint.Color) IPreferenceChangeListener(org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener) FileEditorInput(org.eclipse.ui.part.FileEditorInput) SelectAllAction(org.osate.ge.internal.ui.editor.actions.SelectAllAction) Node(javafx.scene.Node) ContentOutline(org.eclipse.ui.views.contentoutline.ContentOutline) TabbedPropertySheetPage(org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) ProjectReferenceServiceProxy(org.osate.ge.internal.services.impl.ProjectReferenceServiceProxy) Cursor(javafx.scene.Cursor) QueryService(org.osate.ge.services.QueryService) IPartListener(org.eclipse.ui.IPartListener) IContextService(org.eclipse.ui.contexts.IContextService) InputEvent(javafx.scene.input.InputEvent) DiagramModificationAdapter(org.osate.ge.internal.diagram.runtime.DiagramModificationAdapter) LayoutInfoProvider(org.osate.ge.internal.diagram.runtime.layout.LayoutInfoProvider) Preferences(org.osate.ge.gef.ui.preferences.Preferences) Image(javafx.scene.image.Image) EventHandler(javafx.event.EventHandler) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Affine(javafx.scene.transform.Affine) IAction(org.eclipse.jface.action.IAction) ErrorDialog(org.eclipse.jface.dialogs.ErrorDialog) DefaultColoringService(org.osate.ge.internal.services.impl.DefaultColoringService) AgeGefRuntimeException(org.osate.ge.gef.AgeGefRuntimeException) ModificationsCompletedEvent(org.osate.ge.internal.diagram.runtime.ModificationsCompletedEvent) ActionService(org.osate.ge.internal.services.ActionService) IncrementalProjectBuilder(org.eclipse.core.resources.IncrementalProjectBuilder) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) InfiniteCanvas(org.eclipse.gef.fx.nodes.InfiniteCanvas) ISelectionListener(org.eclipse.ui.ISelectionListener) DiagramModificationListener(org.osate.ge.internal.diagram.runtime.DiagramModificationListener) SimplePaletteItem(org.osate.ge.gef.palette.SimplePaletteItem) BusinessObjectNodeFactory(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNodeFactory) DefaultReferenceResolutionService(org.osate.ge.services.impl.DefaultReferenceResolutionService) Bundle(org.osgi.framework.Bundle) ActionExecutor(org.osate.ge.internal.services.ActionExecutor) UndoRedoActionGroup(org.eclipse.ui.operations.UndoRedoActionGroup) RegisteredImage(org.osate.ge.internal.services.ExtensionRegistryService.RegisteredImage) Collection(java.util.Collection) Display(org.eclipse.swt.widgets.Display) DiagramSerialization(org.osate.ge.internal.diagram.runtime.DiagramSerialization) Collectors(java.util.stream.Collectors) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Objects(java.util.Objects) DefaultActionService(org.osate.ge.internal.services.impl.DefaultActionService) List(java.util.List) DeactivatedEvent(org.osate.ge.internal.ui.tools.DeactivatedEvent) AadlModificationService(org.osate.ge.internal.services.AadlModificationService) Optional(java.util.Optional) ISelection(org.eclipse.jface.viewers.ISelection) DiagramEditorNode(org.osate.ge.gef.DiagramEditorNode) DefaultDiagramElementGraphicalConfigurationProvider(org.osate.ge.internal.diagram.runtime.updating.DefaultDiagramElementGraphicalConfigurationProvider) SystemInstanceLoadingService(org.osate.ge.internal.services.SystemInstanceLoadingService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CopyAction(org.osate.ge.internal.ui.editor.actions.CopyAction) EclipseContextFactory(org.eclipse.e4.core.contexts.EclipseContextFactory) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Scene(javafx.scene.Scene) IOperationHistory(org.eclipse.core.commands.operations.IOperationHistory) ProjectReferenceService(org.osate.ge.internal.services.ProjectReferenceService) MouseEvent(javafx.scene.input.MouseEvent) HashMap(java.util.HashMap) DoubleProperty(javafx.beans.property.DoubleProperty) DiagramContextChecker(org.osate.ge.internal.ui.editor.DiagramContextChecker) ColoringService(org.osate.ge.internal.services.ColoringService) ImmutableList(com.google.common.collect.ImmutableList) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) DiagramUpdater(org.osate.ge.internal.diagram.runtime.updating.DiagramUpdater) ActivatedEvent(org.osate.ge.internal.ui.tools.ActivatedEvent) IWorkbenchSite(org.eclipse.ui.IWorkbenchSite) ActivateAgeEditorAction(org.osate.ge.internal.ui.editor.ActivateAgeEditorAction) DefaultBusinessObjectTreeUpdater(org.osate.ge.internal.diagram.runtime.updating.DefaultBusinessObjectTreeUpdater) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) AgeDiagramUtil(org.osate.ge.internal.diagram.runtime.AgeDiagramUtil) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ExecutionMode(org.osate.ge.internal.services.ActionExecutor.ExecutionMode) AgeHandlerUtil(org.osate.ge.internal.ui.handlers.AgeHandlerUtil) IResource(org.eclipse.core.resources.IResource) Menu(org.eclipse.swt.widgets.Menu) FocusAdapter(org.eclipse.swt.events.FocusAdapter) PasteAction(org.osate.ge.internal.ui.editor.actions.PasteAction) Collections(java.util.Collections) FrameworkUtil(org.osgi.framework.FrameworkUtil) Group(javafx.scene.Group) UndoRedoActionGroup(org.eclipse.ui.operations.UndoRedoActionGroup) FocusAdapter(org.eclipse.swt.events.FocusAdapter) ActivateAgeEditorAction(org.osate.ge.internal.ui.editor.ActivateAgeEditorAction) RegisteredImage(org.osate.ge.internal.services.ExtensionRegistryService.RegisteredImage) KeyAdapter(org.eclipse.swt.events.KeyAdapter) DiagramEditorNode(org.osate.ge.gef.DiagramEditorNode) DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) Node(javafx.scene.Node) DiagramEditorNode(org.osate.ge.gef.DiagramEditorNode) Image(javafx.scene.image.Image) RegisteredImage(org.osate.ge.internal.services.ExtensionRegistryService.RegisteredImage) SimplePaletteItem(org.osate.ge.gef.palette.SimplePaletteItem) Cursor(javafx.scene.Cursor) FocusEvent(org.eclipse.swt.events.FocusEvent) URI(org.eclipse.emf.common.util.URI) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) InfiniteCanvas(org.eclipse.gef.fx.nodes.InfiniteCanvas) IOperationHistory(org.eclipse.core.commands.operations.IOperationHistory) Menu(org.eclipse.swt.widgets.Menu) FXCanvas(javafx.embed.swt.FXCanvas) Scene(javafx.scene.Scene) Overlays(org.osate.ge.gef.ui.editor.overlays.Overlays) GefAgeDiagram(org.osate.ge.gef.ui.diagram.GefAgeDiagram) MenuManager(org.eclipse.jface.action.MenuManager)

Example 2 with GefAgeDiagram

use of org.osate.ge.gef.ui.diagram.GefAgeDiagram in project osate2 by osate.

the class GefDiagramExportService method loadDiagram.

private GefAgeDiagram loadDiagram(final IFile diagramFile) {
    final URI uri = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
    final IProject project = ProjectUtil.getProjectOrNull(uri);
    final org.osate.ge.diagram.Diagram mmDiagram = DiagramSerialization.readMetaModelDiagram(uri);
    final IEclipseContext eclipseContext = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(GefDiagramExportService.class).getBundleContext());
    final ExtensionRegistryService extensionRegistry = Objects.requireNonNull(eclipseContext.get(ExtensionRegistryService.class), "Unable to retrieve extension registry");
    final ReferenceService referenceService = Objects.requireNonNull(eclipseContext.get(ReferenceService.class), "unable to retrieve reference service");
    final ActionService actionService = Objects.requireNonNull(eclipseContext.get(ActionService.class), "unable to retrieve action service");
    final AgeDiagram diagram = DiagramSerialization.createAgeDiagram(project, mmDiagram, extensionRegistry);
    // Update the diagram
    final QueryService queryService = new DefaultQueryService(referenceService);
    final ProjectProvider projectProvider = diagramFile::getProject;
    final ProjectReferenceService projectReferenceService = new ProjectReferenceServiceProxy(referenceService, projectProvider);
    final BusinessObjectNodeFactory nodeFactory = new BusinessObjectNodeFactory(projectReferenceService);
    final DefaultBusinessObjectTreeUpdater boTreeUpdater = new DefaultBusinessObjectTreeUpdater(projectProvider, extensionRegistry, projectReferenceService, queryService, nodeFactory);
    final DefaultDiagramElementGraphicalConfigurationProvider deInfoProvider = new DefaultDiagramElementGraphicalConfigurationProvider(queryService, () -> diagram, extensionRegistry);
    final DiagramUpdater diagramUpdater = new DiagramUpdater(boTreeUpdater, deInfoProvider, actionService, projectReferenceService, projectReferenceService);
    diagramUpdater.updateDiagram(diagram);
    // Create the GEF Diagram
    final GefAgeDiagram gefDiagram = new GefAgeDiagram(diagram, new DefaultColoringService(new org.osate.ge.internal.services.impl.DefaultColoringService.StyleRefresher() {

        @Override
        public void refreshDiagramColoring() {
        // No-op. Handling coloring service refresh requests is not required.
        }

        @Override
        public void refreshColoring(final Collection<DiagramElement> diagramElements) {
        // No-op. Handling coloring service refresh requests is not required.
        }
    }));
    // Add to scene. This is required for text rendering
    new Scene(gefDiagram.getSceneNode());
    // Update the diagram to reflect the scene graph and perform incremental layout
    gefDiagram.updateDiagramFromSceneGraph(false);
    diagram.modify("Incremental Layout", m -> DiagramElementLayoutUtil.layoutIncrementally(diagram, m, gefDiagram));
    return gefDiagram;
}
Also used : ReferenceService(org.osate.ge.internal.services.ReferenceService) ProjectReferenceService(org.osate.ge.internal.services.ProjectReferenceService) ProjectReferenceService(org.osate.ge.internal.services.ProjectReferenceService) DefaultColoringService(org.osate.ge.internal.services.impl.DefaultColoringService) ExtensionRegistryService(org.osate.ge.internal.services.ExtensionRegistryService) URI(org.eclipse.emf.common.util.URI) GefAgeDiagram(org.osate.ge.gef.ui.diagram.GefAgeDiagram) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) ProjectReferenceServiceProxy(org.osate.ge.internal.services.impl.ProjectReferenceServiceProxy) DefaultQueryService(org.osate.ge.services.impl.DefaultQueryService) BusinessObjectNodeFactory(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNodeFactory) ActionService(org.osate.ge.internal.services.ActionService) ProjectProvider(org.osate.ge.internal.services.ProjectProvider) DefaultDiagramElementGraphicalConfigurationProvider(org.osate.ge.internal.diagram.runtime.updating.DefaultDiagramElementGraphicalConfigurationProvider) DiagramUpdater(org.osate.ge.internal.diagram.runtime.updating.DiagramUpdater) Scene(javafx.scene.Scene) IProject(org.eclipse.core.resources.IProject) GefAgeDiagram(org.osate.ge.gef.ui.diagram.GefAgeDiagram) DefaultQueryService(org.osate.ge.services.impl.DefaultQueryService) QueryService(org.osate.ge.services.QueryService) DefaultBusinessObjectTreeUpdater(org.osate.ge.internal.diagram.runtime.updating.DefaultBusinessObjectTreeUpdater) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) Collection(java.util.Collection)

Example 3 with GefAgeDiagram

use of org.osate.ge.gef.ui.diagram.GefAgeDiagram in project osate2 by osate.

the class GefDiagramExportService method export.

@Override
public BufferedImage export(final GraphicalEditor editor, final DiagramNode exportNode, final double scaling) {
    Objects.requireNonNull(exportNode, "exportNode must not be null");
    final GefAgeDiagram diagram = checkEditor(editor).getGefDiagram();
    return exportToRasterImage(diagram, exportNode, diagram.getSceneNode().getSceneToLocalTransform(), scaling);
}
Also used : GefAgeDiagram(org.osate.ge.gef.ui.diagram.GefAgeDiagram)

Example 4 with GefAgeDiagram

use of org.osate.ge.gef.ui.diagram.GefAgeDiagram in project osate2 by osate.

the class GefDiagramExportService method export.

@Override
public void export(final GraphicalEditor editor, final OutputStream outputStream, final String format, final DiagramNode exportNode, final double scaling) throws IOException {
    Objects.requireNonNull(exportNode, "exportNode must not be null");
    final GefAgeDiagram diagram = checkEditor(editor).getGefDiagram();
    export(diagram, exportNode, diagram.getSceneNode().getSceneToLocalTransform(), scaling, outputStream, format);
}
Also used : GefAgeDiagram(org.osate.ge.gef.ui.diagram.GefAgeDiagram)

Example 5 with GefAgeDiagram

use of org.osate.ge.gef.ui.diagram.GefAgeDiagram in project osate2 by osate.

the class GefDiagramExportService method getDimensions.

@Override
public Dimension getDimensions(final GraphicalEditor editor, final DiagramNode exportNode) {
    Objects.requireNonNull(exportNode, "exportNode must not be null");
    final GefAgeDiagram diagram = checkEditor(editor).getGefDiagram();
    final Bounds bounds = getBounds(getExportNodes(diagram, exportNode), diagram.getSceneNode().getSceneToLocalTransform());
    return new Dimension(bounds.getWidth(), bounds.getHeight());
}
Also used : GefAgeDiagram(org.osate.ge.gef.ui.diagram.GefAgeDiagram) Bounds(javafx.geometry.Bounds) Dimension(org.osate.ge.graphics.Dimension)

Aggregations

GefAgeDiagram (org.osate.ge.gef.ui.diagram.GefAgeDiagram)5 Collection (java.util.Collection)2 Bounds (javafx.geometry.Bounds)2 Scene (javafx.scene.Scene)2 IProject (org.eclipse.core.resources.IProject)2 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)2 URI (org.eclipse.emf.common.util.URI)2 AgeDiagram (org.osate.ge.internal.diagram.runtime.AgeDiagram)2 BusinessObjectNodeFactory (org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNodeFactory)2 DefaultBusinessObjectTreeUpdater (org.osate.ge.internal.diagram.runtime.updating.DefaultBusinessObjectTreeUpdater)2 DefaultDiagramElementGraphicalConfigurationProvider (org.osate.ge.internal.diagram.runtime.updating.DefaultDiagramElementGraphicalConfigurationProvider)2 DiagramUpdater (org.osate.ge.internal.diagram.runtime.updating.DiagramUpdater)2 ActionService (org.osate.ge.internal.services.ActionService)2 ExtensionRegistryService (org.osate.ge.internal.services.ExtensionRegistryService)2 ProjectProvider (org.osate.ge.internal.services.ProjectProvider)2 ProjectReferenceService (org.osate.ge.internal.services.ProjectReferenceService)2 ReferenceService (org.osate.ge.internal.services.ReferenceService)2 DefaultColoringService (org.osate.ge.internal.services.impl.DefaultColoringService)2 ProjectReferenceServiceProxy (org.osate.ge.internal.services.impl.ProjectReferenceServiceProxy)2 QueryService (org.osate.ge.services.QueryService)2