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.
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
Implement task progress indicator (and dialog) in the toolbar #6443
Implement task progress indicator (and dialog) in the toolbar #6443
Changes from 2 commits
fdfe074
6fd1811
b883491
255a6e4
38dd89d
1b2aaa6
baf9bd0
40a8feb
cac989b
8f525b8
c877431
1ad9598
cd4e38e
23f8cf0
4628c3d
90ff19e
62d7c14
008d55e
a9f4493
66ac316
e9a7176
d7442cc
5defe3e
fba9c70
6a62e6f
a97af13
3ee4571
44d9ca8
bd2eefd
41efc04
2c9ccea
ff9ce00
d56138b
cf10859
fcb1d0c
396411a
e24c141
478ee05
0557c67
23b7e69
e3ae796
3db3997
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Instead of using a real dialog, what about using a collapse overlay similar to how it's done in firefox?
https://github.com/controlsfx/controlsfx/wiki/ControlsFX-Features#popover
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.
Uh fancy! I'll look into it!
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.
That looks much better! Great idea!
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.
For the bindings to update, you need to add the list as a dependency (second argument of the
createXBinding
method). In the case of lists, however, its easier to useEasyBind.combine
: https://github.com/TomasMikula/EasyBind#combine-listThere 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.
Aha, that looks useful.
However, I think I am running into some typing issues which I am struggling to resolve.
With the library you pointed me to, I wound up with the following:
public Binding<Boolean> anyTaskRunningBinding = EasyBind.combine( backgroundTasks, stream -> stream.anyMatch(Task::getProgress) );
This gives me an error that it expects a Binding, but gets a MonadicBinding.
If I just cast it, I get the following:
no instance(s) of type variable(s) T exist so that Task conforms to ObservableValue<? extends T>
I think this is the issue I need to resolve first. As the example in the library works fine, I guess the conversion from MonadicBinding to Binding is then done implicitly, is that correct?
I struggle solving this because I dont know the type parameter of the tasks I am storing.
When storing, the Task has type V:
https://github.com/btut/jabref/blob/b8834914e5e735abaa7a710216888abe6bf54277/src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java#L99-L104
But in the list I just use Task:
https://github.com/btut/jabref/blob/b8834914e5e735abaa7a710216888abe6bf54277/src/main/java/org/jabref/gui/StateManager.java#L49
How do I need to change the list in order for it to work?
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.
Add the generics to the Task as welll:
private final UiThreadObservableList<Task<V>> backgroundTasks = new UiThreadObservableList(FXCollections.observableArrayList());
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.
But where would I get the V from in this case?
Cannot resolve symbol 'V'
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 changed it to Task<?> now and now the progress, title and message properties make their way through to the dialogue.
I still cannot create the bindings for the progress indicator though.
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.
That change also allows me to use EasyBind's listBind to bind the task list in the view to the task list in StateManager.
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.
Here is the first peak at a download in the dialogue (which will probably be changed to a popover later). As you can see, the download task has it's title and message set and progress is updated fine. However, there are still a lot of tasks that do not have any details.
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.
Looks good already!
There are a lot of tasks which don't concern file downloads and just perform some operations in the background. If you search for all references from backgrond task you probably have to adjust each one to add a meaningful description
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 that should be doable. But before I do that: is it a good idea to have all background tasks listed? Or should we just show downloads? If we go with the first option, I suggest turning off the retain-tasks feature of the task view. Then, all completed tasks will automatically disappear. This way we have less tasks that only ran for a very little time filling up the view.
I got the bindings to work by storing a list of Property<Task> Instead of Task. That does the trick for the progress indicator. It now is indeterminate when one of the tasks has an indeterminate progress and shows the average progress otherwise (100% if no tasks are running).
For some reason, this breaks the task view. Since I now store a list of properties, and not a list of tasks, I cannot bind them directly to the view, so I went back to doing it manually, but that does not seem to work.
https://github.com/btut/jabref/blob/38dd89dce28b72d195de18b848b011532ef1f868/src/main/java/org/jabref/gui/taskprogressmanager/TaskProgressDialog.java#L34-L47
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.
Now I just converted the list of properties back into a list of tasks using EasyBind and the bind that list to the list of tasks in the view (again using EasyBind). Now both the indicator and the dialogue work fine and are updated with the running tasks!