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

Year/date format suggestion #2186

Merged
merged 9 commits into from
Oct 26, 2016
Merged

Year/date format suggestion #2186

merged 9 commits into from
Oct 26, 2016

Conversation

grimes2
Copy link
Contributor

@grimes2 grimes2 commented Oct 23, 2016

Year/date format suggestion. The change adds a greyed-out suggestion for the recommended format of the field. Example: for the date field the format should be yyyy-mm-dd.

  • 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?

@koppor
Copy link
Member

koppor commented Oct 23, 2016

The idea is good. Shouldn't the ifs be else ifs?

Further date/time rework is discussed at JabRef#130.

Suggestion: you could elaborate a bit in the PR description. If one reads the notifications via mail, one cannot directly see the diff and get the idea.

@grimes2
Copy link
Contributor Author

grimes2 commented Oct 23, 2016

I'm not sure, but else if s were eventually skipped.

@grimes2
Copy link
Contributor Author

grimes2 commented Oct 24, 2016

Please set label "ready-for-review". Thanks.

@matthiasgeiger matthiasgeiger added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 24, 2016
prompt = String.format("YYYY-MM-DD");
}
if (field.equals(FieldName.URL)) {
prompt = String.format("http://");
Copy link
Member

Choose a reason for hiding this comment

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

Better suggest https://

@lenhard
Copy link
Member

lenhard commented Oct 25, 2016

Tested locally and looks good! It is also interesting to see that we have not quite listed all BibLaTeX fields.

Very minor issue: Could you add a changelog entry? After all something visible has changed (New suggestions in certain fields in the entry editor). Then I would merge.

@koppor
Copy link
Member

koppor commented Oct 25, 2016

Could you also check the biblatex mode? editora, editorb, editorc, translator, ...?

@lenhard
Copy link
Member

lenhard commented Oct 25, 2016

@koppor What exactly do you mean? Those fields (except URL) are only visible in the entry editor in biblatex mode anyway.

@grimes2
Copy link
Contributor Author

grimes2 commented Oct 25, 2016

Everything ok with editora, editorb... It only makes sense to define a field name constant for this fields, if you want to use the constant somewhere else in the code.

@lenhard
Copy link
Member

lenhard commented Oct 25, 2016

@grimes2 @koppor Excellent hint! And also something additional to do in this PR!

Please have a look at net.sf.jabref.model.entry.BibLatexEntryTypes. Reuse your newly introduced field name constants in the definition of the entry types (where the string representations are still used directly). Also, you could introduce field name constants for every field name that is still used explicitly as string in the type definitions. This is, I think, what @koppor suggests. It would improve the types, since we would have more static checking.

@lenhard
Copy link
Member

lenhard commented Oct 25, 2016

The replacement looks good!

Now, one more refactoring (and apologies for all the requests). After looking at the code a second time, I think @koppor is correct in that this should be if else blocks. After all, if field.equals(FieldName.YEAR) is true, field.equals(FieldName.DATE) can never be true. Furthermore, the code blocks should be reversed, e.g. FieldName.YEAR.equals(field). This has the same outcome, but we are very sure that FieldName.YEAR will never be null, whereas field might be just be for some buggy reason. The code would be a little more stable if equals is invoked on FieldName.YEAR (no NullPointerException). Finally, the whole prompt selection could be extracted into a new method private String getPrompt() or a similar name. This would make setupPanel a little less complex.

Thanks for your patience with our requests, we are just trying to get the best quality code :-)

@tobiasdiez
Copy link
Member

tobiasdiez commented Oct 25, 2016

why not just switch(field) instead of if + else?

After @lenhard's comments are implemented 👍 for merge.

@lenhard
Copy link
Member

lenhard commented Oct 25, 2016

@tobiasdiez Because switches are ugly and if-elseifs are beautiful :-P

Let us leave that open for @grimes2

prompt = String.format("%1$s and %1$s and others", Localization.lang("Firstname Lastname"));
break;
case FieldName.EDITOR:
prompt = String.format("%1$s andk %1$s and others", Localization.lang("Firstname Lastname"));
Copy link
Member

Choose a reason for hiding this comment

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

is the "k" after and a typo?

@Siedlerchr
Copy link
Member

Code looks good to me!

@lenhard Switches are compiled to more efficient bytecode and instead of chained if/else ifs they are actually better readable:
http://www.artima.com/underthehood/flowP.html
http://stackoverflow.com/questions/6705955/why-switch-is-faster-than-if

@grimes2
Copy link
Contributor Author

grimes2 commented Oct 26, 2016

The general form of the ISSN code is NNNN-NNNC (Wikipedia). Should I add this form as a suggestion to the ISSN field?

@matthiasgeiger
Copy link
Member

I think a Suggestion for ISSN is not necessary - there is only one existing Format. And if you search for the ISSN of Journal it should be found in this format.

@lenhard
Copy link
Member

lenhard commented Oct 26, 2016

@Siedlerchr: Switches are the source of many infamous switch-fall-through bugs (Apple's certificate validation system for example, if I remember it correctly), which is why I try to avoid them. To me, a potential increase in maintainability beats a potential improvement in performance any day. But anyway, there is not really a point in arguing about this.

To me the current solution is fine and I am merging it now. @grimes2 Thank you very much for your contribution!

@lenhard lenhard merged commit a1b838a into JabRef:master Oct 26, 2016
@grimes2 grimes2 mentioned this pull request Oct 26, 2016
6 tasks
@grimes2 grimes2 deleted the yearformat branch October 26, 2016 17:23
@koppor
Copy link
Member

koppor commented Oct 27, 2016

Sorry for the late reply. I mean that at "Optional fields 2", all fields containing persons should also contain such a help text, shouldn't they?

grabbed_20161027-121900

At editor, it works (even though, DOI could also have a help text to prevent users keying in the https://dx.doi.org/ prefix)

grabbed_20161027-122043

@grimes2
Copy link
Contributor Author

grimes2 commented Oct 27, 2016

@bartsch-dev refactors the suggestion switch in EntryEditorTab (#2199). He can easily add further cases. In DOI field is the DOI-Resolver https://dx.doi.org/ not allowed? The Standard DOI is in the form10.ORGANISATION/ID

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.

7 participants