From 327fd647d4a69c3d3f9b2704eb3fcb230623e6f8 Mon Sep 17 00:00:00 2001 From: Quang Truong Date: Tue, 10 Dec 2024 12:02:17 +0100 Subject: [PATCH] both direction is a illegal direction --- .../table/pt1/ssks/SsksTransformator.xtend | 89 ++++++++++--------- .../extensions/CellContentExtensions.xtend | 2 +- .../nattable/utils/BasePainterDecorator.java | 4 +- .../utils/PlanProTableCellPainter.java | 23 +++-- .../utils/PlanProTableThemeConfiguration.java | 6 +- .../AbstractTableModelTransformator.xtend | 21 ++++- 6 files changed, 82 insertions(+), 63 deletions(-) diff --git a/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend b/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend index c3bdbeb3e..2e3089202 100644 --- a/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend +++ b/java/bundles/org.eclipse.set.feature.table.pt1/src/org/eclipse/set/feature/table/pt1/ssks/SsksTransformator.xtend @@ -352,8 +352,8 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator { ] waitingFileSideDistanceSignal.put(row, signal) } else { - val abstandMastmitteLinks = new HashSet> - val abstandMastmitteRechts = new HashSet> + val abstandMastmitteLinks = new HashSet> + val abstandMastmitteRechts = new HashSet> signal.initAbstandMastmitte(signal.signalRahmen, abstandMastmitteLinks, abstandMastmitteRechts); @@ -364,7 +364,7 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator { signal, [ abstandMastmitteLinks.map [ - '''«key»«IF value > 0» («value»)«ENDIF»''' + '''«key»«IF value !== null» («value»)«ENDIF»''' ] ], null, @@ -377,11 +377,10 @@ class SsksTransformator extends AbstractPlanPro2TableModelTransformator { signal, [ abstandMastmitteRechts.map [ - '''«key»«IF value > 0» («value»)«ENDIF»''' + '''«key»«IF value !== null» («value»)«ENDIF»''' ] ], - null, - [toString] + null ) } @@ -918,19 +917,19 @@ class .simpleName»: «e.message» - failed to transform table contents''', e) private def void refillSideDistance(TableRow row, Signal signal, List changeProperties) { - val abstandMastmitteLinks = new HashSet> - val abstandMastmitteRechts = new HashSet> + val abstandMastmitteLinks = new HashSet> + val abstandMastmitteRechts = new HashSet> val containerType = signal.container.containerType signal.initAbstandMastmitte(signal.signalRahmen, abstandMastmitteLinks, abstandMastmitteRechts); val leftDistance = new Pt1TableChangeProperties(containerType, row, cols.getColumn(Mastmitte_Links), abstandMastmitteLinks.map [ - '''«key» «IF value > 0»(«value»)«ENDIF»''' + '''«key» «IF value !== null»(«value»)«ENDIF»''' ].toList, ITERABLE_FILLING_SEPARATOR) changeProperties.add(leftDistance) val rightDistance = new Pt1TableChangeProperties(containerType, row, cols.getColumn(Mastmitte_Rechts), abstandMastmitteRechts.map [ - '''«key» «IF value > 0»(«value»)«ENDIF»''' + '''«key» «IF value !== null»(«value»)«ENDIF»''' ].toList, ITERABLE_FILLING_SEPARATOR) changeProperties.add(rightDistance) } @@ -938,8 +937,8 @@ class .simpleName»: «e.message» - failed to transform table contents''', e) private def void initAbstandMastmitte( Signal signal, List signalRahmen, - Set> abstandMastmitteLinks, - Set> abstandMastmitteRechts + Set> abstandMastmitteLinks, + Set> abstandMastmitteRechts ) { signalRahmen.map [ signalBefestigungIterator.findFirst [ @@ -949,24 +948,32 @@ class .simpleName»: «e.message» - failed to transform table contents''', e) ENUM_BEFESTIGUNG_ART_REGELANORDNUNG_MAST_NIEDRIG ] ].filterNull.map[singlePoints].flatten.toSet.forEach [ p | - val seitlicherAbstand = Math.round( - p.seitlicherAbstand.wert.doubleValue * 1000) + if (p?.seitlicherAbstand?.wert === null) { + val exception = new NullPointerException( + "The Signal_Befestigung haven't seitlicherAbstand") + abstandMastmitteLinks.add( + exception.createErrorMsg(signal.identitaet.wert) -> null) + abstandMastmitteRechts.add( + exception.createErrorMsg(signal.identitaet.wert) -> null) + return + } + val seitlicherAbstand = Math.round(p.seitlicherAbstand.wert.doubleValue * 1000) val wirkrichtung = p.wirkrichtung.wert val distanceFromPoint = MAX_OPOSIDE_DISTANCE - Math.abs(seitlicherAbstand) - var perpendicularRotation = 0 - - switch (wirkrichtung) { - case ENUM_WIRKRICHTUNG_IN, - case ENUM_WIRKRICHTUNG_BEIDE: - perpendicularRotation = seitlicherAbstand >= 0 ? 90 : -90 - case ENUM_WIRKRICHTUNG_GEGEN: - perpendicularRotation = seitlicherAbstand < 0 ? 90 : -90 - default: { - LOGGER.error("Illegal Wirkrichtung") - return - } + if (wirkrichtung !== ENUM_WIRKRICHTUNG_IN && + wirkrichtung !== ENUM_WIRKRICHTUNG_GEGEN) { + val exception = new IllegalArgumentException( + "The Signal_Befestigung have Illegal Wirkrichtung") + abstandMastmitteLinks.add( + exception.createErrorMsg(signal.identitaet.wert) -> null) + abstandMastmitteRechts.add( + exception.createErrorMsg(signal.identitaet.wert) -> null) + return } + val isLeftsideOfTrack = (wirkrichtung === ENUM_WIRKRICHTUNG_IN) === + (seitlicherAbstand >= 0) + val perpendicularRotation = isLeftsideOfTrack ? 90 : -90 var opposideSideDistance = 0.0 val geoPosition = Services.pointObjectService.getCoordinate(p). geoPosition @@ -977,24 +984,18 @@ class .simpleName»: «e.message» - failed to transform table contents''', e) LOGGER.error(e.message) } val distanceBetweenTracks = opposideSideDistance > 0 - ? Math.abs(seitlicherAbstand) + - Math.round(opposideSideDistance * 1000) - : 0 - - switch (wirkrichtung) { - case ENUM_WIRKRICHTUNG_IN, - case ENUM_WIRKRICHTUNG_BEIDE: - seitlicherAbstand >= 0 - ? abstandMastmitteLinks.add( - Math.abs(seitlicherAbstand) -> distanceBetweenTracks) - : abstandMastmitteRechts.add( - Math.abs(seitlicherAbstand) -> distanceBetweenTracks) - case ENUM_WIRKRICHTUNG_GEGEN: - seitlicherAbstand < 0 - ? abstandMastmitteLinks.add( - Math.abs(seitlicherAbstand) -> distanceBetweenTracks) - : abstandMastmitteRechts.add( - Math.abs(seitlicherAbstand) -> distanceBetweenTracks) + ? (Math.abs(seitlicherAbstand) + + Math.round(opposideSideDistance * 1000)).toString + : null + + if (isLeftsideOfTrack) { + abstandMastmitteLinks.add( + Math.abs(seitlicherAbstand).toString -> + distanceBetweenTracks) + } else { + abstandMastmitteRechts.add( + Math.abs(seitlicherAbstand).toString -> + distanceBetweenTracks) } ] } diff --git a/java/bundles/org.eclipse.set.model.tablemodel.extensions/src/org/eclipse/set/model/tablemodel/extensions/CellContentExtensions.xtend b/java/bundles/org.eclipse.set.model.tablemodel.extensions/src/org/eclipse/set/model/tablemodel/extensions/CellContentExtensions.xtend index 3245cf622..22d43ceaf 100644 --- a/java/bundles/org.eclipse.set.model.tablemodel.extensions/src/org/eclipse/set/model/tablemodel/extensions/CellContentExtensions.xtend +++ b/java/bundles/org.eclipse.set.model.tablemodel.extensions/src/org/eclipse/set/model/tablemodel/extensions/CellContentExtensions.xtend @@ -314,7 +314,7 @@ class CellContentExtensions { return '''«value.htmlString»''' } case WARNING_MARK_YELLOW: { - return '''«value.htmlString»''' + return '''«value.htmlString»''' } case WARNING_MARK_RED: { return '''«value.htmlString»''' diff --git a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/BasePainterDecorator.java b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/BasePainterDecorator.java index b55d95876..9b6629359 100644 --- a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/BasePainterDecorator.java +++ b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/BasePainterDecorator.java @@ -81,7 +81,7 @@ public Rectangle getDecoratorCellPainterBounds(final ILayerCell cell, configRegistry) : 0; - switch (getCellEdge()) { + switch (super.getCellEdge()) { case LEFT: return new Rectangle(adjustedCellBounds.x, adjustedCellBounds.y, preferredDecoratorWidth, preferredDecoratorHeight) @@ -90,7 +90,7 @@ public Rectangle getDecoratorCellPainterBounds(final ILayerCell cell, case RIGHT: return new Rectangle(adjustedCellBounds.x, adjustedCellBounds.y + preferredBaseHeight - - preferredDecoratorHeight, + - getSpacing(), preferredDecoratorWidth, preferredDecoratorHeight) .intersection(adjustedCellBounds); diff --git a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableCellPainter.java b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableCellPainter.java index 4409819f4..74c2b3faa 100644 --- a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableCellPainter.java +++ b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableCellPainter.java @@ -11,9 +11,8 @@ import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter; import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter; import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator; -import org.eclipse.swt.graphics.Image; - import org.eclipse.set.model.tablemodel.extensions.CellContentExtensions; +import org.eclipse.swt.graphics.Image; /** * Painter used to draw PlanPro table cells. @@ -30,27 +29,27 @@ public class PlanProTableCellPainter extends BackgroundPainter { /** * @param interiorPainter * the interior painter - * @param leftWarningImage - * the left warning image - * @param rightWarningImage - * the right warning image + * @param yellowWarningImage + * the yellow warning image + * @param redWarningImage + * the red warning image * @param blackWarningImage * the black warning image */ public PlanProTableCellPainter(final ICellPainter interiorPainter, - final Image leftWarningImage, final Image rightWarningImage, + final Image yellowWarningImage, final Image redWarningImage, final Image blackWarningImage) { super(new PaddingDecorator(new BasePainterDecorator( new BasePainterDecorator(new BasePainterDecorator( interiorPainter, BaseEdgeEnum.BEFORE, + new WarningPainter(redWarningImage, + CellContentExtensions.WARNING_MARK_RED)), + BaseEdgeEnum.BEFORE, new WarningPainter(blackWarningImage, CellContentExtensions.WARNING_MARK_BLACK)), - BaseEdgeEnum.BEFORE, - new WarningPainter(leftWarningImage, - CellContentExtensions.WARNING_MARK_YELLOW)), BaseEdgeEnum.AFTER, - new WarningPainter(rightWarningImage, - CellContentExtensions.WARNING_MARK_RED)), + new WarningPainter(yellowWarningImage, + CellContentExtensions.WARNING_MARK_YELLOW)), TOP_PADDING, RIGHT_PADDING, BOTTOM_PADDING, LEFT_PADDING, false)); } diff --git a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableThemeConfiguration.java b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableThemeConfiguration.java index c0938564a..a6d9602cb 100644 --- a/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableThemeConfiguration.java +++ b/java/bundles/org.eclipse.set.nattable.utils/src/org/eclipse/set/nattable/utils/PlanProTableThemeConfiguration.java @@ -212,9 +212,9 @@ public void createPainterInstances() { final boolean calculateByTextLength = false; final boolean calculateByTextHeight = true; - final Image leftWarningImage = createImage(resourceManager, + final Image yellowWarningImage = createImage(resourceManager, SetImages.WARNING_YELLOW); - final Image rightWarningImage = createImage(resourceManager, + final Image redWarningImage = createImage(resourceManager, SetImages.WARNING_RED); final Image blackWarningImage = createImage(resourceManager, SetImages.IC_WARNING_BLACK_18DP_1X); @@ -222,7 +222,7 @@ public void createPainterInstances() { this.defaultCellPainter = new PlanProTableCellPainter( new PlanProRichTextCellPainter(wraptext, calculateByTextLength, calculateByTextHeight), - leftWarningImage, rightWarningImage, blackWarningImage); + yellowWarningImage, redWarningImage, blackWarningImage); this.filterRowCellPainter = new PaddingDecorator( new FilterRowPainter( new FilterIconPainter(GUIHelper.getImage("filter"))), //$NON-NLS-1$ diff --git a/java/bundles/org.eclipse.set.utils.table/src/org/eclipse/set/utils/table/AbstractTableModelTransformator.xtend b/java/bundles/org.eclipse.set.utils.table/src/org/eclipse/set/utils/table/AbstractTableModelTransformator.xtend index d6fe239c7..dadd461d5 100644 --- a/java/bundles/org.eclipse.set.utils.table/src/org/eclipse/set/utils/table/AbstractTableModelTransformator.xtend +++ b/java/bundles/org.eclipse.set.utils.table/src/org/eclipse/set/utils/table/AbstractTableModelTransformator.xtend @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory import static extension com.google.common.base.Throwables.* import static extension org.eclipse.set.model.tablemodel.extensions.TableRowExtensions.* import static extension org.eclipse.set.ppmodel.extensions.utils.Debug.* +import org.eclipse.set.model.planpro.Basisobjekte.Ur_Objekt /** * Provides common functions for table transformations. @@ -543,7 +544,7 @@ abstract class AbstractTableModelTransformator implements TableModelTransform ) { var guid = row.group.leadingObject?.identitaet?.wert var leadingObject = getLeadingObjectIdentifier(row, guid) - var errorMsg = '''«e.class.simpleName»: "«e.message»" for leading object "«leadingObject»"''' + var errorMsg = e.createErrorMsg(row) tableErrors.add( new TableError(guid, leadingObject, "", @@ -552,6 +553,24 @@ abstract class AbstractTableModelTransformator implements TableModelTransform logger. error('''«e.class.simpleName» in column "«column.debugString»" for leading object "«leadingObject»" («guid»). «e.message»«System.lineSeparator»«e.stackTraceAsString»''') } + + def String createErrorMsg( + Exception e, + TableRow row + ) { + var guid = row.group.leadingObject?.identitaet?.wert + var leadingObject = getLeadingObjectIdentifier(row, guid) + return e.createErrorMsg(leadingObject) + } + + def String createErrorMsg( + Exception e, + String leadingObjectGuid + ) { + var errorMsg = '''«e.class.simpleName»: "«e.message»" for leading object "«leadingObjectGuid»"''' + return '''«ERROR_PREFIX»«errorMsg»''' + } + /** * Evaluates the given function with the given value for use in sorting.