From cfa6f0af824702969f2e22a1c9bc3ed63848aeab Mon Sep 17 00:00:00 2001 From: CDaut Date: Wed, 30 Oct 2024 21:42:13 +0100 Subject: [PATCH 1/3] button icons now show numper of points subtracted --- .../extensions/guis/AssessmentPanel.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java b/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java index 503e663..ebe7665 100644 --- a/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java +++ b/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import javax.swing.JButton; import javax.swing.JComponent; @@ -32,6 +33,7 @@ import edu.kit.kastel.sdq.artemis4j.grading.Assessment; import edu.kit.kastel.sdq.artemis4j.grading.penalty.CustomPenaltyRule; import edu.kit.kastel.sdq.artemis4j.grading.penalty.MistakeType; +import edu.kit.kastel.sdq.artemis4j.grading.penalty.Points; import edu.kit.kastel.sdq.artemis4j.grading.penalty.RatingGroup; import edu.kit.kastel.sdq.artemis4j.grading.penalty.StackingPenaltyRule; import edu.kit.kastel.sdq.artemis4j.grading.penalty.ThresholdPenaltyRule; @@ -139,7 +141,7 @@ private void updateButtonIcons(Assessment assessment) { var settings = ArtemisSettingsState.getInstance(); var mistakeType = assessmentButton.mistakeType(); - String iconText; + StringBuilder iconText = new StringBuilder(); Color color; Font font = JBFont.regular(); @@ -149,7 +151,7 @@ private void updateButtonIcons(Assessment assessment) { switch (rule) { case ThresholdPenaltyRule thresholdRule -> { - iconText = count + "/" + thresholdRule.getThreshold(); + iconText.append(count).append("/").append(thresholdRule.getThreshold()); if (count >= thresholdRule.getThreshold()) { color = settings.getFinishedAssessmentButtonColor(); font = font.deriveFont(Map.of(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON)); @@ -158,20 +160,30 @@ private void updateButtonIcons(Assessment assessment) { } } case CustomPenaltyRule customPenaltyRule -> { - iconText = "C"; + iconText.append("C"); color = settings.getActiveAssessmentButtonColor(); } case StackingPenaltyRule stackingPenaltyRule -> { - iconText = String.valueOf(count); + iconText.append(count); color = settings.getActiveAssessmentButtonColor(); } } + + //find out how many points this button subtracts + Optional pointsSubtractedByButton = assessment.calculatePointsForMistakeType(mistakeType); + + //annotate the amount of points subtracted by this button + pointsSubtractedByButton.ifPresentOrElse( + points -> iconText.append(" | ").append(points.score()).append("P"), + () -> iconText.append(" | 0P") + ); + } else { - iconText = "R"; + iconText.append("R"); color = settings.getReportingAssessmentButtonColor(); } - assessmentButton.iconRenderer().update(iconText, color); + assessmentButton.iconRenderer().update(iconText.toString(), color); assessmentButton.button().setForeground(color); assessmentButton.button().setFont(font); } @@ -266,5 +278,6 @@ private void update(String text, Color bgColor) { } } - private record AssessmentButton(MistakeType mistakeType, JButton button, MistakeTypeIconRenderer iconRenderer) {} + private record AssessmentButton(MistakeType mistakeType, JButton button, MistakeTypeIconRenderer iconRenderer) { + } } From cf540c84c77fe7c18b29d8da79f080733c746160 Mon Sep 17 00:00:00 2001 From: CDaut Date: Wed, 30 Oct 2024 21:43:17 +0100 Subject: [PATCH 2/3] spotless --- .../intelligrade/extensions/guis/AssessmentPanel.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java b/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java index ebe7665..cade988 100644 --- a/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java +++ b/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java @@ -169,14 +169,13 @@ private void updateButtonIcons(Assessment assessment) { } } - //find out how many points this button subtracts + // find out how many points this button subtracts Optional pointsSubtractedByButton = assessment.calculatePointsForMistakeType(mistakeType); - //annotate the amount of points subtracted by this button + // annotate the amount of points subtracted by this button pointsSubtractedByButton.ifPresentOrElse( points -> iconText.append(" | ").append(points.score()).append("P"), - () -> iconText.append(" | 0P") - ); + () -> iconText.append(" | 0P")); } else { iconText.append("R"); @@ -278,6 +277,5 @@ private void update(String text, Color bgColor) { } } - private record AssessmentButton(MistakeType mistakeType, JButton button, MistakeTypeIconRenderer iconRenderer) { - } + private record AssessmentButton(MistakeType mistakeType, JButton button, MistakeTypeIconRenderer iconRenderer) {} } From a6302982ed8799f6985f0679fa10225b582f1267 Mon Sep 17 00:00:00 2001 From: CDaut Date: Thu, 31 Oct 2024 15:35:49 +0100 Subject: [PATCH 3/3] remove tooltip for Custom comments --- .idea/sonarlint.xml | 3 --- .../sdq/intelligrade/extensions/guis/AssessmentPanel.java | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.idea/sonarlint.xml b/.idea/sonarlint.xml index a43053d..c732a21 100644 --- a/.idea/sonarlint.xml +++ b/.idea/sonarlint.xml @@ -1,13 +1,10 @@ - - \ No newline at end of file diff --git a/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java b/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java index cade988..e3ed289 100644 --- a/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java +++ b/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/AssessmentPanel.java @@ -97,7 +97,11 @@ private void createMistakeButtons(ActiveAssessment assessment) { var panel = new JBPanel<>(new MigLayout("fill, gap 0, wrap " + buttonsPerRow)); for (var mistakeType : ratingGroup.getMistakeTypes()) { var button = new JButton(mistakeType.getButtonText().translateTo(LOCALE)); - button.setToolTipText(mistakeType.getMessage().translateTo(LOCALE)); + + // no tooltip for custom comment + if (!mistakeType.isCustomAnnotation()) { + button.setToolTipText(mistakeType.getMessage().translateTo(LOCALE)); + } button.setMargin(JBUI.emptyInsets()); var iconRenderer = new MistakeTypeIconRenderer();