From 9f04b0847c864d561c0c315d57cac7020cabe021 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 18 Apr 2017 19:29:59 +0200 Subject: [PATCH 1/4] Reimplement journal editior in JavaFX --- .../jabref/gui/entryeditor/EntryEditor.java | 5 -- .../gui/entryeditor/EntryEditorTab.java | 14 ++++- .../gui/entryeditor/FieldExtraComponents.java | 51 ------------------- .../jabref/gui/fieldeditors/FieldEditors.java | 10 ++-- .../gui/fieldeditors/JournalEditor.fxml | 19 +++++++ .../gui/fieldeditors/JournalEditor.java | 51 +++++++++++++++++++ .../fieldeditors/JournalEditorViewModel.java | 44 ++++++++++++++++ src/main/resources/l10n/JabRef_da.properties | 4 -- src/main/resources/l10n/JabRef_de.properties | 4 -- src/main/resources/l10n/JabRef_en.properties | 4 -- src/main/resources/l10n/JabRef_es.properties | 4 -- src/main/resources/l10n/JabRef_fa.properties | 4 -- src/main/resources/l10n/JabRef_fr.properties | 4 -- src/main/resources/l10n/JabRef_in.properties | 4 -- src/main/resources/l10n/JabRef_it.properties | 4 -- src/main/resources/l10n/JabRef_ja.properties | 4 -- src/main/resources/l10n/JabRef_nl.properties | 4 -- src/main/resources/l10n/JabRef_no.properties | 4 -- .../resources/l10n/JabRef_pt_BR.properties | 4 -- src/main/resources/l10n/JabRef_ru.properties | 4 -- src/main/resources/l10n/JabRef_sv.properties | 4 -- src/main/resources/l10n/JabRef_tr.properties | 4 -- src/main/resources/l10n/JabRef_vi.properties | 4 -- src/main/resources/l10n/JabRef_zh.properties | 4 -- 24 files changed, 131 insertions(+), 131 deletions(-) create mode 100644 src/main/java/org/jabref/gui/fieldeditors/JournalEditor.fxml create mode 100644 src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java create mode 100644 src/main/java/org/jabref/gui/fieldeditors/JournalEditorViewModel.java diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index d4f6e5b5f00..c2877973859 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -618,11 +618,6 @@ public Optional getExtra(final FieldEditor editor) { fieldExtras.contains(FieldProperty.DATE), fieldExtras.contains(FieldProperty.ISO_DATE)); } else if (fieldExtras.contains(FieldProperty.EXTERNAL)) { return FieldExtraComponents.getExternalExtraComponent(panel, editor); - } else if (fieldExtras.contains(FieldProperty.JOURNAL_NAME)) { - // Add controls for switching between abbreviated and full journal names. - // If this field also has a FieldContentSelector, we need to combine these. - return FieldExtraComponents.getJournalExtraComponent(frame, panel, editor, entry, contentSelectors, - storeFieldAction); } else if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) { return FieldExtraComponents.getSelectorExtraComponent(frame, panel, editor, contentSelectors, storeFieldAction); diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java index 3f2da06a572..4a3859ebec1 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java @@ -166,7 +166,7 @@ private void setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField fieldEditor.setAutoCompleteListener(autoCompleteListener); */ - FieldEditorFX fieldEditor = FieldEditors.getForField(fieldName, Globals.taskExecutor, new FXDialogService()); + FieldEditorFX fieldEditor = FieldEditors.getForField(fieldName, Globals.taskExecutor, new FXDialogService(), Globals.journalAbbreviationLoader, Globals.prefs.getJournalAbbreviationPreferences()); editors.put(fieldName, fieldEditor); /* // TODO: Reenable this @@ -182,6 +182,18 @@ private void setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField } */ + /* + // TODO: Reenable content selector + if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(editor.getFieldName()).isEmpty()) { + FieldContentSelector ws = new FieldContentSelector(frame, panel, frame, editor, storeFieldAction, false, + ", "); + contentSelectors.add(ws); + controls.add(ws, BorderLayout.NORTH); + } + //} else if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) { + //return FieldExtraComponents.getSelectorExtraComponent(frame, panel, editor, contentSelectors, storeFieldAction); + */ + builder.append(new FieldNameLabel(fieldName)); JFXPanel swingPanel = new JFXPanel(); diff --git a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java index ab466a57ab7..7f214d502ac 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java +++ b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java @@ -24,11 +24,8 @@ import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.gui.entryeditor.EntryEditor.StoreFieldAction; import org.jabref.gui.fieldeditors.FieldEditor; -import org.jabref.gui.undo.UndoableFieldChange; -import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseMode; -import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldProperty; import org.jabref.model.entry.InternalBibtexFields; import org.jabref.model.entry.Month; @@ -40,58 +37,10 @@ public class FieldExtraComponents { private static final Log LOGGER = LogFactory.getLog(FieldExtraComponents.class); - private static final String ABBREVIATION_TOOLTIP_TEXT = "" - + Localization.lang("Switches between full and abbreviated journal name if the journal name is known.") - + "
" + Localization.lang("To set up, go to") + " " + Localization.lang("Options") + " -> " - + Localization.lang("Manage journal abbreviations") + ""; private FieldExtraComponents() { } - /** - * Add controls for switching between abbreviated and full journal names. - * If this field also has a FieldContentSelector, we need to combine these. - * - * @param panel - * @param editor - * @param entry - * @param storeFieldAction - * @return - */ - public static Optional getJournalExtraComponent(JabRefFrame frame, BasePanel panel, FieldEditor editor, - BibEntry entry, Set contentSelectors, StoreFieldAction storeFieldAction) { - JPanel controls = new JPanel(); - controls.setLayout(new BorderLayout()); - if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(editor.getFieldName()).isEmpty()) { - FieldContentSelector ws = new FieldContentSelector(frame, panel, frame, editor, storeFieldAction, false, - ", "); - contentSelectors.add(ws); - controls.add(ws, BorderLayout.NORTH); - } - - - // Button to toggle abbreviated/full journal names - JButton button = new JButton(Localization.lang("Toggle abbreviation")); - button.setToolTipText(ABBREVIATION_TOOLTIP_TEXT); - button.addActionListener(actionEvent -> { - String text = editor.getText(); - JournalAbbreviationRepository abbreviationRepository = Globals.journalAbbreviationLoader - .getRepository(Globals.prefs.getJournalAbbreviationPreferences()); - if (abbreviationRepository.isKnownName(text)) { - String s = abbreviationRepository.getNextAbbreviation(text).orElse(text); - - if (s != null) { - editor.setText(s); - storeFieldAction.actionPerformed(new ActionEvent(editor, 0, "")); - panel.getUndoManager().addEdit(new UndoableFieldChange(entry, editor.getFieldName(), text, s)); - } - } - }); - - controls.add(button, BorderLayout.SOUTH); - return Optional.of(controls); - } - /** * Set up a mouse listener for opening an external viewer for with with EXTRA_EXTERNAL * diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index 00ad7941dc5..35d5d55a1e9 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -5,6 +5,8 @@ import org.jabref.Globals; import org.jabref.gui.DialogService; import org.jabref.gui.util.TaskExecutor; +import org.jabref.logic.journals.JournalAbbreviationLoader; +import org.jabref.logic.journals.JournalAbbreviationPreferences; import org.jabref.model.entry.FieldProperty; import org.jabref.model.entry.InternalBibtexFields; import org.jabref.preferences.JabRefPreferences; @@ -12,7 +14,7 @@ public class FieldEditors { - public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecutor, DialogService dialogService) { + public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecutor, DialogService dialogService, JournalAbbreviationLoader journalAbbreviationLoader, JournalAbbreviationPreferences journalAbbreviationPreferences) { final Set fieldExtras = InternalBibtexFields.getFieldProperties(fieldName); // TODO: Implement this @@ -24,11 +26,7 @@ public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecu } else if (fieldExtras.contains(FieldProperty.EXTERNAL)) { //return FieldExtraComponents.getExternalExtraComponent(panel, editor); } else if (fieldExtras.contains(FieldProperty.JOURNAL_NAME)) { - // Add controls for switching between abbreviated and full journal names. - // If this field also has a FieldContentSelector, we need to combine these. - //return FieldExtraComponents.getJournalExtraComponent(frame, panel, editor, entry, contentSelectors, storeFieldAction); - //} else if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) { - //return FieldExtraComponents.getSelectorExtraComponent(frame, panel, editor, contentSelectors, storeFieldAction); + return new JournalEditor(fieldName, journalAbbreviationLoader, journalAbbreviationPreferences); } else if (fieldExtras.contains(FieldProperty.DOI) || fieldExtras.contains(FieldProperty.EPRINT) || fieldExtras.contains(FieldProperty.ISBN)) { diff --git a/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.fxml new file mode 100644 index 00000000000..55c14134817 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.fxml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java new file mode 100644 index 00000000000..3362b9a849b --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java @@ -0,0 +1,51 @@ +package org.jabref.gui.fieldeditors; + +import java.util.Optional; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.Parent; +import javafx.scene.layout.HBox; + +import org.jabref.gui.util.ControlHelper; +import org.jabref.logic.journals.JournalAbbreviationLoader; +import org.jabref.logic.journals.JournalAbbreviationPreferences; +import org.jabref.model.entry.BibEntry; + + +public class JournalEditor extends HBox implements FieldEditorFX { + + private final String fieldName; + @FXML private JournalEditorViewModel viewModel; + @FXML private EditorTextArea textArea; + private Optional entry; + + public JournalEditor(String fieldName, JournalAbbreviationLoader journalAbbreviationLoader, JournalAbbreviationPreferences journalAbbreviationPreferences) { + this.fieldName = fieldName; + this.viewModel = new JournalEditorViewModel(journalAbbreviationLoader, journalAbbreviationPreferences); + + ControlHelper.loadFXMLForControl(this); + + viewModel.textProperty().bindBidirectional(textArea.textProperty()); + } + + public JournalEditorViewModel getViewModel() { + return viewModel; + } + + @Override + public void bindToEntry(BibEntry entry) { + this.entry = Optional.of(entry); + textArea.bindToEntry(fieldName, entry); + } + + @Override + public Parent getNode() { + return this; + } + + @FXML + private void toggleAbbreviation(ActionEvent event) { + viewModel.toggleAbbreviation(); + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/JournalEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/JournalEditorViewModel.java new file mode 100644 index 00000000000..ecd05e5f7e1 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/JournalEditorViewModel.java @@ -0,0 +1,44 @@ +package org.jabref.gui.fieldeditors; + +import java.util.Optional; + +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +import org.jabref.gui.AbstractViewModel; +import org.jabref.logic.journals.JournalAbbreviationLoader; +import org.jabref.logic.journals.JournalAbbreviationPreferences; +import org.jabref.logic.journals.JournalAbbreviationRepository; +import org.jabref.model.strings.StringUtil; + +public class JournalEditorViewModel extends AbstractViewModel { + private final JournalAbbreviationLoader journalAbbreviationLoader; + private final JournalAbbreviationPreferences journalAbbreviationPreferences; + private StringProperty text = new SimpleStringProperty(); + + public JournalEditorViewModel(JournalAbbreviationLoader journalAbbreviationLoader, JournalAbbreviationPreferences journalAbbreviationPreferences) { + this.journalAbbreviationLoader = journalAbbreviationLoader; + this.journalAbbreviationPreferences = journalAbbreviationPreferences; + } + + public StringProperty textProperty() { + return text; + } + + public void toggleAbbreviation() { + if (StringUtil.isBlank(text.get())) { + return; + } + + JournalAbbreviationRepository abbreviationRepository = journalAbbreviationLoader.getRepository(journalAbbreviationPreferences); + if (abbreviationRepository.isKnownName(text.get())) { + Optional nextAbbreviation = abbreviationRepository.getNextAbbreviation(text.get()); + + if (nextAbbreviation.isPresent()) { + text.set(nextAbbreviation.get()); + // TODO: Add undo + //panel.getUndoManager().addEdit(new UndoableFieldChange(entry, editor.getFieldName(), text, nextAbbreviation)); + } + } + } +} diff --git a/src/main/resources/l10n/JabRef_da.properties b/src/main/resources/l10n/JabRef_da.properties index 03bcff23388..edf5ce297b6 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Opsæt_eksterne_eksportfiltre Manage_custom_imports=Opsæt_eksterne_importfiltre Manage_external_file_types=Opsæt_eksterne_filtyper -Manage_journal_abbreviations=Opsæt_tidsskriftsforkortelser - Mark_entries=Mærk_poster Mark_entry=Mærk_post @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Denne_ This_operation_requires_one_or_more_entries_to_be_selected.=Denne_operation_kræver,_at_en_eller_flere_poster_er_valgt. -Toggle_abbreviation=Forkort/ekspander Toggle_entry_preview=Vis/skjul_forhåndsvisning Toggle_groups_interface=Vis/skjul_grupperingspanel Try_different_encoding=Prøv_en_anden_tegnkodning @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Kopier_\\cite{BibTeX-nøgler} Copy_BibTeX_key_and_title= File_rename_failed_for_%0_entries.= -To_set_up,_go_to=For_at_sætte_op,_gå_til Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=Ugyldig_DOI\:_'%0'. should_start_with_a_name= diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index e3dc2596def..57a8c11013b 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Verwalte_externe_Exportfilter Manage_custom_imports=Verwalte_externe_Importfilter Manage_external_file_types=Externe_Dateitypen_verwalten -Manage_journal_abbreviations=Abkürzungen_der_Zeitschriften_verwalten - Mark_entries=Einträge_markieren Mark_entry=Eintrag_markieren @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Für_d This_operation_requires_one_or_more_entries_to_be_selected.=Für_diesen_Vorgang_muss_mindestens_ein_Eintrag_ausgewählt_sein. -Toggle_abbreviation=Abkürzung_an-/abschalten Toggle_entry_preview=Eintragsvorschau_ein-/ausblenden Toggle_groups_interface=Gruppenansicht_ein-/ausblenden Try_different_encoding=Versuchen_Sie_es_mit_einer_anderen_Kodierung @@ -1852,7 +1849,6 @@ Copy_title=Kopiere_Titel Copy_\\cite{BibTeX_key}=\\cite{BibTeX_key}_kopieren Copy_BibTeX_key_and_title=BibTeX-Key_und_Titel_kopieren File_rename_failed_for_%0_entries.=Dateiumbennung_schlug_ür_%0_Einträge_fehl. -To_set_up,_go_to=Einstellungen_unter Merged_BibTeX_source_code=BibTeX-Quelltext_zusammengeführt Invalid_DOI\:_'%0'.=Ungültiger_DOI\:_'%0'. should_start_with_a_name=sollte_mit_einem_Name_beginnen diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index bdcb49c9292..221968244b9 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Manage_custom_exports Manage_custom_imports=Manage_custom_imports Manage_external_file_types=Manage_external_file_types -Manage_journal_abbreviations=Manage_journal_abbreviations - Mark_entries=Mark_entries Mark_entry=Mark_entry @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=This_o This_operation_requires_one_or_more_entries_to_be_selected.=This_operation_requires_one_or_more_entries_to_be_selected. -Toggle_abbreviation=Toggle_abbreviation Toggle_entry_preview=Toggle_entry_preview Toggle_groups_interface=Toggle_groups_interface Try_different_encoding=Try_different_encoding @@ -1852,7 +1849,6 @@ Copy_title=Copy_title Copy_\\cite{BibTeX_key}=Copy_\\cite{BibTeX_key} Copy_BibTeX_key_and_title=Copy_BibTeX_key_and_title File_rename_failed_for_%0_entries.=File_rename_failed_for_%0_entries. -To_set_up,_go_to=To_set_up,_go_to Merged_BibTeX_source_code=Merged_BibTeX_source_code Invalid_DOI\:_'%0'.=Invalid_DOI\:_'%0'. should_start_with_a_name=should_start_with_a_name diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index dec18576d03..15a7fac2189 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Administrar_esportaciones_personalizadas Manage_custom_imports=Administrar_importaciones_personalizadas Manage_external_file_types=Administrar_tipos_de_archivo_externos -Manage_journal_abbreviations=Administrar_abreviaturas_de_revistas - Mark_entries=Marcar_entradas Mark_entry=Marcar_entrada @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Esta_o This_operation_requires_one_or_more_entries_to_be_selected.=Esta_operación_requiere_seleccionar_una_o_más_entradas. -Toggle_abbreviation=Usar_abreviatura_si/no Toggle_entry_preview=Usar_vista_previa_de_la_entrada_si/no Toggle_groups_interface=Usar_interfaz_de_grupos_si/no Try_different_encoding=Probar_una_codificación_diferente @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Copiar_\\cite{clave_BibTeX} Copy_BibTeX_key_and_title=Copiar_clave_y_título_BibTeX File_rename_failed_for_%0_entries.=Ha_fallado_el_renombrado_para_%0_entradas. -To_set_up,_go_to=Para_configurar,_vaya_a Merged_BibTeX_source_code=Código_fuente_BibTex_fusionado Invalid_DOI\:_'%0'.=DOI_no_válida\:_'%0'. should_start_with_a_name=debería_comenzar_por_un_nombre diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index 814a5c82390..664a4d91d70 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -732,8 +732,6 @@ Manage_custom_exports= Manage_custom_imports= Manage_external_file_types= -Manage_journal_abbreviations= - Mark_entries= Mark_entry= @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.= This_operation_requires_one_or_more_entries_to_be_selected.= -Toggle_abbreviation= Toggle_entry_preview= Toggle_groups_interface= Try_different_encoding= @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}= Copy_BibTeX_key_and_title= File_rename_failed_for_%0_entries.= -To_set_up,_go_to= Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.= should_start_with_a_name= diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index de264d67d0a..b62be6347d4 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Gérer_les_exportations_personnalisées Manage_custom_imports=Gérer_les_importations_personnalisées Manage_external_file_types=Gérer_les_types_de_fichiers_externes -Manage_journal_abbreviations=Gérer_les_abréviations_de_journaux - Mark_entries=Etiqueter_ces_entrées Mark_entry=Etiqueter_l'entrée @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Cette_ This_operation_requires_one_or_more_entries_to_be_selected.=Cette_opération_nécessite_qu'une_ou_plusieurs_entrées_soient_sélectionnées. -Toggle_abbreviation=Afficher/Masquer_l'abréviation Toggle_entry_preview=Afficher/Masquer_l'aperçu Toggle_groups_interface=Afficher/Masquer_l'interface_des_groupes Try_different_encoding=Essayer_un_encodage_différent @@ -1852,7 +1849,6 @@ Copy_title=Copier_le_titre Copy_\\cite{BibTeX_key}=Copier_\\cite{clé_BibTeX} Copy_BibTeX_key_and_title=Copier_la_clef_BibTeX_et_le_titre File_rename_failed_for_%0_entries.=Le_renommage_des_fichiers_a_échoué_pour_%0_entrées. -To_set_up,_go_to=Pour_configurer,_voir Merged_BibTeX_source_code=Code_source_BibTeX_fusionné Invalid_DOI\:_'%0'.=DOI_invalide_\:_'%0'. should_start_with_a_name=devrait_débuter_par_un_nom diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index 7a876aad0e1..6ef62ecb4e3 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Mengatur_ekspor_atursendiri Manage_custom_imports=Mengatur_impor_atursendiri Manage_external_file_types=Pengaturan_program_eksternal -Manage_journal_abbreviations=Pengaturan_singkatan_jurnal - Mark_entries=Tandai_entri Mark_entry=Tandai_entri @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Operas This_operation_requires_one_or_more_entries_to_be_selected.=Operasi_ini_memerlukan_satu_atau_lebih_entri_yang_dipilih. -Toggle_abbreviation=Gunakan_singkatan Toggle_entry_preview=Gunakan_pratampilan_entri Toggle_groups_interface=Gunakan_antarmuka_grup Try_different_encoding=Coba_enkoding_lain @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Salin_\\cite{kunci_BibTeX} Copy_BibTeX_key_and_title=Salin_kunci_BibTeX_dan_judul File_rename_failed_for_%0_entries.=Perubahan_nama_berkas_gagal_untuk_%0_entri. -To_set_up,_go_to=Untuk_mengatur,_dari Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=DOI_salah\:_'%0'. should_start_with_a_name=harus_bermula_dengan_nama diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index 2de9f8d33c5..bffede959ac 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Gestione_delle_esportazioni_personalizzate Manage_custom_imports=Gestione_delle_importazioni_personalizzate Manage_external_file_types=Gestione_dei_tipi_di_file_esterni -Manage_journal_abbreviations=Gestione_delle_abbreviazioni_delle_riviste - Mark_entries=Contrassegna_voci Mark_entry=Contrassegna_voce @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Per_qu This_operation_requires_one_or_more_entries_to_be_selected.=Per_questa_operazione_una_o_più_voci_devono_essere_selezionate -Toggle_abbreviation=Mostra/Nascondi_l'abbreviazione Toggle_entry_preview=Mostra/Nascondi_l'anteprima Toggle_groups_interface=Mostra/Nascondi_l'interfaccia_dei_gruppi Try_different_encoding=Prova_codifiche_differenti @@ -1852,7 +1849,6 @@ Copy_title=Copia_titolo Copy_\\cite{BibTeX_key}=Copia_\\cite{chiave_BibTeX} Copy_BibTeX_key_and_title=Copia_la_chiave_BibTeX_ed_il_titolo File_rename_failed_for_%0_entries.=Rinominazione_dei_file_fallita_per_%0_voci. -To_set_up,_go_to=Per_configurare_vedi Merged_BibTeX_source_code=Codice_sorgente_BibTeX_accorpato Invalid_DOI\:_'%0'.=DOI_non_valido\:_'%0'. should_start_with_a_name=deve_cominciare_con_un_nome diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index 3616656d132..fc16c2f9f57 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -732,8 +732,6 @@ Manage_custom_exports=ユーザー書出の管理 Manage_custom_imports=ユーザー読込の管理 Manage_external_file_types=外部ファイル型の管理 -Manage_journal_abbreviations=学術誌名短縮形の管理 - Mark_entries=項目を標識 Mark_entry=項目を標識 @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=この This_operation_requires_one_or_more_entries_to_be_selected.=この操作を行うには、1つ以上の項目が選択されている必要があります。 -Toggle_abbreviation=短縮形/非短縮形の切替 Toggle_entry_preview=項目プレビューを入切 Toggle_groups_interface=グループ制御面を入切 Try_different_encoding=別のエンコーディングを試す @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=\\cite{BibTeX鍵}をコピー Copy_BibTeX_key_and_title=BibTeX鍵とタイトルをコピー File_rename_failed_for_%0_entries.=%0項目のファイル名変更が失敗しました。 -To_set_up,_go_to=設定するには、 Merged_BibTeX_source_code=統合後のBibTeXソースコード Invalid_DOI\:_'%0'.=無効なDOIです\:_'%0'. should_start_with_a_name=始まりは名前でなくてはなりません diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index 08a22e88951..be209473ca4 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Beheer_externe_exportfilters Manage_custom_imports=Beheer_externe_importfilters Manage_external_file_types= -Manage_journal_abbreviations=Beheer_tijdschrift_afkortingen - Mark_entries=Markeer_entries Mark_entry=Markeer_entry @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Deze_o This_operation_requires_one_or_more_entries_to_be_selected.=Deze_operatie_vereist_dat_een_of_meer_entries_geselecteerd_zijn. -Toggle_abbreviation=Toon_afkorting Toggle_entry_preview=Toon_entry_voorbeeld Toggle_groups_interface=Toon_groepenvenster Try_different_encoding=Probeer_een_andere_encodering @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Kopieer_\\cite{BibTeX-sleutel} Copy_BibTeX_key_and_title=Kopieer_BibTeX_sleutel_en_titel File_rename_failed_for_%0_entries.= -To_set_up,_go_to=Om_in_te_stellen,_ga_naar Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=Ongeldig_DOI\:_'%0'. should_start_with_a_name= diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index bd1304bcc4d..e7cccef94c9 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Sett_opp_eksterne_eksportfiltre Manage_custom_imports=Sett_opp_eksterne_importfiltre Manage_external_file_types=Sett_opp_eksterne_filtyper -Manage_journal_abbreviations=Sett_opp_journalforkortelser - Mark_entries=Merk_enheter Mark_entry=Merk_enhet @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Denne_ This_operation_requires_one_or_more_entries_to_be_selected.=Denne_operasjonen_krever_at_en_eller_flere_enheter_er_valgt. -Toggle_abbreviation=Forkort/ekspander Toggle_entry_preview=Vis/skjul_forh\u00e5ndsvisning Toggle_groups_interface=Vis/skjul_grupperingskontroll Try_different_encoding=Pr\u00f8v_en_annen_tegnkoding @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Kopier_\\cite{BibTeX-n\u00f8kkel} Copy_BibTeX_key_and_title=Kopier_BibTeX-n\u00f8kkel_og_tittel File_rename_failed_for_%0_entries.= -To_set_up,_go_to=For_\u00e5_sette_opp,_g\u00e5_til Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=Ugyldig_DOI\:_'%0'. should_start_with_a_name= diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index cba314df7f1..183ea4f61ed 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Gerenciar_exportações_personalizadas Manage_custom_imports=Gerenciar_importações_personalizadas Manage_external_file_types=Gerenciar_tipos_de_arquivo_externos -Manage_journal_abbreviations=Gerenciar_abreviações_de_periódicos - Mark_entries=Marcar_referências Mark_entry=Marcar_referências @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Esta_o This_operation_requires_one_or_more_entries_to_be_selected.=Esta_operação_exige_que_uma_ou_mais_referências_sejam_selecionadas -Toggle_abbreviation=Habilitar/Desabilitar_abreviação Toggle_entry_preview=Habilitar/Desabilitar_previsualização_da_referência Toggle_groups_interface=Habilitar/Desabilitar_interface_de_grupos Try_different_encoding=Tente_uma_codificação_diferente @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Copiar_como_\\cite{chave_BibTeX} Copy_BibTeX_key_and_title=Copiar_chave_BibTeX_e_título File_rename_failed_for_%0_entries.= -To_set_up,_go_to=Para_configurar,_acesse_o_menu Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=DOI_inválida\:_'%0'. should_start_with_a_name= diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index a656aee692c..2b4d7416ea1 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Управление_пользовательским_эк Manage_custom_imports=Управление_пользовательским_импортом Manage_external_file_types=Управление_внешними_типами_файлов -Manage_journal_abbreviations=Управление_сокращениями_для_журналов - Mark_entries=Метки_записей Mark_entry=Метка_записи @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Для This_operation_requires_one_or_more_entries_to_be_selected.=Для_этой_операции_необходимо_выбрать_одну_или_несколько_записей. -Toggle_abbreviation=Показать/скрыть_сокращения Toggle_entry_preview=Показать/скрыть_просмотр_записи Toggle_groups_interface=Показать/скрыть_интерфейс_групп Try_different_encoding=Используйте_другую_кодировку @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Копировать_\\цитировать{ключ_BibTeX} Copy_BibTeX_key_and_title=Копировать_ключ_и_заголовок_BibTeX File_rename_failed_for_%0_entries.=Ошибка_переименования_файла_для_%0_записи. -To_set_up,_go_to=Для_настройки_перейдите\: Merged_BibTeX_source_code=Объединенный_исходный_код_BibTeX Invalid_DOI\:_'%0'.=Недопустимый_DOI-адрес\:_'%0'. should_start_with_a_name=должно_начинаться_с_имени diff --git a/src/main/resources/l10n/JabRef_sv.properties b/src/main/resources/l10n/JabRef_sv.properties index f5524ab121a..c931ca042cd 100644 --- a/src/main/resources/l10n/JabRef_sv.properties +++ b/src/main/resources/l10n/JabRef_sv.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Hantera_egna_exporterare Manage_custom_imports=Hantera_egna_importerare Manage_external_file_types=Hantera_externa_filetyper -Manage_journal_abbreviations=Hantera_tidskriftsförkortningar - Mark_entries=Markera_poster Mark_entry=Markera_post @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Denna_ This_operation_requires_one_or_more_entries_to_be_selected.=Den_här_operationen_kräver_att_en_eller_flera_poster_är_valda. -Toggle_abbreviation=Växla_förkortning Toggle_entry_preview=Växla_postvisning Toggle_groups_interface=Växla_grupphantering Try_different_encoding=Prova_en_annan_teckenkodning @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Kopiera_\\cite{BibTeX-nyckel} Copy_BibTeX_key_and_title=Kopiera_BibTeX-nyckel_och_titel File_rename_failed_for_%0_entries.=Döpa_om_filen_misslyckades_för_%0_poster. -To_set_up,_go_to=För_att_ställa_in,_gå_till Merged_BibTeX_source_code=Kombinerad_BibTeX-källkod Invalid_DOI\:_'%0'.=Ogiltig_DOI\:_'%0'. should_start_with_a_name=ska_börja_med_ett_namn diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index 42ea786a800..0cbd58b518e 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Özel_dışa_aktarımları_yönet Manage_custom_imports=Özel_içe_aktarımları_yönet Manage_external_file_types=Harici_dosya_türlerini_yönet -Manage_journal_abbreviations=Degi_kısaltmalarını_yönet - Mark_entries=Girdileri_işaretle Mark_entry=Girdiyi_işaretle @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Bu_iş This_operation_requires_one_or_more_entries_to_be_selected.=Bu_işlem,_bir_ya_da_daha_çok_girdinin_seçili_olmasını_gerektirir. -Toggle_abbreviation=Kısaltmayı_aç/kapat Toggle_entry_preview=Girdi_önizlemeyi_aç/kapat Toggle_groups_interface=Grup_arayüzünü_aç/kapat Try_different_encoding=Başka_kodlama_deneyin @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=\\cite{BibTeX_anahtarı}'nı_kopyala Copy_BibTeX_key_and_title=BibTeX_anahtarı_ve_başlığını_kopyala File_rename_failed_for_%0_entries.=%0_girdide_dosya_yeniden_adlandırma_başarısız. -To_set_up,_go_to=Kurmak_için,_şuraya_git Merged_BibTeX_source_code=Birleşik_BibTeX_kaynak_kodu Invalid_DOI\:_'%0'.=Geçersiz_DOI\:_'%0'. should_start_with_a_name=bir_isimle_başlamalı diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index d6242c98d32..32d6748377e 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -732,8 +732,6 @@ Manage_custom_exports=Quản_lý_các_phép_xuất_tùy_chọn Manage_custom_imports=Quản_lý_các_phép_nhập_tùy_chọn Manage_external_file_types=Quản_lý_các_kiểu_tập_tin_ngoài -Manage_journal_abbreviations=Quản_lý_các_viết_tắt_tên_tạp_chí - Mark_entries=Đánh_dấu_các_mục Mark_entry=Đánh_dấu_mục @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=Lệnh This_operation_requires_one_or_more_entries_to_be_selected.=Lệnh_này_yêu_cầu_phải_chọn_trước_một_hoặc_nhiều_mục. -Toggle_abbreviation=Bật/tắt_viết_tắt Toggle_entry_preview=Bật/tắt_xem_trước_mục Toggle_groups_interface=Bật/tắt_giao_diện_nhóm Try_different_encoding=Thử_mã_hóa_khác @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=Chép\\trích_dẫn{khóa_BibTeX} Copy_BibTeX_key_and_title= File_rename_failed_for_%0_entries.= -To_set_up,_go_to=Để_cài_đặt,_chọn Merged_BibTeX_source_code= Invalid_DOI\:_'%0'.=DOI_không_hợp_lệ\:_'%0'. should_start_with_a_name= diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index 23b31522681..ba8bb010e1c 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -732,8 +732,6 @@ Manage_custom_exports=管理自定义导出器 Manage_custom_imports=管理自定义导入器 Manage_external_file_types=管理外部文件类型 -Manage_journal_abbreviations=管理期刊名称缩写 - Mark_entries=高亮标记多条记录 Mark_entry=高亮标记该记录 @@ -1252,7 +1250,6 @@ This_operation_requires_all_selected_entries_to_have_BibTeX_keys_defined.=此操 This_operation_requires_one_or_more_entries_to_be_selected.=这个操作要求选中一条或多条记录。 -Toggle_abbreviation=打开/关闭名称缩写 Toggle_entry_preview=打开/关闭记录预览 Toggle_groups_interface=打开/关闭组界面 Try_different_encoding=尝试其它编码 @@ -1852,7 +1849,6 @@ Copy_title= Copy_\\cite{BibTeX_key}=复制_\\cite{BibTeX_键值} Copy_BibTeX_key_and_title=复制_BibTeX_键值和标题 File_rename_failed_for_%0_entries.= -To_set_up,_go_to=要设置的话,请到 Merged_BibTeX_source_code=已合并_BibTeX_源代码 Invalid_DOI\:_'%0'.=不合法的_DOI\: should_start_with_a_name= From 91d19f9fa66d2f6cf275d38c66fe27c48549ae02 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 18 Apr 2017 19:53:15 +0200 Subject: [PATCH 2/4] Reimplement url editior in JavaFX --- .../jabref/gui/entryeditor/EntryEditor.java | 2 - .../gui/entryeditor/FieldExtraComponents.java | 59 ------------------- .../jabref/gui/fieldeditors/FieldEditors.java | 2 +- .../gui/fieldeditors/IdentifierEditor.fxml | 2 +- .../gui/fieldeditors/JournalEditor.fxml | 2 +- .../jabref/gui/fieldeditors/SimpleEditor.fxml | 2 +- .../jabref/gui/fieldeditors/UrlEditor.fxml | 19 ++++++ .../jabref/gui/fieldeditors/UrlEditor.java | 50 ++++++++++++++++ .../gui/fieldeditors/UrlEditorViewModel.java | 55 +++++++++++++++++ 9 files changed, 128 insertions(+), 65 deletions(-) create mode 100644 src/main/java/org/jabref/gui/fieldeditors/UrlEditor.fxml create mode 100644 src/main/java/org/jabref/gui/fieldeditors/UrlEditor.java create mode 100644 src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index c2877973859..3f1fb6c8e28 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -616,8 +616,6 @@ public Optional getExtra(final FieldEditor editor) { // double click AND datefield => insert the current date (today) return FieldExtraComponents.getDateTimeExtraComponent(editor, fieldExtras.contains(FieldProperty.DATE), fieldExtras.contains(FieldProperty.ISO_DATE)); - } else if (fieldExtras.contains(FieldProperty.EXTERNAL)) { - return FieldExtraComponents.getExternalExtraComponent(panel, editor); } else if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) { return FieldExtraComponents.getSelectorExtraComponent(frame, panel, editor, contentSelectors, storeFieldAction); diff --git a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java index 7f214d502ac..09c947cea9f 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java +++ b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java @@ -1,8 +1,6 @@ package org.jabref.gui.entryeditor; -import java.awt.BorderLayout; import java.awt.event.ActionEvent; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -14,14 +12,12 @@ import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; -import javax.swing.JPanel; import org.jabref.Globals; import org.jabref.gui.BasePanel; import org.jabref.gui.JabRefFrame; import org.jabref.gui.contentselector.FieldContentSelector; import org.jabref.gui.date.DatePickerButton; -import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.gui.entryeditor.EntryEditor.StoreFieldAction; import org.jabref.gui.fieldeditors.FieldEditor; import org.jabref.logic.l10n.Localization; @@ -41,61 +37,6 @@ public class FieldExtraComponents { private FieldExtraComponents() { } - /** - * Set up a mouse listener for opening an external viewer for with with EXTRA_EXTERNAL - * - * @param fieldEditor - * @param panel - * @return - */ - public static Optional getExternalExtraComponent(BasePanel panel, FieldEditor fieldEditor) { - JPanel controls = new JPanel(); - controls.setLayout(new BorderLayout()); - JButton button = new JButton(Localization.lang("Open")); - button.setEnabled(false); - button.addActionListener(actionEvent -> { - try { - JabRefDesktop.openExternalViewer(panel.getBibDatabaseContext(), fieldEditor.getText(), fieldEditor.getFieldName()); - } catch (IOException ex) { - panel.output(Localization.lang("Unable to open link.")); - } - }); - - controls.add(button, BorderLayout.SOUTH); - - // enable/disable button - /* - JTextComponent url = (JTextComponent) fieldEditor; - - url.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void changedUpdate(DocumentEvent documentEvent) { - checkUrl(); - } - - @Override - public void insertUpdate(DocumentEvent documentEvent) { - checkUrl(); - } - - @Override - public void removeUpdate(DocumentEvent documentEvent) { - checkUrl(); - } - - private void checkUrl() { - if (URLUtil.isURL(url.getText())) { - button.setEnabled(true); - } else { - button.setEnabled(false); - } - } - }); - */ - - return Optional.of(controls); - } - /** * Return a dropdown list containing Yes and No for fields with EXTRA_YES_NO * diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index 35d5d55a1e9..80f00c34bd5 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -24,7 +24,7 @@ public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecu //return FieldExtraComponents.getDateTimeExtraComponent(editor, // fieldExtras.contains(FieldProperty.DATE), fieldExtras.contains(FieldProperty.ISO_DATE)); } else if (fieldExtras.contains(FieldProperty.EXTERNAL)) { - //return FieldExtraComponents.getExternalExtraComponent(panel, editor); + return new UrlEditor(fieldName, dialogService); } else if (fieldExtras.contains(FieldProperty.JOURNAL_NAME)) { return new JournalEditor(fieldName, journalAbbreviationLoader, journalAbbreviationPreferences); } else if (fieldExtras.contains(FieldProperty.DOI) || diff --git a/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditor.fxml index f5f3c888828..6475d53ae00 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditor.fxml +++ b/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditor.fxml @@ -8,7 +8,7 @@ - + + diff --git a/src/main/java/org/jabref/gui/fieldeditors/UrlEditor.java b/src/main/java/org/jabref/gui/fieldeditors/UrlEditor.java new file mode 100644 index 00000000000..e8fe54855a6 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/UrlEditor.java @@ -0,0 +1,50 @@ +package org.jabref.gui.fieldeditors; + +import java.util.Optional; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.Parent; +import javafx.scene.layout.HBox; + +import org.jabref.gui.DialogService; +import org.jabref.gui.util.ControlHelper; +import org.jabref.model.entry.BibEntry; + + +public class UrlEditor extends HBox implements FieldEditorFX { + + private final String fieldName; + @FXML private UrlEditorViewModel viewModel; + @FXML private EditorTextArea textArea; + private Optional entry; + + public UrlEditor(String fieldName, DialogService dialogService) { + this.fieldName = fieldName; + this.viewModel = new UrlEditorViewModel(dialogService); + + ControlHelper.loadFXMLForControl(this); + + viewModel.textProperty().bindBidirectional(textArea.textProperty()); + } + + public UrlEditorViewModel getViewModel() { + return viewModel; + } + + @Override + public void bindToEntry(BibEntry entry) { + this.entry = Optional.of(entry); + textArea.bindToEntry(fieldName, entry); + } + + @Override + public Parent getNode() { + return this; + } + + @FXML + private void openExternalLink(ActionEvent event) { + viewModel.openExternalLink(); + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java new file mode 100644 index 00000000000..dfeb7cb6867 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java @@ -0,0 +1,55 @@ +package org.jabref.gui.fieldeditors; + +import java.io.IOException; + +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +import org.jabref.gui.AbstractViewModel; +import org.jabref.gui.DialogService; +import org.jabref.gui.desktop.JabRefDesktop; +import org.jabref.logic.l10n.Localization; +import org.jabref.logic.net.URLUtil; +import org.jabref.model.strings.StringUtil; + +import org.fxmisc.easybind.EasyBind; + +public class UrlEditorViewModel extends AbstractViewModel { + private StringProperty text = new SimpleStringProperty(""); + private DialogService dialogService; + private BooleanProperty validUrlIsNotPresent = new SimpleBooleanProperty(true); + + public UrlEditorViewModel(DialogService dialogService) { + this.dialogService = dialogService; + + validUrlIsNotPresent.bind( + EasyBind.map(text, input -> StringUtil.isBlank(input) || !URLUtil.isURL(input)) + ); + } + + public boolean isValidUrlIsNotPresent() { + return validUrlIsNotPresent.get(); + } + + public BooleanProperty validUrlIsNotPresentProperty() { + return validUrlIsNotPresent; + } + + public StringProperty textProperty() { + return text; + } + + public void openExternalLink() { + if (StringUtil.isBlank(text.get())) { + return; + } + + try { + JabRefDesktop.openBrowser(text.get()); + } catch (IOException ex) { + dialogService.notify(Localization.lang("Unable to open link.")); + } + } +} From 9ec9deed24be4590dac3f3d373f61fcca2093ead Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 18 Apr 2017 20:39:57 +0200 Subject: [PATCH 3/4] Reimplement owner editior in JavaFX --- .../jabref/gui/entryeditor/EntryEditor.java | 2 - .../gui/entryeditor/EntryEditorTab.java | 2 +- .../gui/entryeditor/FieldExtraComponents.java | 21 -------- .../jabref/gui/fieldeditors/FieldEditors.java | 4 +- .../jabref/gui/fieldeditors/OwnerEditor.fxml | 19 +++++++ .../jabref/gui/fieldeditors/OwnerEditor.java | 50 +++++++++++++++++++ .../fieldeditors/OwnerEditorViewModel.java | 24 +++++++++ src/main/resources/l10n/JabRef_da.properties | 4 +- src/main/resources/l10n/JabRef_de.properties | 4 +- src/main/resources/l10n/JabRef_en.properties | 4 +- src/main/resources/l10n/JabRef_es.properties | 4 +- src/main/resources/l10n/JabRef_fa.properties | 4 +- src/main/resources/l10n/JabRef_fr.properties | 4 +- src/main/resources/l10n/JabRef_in.properties | 4 +- src/main/resources/l10n/JabRef_it.properties | 4 +- src/main/resources/l10n/JabRef_ja.properties | 4 +- src/main/resources/l10n/JabRef_nl.properties | 4 +- src/main/resources/l10n/JabRef_no.properties | 4 +- .../resources/l10n/JabRef_pt_BR.properties | 4 +- src/main/resources/l10n/JabRef_ru.properties | 4 +- src/main/resources/l10n/JabRef_sv.properties | 4 +- src/main/resources/l10n/JabRef_tr.properties | 4 +- src/main/resources/l10n/JabRef_vi.properties | 4 +- src/main/resources/l10n/JabRef_zh.properties | 4 +- 24 files changed, 113 insertions(+), 77 deletions(-) create mode 100644 src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.fxml create mode 100644 src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.java create mode 100644 src/main/java/org/jabref/gui/fieldeditors/OwnerEditorViewModel.java diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 3f1fb6c8e28..40ac0002ee5 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -619,8 +619,6 @@ public Optional getExtra(final FieldEditor editor) { } else if (!panel.getBibDatabaseContext().getMetaData().getContentSelectorValuesForField(fieldName).isEmpty()) { return FieldExtraComponents.getSelectorExtraComponent(frame, panel, editor, contentSelectors, storeFieldAction); - } else if (fieldExtras.contains(FieldProperty.OWNER)) { - return FieldExtraComponents.getSetOwnerExtraComponent(editor, storeFieldAction); } else if (fieldExtras.contains(FieldProperty.YES_NO)) { return FieldExtraComponents.getYesNoExtraComponent(editor, this); } else if (fieldExtras.contains(FieldProperty.MONTH)) { diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java index 4a3859ebec1..a8f8ce66250 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java @@ -166,7 +166,7 @@ private void setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField fieldEditor.setAutoCompleteListener(autoCompleteListener); */ - FieldEditorFX fieldEditor = FieldEditors.getForField(fieldName, Globals.taskExecutor, new FXDialogService(), Globals.journalAbbreviationLoader, Globals.prefs.getJournalAbbreviationPreferences()); + FieldEditorFX fieldEditor = FieldEditors.getForField(fieldName, Globals.taskExecutor, new FXDialogService(), Globals.journalAbbreviationLoader, Globals.prefs.getJournalAbbreviationPreferences(), Globals.prefs); editors.put(fieldName, fieldEditor); /* // TODO: Reenable this diff --git a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java index 09c947cea9f..01bf739955d 100644 --- a/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java +++ b/src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java @@ -1,6 +1,5 @@ package org.jabref.gui.entryeditor; -import java.awt.event.ActionEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -9,11 +8,9 @@ import java.util.Set; import java.util.stream.Collectors; -import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; -import org.jabref.Globals; import org.jabref.gui.BasePanel; import org.jabref.gui.JabRefFrame; import org.jabref.gui.contentselector.FieldContentSelector; @@ -25,7 +22,6 @@ import org.jabref.model.entry.FieldProperty; import org.jabref.model.entry.InternalBibtexFields; import org.jabref.model.entry.Month; -import org.jabref.preferences.JabRefPreferences; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -88,23 +84,6 @@ public static Optional getMonthExtraComponent(FieldEditor fieldEdito } - /** - * Return a button which sets the owner if the field for fields with EXTRA_SET_OWNER - * @param fieldEditor - * @param storeFieldAction - * @return - */ - public static Optional getSetOwnerExtraComponent(FieldEditor fieldEditor, - StoreFieldAction storeFieldAction) { - JButton button = new JButton(Localization.lang("Auto")); - button.addActionListener(actionEvent -> { - fieldEditor.setText(Globals.prefs.get(JabRefPreferences.DEFAULT_OWNER)); - storeFieldAction.actionPerformed(new ActionEvent(fieldEditor, 0, "")); - }); - return Optional.of(button); - - } - /** * Return a button opening a content selector for fields where one exists * diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index 80f00c34bd5..bf36781f607 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -14,7 +14,7 @@ public class FieldEditors { - public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecutor, DialogService dialogService, JournalAbbreviationLoader journalAbbreviationLoader, JournalAbbreviationPreferences journalAbbreviationPreferences) { + public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecutor, DialogService dialogService, JournalAbbreviationLoader journalAbbreviationLoader, JournalAbbreviationPreferences journalAbbreviationPreferences, JabRefPreferences preferences) { final Set fieldExtras = InternalBibtexFields.getFieldProperties(fieldName); // TODO: Implement this @@ -32,7 +32,7 @@ public static FieldEditorFX getForField(String fieldName, TaskExecutor taskExecu fieldExtras.contains(FieldProperty.ISBN)) { return new IdentifierEditor(fieldName, taskExecutor, dialogService); } else if (fieldExtras.contains(FieldProperty.OWNER)) { - //return FieldExtraComponents.getSetOwnerExtraComponent(editor, storeFieldAction); + return new OwnerEditor(fieldName, preferences); } else if (fieldExtras.contains(FieldProperty.YES_NO)) { //return FieldExtraComponents.getYesNoExtraComponent(editor, this); } else if (fieldExtras.contains(FieldProperty.MONTH)) { diff --git a/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.fxml new file mode 100644 index 00000000000..90fb1394b58 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.fxml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.java b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.java new file mode 100644 index 00000000000..22485194380 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.java @@ -0,0 +1,50 @@ +package org.jabref.gui.fieldeditors; + +import java.util.Optional; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.Parent; +import javafx.scene.layout.HBox; + +import org.jabref.gui.util.ControlHelper; +import org.jabref.model.entry.BibEntry; +import org.jabref.preferences.JabRefPreferences; + + +public class OwnerEditor extends HBox implements FieldEditorFX { + + private final String fieldName; + @FXML private OwnerEditorViewModel viewModel; + @FXML private EditorTextArea textArea; + private Optional entry; + + public OwnerEditor(String fieldName, JabRefPreferences preferences) { + this.fieldName = fieldName; + this.viewModel = new OwnerEditorViewModel(preferences); + + ControlHelper.loadFXMLForControl(this); + + viewModel.textProperty().bindBidirectional(textArea.textProperty()); + } + + public OwnerEditorViewModel getViewModel() { + return viewModel; + } + + @Override + public void bindToEntry(BibEntry entry) { + this.entry = Optional.of(entry); + textArea.bindToEntry(fieldName, entry); + } + + @Override + public Parent getNode() { + return this; + } + + @FXML + private void setOwner(ActionEvent event) { + viewModel.setOwner(); + } +} diff --git a/src/main/java/org/jabref/gui/fieldeditors/OwnerEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditorViewModel.java new file mode 100644 index 00000000000..6f220f34cc8 --- /dev/null +++ b/src/main/java/org/jabref/gui/fieldeditors/OwnerEditorViewModel.java @@ -0,0 +1,24 @@ +package org.jabref.gui.fieldeditors; + +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +import org.jabref.gui.AbstractViewModel; +import org.jabref.preferences.JabRefPreferences; + +public class OwnerEditorViewModel extends AbstractViewModel { + private final JabRefPreferences preferences; + private StringProperty text = new SimpleStringProperty(""); + + public OwnerEditorViewModel(JabRefPreferences preferences) { + this.preferences = preferences; + } + + public StringProperty textProperty() { + return text; + } + + public void setOwner() { + text.set(preferences.get(JabRefPreferences.DEFAULT_OWNER)); + } +} diff --git a/src/main/resources/l10n/JabRef_da.properties b/src/main/resources/l10n/JabRef_da.properties index edf5ce297b6..5fc79f21a43 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -117,8 +117,6 @@ Attach_URL=Tilføj_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Forsøg_at_sætte_fil-link_automatisk_for_dine_poster._Dette_virker,_hvis_en_fil_i_dit_fil-bibliotek_eller_et_underbibliotek
har_navn_lignende_en_posts_BibTeX-nøgle,_plus_efternavn. -Auto=Auto - Autodetect_format=Autodetekter_format Autogenerate_BibTeX_keys=Autogenerer_BibTeX-nøgler @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index 57a8c11013b..81b745e144a 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -117,8 +117,6 @@ Attach_URL=URL_anfügen Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Versucht,_Datei-Links_für_die_Einträge_automatisch_zuzuordnen._Dies_funktioniert,_wenn_der_Name_einer_Datei_im_Datei-Verzeichnis_oder_einem_Unterverzeichnis
identisch_ist_mit_dem_BibTeX-Key_eines_Eintrags_(erweitert_um_die_jeweilige_Dateiendung). -Auto=Auto - Autodetect_format=Format_automatisch_erkennen Autogenerate_BibTeX_keys=BibTeX-Keys_automatisch_generieren @@ -2353,7 +2351,7 @@ Locked=Gesperrt Show_document_viewer=Zeige_Dokumentenbetrachter Show_the_document_of_the_currently_selected_entry.=Zeige_das_Dokument_zum_selektierten_Eintrag. Show_this_document_until_unlocked.=Zeige_dieses_Dokument_solange_bis_es_entsperrt_wurde. - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)=Sortiere_alle_Untergruppen_(rekursiv) Collect_and_share_telemetry_data_to_help_improve_JabRef.=Sammle_und_teile_Telemetriedaten,_um_bei_der_Verbesserung_von_JabRef_zu_unterstützen. diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 221968244b9..7057d932fc3 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -117,8 +117,6 @@ Attach_URL=Attach_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension. -Auto=Auto - Autodetect_format=Autodetect_format Autogenerate_BibTeX_keys=Autogenerate_BibTeX_keys @@ -2353,7 +2351,7 @@ Locked=Locked Show_document_viewer=Show_document_viewer Show_the_document_of_the_currently_selected_entry.=Show_the_document_of_the_currently_selected_entry. Show_this_document_until_unlocked.=Show_this_document_until_unlocked. - +Set_current_user_name_as_owner.=Set_current_user_name_as_owner. Sort_all_subgroups_(recursively)=Sort_all_subgroups_(recursively) Collect_and_share_telemetry_data_to_help_improve_JabRef.=Collect_and_share_telemetry_data_to_help_improve_JabRef. diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index 15a7fac2189..3ab4a99d46b 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -117,8 +117,6 @@ Attach_URL=Adjuntar_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Intentar_establecer_automáticamente_archivo_enlaces_para_sus_entradas._El_establecimiento_automático_funciona_si_un_archivo_en_la_carpeta_archivo_o_un_subdirectrio_
_tiene_nombre_idéntico_a_una_entrada_BibTeX_más_la_extensión. -Auto=Auto - Autodetect_format=Autodetectar_formato Autogenerate_BibTeX_keys=Autogenerar_claves_BibTeX @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index 664a4d91d70..8e11a887f24 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -117,8 +117,6 @@ Attach_URL= Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.= -Auto= - Autodetect_format= Autogenerate_BibTeX_keys= @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index b62be6347d4..c7feba1801c 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -117,8 +117,6 @@ Attach_URL=Attacher_l'URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Cela_tente_de_définir_automatiquement_les_liens_fichier_de_vos_entrées.
La_définition_automatique_fonctionne_si_un_fichier_dans_votre_répertoire_fichier
ou_dans_un_sous-répertoire_porte_le_même_nom_que_la_clef_d'une_entrée_BibTeX,
_l'extension_en_plus. -Auto=Auto - Autodetect_format=Détection_automatique_du_format Autogenerate_BibTeX_keys=Création_automatique_des_clefs_BibTeX @@ -2353,7 +2351,7 @@ Locked=Vérrouillé Show_document_viewer=Ouvre_l'afficheur_de_document Show_the_document_of_the_currently_selected_entry.=Affiche_le_document_de_l'entrée_sélectionnée. Show_this_document_until_unlocked.=Affiche_le_document_jusqu'à_déverrouillage. - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)=Trier_les_sous-groupes_(récursivement) Collect_and_share_telemetry_data_to_help_improve_JabRef.=Collecter_et_partager_les_données_de_télémétrie_pour_contribuer_à_l'amélioration_de_JabRef diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index 6ef62ecb4e3..243c97c2dba 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -117,8 +117,6 @@ Attach_URL=Lampirkan_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Mencoba_atur_otomatis_berkas_tautan_untuk_entri_anda._Pengaturan_otomatis_berfungsi_jika_berkas_di_folder_berkas_atau_subfolder
diberi_nama_sama_dengan_kunci_BibTeX,_tambah_ekstensi. -Auto=Otomatis - Autodetect_format=Deteksi_format_otomatis Autogenerate_BibTeX_keys=Kunci_BibTeX_dibuat_otomatis @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index bffede959ac..bf45c4ca725 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -117,8 +117,6 @@ Attach_URL=Allega_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Tentativo_di_definire_automaticamente_collegamenti_a_file_per_le_tue_voci._La_definizione_avviene_automaticamente_se_un_file_nella_cartella_file_o_sottocartella
ha_lo_stesso_nome_della_chiave_di_una_voce_BibTeX,_a_meno_dell'estensione. -Auto=Auto - Autodetect_format=Rivelamento_automatico_del_formato Autogenerate_BibTeX_keys=Generazione_automatica_delle_chiavi_BibTeX @@ -2353,7 +2351,7 @@ Locked=bloccato Show_document_viewer=Mostra_il_visualizzatore_del_documento Show_the_document_of_the_currently_selected_entry.=Mostra_il_documento_della_voce_attualmente_selezionata. Show_this_document_until_unlocked.=Mostra_questo_documento_finché_non_viene_sbloccato. - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)=Ordina_tutti_i_sottogruppi_(ricorsivamente) Collect_and_share_telemetry_data_to_help_improve_JabRef.=Registra_e_condividi_i_dati_di_telemetria_per_aiutare_a_migliorare_JabRef. diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index fc16c2f9f57..f8cd4da1d3b 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -117,8 +117,6 @@ Attach_URL=URLを添付 Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=これは、使用中の項目のファイルリンクを自動設定します。自動設定は、ファイルディレクトリないし下層ディレクトリの
ファイルが、項目のBibTeX鍵と同一名+拡張子として命名されているときのみ、機能します。 -Auto=自動 - Autodetect_format=書式を自動検出 Autogenerate_BibTeX_keys=BibTeX鍵を自動生成 @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index be209473ca4..13f8e0b2273 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -117,8 +117,6 @@ Attach_URL=URL_bijvoegen Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Poging_om_bestand_snelkoppelingen_voor_jouw_entries_automatisch_in_te_stellen._Automatisch_instellen_werkt_als_een_bestand_in_jouw_bestand_map_of_een_submap
een_identieke_naam_heeft_als_een_BibTeX-sleutel_van_een_entry,_plus_extensie. -Auto=Auto - Autodetect_format=Formaat_automatisch_detecteren Autogenerate_BibTeX_keys=BibTeX-sleutels_automatisch_genereren @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index e7cccef94c9..3a306127dc2 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -117,8 +117,6 @@ Attach_URL=Tilordne_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Pr\u00f8v_\u00e5_sette_fil-linker_automatisk_for_dine_enheter._Dette_virker_dersom_en_fil_i_fil-katalogen_din_eller_en_underkatalog
har_navn_likt_en_enhets_BibTeX-n\u00f8kkel,_pluss_etternavn. -Auto=Auto - Autodetect_format=Autodetekter_format Autogenerate_BibTeX_keys=Autogenerer_BibTeX-n\u00f8kler @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index 183ea4f61ed..ee61cacbcb4 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -117,8 +117,6 @@ Attach_URL=Anexar_a_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Tentativa_de_definir_automaticamente_links_de_arquivos_para_suas_referências._A_definição_automática_funciona_se_um_arquivo_em_seu_diretório_arquivo_ou_um_subdiretório
tem_o_mesmo_nome_de_uma_chave_BibTeX_de_uma_referência,_mais_sua_extensão. -Auto=Auto - Autodetect_format=Detecção_automática_de_formato Autogenerate_BibTeX_keys=Geração_automática_de_chaves_BibTeX @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index 2b4d7416ea1..fc215ce6f8b 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -117,8 +117,6 @@ Attach_URL=Добавить_URL-адрес Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Попытка_автоопределения_ссылок_файл_для_записей._Автоопределение_возможно_если_файл_находящийся_в_каталоге_файлов_файл_или_его_подкаталоге
имеет_имя,_идентичное_имени_ключа_BibTeX_для_записи,_с_соответствующим_разрешением. -Auto=Авто - Autodetect_format=Автоопределение_формата Autogenerate_BibTeX_keys=Автосоздание_ключей_BibTeX @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_sv.properties b/src/main/resources/l10n/JabRef_sv.properties index c931ca042cd..a25c1558934 100644 --- a/src/main/resources/l10n/JabRef_sv.properties +++ b/src/main/resources/l10n/JabRef_sv.properties @@ -117,8 +117,6 @@ Attach_URL=Lägg_till_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.= -Auto=Automatiskt - Autodetect_format=Bestäm_format_automatiskt Autogenerate_BibTeX_keys=Generera_BibTeX-nycklar_automatiskt @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index 0cbd58b518e..76331dcd6fd 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -117,8 +117,6 @@ Attach_URL=URL_ekle Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Girdileriniz_için_dosya_link_otokurma_girişiminde_bulunuluyor._Otokur,_eğer_dosya_dizinindeki_ya_da_bir_
_altdizinindeki_dosyası_bir_BibTeX_anahtarıyla_özdeş_adlandırılmış_artı_uzantılandılılmışsa_çalışır. -Auto=Oto - Autodetect_format=Biçemi_otomatik_tanı Autogenerate_BibTeX_keys=BibTeX_anahtarlarını_otomatik_oluştur @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index 32d6748377e..750378c4674 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -117,8 +117,6 @@ Attach_URL=Gắn_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=Cố_gắng_thiết_lập_tự_động_tập_tin_liên_kết_vào_các_mục._Thiết_lập_tự_động_chạy_được_nếu_một_tập_tin_ở_trong_thư_mục_hoặc_thư_mục_con_tập_tin_của_bạn
được_đặt_tên_giống_hệt_một_khóa_BibTeX_của_mục,_cộng_với_phần_mở_rộng. -Auto=Tự_động - Autodetect_format=Tự_động_phát_hiện_định_dạng Autogenerate_BibTeX_keys=Tự_động_tạo_các_khóa_BibTeX @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index ba8bb010e1c..a8a14b14dcf 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -117,8 +117,6 @@ Attach_URL=附加_URL Attempt_to_automatically_set_file_links_for_your_entries._Automatically_setting_works_if_a_file_in_your_file_directory
or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=尝试为您的记录自动设置_文件_链接,该操作要求和记录_BibTeX_键同名的_文件存在于您的_文件_目录或者子目录中。 -Auto=自动 - Autodetect_format=自动检测格式 Autogenerate_BibTeX_keys=自动生成_BibTeX_键 @@ -2353,7 +2351,7 @@ Locked= Show_document_viewer= Show_the_document_of_the_currently_selected_entry.= Show_this_document_until_unlocked.= - +Set_current_user_name_as_owner.= Sort_all_subgroups_(recursively)= Collect_and_share_telemetry_data_to_help_improve_JabRef.= From 51ce1ec6a14ad40a09538beff8047ef75c1a2f6e Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 20 Apr 2017 15:04:43 +0200 Subject: [PATCH 4/4] Fix language tests --- .../l10n/LocalizationConsistencyTest.java | 65 +++++++++---------- .../jabref/logic/l10n/LocalizationParser.java | 9 ++- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java index 52bdb1e755b..cc73fe68728 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java @@ -43,37 +43,6 @@ public void allFilesMustHaveSameKeys() { } } - - private static class DuplicationDetectionProperties extends Properties { - - private static final long serialVersionUID = 1L; - - private final List duplicates = new LinkedList<>(); - - - public DuplicationDetectionProperties() { - super(); - } - - /** - * Overriding the HashTable put() so we can check for duplicates - */ - @Override - public synchronized Object put(Object key, Object value) { - // Have we seen this key before? - if (containsKey(key)) { - duplicates.add(String.valueOf(key)); - } - - return super.put(key, value); - } - - public List getDuplicates() { - return duplicates; - } - } - - @Test public void ensureNoDuplicates() { for (String bundle : Arrays.asList("JabRef", "Menu")) { @@ -135,8 +104,7 @@ public void findMissingLocalizationKeys() throws IOException { @Test public void findMissingMenuLocalizationKeys() throws IOException { - List missingKeys = LocalizationParser.find(LocalizationBundleForTest.MENU).stream() - .collect(Collectors.toList()); + Set missingKeys = LocalizationParser.find(LocalizationBundleForTest.MENU); assertEquals("DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH MENU FILE\n" + "1. PASTE THESE INTO THE ENGLISH MENU FILE\n" + @@ -144,7 +112,7 @@ public void findMissingMenuLocalizationKeys() throws IOException { missingKeys.parallelStream() .map(key -> String.format("%s=%s", key.getKey(), key.getKey())) .collect(Collectors.toList()), - Collections.emptyList(), missingKeys); + Collections.emptySet(), missingKeys); } @Test @@ -188,4 +156,33 @@ public void localizationParameterMustIncludeAString() throws IOException { } } + private static class DuplicationDetectionProperties extends Properties { + + private static final long serialVersionUID = 1L; + + private final List duplicates = new LinkedList<>(); + + + public DuplicationDetectionProperties() { + super(); + } + + /** + * Overriding the HashTable put() so we can check for duplicates + */ + @Override + public synchronized Object put(Object key, Object value) { + // Have we seen this key before? + if (containsKey(key)) { + duplicates.add(String.valueOf(key)); + } + + return super.put(key, value); + } + + public List getDuplicates() { + return duplicates; + } + } + } diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationParser.java b/src/test/java/org/jabref/logic/l10n/LocalizationParser.java index a02bee4d0eb..45e63d302cc 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationParser.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationParser.java @@ -61,7 +61,7 @@ public static SortedSet findObsolete(LocalizationBundleForTest type) thr } englishKeys.removeAll(keysInFiles); - return englishKeys.stream().collect(Collectors.toCollection(TreeSet::new)); + return new TreeSet<>(englishKeys); } private static Set findLocalizationEntriesInFiles(LocalizationBundleForTest type) throws IOException { @@ -195,9 +195,14 @@ public boolean containsKey(String key) { } }; + PlatformImpl.startup(() -> { + }); try { - PlatformImpl.startup(() -> {}); FXMLLoader loader = new FXMLLoader(path.toUri().toURL(), registerUsageResourceBundle); + // We don't want to initialize controller + loader.setControllerFactory(controllerType -> null); + // Don't check if root is null (needed for custom controls, where the root value is normally set in the FXMLLoader) + loader.impl_setStaticLoad(true); loader.load(); } catch (IOException ignore) { ignore.printStackTrace();