This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Feature
edit annotation messages
#170
Merged
dfuchss
merged 8 commits into
kit-sdq:main
from
Shirkanesi:feature/editAnnotationMessage
Apr 9, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ac88e4d
Initial work on edit-annotations
Shirkanesi d543de3
Applied spotless
Shirkanesi eee1cb3
Code-cleanup
Shirkanesi 52c2244
Merge branch 'kit-sdq:main' into feature/editAnnotationMessage
Shirkanesi 36e03b3
Applied spotless
Shirkanesi 932a1d1
Update formatter file
dfuchss acdb4fe
Fixed Nullpointer
Shirkanesi 752f78f
Fixed operator precedence
Shirkanesi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...du/kit/kastel/eclipse/grading/view/listeners/AssessmentMarkerViewDoubleClickListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* Licensed under EPL-2.0 2022. */ | ||
package edu.kit.kastel.eclipse.grading.view.listeners; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.jface.viewers.DoubleClickEvent; | ||
import org.eclipse.jface.viewers.IDoubleClickListener; | ||
import org.eclipse.jface.viewers.TreeSelection; | ||
import org.eclipse.ui.views.markers.MarkerItem; | ||
|
||
import edu.kit.kastel.eclipse.common.view.utilities.AssessmentUtilities; | ||
import edu.kit.kastel.eclipse.grading.view.activator.Activator; | ||
import edu.kit.kastel.eclipse.grading.view.assessment.ArtemisGradingView; | ||
import edu.kit.kastel.eclipse.grading.view.assessment.CustomButtonDialog; | ||
import edu.kit.kastel.sdq.eclipse.grading.api.model.IAnnotation; | ||
|
||
public class AssessmentMarkerViewDoubleClickListener implements IDoubleClickListener { | ||
|
||
private ArtemisGradingView gradingView; | ||
|
||
public AssessmentMarkerViewDoubleClickListener(ArtemisGradingView gradingView) { | ||
this.gradingView = gradingView; | ||
} | ||
|
||
@Override | ||
public void doubleClick(DoubleClickEvent event) { | ||
if (event.getSelection().isEmpty()) { | ||
// No element clicked | ||
return; | ||
} | ||
|
||
// instanceof is required... :( | ||
if (event.getSelection()instanceof TreeSelection selection) { | ||
if (selection.getFirstElement()instanceof MarkerItem item) { | ||
try { | ||
IAnnotation annotation = Activator.getDefault().getSystemwideController().getCurrentAssessmentController() | ||
.getAnnotationByUUID(item.getMarker().getAttribute(AssessmentUtilities.MARKER_ATTRIBUTE_ANNOTATION_ID).toString()) | ||
.orElseThrow(() -> new NoSuchElementException("Could not find annotation. Please create it again.")); | ||
|
||
String customMessage = annotation.getCustomMessage().orElse(""); | ||
|
||
CustomButtonDialog dialog = new CustomButtonDialog(AssessmentUtilities.getWindowsShell(), null, null, null); | ||
|
||
if (annotation.getMistakeType().isCustomPenalty()) { | ||
dialog.setCustomPenalty(annotation.getCustomPenalty().orElse(0d)); | ||
dialog.setForcePenaltyField(true); | ||
} | ||
|
||
dialog.setCustomMessage(customMessage); | ||
dialog.setBlockOnOpen(true); | ||
dialog.open(); | ||
|
||
String newMessage = dialog.getCustomMessage(); | ||
Double newPenalty = annotation.getMistakeType().isCustomPenalty() ? dialog.getCustomPenalty() : annotation.getCustomPenalty().orElse(0d); | ||
|
||
item.getMarker().setAttribute(AssessmentUtilities.MARKER_ATTRIBUTE_CUSTOM_MESSAGE, newMessage); | ||
item.getMarker().setAttribute(AssessmentUtilities.MARKER_ATTRIBUTE_CUSTOM_PENALTY, newPenalty.toString()); | ||
|
||
Activator.getDefault().getSystemwideController().getCurrentAssessmentController().modifyAnnotation(annotation.getUUID(), newMessage, | ||
newPenalty); | ||
this.gradingView.updatePenalties(); | ||
} catch (CoreException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change our formatter here .. :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind .. it's a bug :( diffplug/spotless#1046