Search in sources :

Example 11 with QueryService

use of org.osate.ge.services.QueryService in project osate2 by osate.

the class ModeTransitionHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext boc = ctx.getBusinessObjectContext();
    final QueryService queryService = ctx.getQueryService();
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(AadlGraphics.getModeTransitionGraphic()).source(getSource(boc, queryService)).destination(getDestination(boc, queryService)).style(StyleBuilder.create(AadlInheritanceUtil.isInherited(boc) ? Styles.INHERITED_ELEMENT : Style.EMPTY).build()).build());
}
Also used : QueryService(org.osate.ge.services.QueryService) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 12 with QueryService

use of org.osate.ge.services.QueryService in project osate2 by osate.

the class ModeTransitionInstanceHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext boc = ctx.getBusinessObjectContext();
    final QueryService queryService = ctx.getQueryService();
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(AadlGraphics.getModeTransitionGraphic()).source(getSource(boc, queryService)).destination(getDestination(boc, queryService)).style(StyleBuilder.create(AadlInheritanceUtil.isInherited(boc) ? Styles.INHERITED_ELEMENT : Style.EMPTY).build()).build());
}
Also used : QueryService(org.osate.ge.services.QueryService) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 13 with QueryService

use of org.osate.ge.services.QueryService in project osate2 by osate.

the class ModeTransitionTriggerHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext boc = ctx.getBusinessObjectContext();
    final QueryService queryService = ctx.getQueryService();
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(GRAPHIC).style(STYLE).source(getSource(boc)).destination(getDestination(boc, queryService)).build());
}
Also used : QueryService(org.osate.ge.services.QueryService) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 14 with QueryService

use of org.osate.ge.services.QueryService in project osate2 by osate.

the class ConnectionReferenceHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext boc = ctx.getBusinessObjectContext();
    final QueryService queryService = ctx.getQueryService();
    final ConnectionReference bo = boc.getBusinessObject(ConnectionReference.class).orElseThrow();
    final QueryResult srcResult = queryService.getFirstResult(SRC_QUERY, boc, bo).orElse(null);
    final QueryResult dstResult = queryService.getFirstResult(DST_QUERY, boc, bo).orElse(null);
    final boolean partial = (srcResult != null && srcResult.isPartial()) || (dstResult != null && dstResult.isPartial());
    final BusinessObjectContext src = srcResult == null ? null : srcResult.getBusinessObjectContext();
    final BusinessObjectContext dst = dstResult == null ? null : dstResult.getBusinessObjectContext();
    if (src == dst) {
        return Optional.empty();
    }
    // Don't display connection references when one endpoint is an ancestor of the other. This can happen for a subset of partial connections.
    if (src != null && dst != null) {
        for (BusinessObjectContext srcAncestor = src.getParent(); srcAncestor != null; srcAncestor = srcAncestor.getParent()) {
            if (srcAncestor == dst) {
                return Optional.empty();
            }
        }
        for (BusinessObjectContext dstAncestor = dst.getParent(); dstAncestor != null; dstAncestor = dstAncestor.getParent()) {
            if (dstAncestor == src) {
                return Optional.empty();
            }
        }
    }
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(GRAPHIC).style(partial ? PARTIAL_STYLE : STYLE).source(src).destination(dst).build());
}
Also used : QueryResult(org.osate.ge.query.QueryResult) QueryService(org.osate.ge.services.QueryService) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 15 with QueryService

use of org.osate.ge.services.QueryService in project osate2 by osate.

the class FlowSpecificationHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext boc = ctx.getBusinessObjectContext();
    final FlowSpecification fs = boc.getBusinessObject(FlowSpecification.class).orElseThrow();
    final QueryService queryService = ctx.getQueryService();
    final QueryResult srcResult = queryService.getFirstResult(SRC_QUERY, boc, fs).orElse(null);
    final BusinessObjectContext src = srcResult == null ? null : srcResult.getBusinessObjectContext();
    boolean partial = (srcResult != null && srcResult.isPartial());
    BusinessObjectContext dst = null;
    if (fs.getKind() == FlowKind.PATH) {
        final QueryResult dstResult = queryService.getFirstResult(DST_QUERY, boc, fs).orElse(null);
        dst = dstResult == null ? null : dstResult.getBusinessObjectContext();
        partial |= (dstResult != null && dstResult.isPartial());
    }
    final StyleBuilder sb = StyleBuilder.create(AadlInheritanceUtil.isInherited(boc) ? Styles.INHERITED_ELEMENT : Style.EMPTY);
    if (fs.getKind() == FlowKind.PATH) {
        sb.lineWidth(4.0);
    }
    if (partial) {
        sb.dotted();
    }
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(AadlGraphics.getFlowSpecificationGraphic(fs)).style(sb.build()).source(src).destination(dst).build());
}
Also used : QueryResult(org.osate.ge.query.QueryResult) FlowSpecification(org.osate.aadl2.FlowSpecification) QueryService(org.osate.ge.services.QueryService) StyleBuilder(org.osate.ge.graphics.StyleBuilder) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Aggregations

QueryService (org.osate.ge.services.QueryService)18 BusinessObjectContext (org.osate.ge.BusinessObjectContext)16 Collectors (java.util.stream.Collectors)4 Subcomponent (org.osate.aadl2.Subcomponent)4 QueryResult (org.osate.ge.query.QueryResult)4 List (java.util.List)3 Optional (java.util.Optional)3 ExecutableQuery (org.osate.ge.query.ExecutableQuery)3 Objects (com.google.common.base.Objects)2 Collections (java.util.Collections)2 Stream (java.util.stream.Stream)2 ComboViewer (org.eclipse.jface.viewers.ComboViewer)2 LabelProvider (org.eclipse.jface.viewers.LabelProvider)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 Composite (org.eclipse.swt.widgets.Composite)2 Control (org.eclipse.swt.widgets.Control)2 IEditorPart (org.eclipse.ui.IEditorPart)2 ComponentClassifier (org.osate.aadl2.ComponentClassifier)2 ComponentImplementation (org.osate.aadl2.ComponentImplementation)2 Element (org.osate.aadl2.Element)2