Skip to content

Commit

Permalink
[558270] Diagrams handling in selective generation
Browse files Browse the repository at this point in the history
- Updated conditions to generate diagrams in diagrams tree according to
diagram selection, diagram target selection and ScopeReferenceStrategy
selection
- Update conditions for diagram link in "Diagrams displaying" section
- Update conditions for diagram display in "Owned diagrams" section

Change-Id: I9978f925ebd74c6d3fe8c71d4a2dc63af86a76c2
Signed-off-by: Arnaud Dieumegard <[email protected]>
  • Loading branch information
arnauddieumegard committed Dec 13, 2019
1 parent aa4fd13 commit 42645de
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.polarsys.kitalpha.doc.gen.business.core.preference.helper.DocgenDiagramPreferencesHelper;
import org.polarsys.kitalpha.doc.gen.business.core.scope.GenerationGlobalScope;
import org.polarsys.kitalpha.doc.gen.business.core.scope.ScopeReferencesStrategy;
import org.polarsys.kitalpha.doc.gen.business.core.scope.ScopeStatus;
import org.polarsys.kitalpha.doc.gen.business.core.sirius.util.session.DiagramSessionHelper;
import org.polarsys.kitalpha.doc.gen.business.core.util.SiriusHelper;

Expand All @@ -62,7 +63,10 @@ public static Collection<DRepresentation> getDiagramForObject(CapellaElement ele
representations = DialectManager.INSTANCE.getRepresentations(element, currentSession);
}

return representations;
return representations.stream()
.filter(rep -> rep instanceof DSemanticDiagram)
.filter(rep -> exportRefToDiagram(rep, ((DSemanticDiagram) rep).getTarget()))
.collect(Collectors.toList());
}

public static Resource getAIRDResource(CapellaElement element) {
Expand All @@ -82,7 +86,7 @@ public static Set<DSemanticDiagram> getDiagramContainingObject(CapellaElement el

getAllDiagramsForObject(element).stream()
.filter(rep -> rep instanceof DSemanticDiagram)
.filter(rep -> GenerationGlobalScope.getInstance().isCopyInScope(((DSemanticDiagram) rep).getTarget()))
.filter(rep -> exportRefToDiagram(rep, ((DSemanticDiagram) rep).getTarget()))
.forEach(diag -> diagrams.add((DSemanticDiagram) diag));

return diagrams;
Expand Down Expand Up @@ -162,7 +166,11 @@ public static Collection<DRepresentation> getAllDiagramsIn(BlockArchitecture arc
Collection<DRepresentation> representations = new ArrayList<DRepresentation>();
for (DRepresentation rep : DiagramSessionHelper.getSessionDRepresentation()) {
// Return only representations belonging to the current BlockArchitecture
if (archi.equals(getBlockArchitectureContainer(rep))) {
EObject originalContainer = archi;
if (GenerationGlobalScope.getInstance().getScopeStatus().equals(ScopeStatus.LIMITED)) {
originalContainer = GenerationGlobalScope.getInstance().getOriginalModelElement(archi);
}
if (originalContainer.equals(getBlockArchitectureContainer(rep))) {
representations.add(rep);
}
}
Expand All @@ -178,7 +186,11 @@ public static Collection<DRepresentation> getAllDiagramsIn(BlockArchitecture arc
public static boolean hostDiagrams(BlockArchitecture archi) {
for (DRepresentation rep : DiagramSessionHelper.getSessionDRepresentation()) {
// Return only representations belonging to the current BlockArchitecture
if (archi.equals(getBlockArchitectureContainer(rep))) {
EObject originalContainer = archi;
if (GenerationGlobalScope.getInstance().getScopeStatus().equals(ScopeStatus.LIMITED)) {
originalContainer = GenerationGlobalScope.getInstance().getOriginalModelElement(archi);
}
if (originalContainer.equals(getBlockArchitectureContainer(rep))) {
return true;
}
}
Expand All @@ -202,4 +214,15 @@ private static EObject getBlockArchitectureContainer(DRepresentation representat
}
return parent;
}

/**
* Checks whether we have to export at least a reference to the representation
* @param rep A DRepresentation to check
* @param target The target of the DRepresentation
* @return
*/
public static boolean exportRefToDiagram(DRepresentation rep, EObject target) {
return GenerationGlobalScope.getInstance().inScope(rep, false) ||
(GenerationGlobalScope.getInstance().getReferencesStrategy().equals(ScopeReferencesStrategy.EXPORT) && GenerationGlobalScope.getInstance().inScope(target, false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private static String getHyperlinkFromDiagram(DSemanticDiagram diagram) {
buffer.append(getPathFromElement(diagram.getTarget()));
// Add diagram fragment id as link anchor
buffer.append("#");
buffer.append(getDiagramId(diagram));
buffer.append(getDiagramUid(diagram));
// Add the href tag completion to the buffer
buffer.append(HYPERLINK_COMPLETE);
// Add the name to present to the buffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.polarsys.capella.core.data.requirement.Requirement;
import org.polarsys.capella.core.data.requirement.RequirementsPkg;
import org.polarsys.capella.docgen.diagram.CapellaHelper;
import org.polarsys.kitalpha.doc.gen.business.core.scope.GenerationGlobalScope;

/**
* A class providing methods to build trees of elements and to display them as html lists
Expand Down Expand Up @@ -227,13 +226,13 @@ private static DefaultMutableTreeNode buildDiagramsTree(BlockArchitecture archi)
RepresentationDescription description = null;
if (rep instanceof DSemanticDiagram) {
EObject target = ((DSemanticDiagram) rep).getTarget();
if (! GenerationGlobalScope.getInstance().inScope(target, false)){
if (!CapellaHelper.exportRefToDiagram(rep, target)) {
continue;
}
description = ((DSemanticDiagram) rep).getDescription();
} else if (rep instanceof DTable) {
EObject target = ((DTable) rep).getTarget();
if (! GenerationGlobalScope.getInstance().inScope(target, false)){
if (!CapellaHelper.exportRefToDiagram(rep, target)) {
continue;
}
description = ((DTable) rep).getDescription();
Expand Down

0 comments on commit 42645de

Please sign in to comment.