-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Control clicking exercise opens submit window #447
Conversation
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.
In general, this looks pretty nice! 👍 I have a couple of concerns I discuss in my comments. See them and tell your thoughts of them! :)
nodeAppliedListeners.get("submitExercise").actionPerformed(actionEvent); | ||
} else if (e.getClickCount() == 2 && selectedItem != null) { | ||
ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null); | ||
nodeAppliedListeners.get("openSubmission").actionPerformed(actionEvent); |
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.
TreeView should be a domain-ignorant class; it shouldn't deal with concepts such as "submission". It's a general purpose tree widget.
So if anything, the keys should be something like "doubleClick" and "ctrlClick", or maybe more preferably something abstract like "nodePrimaryAction", "nodeSecondaryAction".
I wouldn't, however, introduce any magic strings into the public interface of this class (they can be used internally, if you like). Instead, I would make a separate add*Listener and remove*Listener methods for different kind of events.
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 think separate add*Listener and remove*Listener methods for different kind of events sounds good, I'll do that
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.
Sounds good to me too, but in that case I would prefer two sets for primary and secondary listeners respectively, instead of a map (even if only used internally).
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.
Oops, Olli already suggested this in his later comment, but yes, I agree
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.
The javadocs for add*Listener
could also mention when primary and secondary actions are triggered, since "primary" and "secondary" don't make it obvious
@@ -34,7 +34,7 @@ | |||
} | |||
}; | |||
|
|||
private final transient Set<ActionListener> nodeAppliedListeners = ConcurrentHashMap.newKeySet(); | |||
private final transient HashMap<String, ActionListener> nodeAppliedListeners = new HashMap<>(); |
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.
Should probably be ConcurrentHashMap
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.
One thing
public void addNodeAppliedListener(ActionListener listener) { | ||
nodeAppliedListeners.add(listener); | ||
public void addNodeAppliedListener(String key, ActionListener listener) { | ||
nodeAppliedListeners.put(key, listener); |
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.
In my previous comments, I overlooked one issue. As implemented here, this allows only one listener per key. It's possible that we never need more than one but at least in that case the name of this method should reflect that.
Anyways, I would probably just instead of key-listener map have to separate set of listeners, one per an event type. And add and remove methods for both.
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.
This is a nice addition and a good idea! 👍
Eventually we'll have to figure out how to let users know of this feature, but it is nice to have for "power users" even as is.
Btw, does double-clicking (without ctrl
) a submission also open the submission dialog, or does that open the submission in the browser?
Yes, double clicking submissions still opens them in a browser @nikke234 |
Ctrl-clicking a selected assignment doesn't work since it unselects it |
SonarCloud Quality Gate failed. |
So if I understood correctly:
Number 3 and 4 is potentially a weird combination, but then again I think the "submit assignment" icon also works when a submission (instead of an assignment) is selected, so it makes sense. Number 2 however seems undesirable/unintuitive? I think it would be nice if ctrl-click would always submit, although I wouldn't say it's worth it if it requires significant effort |
can you please link as described @jaakkonarhi |
It's related, but this doesn't directly close it, so let's unlink the issue for now. |
I suggest thinking about this approach a bit more... Currently, in modules subtab, |
@@ -151,9 +160,12 @@ public void valueChanged(@NotNull TreeSelectionEvent e) { | |||
|
|||
@Override | |||
public void mouseClicked(@NotNull MouseEvent e) { |
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.
do you think the logic inside the method can be tested fully or maybe at least to the extent of the conditional statements?
I'm starting to feel that the ctrl clicking is a bit useless, since you can submit with a single click with the popup menu, so I'm focusing on that now |
Closing this, as we agreed in a meeting that this is the way to go |
Description of the PR
Ctrl + left clicking an assignment opens the submission window. Also works when clicking submissions, which I think is fine. Part of #248
Testing
Have you updated the TESTING.md or other relevant documentation?