use of org.osate.ge.aadl2.ui.internal.editor.FlowContributionItem.HighlightableFlowInfo in project osate2 by osate.
the class FlowContributionItem method onSelection.
@Override
protected void onSelection(final Object value) {
if (editor != null && !editor.isDisposed() && value != null) {
@SuppressWarnings("unchecked") final Map.Entry<String, HighlightableFlowInfo> highlightableFlowsMapEntry = (Entry<String, HighlightableFlowInfo>) value;
final FlowSegmentReference highlightableFlowElement = highlightableFlowsMapEntry.getValue().highlightableFlowElement;
NamedElement flowSegmentElement = null;
BusinessObjectContext container = null;
if (highlightableFlowElement != null) {
flowSegmentElement = highlightableFlowElement.flowSegmentElement;
container = highlightableFlowElement.container;
}
ContributionUtil.getColoringService(editor).setHighlightedFlow(flowSegmentElement, container);
}
}
use of org.osate.ge.aadl2.ui.internal.editor.FlowContributionItem.HighlightableFlowInfo in project osate2 by osate.
the class FlowContributionItem method refresh.
void refresh() {
final ComboViewer comboViewer = getComboViewer();
final Map<String, HighlightableFlowInfo> highlightableFlowElements = new TreeMap<>((o1, o2) -> o1.toLowerCase().compareTo(o2.toLowerCase()));
if (comboViewer != null) {
final Map.Entry<String, HighlightableFlowInfo> nullMapEntry = new AbstractMap.SimpleEntry<>(getNullValueString(), new HighlightableFlowInfo(null, FlowSegmentState.COMPLETE));
highlightableFlowElements.put(nullMapEntry.getKey(), nullMapEntry.getValue());
Map.Entry<String, HighlightableFlowInfo> selectedValue = nullMapEntry;
final String selectedFlowName = editor == null ? null : editor.getPartProperty(SELECTED_FLOW_PROPERTY_KEY);
// Clear the combo box
comboViewer.setInput(null);
if (editor == null) {
return;
}
final AgeDiagram diagram = editor.getDiagram();
if (diagram != null) {
final QueryService queryService = ContributionUtil.getQueryService(editor);
if (queryService != null) {
// Determine which flows have elements contained in the diagram and whether the flow is partial.
queryService.getResults(FLOW_CONTAINER_QUERY, diagram, null).stream().flatMap(flowContainerQueryable -> {
if (flowContainerQueryable.getBusinessObject() instanceof ComponentInstance) {
return AadlInstanceObjectUtil.getComponentInstance(flowContainerQueryable.getBusinessObjectContext()).map(ci -> createFlowSegmentReferences(flowContainerQueryable.getBusinessObjectContext(), ci)).orElse(Stream.empty());
} else {
return AadlClassifierUtil.getComponentImplementation(flowContainerQueryable.getBusinessObjectContext()).map(ci -> createFlowSegmentReferences(flowContainerQueryable.getBusinessObjectContext(), ci)).orElse(Stream.empty());
}
}).map(HighlightableFlowInfo::create).filter(Predicates.notNull()).forEachOrdered(highlightableFlowElement -> {
highlightableFlowElements.put(getName(highlightableFlowElement.highlightableFlowElement), highlightableFlowElement);
});
// Determine which value should be selected
final Optional<Entry<String, HighlightableFlowInfo>> tmpSelectedValue = highlightableFlowElements.entrySet().stream().filter(entry -> entry.getKey().equalsIgnoreCase(selectedFlowName)).findAny();
if (tmpSelectedValue.isPresent()) {
selectedValue = tmpSelectedValue.get();
}
comboViewer.setInput(highlightableFlowElements.entrySet());
}
}
showFlowContributionItem.updateShowFlowItem(selectedValue.getValue());
editFlowContributionItem.updateEditFlowItem(selectedValue.getValue());
deleteFlowContributionItem.updateDeleteFlowItem(selectedValue.getValue());
final StructuredSelection newSelection = new StructuredSelection(selectedValue);
if (!Objects.equal(newSelection, comboViewer.getSelection())) {
comboViewer.setSelection(newSelection);
onSelection(newSelection.getFirstElement());
}
}
}
Aggregations