Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

jaakkonakaza
Copy link
Member

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

unit integration manual
  • new unit tests created
  • all unit tests pass
  • new integration tests created
  • all integration tests pass
  • manual testing went well

Have you updated the TESTING.md or other relevant documentation?

  • Yes
  • Not yet. I will do it next.
  • Not relevant

Copy link
Member

@OlliKiljunen OlliKiljunen left a 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);
Copy link
Member

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.

Copy link
Member Author

@jaakkonakaza jaakkonakaza Jan 8, 2021

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

Copy link
Contributor

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).

Copy link
Contributor

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

Copy link
Contributor

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<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be ConcurrentHashMap

Copy link
Member

@OlliKiljunen OlliKiljunen left a 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);
Copy link
Member

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.

Copy link
Contributor

@nikke234 nikke234 left a 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?

@jaakkonakaza
Copy link
Member Author

Yes, double clicking submissions still opens them in a browser @nikke234

@jaakkonakaza
Copy link
Member Author

Ctrl-clicking a selected assignment doesn't work since it unselects it

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2021

@nikke234
Copy link
Contributor

nikke234 commented Jan 8, 2021

So if I understood correctly:

  1. ctrl-clicking an unselected assignment opens the submission dialog
  2. ctrl-clicking a selected assignment unselects it
  3. ctrl-clicking a submission opens the submission dialog for the corresponding assignment
  4. double-clicking a submission opens the submission in a browser.

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

@superseacat
Copy link
Member

can you please link as described @jaakkonarhi

@superseacat superseacat requested review from superseacat and a team January 9, 2021 10:38
@nikke234
Copy link
Contributor

It's related, but this doesn't directly close it, so let's unlink the issue for now.

@superseacat
Copy link
Member

  1. ctrl-clicking an unselected assignment opens the submission dialog
  2. ctrl-clicking a selected assignment unselects it
  3. ctrl-clicking a submission opens the submission dialog for the corresponding assignment
  4. double-clicking a submission opens the submission in a browser.

I suggest thinking about this approach a bit more... Currently, in modules subtab, ctrl+click regardless of the previous selection state selects and unselects correspondingly, however, allows for multiple selections. And hence, the multiple selections do not make that much sense in assignments subtab, how much do we want to retain the uniform approach between subtabs?

@@ -151,9 +160,12 @@ public void valueChanged(@NotNull TreeSelectionEvent e) {

@Override
public void mouseClicked(@NotNull MouseEvent e) {
Copy link
Member

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?

@jaakkonakaza
Copy link
Member Author

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

@superseacat
Copy link
Member

superseacat commented Jan 11, 2021

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

let's discuss after the daily!
A13usaonutL _AC_CLa_2140,2000_61+2E4yqnzL png_0,0,2140,2000+0 0,0 0,2140 0,2000 0_SX466 _SX _UX _SY UY

@nikke234
Copy link
Contributor

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

@nikke234 nikke234 closed this Jan 11, 2021
@jaakkonakaza jaakkonakaza deleted the exercise-clicks branch January 11, 2021 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants