Search in sources :

Example 21 with DiagramNode

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

the class GefAgeDiagram method ensureSceneNodesExistForChildren.

/**
 * Ensures the scene node exists for the children of a diagram node.
 * Creates or recreates scene graph nodes and adds to the scene graph as necessary. Populates {@link #diagramElementToGefDiagramElementMap}.
 * @param parentDiagramNode the diagram node for which scene nodes will be created for its children.
 * @param parentDiagramNodeSceneNode the scene node for the parent diagram node
 * @return the created or updated JavaFX node
 */
private void ensureSceneNodesExistForChildren(final DiagramNode parentDiagramNode, final Node parentDiagramNodeSceneNode) {
    for (final DiagramElement childDiagramElement : parentDiagramNode.getChildren()) {
        final GefDiagramElement childGefDiagramElement = diagramElementToGefDiagramElementMap.computeIfAbsent(childDiagramElement, e -> new GefDiagramElement(childDiagramElement));
        final Node childSceneNode = ensureSceneNodeExists(childGefDiagramElement, parentDiagramNodeSceneNode);
        ensureSceneNodesExistForChildren(childDiagramElement, childSceneNode);
    }
}
Also used : DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) BaseConnectionNode(org.osate.ge.gef.BaseConnectionNode) DiagramRootNode(org.osate.ge.gef.DiagramRootNode) DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) FeatureGroupNode(org.osate.ge.gef.FeatureGroupNode) LabelNode(org.osate.ge.gef.LabelNode) Node(javafx.scene.Node) ConnectionNode(org.osate.ge.gef.ConnectionNode) FlowIndicatorNode(org.osate.ge.gef.FlowIndicatorNode)

Example 22 with DiagramNode

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

the class DiagramUpdater method updateStructure.

/**
 * Updates the structure of the diagram based on the business object tree.
 * Creates/Unghosts elements to match the business object tree. Ghosts diagram elements which are not in the diagram element tree.
 * @param m
 * @param container
 * @param bos
 */
private void updateStructure(final DiagramModification m, final DiagramNode container, final Collection<BusinessObjectNode> bos) {
    for (final BusinessObjectNode n : bos) {
        // Get existing element if it exists.
        DiagramElement element = container.getChildByRelativeReference(n.getRelativeReference());
        // Create the element if it does not exist
        if (element == null) {
            final DiagramElement removedGhost = removeGhost(container, n.getRelativeReference());
            if (removedGhost == null) {
                final BusinessObjectHandler boh = infoProvider.getApplicableBusinessObjectHandler(n.getBusinessObject());
                if (boh == null) {
                    // Ignore the object
                    continue;
                }
                element = new DiagramElement(container, n.getBusinessObject(), boh, n.getRelativeReference(), n.getId());
            } else {
                element = removedGhost;
                m.updateBusinessObject(element, n.getBusinessObject(), n.getRelativeReference());
            }
            m.addElement(element);
        } else {
            // Update the business object and relative reference. Although the reference matches. The business object may be new and the
            // relative reference may have case differences.
            m.updateBusinessObject(element, n.getBusinessObject(), n.getRelativeReference());
        }
        // Set the business object handler if it is null
        if (element.getBusinessObjectHandler() == null) {
            final BusinessObjectHandler boh = infoProvider.getApplicableBusinessObjectHandler(n.getBusinessObject());
            if (boh == null) {
                ghostAndRemove(m, element);
                continue;
            } else {
                m.setBusinessObjectHandler(element, boh);
            }
        }
        // Update the element's children
        updateStructure(m, element, n.getChildren());
    }
    // If the collections are the same size, there is nothing to remove
    if (bos.size() != container.getChildren().size()) {
        // Build Set of Relative References of All the Objects in the Business Object Tree
        final Set<RelativeBusinessObjectReference> boTreeRelativeReferenceSet = bos.stream().map((n) -> n.getRelativeReference()).collect(Collectors.toCollection(HashSet::new));
        Iterator<DiagramElement> childrenIt = container.getChildren().iterator();
        while (childrenIt.hasNext()) {
            final DiagramElement child = childrenIt.next();
            if (!boTreeRelativeReferenceSet.contains(child.getRelativeReference())) {
                ghostAndRemove(m, child);
            }
        }
    }
}
Also used : DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler) DiagramConfigurationBuilder(org.osate.ge.internal.diagram.runtime.DiagramConfigurationBuilder) DiagramModification(org.osate.ge.internal.diagram.runtime.DiagramModification) HashMap(java.util.HashMap) EmbeddedBusinessObject(org.osate.ge.internal.model.EmbeddedBusinessObject) GraphicalConfiguration(org.osate.ge.GraphicalConfiguration) HashSet(java.util.HashSet) DockArea(org.osate.ge.internal.diagram.runtime.DockArea) Map(java.util.Map) ReferenceResolutionService(org.osate.ge.services.ReferenceResolutionService) LinkedList(java.util.LinkedList) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) DiagramElementPredicates(org.osate.ge.internal.diagram.runtime.DiagramElementPredicates) ActionExecutor(org.osate.ge.internal.services.ActionExecutor) Iterator(java.util.Iterator) ReferenceBuilderService(org.osate.ge.services.ReferenceBuilderService) Collection(java.util.Collection) Set(java.util.Set) Point(org.osate.ge.graphics.Point) Collectors(java.util.stream.Collectors) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference) DockingPosition(org.osate.ge.DockingPosition) Objects(java.util.Objects) PropertyValueGroup(org.osate.ge.aadl2.internal.model.PropertyValueGroup) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) List(java.util.List) AgeAction(org.osate.ge.internal.services.AgeAction) AgeConnection(org.osate.ge.graphics.internal.AgeConnection) Collections(java.util.Collections) DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler)

Example 23 with DiagramNode

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

the class PasteAction method isEnabled.

@Override
public boolean isEnabled() {
    // Return value if this is called before constructor is finished
    if (clipboard == null) {
        return false;
    }
    final DiagramNode dstDiagramNode = getDestinationDiagramNode();
    if (dstDiagramNode == null) {
        return false;
    }
    final Collection<CopiedDiagramElement> copiedDiagramElements = getCopiedDiagramElements();
    if (copiedDiagramElements.isEmpty()) {
        return false;
    }
    final boolean anyEmbeddedBoCopied = copiedDiagramElements.stream().anyMatch(de -> de.getCopiedBusinessObject() instanceof EmbeddedBusinessObject);
    final boolean anyEObjectCopied = copiedDiagramElements.stream().anyMatch(de -> de.getCopiedBusinessObject() instanceof EObject);
    // Such objects are not supported because layout issues have been observed.
    return !(getBusinessObject(dstDiagramNode) instanceof EmbeddedBusinessObject) && (!anyEmbeddedBoCopied || DiagramNodePredicates.isDiagramOrUndockedShape(dstDiagramNode)) && (!anyEObjectCopied || getDestinationEObject(dstDiagramNode) != null);
}
Also used : DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) EObject(org.eclipse.emf.ecore.EObject) EmbeddedBusinessObject(org.osate.ge.internal.model.EmbeddedBusinessObject)

Example 24 with DiagramNode

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

the class PasteAction method copyClipboardContents.

/**
 * Copies the clipboard contents to the destination business object and diagram element.
 * @return the diagram elements which were created. Does not include children of created diagram elements.
 */
private Collection<DiagramElement> copyClipboardContents(final EObject dstBoToModify, final DiagramNode dstDiagramNode, final DiagramModification m, final ReferenceBuilderService refBuilder) {
    // Determine the minimum coordinates from the elements whose positions will be copied
    // The minimum coordinates is null if none of the copied diagram elements have an absolute position. This is reasonable because the minimum coordinates
    // are only needed if a copied diagram element has an absolute position.
    final Point minCoordinates = getCopiedDiagramElements().stream().map(CopiedDiagramElement::getAbsolutePosition).filter(Predicates.notNull()).reduce((a, b) -> new Point(Math.min(a.x, b.x), Math.min(a.y, b.y))).orElse(null);
    // This list will contain the diagram elements that are created by the copying process. Does not contain their children.
    final List<DiagramElement> newDiagramElements = new ArrayList<>();
    // Copy each copied diagram element into the diagram and model.
    for (final CopiedDiagramElement copiedDiagramElement : getCopiedDiagramElements()) {
        final DiagramElement newDiagramElement;
        if (copiedDiagramElement.getCopiedBusinessObject() == null) {
            newDiagramElement = CopyAndPasteUtil.copyDiagramElement(copiedDiagramElement.getDiagramElement(), dstDiagramNode, copiedDiagramElement.getDiagramElement().getRelativeReference(), refBuilder);
        } else {
            final Object boFromCopiedDiagramElement = copiedDiagramElement.getCopiedBusinessObject();
            final RelativeBusinessObjectReference newRelativeRef;
            if (boFromCopiedDiagramElement instanceof EmbeddedBusinessObject) {
                // The relative reference will be assigned when copying the diagram element.
                newRelativeRef = null;
            } else if (boFromCopiedDiagramElement instanceof EObject) {
                // Get the list that to which the copied object will be added
                final EStructuralFeature compatibleFeature = getCompatibleStructuralFeature(copiedDiagramElement.getContainingFeature(), dstBoToModify.eClass());
                final Object containingFeatureValue = dstBoToModify.eGet(compatibleFeature);
                if (!(containingFeatureValue instanceof Collection)) {
                    throw new RuntimeException("Unexpected case. Value of containing feature was not a collection");
                }
                @SuppressWarnings("unchecked") final Collection<EObject> containingFeatureValueCollection = (Collection<EObject>) containingFeatureValue;
                final EObject copiedEObject = EcoreUtil.copy((EObject) boFromCopiedDiagramElement);
                containingFeatureValueCollection.add(copiedEObject);
                ensureBusinessObjectHasUniqueName(copiedEObject, copiedDiagramElement.getDiagramElement().getBusinessObjectHandler());
                ensurePackagesAreImported(copiedEObject);
                newRelativeRef = refBuilder.getRelativeReference(copiedEObject);
            } else {
                throw new RuntimeException("Unsupported case:  " + boFromCopiedDiagramElement);
            }
            newDiagramElement = CopyAndPasteUtil.copyDiagramElement(copiedDiagramElement.getDiagramElement(), dstDiagramNode, newRelativeRef, refBuilder);
        }
        // Set the position of the new diagram element. They are positioned relative to each other at a fixed offset within the new parent.
        final Point cp = copiedDiagramElement.getAbsolutePosition();
        final Point newPosition = cp == null ? null : new Point(cp.x - minCoordinates.x + 50, cp.y - minCoordinates.y + 50);
        DiagramElementLayoutUtil.moveElement(m, newDiagramElement, newPosition);
        // Remove existing element
        final DiagramElement existingDiagramElement = dstDiagramNode.getChildByRelativeReference(newDiagramElement.getRelativeReference());
        if (existingDiagramElement != null) {
            m.removeElement(existingDiagramElement);
        }
        // Add the new diagram element to the diagram.
        m.addElement(newDiagramElement);
        newDiagramElements.add(newDiagramElement);
    }
    return newDiagramElements;
}
Also used : Element(org.osate.aadl2.Element) BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler) RenameUtil(org.osate.ge.internal.ui.RenameUtil) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) DiagramElementLayoutUtil(org.osate.ge.internal.diagram.runtime.layout.DiagramElementLayoutUtil) EmbeddedBusinessObject(org.osate.ge.internal.model.EmbeddedBusinessObject) ClipboardService(org.osate.ge.internal.services.ClipboardService) ClassifierCreationHelper(org.osate.ge.aadl2.internal.util.classifiers.ClassifierCreationHelper) Classifier(org.osate.aadl2.Classifier) ComponentType(org.osate.aadl2.ComponentType) DiagramNodePredicates(org.osate.ge.internal.diagram.runtime.DiagramNodePredicates) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) Bundle(org.osgi.framework.Bundle) ReferenceBuilderService(org.osate.ge.services.ReferenceBuilderService) Collection(java.util.Collection) PackageSection(org.osate.aadl2.PackageSection) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) AadlImportsUtil(org.osate.ge.aadl2.AadlImportsUtil) Point(org.osate.ge.graphics.Point) DiagramElementUtil(org.osate.ge.internal.util.DiagramElementUtil) Objects(java.util.Objects) List(java.util.List) AadlModificationService(org.osate.ge.internal.services.AadlModificationService) DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) EclipseContextFactory(org.eclipse.e4.core.contexts.EclipseContextFactory) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) Feature(org.osate.aadl2.Feature) ComponentImplementation(org.osate.aadl2.ComponentImplementation) DiagramModification(org.osate.ge.internal.diagram.runtime.DiagramModification) ArrayList(java.util.ArrayList) InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) EClass(org.eclipse.emf.ecore.EClass) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) Predicates(com.google.common.base.Predicates) GetNameContext(org.osate.ge.businessobjecthandling.GetNameContext) SimpleModifier(org.osate.ge.internal.services.AadlModificationService.SimpleModifier) Subcomponent(org.osate.aadl2.Subcomponent) XtextResource(org.eclipse.xtext.resource.XtextResource) AadlNameUtil(org.osate.ge.aadl2.internal.util.AadlNameUtil) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) Action(org.eclipse.jface.action.Action) CanRenameContext(org.osate.ge.businessobjecthandling.CanRenameContext) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) AgeHandlerUtil(org.osate.ge.internal.ui.handlers.AgeHandlerUtil) ComponentTypeRename(org.osate.aadl2.ComponentTypeRename) ActionFactory(org.eclipse.ui.actions.ActionFactory) NamedElement(org.osate.aadl2.NamedElement) Collections(java.util.Collections) FrameworkUtil(org.osgi.framework.FrameworkUtil) ArrayList(java.util.ArrayList) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) EmbeddedBusinessObject(org.osate.ge.internal.model.EmbeddedBusinessObject) Point(org.osate.ge.graphics.Point) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) EObject(org.eclipse.emf.ecore.EObject) Collection(java.util.Collection) EmbeddedBusinessObject(org.osate.ge.internal.model.EmbeddedBusinessObject) EObject(org.eclipse.emf.ecore.EObject)

Example 25 with DiagramNode

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

the class AgeContentOutlinePage method createControl.

@Override
public void createControl(final Composite parent) {
    super.createControl(parent);
    final TreeViewer viewer = getTreeViewer();
    ContextHelpUtil.setHelp(viewer.getControl(), ContextHelpUtil.OUTLINE_VIEW);
    // A comparator is set to allow comparing tree elements of different types in a way where they will be equal if the relative reference is equal.
    // This is needed so that tree node will be preserved when elements are hidden and shown and the underlying object type changes.
    // If link with editor is enabled, selection may not be retained.
    viewer.setComparer(new IElementComparer() {

        @Override
        public int hashCode(final Object element) {
            if (element == null) {
                return 0;
            }
            return Objects.hashCode(getRelativeReferenceForElement(element)) + hashCode(getElementParent(element));
        }

        @Override
        public boolean equals(final Object element1, final Object element2) {
            final Object ref1 = getRelativeReferenceForElement(element1);
            final Object ref2 = getRelativeReferenceForElement(element2);
            final boolean referencesAreEqual = Objects.equals(ref1, ref2);
            if (!referencesAreEqual) {
                return false;
            }
            if (element1 == null || element2 == null) {
                return element1 == element2;
            }
            return equals(getElementParent(element1), getElementParent(element2));
        }
    });
    viewer.setContentProvider(new ITreeContentProvider() {

        @Override
        public void dispose() {
        }

        @Override
        public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
        }

        @Override
        public Object[] getElements(final Object inputElement) {
            if (inputElement instanceof InternalDiagramEditor) {
                final InternalDiagramEditor editor = (InternalDiagramEditor) inputElement;
                return getChildren(editor.getDiagram());
            }
            return new BusinessObjectContext[0];
        }

        @Override
        public Object[] getChildren(final Object parentElement) {
            if (parentElement instanceof BusinessObjectContext) {
                final BusinessObjectContext parent = ((BusinessObjectContext) parentElement);
                final List<BusinessObjectContext> children = new ArrayList<>();
                // DiagramNodes represent elements which are part of the diagram
                if (parent instanceof DiagramNode) {
                    final DiagramNode parentNode = (DiagramNode) parent;
                    // Add child diagram nodes
                    parentNode.getChildren().stream().filter((de) -> !Strings.isNullOrEmpty(de.getUserInterfaceName()) || de.getBusinessObject() instanceof EObject).forEach(children::add);
                    // Add children which are hidden based on user preference
                    if (showHiddenElementsAction.isChecked()) {
                        // If the diagram is a contextless diagram, create a business object context which uses the current project as the business object
                        final BusinessObjectContext parentForRetrieval;
                        if (parentElement instanceof AgeDiagram && ((AgeDiagram) parentElement).getConfiguration().getContextBoReference() == null) {
                            parentForRetrieval = new BusinessObjectContext() {

                                @Override
                                public Collection<? extends BusinessObjectContext> getChildren() {
                                    return parentNode.getChildren();
                                }

                                @Override
                                public BusinessObjectContext getParent() {
                                    return parent.getParent();
                                }

                                @Override
                                public Object getBusinessObject() {
                                    return projectProvider.getProject();
                                }
                            };
                        } else {
                            parentForRetrieval = parent;
                        }
                        // Add children based on the objects returns by the business object provider for business objects which are not currently in the
                        // diagram.
                        getChildContextsFromProvider(parent, parentForRetrieval, childRef -> {
                            return !children.stream().map(AgeContentOutlinePage.this::getRelativeReferenceForElement).anyMatch(childRef::equals);
                        }).filter(this::includeHiddenBusinessObjectContext).forEachOrdered(children::add);
                    }
                } else if (parent instanceof BusinessObjectContext) {
                    // Add children which are hidden based on user preference
                    if (showHiddenElementsAction.isChecked()) {
                        getChildContextsFromProvider(parent, parent, childRef -> true).filter(this::includeHiddenBusinessObjectContext).forEachOrdered(children::add);
                    }
                }
                return children.toArray();
            }
            return new BusinessObjectContext[0];
        }

        /**
         * Filter returns whether a hidden business object context should be shown. This is implemented to be consistent with
         * handling for diagram elements.
         */
        private boolean includeHiddenBusinessObjectContext(final BusinessObjectContext boc) {
            final Object bo = boc.getBusinessObject();
            if (bo instanceof EObject) {
                return true;
            }
            final BusinessObjectHandler boh = extRegistry.getApplicableBusinessObjectHandler(bo);
            return boh != null && !Strings.isNullOrEmpty(boh.getName(new GetNameContext(bo)));
        }

        /**
         * Creates a stream of business object contexts representing the children returned by the business object provider.
         * Such contexts do not have a valid isChildren() method.
         * @param parent is the context to use as the parent of returned contexts. This should be the DiagramNode if one exists.
         * @param parentForRetrieval is the context to use when requesting children from the business object provider
         * @param filterPredicate is a filter that can be used to filter results by the relative reference before the context is created
         * @return A stream of child business object contexts
         */
        private Stream<BusinessObjectContext> getChildContextsFromProvider(final BusinessObjectContext parent, final BusinessObjectContext parentForRetrieval, final Predicate<RelativeBusinessObjectReference> filterPredicate) {
            return bopHelper.getChildBusinessObjects(parentForRetrieval).stream().map(childBo -> {
                if (childBo instanceof BusinessObjectProxy) {
                    return ((BusinessObjectProxy) childBo).resolve(referenceService);
                } else {
                    return childBo;
                }
            }).filter(Objects::nonNull).filter(childBo -> {
                final RelativeBusinessObjectReference childRef = referenceService.getRelativeReference(childBo);
                return childRef != null && filterPredicate.test(childRef);
            }).map(childBo -> new BusinessObjectContext() {

                @Override
                public Collection<? extends BusinessObjectContext> getChildren() {
                    // Returns an empty list. Shouldn't be needed. All children are hidden and such children will be provided by the content provider.
                    return Collections.emptyList();
                }

                @Override
                public BusinessObjectContext getParent() {
                    return parent;
                }

                @Override
                public Object getBusinessObject() {
                    return childBo;
                }
            });
        }

        @Override
        public Object getParent(final Object element) {
            return getElementParent(element);
        }

        @Override
        public boolean hasChildren(final Object element) {
            if (element instanceof BusinessObjectContext) {
                return getChildren(element).length > 0;
            }
            return false;
        }
    });
    // Create a label provider that will be used by the tree's actual label provider which will be a StyledCellLabelProvider.
    // This label provider is also used by the custom comparator because the default one does not support text provided by the styled cell label provider.
    final LabelProvider innerLabelProvider = new LabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof BusinessObjectContext) {
                final BusinessObjectContext boc = (BusinessObjectContext) element;
                return UiUtil.getDescription(boc, extRegistry);
            }
            return super.getText(element);
        }

        @Override
        public Image getImage(final Object element) {
            if (element instanceof DiagramElement) {
                final DiagramElement de = (DiagramElement) element;
                return UiUtil.getImage(de.getBusinessObjectHandler(), de.getBusinessObject()).orElse(null);
            } else if (element instanceof BusinessObjectContext) {
                final BusinessObjectContext boc = (BusinessObjectContext) element;
                final Object bo = boc.getBusinessObject();
                return UiUtil.getImage(extRegistry, bo).orElse(null);
            }
            return null;
        }
    };
    viewer.setLabelProvider(new StyledCellLabelProvider(StyledCellLabelProvider.COLORS_ON_SELECTION) {

        @Override
        public void update(final ViewerCell cell) {
            final Object element = cell.getElement();
            cell.setText(innerLabelProvider.getText(element));
            cell.setForeground(element instanceof DiagramNode ? null : Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
            cell.setImage(innerLabelProvider.getImage(element));
        }
    });
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(final Viewer viewer, final Object e1, final Object e2) {
            final String t1 = innerLabelProvider.getText(e1);
            final String t2 = innerLabelProvider.getText(e2);
            return getComparator().compare(t1, t2);
        }
    });
    viewer.addDoubleClickListener(event -> UiUtil.openPropertiesView());
    final MenuManager menuMgr = new MenuManager();
    menuMgr.setRemoveAllWhenShown(true);
    final Tree tree = viewer.getTree();
    final Menu menu = menuMgr.createContextMenu(tree);
    tree.setMenu(menu);
    // Allow contributions
    getSite().registerContextMenu("org.osate.ge.editor.AgeDiagramEditor", menuMgr, viewer);
    editor.addSelectionChangedListener(event -> updateOutlineSelectionIfLinked());
    editor.getDiagram().addModificationListener(diagramModificationListener);
    viewer.addSelectionChangedListener(this);
    viewer.setInput(editor);
}
Also used : BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler) ContentOutlinePage(org.eclipse.ui.views.contentoutline.ContentOutlinePage) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ModificationsCompletedEvent(org.osate.ge.internal.diagram.runtime.ModificationsCompletedEvent) TreePath(org.eclipse.jface.viewers.TreePath) BusinessObjectContext(org.osate.ge.BusinessObjectContext) ViewerCell(org.eclipse.jface.viewers.ViewerCell) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) DiagramModificationListener(org.osate.ge.internal.diagram.runtime.DiagramModificationListener) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ProjectProvider(org.osate.ge.internal.services.ProjectProvider) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) PlatformUI(org.eclipse.ui.PlatformUI) Predicate(java.util.function.Predicate) Collection(java.util.Collection) MenuManager(org.eclipse.jface.action.MenuManager) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Display(org.eclipse.swt.widgets.Display) ContextHelpUtil(org.osate.ge.internal.ui.util.ContextHelpUtil) BusinessObjectProxy(org.osate.ge.internal.model.BusinessObjectProxy) Objects(java.util.Objects) IElementComparer(org.eclipse.jface.viewers.IElementComparer) ISharedImages(org.eclipse.ui.ISharedImages) List(java.util.List) Stream(java.util.stream.Stream) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) UiUtil(org.osate.ge.internal.ui.util.UiUtil) Tree(org.eclipse.swt.widgets.Tree) IPageSite(org.eclipse.ui.part.IPageSite) SWT(org.eclipse.swt.SWT) TreeViewer(org.eclipse.jface.viewers.TreeViewer) BusinessObjectProviderHelper(org.osate.ge.internal.util.BusinessObjectProviderHelper) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ProjectReferenceService(org.osate.ge.internal.services.ProjectReferenceService) Image(org.eclipse.swt.graphics.Image) ExtensionRegistryService(org.osate.ge.internal.services.ExtensionRegistryService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Strings(com.google.common.base.Strings) TreeSelection(org.eclipse.jface.viewers.TreeSelection) GetNameContext(org.osate.ge.businessobjecthandling.GetNameContext) Activator(org.osate.ge.internal.Activator) IPreferenceChangeListener(org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener) Viewer(org.eclipse.jface.viewers.Viewer) Action(org.eclipse.jface.action.Action) IActionBars(org.eclipse.ui.IActionBars) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) StyledCellLabelProvider(org.eclipse.jface.viewers.StyledCellLabelProvider) IMenuManager(org.eclipse.jface.action.IMenuManager) ActionFactory(org.eclipse.ui.actions.ActionFactory) DiagramModificationAdapter(org.osate.ge.internal.diagram.runtime.DiagramModificationAdapter) Menu(org.eclipse.swt.widgets.Menu) Collections(java.util.Collections) LabelProvider(org.eclipse.jface.viewers.LabelProvider) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) DiagramNode(org.osate.ge.internal.diagram.runtime.DiagramNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IElementComparer(org.eclipse.jface.viewers.IElementComparer) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) BusinessObjectProxy(org.osate.ge.internal.model.BusinessObjectProxy) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) GetNameContext(org.osate.ge.businessobjecthandling.GetNameContext) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) EObject(org.eclipse.emf.ecore.EObject) Tree(org.eclipse.swt.widgets.Tree) List(java.util.List) ArrayList(java.util.ArrayList) Stream(java.util.stream.Stream) Menu(org.eclipse.swt.widgets.Menu) StyledCellLabelProvider(org.eclipse.jface.viewers.StyledCellLabelProvider) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler) ViewerCell(org.eclipse.jface.viewers.ViewerCell) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) EObject(org.eclipse.emf.ecore.EObject) BusinessObjectContext(org.osate.ge.BusinessObjectContext) StyledCellLabelProvider(org.eclipse.jface.viewers.StyledCellLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

DiagramNode (org.osate.ge.internal.diagram.runtime.DiagramNode)29 DiagramElement (org.osate.ge.internal.diagram.runtime.DiagramElement)18 List (java.util.List)13 Point (org.osate.ge.graphics.Point)13 AgeDiagram (org.osate.ge.internal.diagram.runtime.AgeDiagram)13 InternalDiagramEditor (org.osate.ge.internal.ui.editor.InternalDiagramEditor)13 Objects (java.util.Objects)12 IEditorPart (org.eclipse.ui.IEditorPart)11 Collection (java.util.Collection)10 Collections (java.util.Collections)10 BusinessObjectContext (org.osate.ge.BusinessObjectContext)9 LinkedList (java.util.LinkedList)8 Collectors (java.util.stream.Collectors)8 DiagramModification (org.osate.ge.internal.diagram.runtime.DiagramModification)8 Stream (java.util.stream.Stream)7 Node (javafx.scene.Node)7 IStatus (org.eclipse.core.runtime.IStatus)7 Status (org.eclipse.core.runtime.Status)7 DiagramNodePredicates (org.osate.ge.internal.diagram.runtime.DiagramNodePredicates)7 DiagramElementUtil (org.osate.ge.internal.util.DiagramElementUtil)7