use of org.osate.ge.internal.diagram.runtime.updating.FutureElementInfo in project osate2 by osate.
the class OperationResultsProcessor method processResults.
/**
* @param editor the editor which is displaying the diagram for which the operation was executed
* @param targetNode is the node to which the targetPosition is relative.
* @param targetPosition the position at which the operation was executed. Relative to the target node. This is used to position
* a newly created diagram element.
* @param results the results to process
*/
public static void processResults(final InternalDiagramEditor editor, final DiagramNode targetNode, final Point targetPosition, final OperationResults results) {
Objects.requireNonNull(editor, "diagram must not be null");
boolean update = false;
// Notify the diagram updater to add the element on the next update
for (final Entry<BusinessObjectContext, OperationResults.BusinessObjectToShowDetails> containerToBoEntry : results.getContainerToBoToShowDetailsMap().entries()) {
if (containerToBoEntry.getKey() instanceof DiagramNode) {
final DiagramNode containerNode = (DiagramNode) containerToBoEntry.getKey();
final OperationResults.BusinessObjectToShowDetails newValue = containerToBoEntry.getValue();
// Don't set the position if multiple items are being added.
// Don't set the position if the incremental layout mode is set to diagram.
// This will ensure the shape is laid out even if it is a docked shape.
final Point position;
if (results.getContainerToBoToShowDetailsMap().size() == 1 && LayoutPreferences.getCurrentIncrementalLayoutMode() != IncrementalLayoutMode.LAYOUT_DIAGRAM && containerNode == targetNode) {
position = targetPosition;
} else {
position = null;
}
// If the BO being added is an embedded business object, it must be provided to the diagram updater.
final EmbeddedBusinessObject embeddedBo = (newValue.bo instanceof EmbeddedBusinessObject) ? (EmbeddedBusinessObject) newValue.bo : null;
editor.getDiagramUpdater().addToNextUpdate(containerNode, newValue.ref, new FutureElementInfo(position, embeddedBo));
if (embeddedBo != null) {
update = true;
}
}
}
// If an embedded business object was added, then update the diagram to ensure it was updated.
if (update) {
editor.updateDiagram();
}
}
use of org.osate.ge.internal.diagram.runtime.updating.FutureElementInfo in project osate2 by osate.
the class ShowContentsUtil method addChildrenDuringNextUpdate.
/**
* Adds children of the specified diagram elements to the list of elements which will be added during the next diagram update.
* @return whether children were added to the diagram.
*/
private static boolean addChildrenDuringNextUpdate(final List<DiagramElement> diagramElements, final DiagramUpdater diagramUpdater, final ExtensionRegistryService extService, final ReferenceBuilderService referenceBuilder, final Function<DiagramElement, ImmutableSet<ContentFilter>> filters) {
boolean childrenAdded = false;
final BusinessObjectProviderHelper bopHelper = new BusinessObjectProviderHelper(extService);
for (final DiagramElement selectedElement : diagramElements) {
final ImmutableSet<ContentFilter> contentFilters = filters.apply(selectedElement);
if (!contentFilters.isEmpty()) {
for (final Object childBo : bopHelper.getChildBusinessObjects(selectedElement)) {
final RelativeBusinessObjectReference relativeReference = referenceBuilder.getRelativeReference(childBo);
if (relativeReference != null && selectedElement.getChildByRelativeReference(relativeReference) == null && ContentFilterUtil.passesAnyContentFilter(childBo, contentFilters)) {
diagramUpdater.addToNextUpdate(selectedElement, relativeReference, new FutureElementInfo());
childrenAdded = true;
}
}
}
}
return childrenAdded;
}
Aggregations