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

Add file description to gui and fix sync bug #3210

Merged
merged 9 commits into from
Sep 20, 2017
Merged

Add file description to gui and fix sync bug #3210

merged 9 commits into from
Sep 20, 2017

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Sep 11, 2017

Fixes #3208

  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)
  • If you changed the localization: Did you run gradle localizationUpdate?

Add tests for identifying file descr bug
@tobiasdiez
Copy link
Member

The problem is that the changes in the underlying LinkedFile are not propagated to the list LinkedFilesEditorViewModel.files so that the serialization

private static String getStringRepresentation(List<LinkedFileViewModel> files) {
// Only serialize linked files, not the ones that are automatically found
List<LinkedFile> filesToSerialize = files.stream()
.filter(file -> !file.isAutomaticallyFound())
.map(LinkedFileViewModel::getFile)
.collect(Collectors.toList());
return FileFieldWriter.getStringRepresentation(filesToSerialize);
}
is never called. By the way, also changes to the file name or icon do not trigger an update and thus are not serialized.

As a solution, I propose to convert the data fields in LinkedFile to real properties, add Observable[] getObservables() to LinkedFile and return these observables here:

public Observable[] getObservables() {
return new Observable[] {this.downloadProgress, this.isAutomaticallyFound};
}

Ps: Can you pls add a screenshot how the file editor now looks like with the description added (especially when the file link is relatively long). Thanks.

* upstream/master:
  Localization: French: Translation of a new string (#3212)
  Fix #2775: Hyphens in last names are properly parsed (#3209)
  Followup to Issue #3167 (#3202)
  Update mockito-core from 2.9.0 -> 2.10.0
@Siedlerchr
Copy link
Member Author

Siedlerchr commented Sep 13, 2017

@tobiasdiez I did as you suggested, but still does not work. I think it has something to do with the LIstProperty, but I am not that deep inside javafx binding stuff to know why it is not synced

}

public Observable[] getObservables() {
return new Observable[] {this.downloadProgress, this.isAutomaticallyFound};
Copy link
Member

Choose a reason for hiding this comment

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

you need to return description, link, fileType here (and move downloadProgress and isAutomaticallyFound back to the viewmodel).

The observable tell javafx which properties mark the object as changed, i.e. if description is changed this should mark the LinkedFile as changed and thus also LinkedFileViewModel and thus finally the list

private final ListProperty<LinkedFileViewModel> files = new SimpleListProperty<>(FXCollections.observableArrayList(LinkedFileViewModel::getObservables));
.
For more details see https://docs.oracle.com/javase/8/javafx/api/javafx/collections/FXCollections.html#observableList-java.util.List-javafx.util.Callback- or https://stackoverflow.com/questions/31687642/callback-and-extractors-for-javafx-observablelist

@Siedlerchr
Copy link
Member Author

Yeah! Got it now!
grafik

Fix serializing
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Sep 13, 2017
@Siedlerchr Siedlerchr added this to the v4.0 milestone Sep 13, 2017
add changelog
@Siedlerchr Siedlerchr changed the title [WIP] Add file description to gui and fix sync bug Add file description to gui and fix sync bug Sep 13, 2017
Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

Codewise this looks good to me (except a few very minor remarks).
However, I'm still not convinced that we should add the description of the file to the list. In my opinion, it now looks cramped and has too much information, without really helping (for long file names, you need to scroll in order to read the description - which is more inconvenient then hovering the link). In my view it would be sufficient to decrease the time until the tooltip appears (which is relatively easy or see disscussion).

return new Observable[] {this.downloadProgress, this.isAutomaticallyFound};
List<Observable> observables = new ArrayList<>(Arrays.asList(linkedFile.getObservables()));
observables.add(downloadOngoing);
observables.add(downloadProgress);
Copy link
Member

Choose a reason for hiding this comment

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

also add isAutomaticallyFound

Copy link

@notuntoward notuntoward Sep 15, 2017

Choose a reason for hiding this comment

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

Just budding in here...

The file list would be cleaner if the filenames weren't shown when there is a description, as was done in JabRef 3.x. If there are very long descriptions, it will still be cluttered, but in my opinion, tooltips aren't an improvement.

The problem with descriptions only in tooltips is that you have to mouse over each one. This makes JabRef harder to use:

  1. It forces you to lift your hands off the keyboard, but more importantly,
  2. You can't scan the descriptions at a glance. Instead, you have to mouse over the first one, then mouse over the next one (which causes the previous description to vanish), and so on.

You can simulate the user experience by having somebody else make you a JabRef entry with, say five files with slightly different descriptions -- this is what your own entries will look like to you, a couple years after you have made them. You won't remember anything.

Now, try to decide which file to open. With tooltips, you see only one description at a time, like you're viewing them through a straw. Now compare that with the JabRef 3.x experience, where all descriptions are visible; with a glance, you can comprehend them all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds reasonable!

Copy link
Member Author

Choose a reason for hiding this comment

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

I now changed the order: Description is shown first and then the file link

Copy link

@notuntoward notuntoward Sep 15, 2017

Choose a reason for hiding this comment

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

Come to think of it, you could even make the filename a tooltip. Once you've got the description, the filename is probably not so useful, but in some situation, you still might want to know it.

But then again, there is the "see everything at a glance" argument I just made...

@@ -7,7 +7,7 @@

public class FileFieldWriter {

private FileFieldWriter() {
FileFieldWriter() {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this constructor not private anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Was a relict from testing. Didn't see that it had static method on the first try

* upstream/master:
  Add tests for removal changes
  Improve telemetry (#3218)
  Real test linking real other entry (#3214)
  Check for explicit group at different location
  Update java-string-similarity from 0.24 -> 1.0.0
  Only remove ExplicitGroups from entries, but not keyword-based groups
  Remove unused import in GroupTreeNode
  Move getEntriesInGroup to GroupTreeNode
  Inline Consumer updateViewModel
  Undo IntelliJ autoformat of FXML annotations
  Remove unused import
  Rewrite selection logic to avoid NPEs
  Clear group selection when a group is removed
  Also remove a group from entries when you remove it
Show description first then file link
remove unnecesary separator
Copy link
Member

@lenhard lenhard left a comment

Choose a reason for hiding this comment

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

Apart from a few very minor things, the code looks fine. +1 for merge.

@@ -69,6 +69,7 @@ public LinkedFilesEditorViewModel(String fieldName, AutoCompleteSuggestionProvid
text,
LinkedFilesEditorViewModel::getStringRepresentation,
this::parseToFileViewModel);

Copy link
Member

Choose a reason for hiding this comment

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

Very minor, but as far as I can see this blank line is unnecessary.

out.writeUTF(getLink());
out.writeUTF(getDescription());
out.flush();

Copy link
Member

Choose a reason for hiding this comment

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

Very minor, but as far as I can see this blank line is unnecessary.

fileType = new SimpleStringProperty(in.readUTF());
link = new SimpleStringProperty(in.readUTF());
description = new SimpleStringProperty(in.readUTF());

Copy link
Member

Choose a reason for hiding this comment

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

Very minor, but as far as I can see this blank line is unnecessary.

* upstream/master:
  Don't highlight odd rows in file list editor (#3223)
  Fix assertion by removing typo (#3220)
  Update assertion to change of online reference (#3221)
  Put in null return
  Reformatted code, renamed method, added try/catch
  Fix null return
  Changed from Path to Optional<Path>
  Added logic to check whether linked file already exists
@Siedlerchr Siedlerchr merged commit c47d2a4 into master Sep 20, 2017
@Siedlerchr Siedlerchr deleted the fileDescr branch September 20, 2017 08:26
@tobiasdiez
Copy link
Member

I just discovered that there is additional space between the icon and the file name if the file doesn't have a description. Can you please fix this. Thanks!

@Siedlerchr
Copy link
Member Author

Fixed in master.

Siedlerchr added a commit that referenced this pull request Sep 23, 2017
* upstream/master: (188 commits)
  Show file description only if not empty
  Add file description to gui and fix sync bug (#3210)
  Don't highlight odd rows in file list editor (#3223)
  Fix assertion by removing typo (#3220)
  Update assertion to change of online reference (#3221)
  Put in null return
  Reformatted code, renamed method, added try/catch
  Add tests for removal changes
  Improve telemetry (#3218)
  Real test linking real other entry (#3214)
  Check for explicit group at different location
  Update java-string-similarity from 0.24 -> 1.0.0
  Only remove ExplicitGroups from entries, but not keyword-based groups
  Localization: French: Translation of a new string (#3212)
  Fix null return
  Changed from Path to Optional<Path>
  Fix #2775: Hyphens in last names are properly parsed (#3209)
  Followup to Issue #3167 (#3202)
  Remove unused import in GroupTreeNode
  Move getEntriesInGroup to GroupTreeNode
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants