Skip to content

Commit

Permalink
[2069] FunctionalChain, PhysicalPath internal arrow to a port without
Browse files Browse the repository at this point in the history
exchanges
must not be displayed

Automatically hide and show internal functional chain and unused ports.
Automatically hide and show physical path and unused ports.

- Use DiagramServices.getDiagramServices().isHidden(edge) instead of
edge.isVisible()
- Add new algorithm in PhysicalServices to evaluate if a internal
physical path is valid or
not.
- Refactoring FaServices.switchFECategories() and associated methods
- Refactoring ABServices.switchABPhysicalCategories() and associated
methods.
- Add/Remove internal edges for functional chains in "beforeRefresh" of
ComponentArchitectureBlank, DataFlowBlank, EntityArchitectureBlank
- Add/Remove internal edges for functional chains in "beforeRefresh" of
ComponentArchitectureBlank, DataFlowBlank, EntityArchitectureBlank
- Add/Remove internal edges for physical paths in "beforeRefresh" of
ComponentArchitectureBlank
- Do not use updateFECategories anymore. It does not do anything
concrete because the method
isValidFECategoryEdge always return true.
- Re-factoring the FunctionalChainServices.updateFunctionalChainStyles
by creating a new
FunctionalChainServices.updateInternalFunctionalChains()
- Re-factoring the PhysicalServices.updatePhysicalPathStyles and
creating a new PhysicalServices.updateInternalPhysicalPaths()
- In physical.odesign: force refresh the diagram after switching
categories.
- In context.odesign: force refresh the diagram after switching physical
links / categories
- In logical.odesign: force refresh the diagram after switching physical
links / categories
- Adapt the test SysmodelMigrationLayout.
- Add test switching physical links / categories on PAB, SAB, LAB
diagram
- Add test switching functional exchanges / categories on SAB, LAB
diagram

Bug: 2069
Change-Id: I389856debf97b8b17093943d9bc4124f19137814
Signed-off-by: cong-bang.do <docongbang1993@gmail.com>
  • Loading branch information
bang-dc committed Aug 10, 2018
1 parent bb3be3e commit bc97089
Show file tree
Hide file tree
Showing 25 changed files with 4,835 additions and 822 deletions.
Expand Up @@ -4171,6 +4171,7 @@
</subModelOperations>
<subModelOperations xsi:type="tool_1:If" conditionExpression="aql:(selectedElements != 'WIZARD_CANCELED')">
<subModelOperations xsi:type="tool_1:ChangeContext" browseExpression="aql:elementView.switchABPhysicalCategories(scope,initialSelection,selectedElements)"/>
<subModelOperations xsi:type="tool_1:ChangeContext" browseExpression="aql:elementView.getDiagramContainer().forceRefresh()"/>
</subModelOperations>
</firstModelOperations>
</initialOperation>
Expand Down
Expand Up @@ -2977,6 +2977,7 @@
</subModelOperations>
<subModelOperations xsi:type="tool:If" conditionExpression="aql:(selectedElements != 'WIZARD_CANCELED')">
<subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:elementView.switchABPhysicalCategories(scope,initialSelection,selectedElements)"/>
<subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:elementView.getDiagramContainer().forceRefresh()"/>
</subModelOperations>
</firstModelOperations>
</initialOperation>
Expand Down
Expand Up @@ -2905,6 +2905,7 @@
</subModelOperations>
<subModelOperations xsi:type="tool:If" conditionExpression="aql:(selectedElements != 'WIZARD_CANCELED')">
<subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:elementView.switchABPhysicalCategories(scope,initialSelection,selectedElements)"/>
<subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:elementView.getDiagramContainer().forceRefresh()"/>
</subModelOperations>
</firstModelOperations>
</initialOperation>
Expand Down
Expand Up @@ -1730,75 +1730,49 @@ public EObject switchABPhysicalCategories(DDiagramContents content, DSemanticDec
Collection<EObject> selectedElements, boolean showHiddenPhysicalLinks) {
ABServices.getService().updateABPhysicalCategories(content);

DDiagram currentDiagram = content.getDDiagram();
Collection<DDiagramElement> sourceViews = new ArrayList<DDiagramElement>();

// retrieve all part views where to apply the show/hide
if (context instanceof DDiagramElement) {
sourceViews.add((DDiagramElement) context);
}
if (sourceViews.isEmpty()) {
DiagramElementMapping mapping = content
.getMapping(MappingConstantsHelper.getMappingABComponent(CsPackage.Literals.ABSTRACT_ACTOR, currentDiagram));
for (DDiagramElement element : content.getDiagramElements(mapping)) {
sourceViews.add(element);
}
mapping = content
.getMapping(MappingConstantsHelper.getMappingABComponent(CsPackage.Literals.COMPONENT, currentDiagram));
for (DDiagramElement element : content.getDiagramElements(mapping)) {
sourceViews.add(element);
}
if (currentDiagram.getDescription().getName()
.equalsIgnoreCase(IDiagramNameConstants.PHYSICAL_ARCHITECTURE_BLANK_DIAGRAM_NAME)) {
mapping = content.getMapping(MappingConstantsHelper.getMappingABDeployedElement(currentDiagram));
for (DDiagramElement element : content.getDiagramElements(mapping)) {
sourceViews.add(element);
}
}
}
Collection<DDiagramElement> sourceViews = computeRelatedSourceViewsToPhysicalLinks(content, context);

AbstractShowHide categories = new ShowHideABPhysicalCategory(content);
DiagramContext ctx = categories.new DiagramContext();
AbstractShowHide physicalCategoryShowHideService = new ShowHideABPhysicalCategory(content);
DiagramContext ctx = physicalCategoryShowHideService.new DiagramContext();
if (context instanceof DDiagramElement) {
ctx.setVariable(ShowHideABComponentExchange.SOURCE_PART_VIEWS, Collections.singletonList(context));
}

// Compute only once relatedPhysicalLinks and abShowHidePhysicalCategoriesScope of a source view
Map<EObject, Collection<PhysicalLink>> relatedPhysicalLinksMap = new HashMap<EObject, Collection<PhysicalLink>>();
Map<DDiagramElement, HashMapSet<EObject, EObject>> abShowHidePhysicalCategoriesScopeMap = new HashMap<DDiagramElement, HashMapSet<EObject, EObject>>();
Map<DDiagramElement, Collection<PhysicalLink>> sourceViewToRelatedPhysicalLinksMap = new HashMap<>();
Map<DDiagramElement, HashMapSet<EObject, EObject>> abShowHidePhysicalCategoriesScopeMap = new HashMap<>();
for (DDiagramElement sourceView : sourceViews) {
EObject sourceViewTarget = sourceView.getTarget();
if (sourceViewTarget != null) {
EObject source = sourceViewTarget;
Collection<PhysicalLink> relatedPhysicalLinks = getRelatedPhysicalLinks(source);

relatedPhysicalLinksMap.put(source, relatedPhysicalLinks);
Collection<PhysicalLink> relatedPhysicalLinks = getRelatedPhysicalLinks(sourceViewTarget);

sourceViewToRelatedPhysicalLinksMap.put(sourceView, relatedPhysicalLinks);
abShowHidePhysicalCategoriesScopeMap.put(sourceView,
getABShowHidePhysicalCategoriesScope(sourceView, relatedPhysicalLinks));
}
}

// show or hide categorie links
// 1. SHOW OR HIDE PHYSICAL CATEGORIES
for (DDiagramElement sourceView : sourceViews) {
EObject sourceViewTarget = sourceView.getTarget();
if (sourceViewTarget != null) {
EObject source = sourceViewTarget;
HashMapSet<EObject, EObject> scopeSource = abShowHidePhysicalCategoriesScopeMap.get(sourceView);
for (EObject key : scopeSource.keySet()) {

if (selectedElements.contains(key)) {
for (EObject target : scopeSource.get(key)) {
showABPhysicalCategory(categories, ctx, (PhysicalLinkCategory) key, source, target, true);
}
} else {
for (EObject target : scopeSource.get(key)) {
showABPhysicalCategory(categories, ctx, (PhysicalLinkCategory) key, source, target, false);
PhysicalLinkCategory physicalLinkCategory = (PhysicalLinkCategory) key;
for (EObject target : scopeSource.get(key)) {
if (selectedElements.contains(key)) {
showABPhysicalCategory(physicalCategoryShowHideService, ctx, physicalLinkCategory, source, target, true);
} else {
showABPhysicalCategory(physicalCategoryShowHideService, ctx, physicalLinkCategory, source, target, false);
}
}
}
}
}

// 2. SHOW OR HIDE PHYSICAL LINKS
// In tool (showHiddenPhysicalLinks==true), user may have removed some categories, so he wants to display hidden
// physical links associated to them.
// In refresh (showHiddenPhysicalLinks==false), categories haven't been changed by the user, so he doesn't want to
Expand All @@ -1807,43 +1781,73 @@ public EObject switchABPhysicalCategories(DDiagramContents content, DSemanticDec
for (DDiagramElement sourceView : sourceViews) {
EObject sourceViewTarget = sourceView.getTarget();
if (sourceViewTarget != null) {
EObject source = sourceViewTarget;
HashMapSet<EObject, EObject> scopeSource = abShowHidePhysicalCategoriesScopeMap.get(sourceView);

// Traverse the categories selected by the user
for (EObject key : scopeSource.keySet()) {
PhysicalLinkCategory category = (PhysicalLinkCategory) key;
if (selectedElements.contains(key)) {
for (PhysicalLink exchange : relatedPhysicalLinksMap.get(source)) {
if (exchange.getCategories().contains(key)) {
displayABPhysicalCategoryPortDelegation(ctx, category, exchange,
(PhysicalPort) PhysicalLinkExt.getSourcePort(exchange), true, categories);
displayABPhysicalCategoryPortDelegation(ctx, category, exchange,
(PhysicalPort) PhysicalLinkExt.getTargetPort(exchange), true, categories);
categories.hide(exchange, ctx);
}
}
} else if (showHiddenPhysicalLinks) {
for (PhysicalLink exchange : relatedPhysicalLinksMap.get(source)) {
if (exchange.getCategories().contains(key)) {
displayABPhysicalCategoryPortDelegation(ctx, category, exchange,
(PhysicalPort) PhysicalLinkExt.getSourcePort(exchange), false, categories);
displayABPhysicalCategoryPortDelegation(ctx, category, exchange,
(PhysicalPort) PhysicalLinkExt.getTargetPort(exchange), false, categories);
categories.show(exchange, ctx);
for (PhysicalLink physicalLink : sourceViewToRelatedPhysicalLinksMap.get(sourceView)) {
if (physicalLink.getCategories().contains(key)) {
PhysicalPort sourcePort = (PhysicalPort) PhysicalLinkExt.getSourcePort(physicalLink);
PhysicalPort targetPort = (PhysicalPort) PhysicalLinkExt.getTargetPort(physicalLink);
if (selectedElements.contains(key)) {
displayABPhysicalCategoryPortDelegation(ctx, category, physicalLink,
sourcePort, true, physicalCategoryShowHideService);
displayABPhysicalCategoryPortDelegation(ctx, category, physicalLink,
targetPort, true, physicalCategoryShowHideService);
// Hide the physical link
physicalCategoryShowHideService.hide(physicalLink, ctx);
} else if (showHiddenPhysicalLinks) {
displayABPhysicalCategoryPortDelegation(ctx, category, physicalLink,
sourcePort, false, physicalCategoryShowHideService);
displayABPhysicalCategoryPortDelegation(ctx, category, physicalLink,
targetPort, false, physicalCategoryShowHideService);

// Show the physical link
physicalCategoryShowHideService.show(physicalLink, ctx);
}
}
}
}
}
}


// 3.
ABServices.getService().updateABPhysicalCategories(content);

content.commitDeferredActions();

return context;
}

private Collection<DDiagramElement> computeRelatedSourceViewsToPhysicalLinks(DDiagramContents content,
DSemanticDecorator context) {
DDiagram currentDiagram = content.getDDiagram();
Collection<DDiagramElement> sourceViews = new ArrayList<>();
if (context instanceof DDiagramElement) {
sourceViews.add((DDiagramElement) context);
}
if (sourceViews.isEmpty()) {
DiagramElementMapping mapping = content
.getMapping(MappingConstantsHelper.getMappingABComponent(CsPackage.Literals.ABSTRACT_ACTOR, currentDiagram));
for (DDiagramElement element : content.getDiagramElements(mapping)) {
sourceViews.add(element);
}
mapping = content
.getMapping(MappingConstantsHelper.getMappingABComponent(CsPackage.Literals.COMPONENT, currentDiagram));
for (DDiagramElement element : content.getDiagramElements(mapping)) {
sourceViews.add(element);
}
if (currentDiagram.getDescription().getName()
.equalsIgnoreCase(IDiagramNameConstants.PHYSICAL_ARCHITECTURE_BLANK_DIAGRAM_NAME)) {
mapping = content.getMapping(MappingConstantsHelper.getMappingABDeployedElement(currentDiagram));
for (DDiagramElement element : content.getDiagramElements(mapping)) {
sourceViews.add(element);
}
}
}
return sourceViews;
}

public EObject switchABComponentCategories(DSemanticDecorator context, Collection<EObject> scope,
Collection<EObject> initialSelection, Collection<EObject> selectedElements) {
DDiagram currentDiagram = CapellaServices.getService().getDiagramContainer(context);
Expand Down Expand Up @@ -2318,17 +2322,17 @@ public HashMapSet<EObject, EObject> getABShowHidePhysicalCategoriesScope(DSemant
EObject relatedPart = CsServices.getService().getRelatedPart(context);

if (relatedPart != null) {
for (PhysicalLink exchange : relatedPhysicalLinks) {
for (PhysicalLinkCategory value : exchange.getCategories()) {
Collection<? extends EObject> sourceParts = PhysicalLinkExt.getSourceParts(exchange);
Collection<? extends EObject> targetParts = PhysicalLinkExt.getTargetParts(exchange);
for (PhysicalLink physicalLink : relatedPhysicalLinks) {
for (PhysicalLinkCategory physicalLinkCategory : physicalLink.getCategories()) {
Collection<? extends EObject> sourceParts = PhysicalLinkExt.getSourceParts(physicalLink);
Collection<? extends EObject> targetParts = PhysicalLinkExt.getTargetParts(physicalLink);
if (sourceParts.contains(relatedPart)) {
for (EObject related : targetParts) {
result.put(value, related);
for (EObject targetPart : targetParts) {
result.put(physicalLinkCategory, targetPart);
}
} else if (targetParts.contains(relatedPart)) {
for (EObject related : sourceParts) {
result.put(value, related);
for (EObject sourcePart : sourceParts) {
result.put(physicalLinkCategory, sourcePart);
}
}
}
Expand Down

0 comments on commit bc97089

Please sign in to comment.