From 5c346651b6f6abeafb3567900bc8abc421f1592c Mon Sep 17 00:00:00 2001 From: Spayralbe Date: Mon, 4 Dec 2023 17:40:42 +0100 Subject: [PATCH] Decrease size of table panel when using stem table. Without this change, the table panel height is always higher than needed (when using stem table), because the stem table is counted as one of the items in the components list. It is however shown separately at the top, which is already accounted for by the stem table margin. --- .../main/java/org/ohdsi/rabbitInAHat/MappingPanel.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rabbitinahat/src/main/java/org/ohdsi/rabbitInAHat/MappingPanel.java b/rabbitinahat/src/main/java/org/ohdsi/rabbitInAHat/MappingPanel.java index 5b4a0160..2a935797 100644 --- a/rabbitinahat/src/main/java/org/ohdsi/rabbitInAHat/MappingPanel.java +++ b/rabbitinahat/src/main/java/org/ohdsi/rabbitInAHat/MappingPanel.java @@ -266,10 +266,17 @@ private void setLabeledRectanglesLocation(List components, int public Dimension getMinimumSize() { Dimension dimension = new Dimension(); dimension.width = 2 * (ITEM_WIDTH + MARGIN) + MIN_SPACE_BETWEEN_COLUMNS; - int componentsHeight = Math.max(sourceComponents.size(), cdmComponents.size()) * (ITEM_HEIGHT + MARGIN); + int maxComponentsSize = Math.max(sourceComponents.size(), cdmComponents.size()); + int componentsHeight = maxComponentsSize * (ITEM_HEIGHT + MARGIN); dimension.height = Math.min(HEADER_HEIGHT + HEADER_TOP_MARGIN + componentsHeight, maxHeight); + if (ObjectExchange.etl.hasStemTable()) { dimension.height += STEM_HEIGHT_MARGIN; + // For the table mapping panel, deduct the stem table from the items (as it's not shown as a normal item in the list) + boolean isTablesPanel = cdmComponents.stream().allMatch(n -> (n.getItem() instanceof Table)); + if (!cdmComponents.isEmpty() && isTablesPanel) { + dimension.height -= (ITEM_HEIGHT + MARGIN); + } } return dimension;