Search in sources :

Example 6 with CanonicalBusinessObjectReference

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

the class FilterByBusinessObjectCanonicalReferenceQuery method run.

@Override
void run(final Deque<DefaultQuery<T>> remainingQueries, final BusinessObjectContext ctx, final QueryExecutionState<T> state, final QueryResults result) {
    // Look in the cache for the reference and build a new reference string if it is not found
    final CanonicalBusinessObjectReference boRef = (CanonicalBusinessObjectReference) state.cache.computeIfAbsent(this, t -> {
        final Object bo = boSupplier.apply(state.arg);
        CanonicalBusinessObjectReference newValue = bo == null ? nullBoRef : state.refBuilder.getCanonicalReference(bo);
        if (newValue == null) {
            newValue = nullBoRef;
        }
        return newValue;
    });
    if (boRef == nullBoRef) {
        return;
    }
    // Compare references
    final CanonicalBusinessObjectReference ctxCanonicalReference = state.refBuilder.getCanonicalReference(ctx.getBusinessObject());
    if (ctxCanonicalReference != null && ctxCanonicalReference.equals(boRef)) {
        processResultValue(remainingQueries, ctx, state, result);
    }
}
Also used : Objects(java.util.Objects) BusinessObjectContext(org.osate.ge.BusinessObjectContext) Deque(java.util.Deque) Function(java.util.function.Function) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference)

Example 7 with CanonicalBusinessObjectReference

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

the class AgeDiagramUtil method getConfigurationContextBusinessObject.

/**
 * Resolves and returns the diagram's context
 * Diagram configurations have an optional business object which provides a context for the diagram.
 * This function returns the context business object referenced by the diagram's configuration.
 * @param diagram the diagram for which to retrieve the context
 * @param referenceService the service to use to resolve the context reference
 * @return the diagram's context. Will return null if the object cannot be found or if the configuration does not reference a business object.
 */
public static Object getConfigurationContextBusinessObject(final AgeDiagram diagram, final ProjectReferenceService referenceService) {
    final CanonicalBusinessObjectReference contextBoReference = diagram.getConfiguration().getContextBoReference();
    final Object diagramBo;
    if (contextBoReference == null) {
        diagramBo = null;
    } else {
        diagramBo = referenceService.resolve(contextBoReference);
    }
    return diagramBo;
}
Also used : CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference)

Example 8 with CanonicalBusinessObjectReference

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

the class AgeEditor method selectDiagramElementsForBusinessObject.

@Override
public void selectDiagramElementsForBusinessObject(final Object bo) {
    final CanonicalBusinessObjectReference searchRef = referenceService.getCanonicalReference(bo);
    final List<DiagramElement> elementsForBo = diagram.getAllDiagramNodes().filter(DiagramElement.class::isInstance).map(DiagramElement.class::cast).filter(de -> Objects.equals(searchRef, referenceService.getCanonicalReference(de.getBusinessObject()))).collect(Collectors.toList());
    selectDiagramNodes(elementsForBo);
}
Also used : DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) 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) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference)

Example 9 with CanonicalBusinessObjectReference

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

the class ErrorPropagationHandler method getCanonicalReference.

@Override
public CanonicalBusinessObjectReference getCanonicalReference(final ReferenceContext ctx) {
    final ErrorPropagation bo = ctx.getBusinessObject(ErrorPropagation.class).get();
    // Determine exact number of segments
    int numberOfSegments = 4;
    if (bo.getKind() == null) {
        for (FeatureorPPReference t = bo.getFeatureorPPRef(); t != null; t = t.getNext()) {
            numberOfSegments++;
        }
    } else {
        numberOfSegments++;
    }
    // Build segments
    final String[] segments = new String[numberOfSegments];
    int segmentIndex = 0;
    segments[segmentIndex++] = ErrorModelReferenceUtil.TYPE_PROPAGATION;
    segments[segmentIndex++] = ctx.getReferenceBuilder().getCanonicalReference(bo.getContainingClassifier()).encode();
    if (bo.getKind() == null) {
        for (FeatureorPPReference t = bo.getFeatureorPPRef(); t != null; t = t.getNext()) {
            final String name = t.getFeatureorPP() == null ? null : t.getFeatureorPP().getName();
            segments[segmentIndex++] = Strings.isNullOrEmpty(name) ? "?" : name;
        }
    } else {
        segments[segmentIndex++] = bo.getKind();
    }
    segments[segmentIndex++] = Boolean.toString(bo.isNot());
    segments[segmentIndex] = bo.getDirection() == null ? "<null>" : bo.getDirection().getLiteral();
    // Create reference
    return new CanonicalBusinessObjectReference(segments);
}
Also used : CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Example 10 with CanonicalBusinessObjectReference

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

the class DefaultDiagramService method getRuntimeReferencesFromChildren.

/**
 * Gets references from open editors.
 */
private void getRuntimeReferencesFromChildren(final InternalDiagramEditor editor, final DiagramNode node, final Collection<CanonicalBusinessObjectReference> originalCanonicalReferences, final InternalReferencesToUpdate references) {
    for (final DiagramElement child : node.getChildren()) {
        final Object currentBo = child.getBusinessObject();
        final CanonicalBusinessObjectReference currentCanonicalRef = currentBo == null ? null : referenceService.getCanonicalReference(currentBo);
        if (currentCanonicalRef != null && originalCanonicalReferences.contains(currentCanonicalRef)) {
            references.addReference(editor, currentCanonicalRef, new OpenDiagramElementReference(child));
        }
        getRuntimeReferencesFromChildren(editor, child, originalCanonicalReferences, references);
    }
}
Also used : DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference)

Aggregations

CanonicalBusinessObjectReference (org.osate.ge.CanonicalBusinessObjectReference)21 RelativeBusinessObjectReference (org.osate.ge.RelativeBusinessObjectReference)6 HashMap (java.util.HashMap)5 IProject (org.eclipse.core.resources.IProject)4 URI (org.eclipse.emf.common.util.URI)4 AgeDiagram (org.osate.ge.internal.diagram.runtime.AgeDiagram)4 DiagramConfigurationBuilder (org.osate.ge.internal.diagram.runtime.DiagramConfigurationBuilder)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 Objects (java.util.Objects)3 IResource (org.eclipse.core.resources.IResource)3 CoreException (org.eclipse.core.runtime.CoreException)3 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 EObject (org.eclipse.emf.ecore.EObject)3 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 BusinessObjectContext (org.osate.ge.BusinessObjectContext)3 AgeDiagramProvider (org.osate.ge.internal.AgeDiagramProvider)3 DiagramElement (org.osate.ge.internal.diagram.runtime.DiagramElement)3 InternalDiagramEditor (org.osate.ge.internal.ui.editor.InternalDiagramEditor)3 Collections (java.util.Collections)2