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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations