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

Other fields fix and changes #2075

Merged
merged 5 commits into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Fixed [#2060](https://github.com/JabRef/jabref/issues/2060): Medline fetcher now imports data in UTF-8 encoding
- Fixed file menu displays wrong hotkey in the German translation
- Fixed [#2090](https://github.com/JabRef/jabref/issues/#2090): If special fields were not selected, two menu item separator were shown
- Fixed [#2064](https://github.com/JabRef/jabref/issues/2064): Not all `other fields` are shown on entry change of same type

### Removed
- Removed 2nd preview style
- The non-supported feature of being able to define file directories for any extension is removed. Still, it should work for older databases using the legacy `ps` and `pdf` fields, although we strongly encourage using the `file` field.
- Automatic migration for the `evastar_pdf` field is removed.
- We removed the customizable "content selectors" since they are replaced by the auto-completion feature
- Removed optional fields from `other fields` (BibTeX), Removed deprecated fields from `other fields` (BibLaTeX)



Expand Down
26 changes: 6 additions & 20 deletions src/main/java/net/sf/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1658,28 +1658,14 @@ public void showEntry(final BibEntry be) {
*/
public EntryEditor getEntryEditor(BibEntry entry) {
EntryEditor entryEditor;
if (entryEditors.containsKey(entry.getType())) {
EntryEditor visibleNow = currentEditor;

// We already have an editor for this entry type.
entryEditor = entryEditors.get(entry.getType());

// If the cached editor is not the same as the currently shown one,
// make sure the current one stores its current edit:
if ((visibleNow != null) && (!(entryEditor.equals(visibleNow)))) {
visibleNow.storeCurrentEdit();
}
// We must instantiate a new editor for this type. First make sure the old one
// stores its last edit:
storeCurrentEdit();
// Then start the new one:
entryEditor = new EntryEditor(frame, BasePanel.this, entry);

entryEditor.switchTo(entry);
} else {
// We must instantiate a new editor for this type. First make sure the old one
// stores its last edit:
storeCurrentEdit();
// Then start the new one:
entryEditor = new EntryEditor(frame, BasePanel.this, entry);

entryEditors.put(entry.getType(), entryEditor);
}
entryEditors.put(entry.getType(), entryEditor);
return entryEditor;
}

Expand Down
29 changes: 18 additions & 11 deletions src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.swing.AbstractAction;
import javax.swing.Action;
Expand Down Expand Up @@ -226,24 +225,28 @@ private void setupFieldPanels() {
tabbed.removeAll();
tabs.clear();

EntryType type = EntryTypes.getTypeOrDefault(entry.getType(), this.frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
EntryType type = EntryTypes.getTypeOrDefault(entry.getType(),
this.frame.getCurrentBasePanel().getBibDatabaseContext().getMode());

// required fields
List<String> requiredFields = addRequiredTab(type);
addRequiredTab(type);

// optional fields
List<String> displayedOptionalFields = new ArrayList<>();
Set<String> deprecatedFields = new HashSet<>(EntryConverter.FIELD_ALIASES_TEX_TO_LTX.keySet());
Set<String> usedOptionalFieldsDeprecated = new HashSet<>(deprecatedFields);

if ((type.getOptionalFields() != null) && !type.getOptionalFields().isEmpty()) {
if (!frame.getCurrentBasePanel().getBibDatabaseContext().isBiblatexMode()) {
displayedOptionalFields.addAll(type.getOptionalFields());

addOptionalTab(type);
} else {
displayedOptionalFields.addAll(type.getPrimaryOptionalFields());
displayedOptionalFields.addAll(type.getSecondaryOptionalFields());

addOptionalTab(type);

Set<String> deprecatedFields = new HashSet<>(EntryConverter.FIELD_ALIASES_TEX_TO_LTX.keySet());
deprecatedFields.add(FieldName.YEAR);
deprecatedFields.add(FieldName.MONTH);
List<String> secondaryOptionalFields = type.getSecondaryOptionalFields();
Expand All @@ -260,7 +263,6 @@ private void setupFieldPanels() {
}

// Get all optional fields which are deprecated
Set<String> usedOptionalFieldsDeprecated = new HashSet<>(deprecatedFields);
usedOptionalFieldsDeprecated.retainAll(optionalFieldsAndAliases);

// Add tabs
Expand All @@ -269,8 +271,8 @@ private void setupFieldPanels() {
if (optPan2.fileListEditor != null) {
fileListEditor = optPan2.fileListEditor;
}
tabbed.addTab(Localization.lang("Optional fields 2"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan2
.getPane(), Localization.lang("Show optional fields"));
tabbed.addTab(Localization.lang("Optional fields 2"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(),
optPan2.getPane(), Localization.lang("Show optional fields"));
tabs.add(optPan2);

if (!usedOptionalFieldsDeprecated.isEmpty()) {
Expand All @@ -280,16 +282,21 @@ private void setupFieldPanels() {
if (optPan3.fileListEditor != null) {
fileListEditor = optPan3.fileListEditor;
}
tabbed.addTab(Localization.lang("Deprecated fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan3
.getPane(), Localization.lang("Show deprecated BibTeX fields"));
tabbed.addTab(Localization.lang("Deprecated fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(),
optPan3.getPane(), Localization.lang("Show deprecated BibTeX fields"));
tabs.add(optPan3);
}
}
}

// other fields
List<String> displayedFields = Stream.concat(requiredFields.stream(), displayedOptionalFields.stream()).map(String::toLowerCase).collect(Collectors.toList());
List<String> otherFields = entry.getFieldNames().stream().map(String::toLowerCase).filter(f -> !displayedFields.contains(f)).collect(Collectors.toList());
List<String> displayedFields = type.getAllFields().stream().map(String::toLowerCase)
.collect(Collectors.toList());
List<String> otherFields = entry.getFieldNames().stream().map(String::toLowerCase)
.filter(f -> !displayedFields.contains(f)).collect(Collectors.toList());
if (!usedOptionalFieldsDeprecated.isEmpty()) {
otherFields.removeAll(usedOptionalFieldsDeprecated);
}
otherFields.remove(BibEntry.KEY_FIELD);
otherFields.removeAll(Globals.prefs.getCustomTabFieldNames());

Expand Down