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

Tab for remaining fields #858

Merged
merged 4 commits into from
Mar 5, 2016
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -28,6 +28,8 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
- Moved default bibliography mode to general preferences tab
- Add dialog to show all preferences in their raw form plus some filtering
- Added Ordinal formatter (1 -> 1st etc)
- [#492](https://github.com/JabRef/jabref/issues/492): If no text is marked, the whole field is copied. Preview of pasted text in tool tip
- [#454](https://github.com/JabRef/jabref/issues/454) Add a tab that shows all remaining entry fields that are not displayed in any other tab
- The LaTeX to Unicode/HTML functionality is much improved by covering many more cases
- Ability to convert from LaTeX to Unicode in right-click field menu

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/net/sf/jabref/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,24 @@ private JabRefPreferences() {
}
}

public List<String> getCustomTabFieldNames() {
List<String> customFields = new ArrayList<>();

int defNumber = 0;
while(true) {
// saved as CUSTOMTABNAME_def{number} and ; separated
String fields = (String) defaults.get(CUSTOM_TAB_FIELDS + "_def" + defNumber);

if(fields == null || fields.isEmpty()) {
break;
}

customFields.addAll(Arrays.asList(fields.split(";")));
defNumber++;
}
return customFields;
}

public void setLanguageDependentDefaultValues() {
// Entry editor tab 0:
defaults.put(CUSTOM_TAB_NAME + "_def0", Localization.lang("General"));
Expand Down
14 changes: 2 additions & 12 deletions src/main/java/net/sf/jabref/gui/GenFieldsCustomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.labelpattern.LabelPatternUtil;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

public class GenFieldsCustomizer extends JDialog {

private final JPanel buttons = new JPanel();
Expand All @@ -55,8 +46,7 @@ public class GenFieldsCustomizer extends JDialog {
private final JabRefFrame parentFrame;
private final JButton revert = new JButton();


public GenFieldsCustomizer(JabRefFrame frame/*, EntryCustomizationDialog diag*/) {
public GenFieldsCustomizer(JabRefFrame frame) {
super(frame, Localization.lang("Set general fields"), false);
parentFrame = frame;
helpBut = new HelpAction(HelpFiles.generalFieldsHelp).getHelpButton();
Expand Down Expand Up @@ -181,4 +171,4 @@ private void revertActionPerformed() {
fieldsArea.setText(sb.toString());

}
}
}
54 changes: 36 additions & 18 deletions src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.io.IOException;
import java.io.StringWriter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
Expand Down Expand Up @@ -193,27 +195,35 @@ private void setupFieldPanels() {

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

List<String> fieldList = type.getRequiredFieldsFlat();
// required fields
List<String> requiredFields = type.getRequiredFieldsFlat();

EntryEditorTab reqPan = new EntryEditorTab(frame, panel, fieldList, this, true, false, Localization.lang("Required fields"));
if (reqPan.fileListEditor != null) {
fileListEditor = reqPan.fileListEditor;
EntryEditorTab requiredPanel = new EntryEditorTab(frame, panel, requiredFields, this, true, false, Localization.lang("Required fields"));
if (requiredPanel.fileListEditor != null) {
fileListEditor = requiredPanel.fileListEditor;
}
tabbed.addTab(Localization.lang("Required fields"), IconTheme.JabRefIcon.REQUIRED.getSmallIcon(), reqPan
tabbed.addTab(Localization.lang("Required fields"), IconTheme.JabRefIcon.REQUIRED.getSmallIcon(), requiredPanel
.getPane(), Localization.lang("Show required fields"));
tabs.add(reqPan);
tabs.add(requiredPanel);

// optional fields
List<String> displayedOptionalFields = new ArrayList<>();

if ((type.getOptionalFields() != null) && (type.getOptionalFields().size() >= 1)) {
EntryEditorTab optPan;
if (this.frame.getCurrentBasePanel().getBibDatabaseContext().isBiblatexMode()) {
optPan = new EntryEditorTab(frame, panel, type.getPrimaryOptionalFields(), this,
false, true, Localization.lang("Optional fields"));

if (!this.frame.getCurrentBasePanel().getBibDatabaseContext().isBiblatexMode()) {
optPan = new EntryEditorTab(frame, panel, type.getOptionalFields(), this,
false, false, Localization.lang("Optional fields"));
if (optPan.fileListEditor != null) {
fileListEditor = optPan.fileListEditor;
}
tabbed.addTab(Localization.lang("Optional fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan
.getPane(), Localization.lang("Show optional fields"));
tabs.add(optPan);
} else {
displayedOptionalFields.addAll(type.getPrimaryOptionalFields());
displayedOptionalFields.addAll(type.getSecondaryOptionalFields());

Set<String> deprecatedFields = new HashSet<>(EntryConverter.FIELD_ALIASES_TEX_TO_LTX.keySet());
deprecatedFields.add("year");
Expand Down Expand Up @@ -256,18 +266,26 @@ private void setupFieldPanels() {
.getPane(), Localization.lang("Show deprecated bibtex fields"));
tabs.add(optPan3);
}
} else {
optPan = new EntryEditorTab(frame, panel, type.getOptionalFields(), this, false, false,
Localization.lang("Optional fields"));
if (optPan.fileListEditor != null) {
fileListEditor = optPan.fileListEditor;
}
tabbed.addTab(Localization.lang("Optional fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(),
optPan.getPane(), Localization.lang("Show optional fields"));
tabs.add(optPan);
}
}

// other fields
List<String> displayedFields = Stream.concat(requiredFields.stream(), displayedOptionalFields.stream()).map(String::toLowerCase).collect(Collectors.toList());
List<String> otherFields = this.entry.getFieldNames().stream().map(String::toLowerCase).filter(f -> !displayedFields.contains(f)).collect(Collectors.toList());
otherFields.remove("bibtexkey");
otherFields.removeAll(Globals.prefs.getCustomTabFieldNames());

if(!otherFields.isEmpty()) {
EntryEditorTab otherPanel = new EntryEditorTab(frame, panel, otherFields, this,
false, false, Localization.lang("Other fields"));
if (otherPanel.fileListEditor != null) {
fileListEditor = otherPanel.fileListEditor;
}
tabbed.addTab(Localization.lang("Other fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), otherPanel
.getPane(), Localization.lang("Show remaining fields"));
tabs.add(otherPanel);
}

EntryEditorTabList tabList = Globals.prefs.getEntryEditorTabList();
for (int i = 0; i < tabList.getTabCount(); i++) {
EntryEditorTab newTab = new EntryEditorTab(frame, panel, tabList.getTabFields(i), this, false,
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,8 @@ value=
Show_preferences=
Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=
link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,9 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2448,7 +2448,12 @@ Show_preferences=Show_preferences
Save_actions=Save_actions
Enable_save_actions=Enable_save_actions
Enter_field_name_(e.g.,_title,_author)=Enter_field_name_(e.g.,_title,_author)

Other_fields=Other_fields
Show_remaining_fields=Show_remaining_fields

link_should_refer_to_a_correct_file_path=link_should_refer_to_a_correct_file_path
abbreviation_detected=abbreviation_detected
wrong_entry_type_as_proceedings_has_page_numbers=wrong_entry_type_as_proceedings_has_page_numbers
Copy_special=Copy_special

4 changes: 4 additions & 0 deletions src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1664,8 +1664,12 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
wrong_entry_type_as_proceedings_has_page_numbers=
Copy_special=

4 changes: 4 additions & 0 deletions src/main/resources/l10n/JabRef_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2451,8 +2451,12 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
wrong_entry_type_as_proceedings_has_page_numbers=
Copy_special=

4 changes: 4 additions & 0 deletions src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1703,8 +1703,12 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
wrong_entry_type_as_proceedings_has_page_numbers=
Copy_special=

5 changes: 5 additions & 0 deletions src/main/resources/l10n/JabRef_in.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1685,8 +1685,13 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=


Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
wrong_entry_type_as_proceedings_has_page_numbers=
Copy_special=

3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,9 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/l10n/JabRef_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2457,8 +2457,13 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=


Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
wrong_entry_type_as_proceedings_has_page_numbers=
Copy_special=

3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,9 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_no.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2857,6 +2857,9 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,9 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,9 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,9 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=

link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_vi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2455,6 +2455,8 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=
link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2452,6 +2452,8 @@ Show_preferences=

Enter_field_name_(e.g.,_title,_author)=

Other_fields=
Show_remaining_fields=
link_should_refer_to_a_correct_file_path=

abbreviation_detected=
Expand Down