Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public static LogicalDivision addLogicalDivision(String type, Workpiece workpiec
handlePosition(workpiece, logicalDivision, position, viewsToAdd, parents, siblings, newStructure);

if (Objects.nonNull(viewsToAdd) && !viewsToAdd.isEmpty()) {
handleViewsToAdd(viewsToAdd, newStructure);
handleViewsToAdd(viewsToAdd, newStructure, workpiece.getLogicalStructure());
}
return newStructure;
}
Expand Down Expand Up @@ -352,11 +352,18 @@ private static void handlePosition(Workpiece workpiece, LogicalDivision logicalD
}
}

private static void handleViewsToAdd(List<View> viewsToAdd, LogicalDivision newStructure) {
private static void handleViewsToAdd(List<View> viewsToAdd, LogicalDivision newStructure,
LogicalDivision rootStructure) {
for (View viewToAdd : viewsToAdd) {
List<LogicalDivision> logicalDivisions = viewToAdd.getPhysicalDivision().getLogicalDivisions();
for (LogicalDivision elementToUnassign : logicalDivisions) {
elementToUnassign.getViews().remove(viewToAdd);
if (logicalDivisions.isEmpty() && Objects.nonNull(rootStructure)) {
// In an unsaved process, unstructured media may not yet have
// the root logical division registered explicitly.
rootStructure.getViews().remove(viewToAdd);
} else {
for (LogicalDivision elementToUnassign : logicalDivisions) {
elementToUnassign.getViews().remove(viewToAdd);
}
}
logicalDivisions.clear();
logicalDivisions.add(newStructure);
Expand Down
Loading