Search in sources :

Example 1 with CategoryHeader

use of jkind.api.ui.counterexample.CategoryHeader in project AGREE by loonwerks.

the class AgreeCounterexampleContentProvider method getElements.

@Override
public Object[] getElements(Object inputElement) {
    Counterexample cex = (Counterexample) inputElement;
    List<Object> result = new ArrayList<>();
    boolean first = true;
    for (String category : layout.getCategories()) {
        List<Signal<Value>> signals = cex.getCategorySignals(layout, category);
        if (!signals.isEmpty()) {
            if (first) {
                first = false;
            } else {
                result.add(new Spacer());
            }
            result.add(new CategoryHeader(category));
            List<Signal<Value>> inputSignals = signals.stream().filter(it -> {
                EObject ref = refMap.get(it.getName());
                return (ref instanceof org.osate.aadl2.Port) && ((org.osate.aadl2.Port) ref).isIn();
            }).collect(Collectors.toList());
            List<Signal<Value>> outputSignals = signals.stream().filter(it -> {
                EObject ref = refMap.get(it.getName());
                return (ref instanceof org.osate.aadl2.Port) && ((org.osate.aadl2.Port) ref).isOut();
            }).collect(Collectors.toList());
            List<Signal<Value>> otherSignals = signals.stream().filter(it -> !(inputSignals.contains(it) || outputSignals.contains(it))).collect(Collectors.toList());
            result.addAll(SignalGrouper.group(null, Stream.of(inputSignals, otherSignals, outputSignals).flatMap(Collection::stream).collect(Collectors.toList())));
        }
    }
    return result.toArray();
}
Also used : SignalGrouper(jkind.api.ui.counterexample.SignalGrouper) Collection(java.util.Collection) EObject(org.eclipse.emf.ecore.EObject) CounterexampleContentProvider(jkind.api.ui.counterexample.CounterexampleContentProvider) Signal(jkind.results.Signal) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Value(jkind.lustre.values.Value) Layout(jkind.results.layout.Layout) List(java.util.List) Stream(java.util.stream.Stream) CategoryHeader(jkind.api.ui.counterexample.CategoryHeader) Map(java.util.Map) Counterexample(jkind.results.Counterexample) Spacer(jkind.api.ui.counterexample.Spacer) ArrayList(java.util.ArrayList) Counterexample(jkind.results.Counterexample) Signal(jkind.results.Signal) Spacer(jkind.api.ui.counterexample.Spacer) EObject(org.eclipse.emf.ecore.EObject) EObject(org.eclipse.emf.ecore.EObject) CategoryHeader(jkind.api.ui.counterexample.CategoryHeader)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 CategoryHeader (jkind.api.ui.counterexample.CategoryHeader)1 CounterexampleContentProvider (jkind.api.ui.counterexample.CounterexampleContentProvider)1 SignalGrouper (jkind.api.ui.counterexample.SignalGrouper)1 Spacer (jkind.api.ui.counterexample.Spacer)1 Value (jkind.lustre.values.Value)1 Counterexample (jkind.results.Counterexample)1 Signal (jkind.results.Signal)1 Layout (jkind.results.layout.Layout)1 EObject (org.eclipse.emf.ecore.EObject)1