Skip to content

Commit

Permalink
Reimplement owner editior in JavaFX
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Apr 18, 2017
1 parent 91d19f9 commit 9ec9dee
Show file tree
Hide file tree
Showing 24 changed files with 113 additions and 77 deletions.
2 changes: 0 additions & 2 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,6 @@ public Optional<JComponent> 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/org/jabref/gui/entryeditor/FieldExtraComponents.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -88,23 +84,6 @@ public static Optional<JComponent> 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<JComponent> 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
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<FieldProperty> fieldExtras = InternalBibtexFields.getFieldProperties(fieldName);

// TODO: Implement this
Expand All @@ -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)) {
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.layout.HBox?>
<?import org.jabref.gui.fieldeditors.EditorTextArea?>
<?import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" xmlns="http://javafx.com/javafx/8.0.112">
<EditorTextArea fx:id="textArea" prefHeight="0.0" HBox.hgrow="ALWAYS"/>
<Button onAction="#setOwner"
styleClass="flatButton">
<graphic>
<MaterialDesignIconView glyphName="ACCOUNT"/>
</graphic>
<tooltip>
<Tooltip text="%Set current user name as owner."/>
</tooltip>
</Button>
</fx:root>
50 changes: 50 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/OwnerEditor.java
Original file line number Diff line number Diff line change
@@ -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<BibEntry> 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();
}
}
Original file line number Diff line number Diff line change
@@ -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));
}
}
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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<BR>har_navn_lignende_en_posts_BibTeX-nøgle,_plus_efternavn.

Auto=Auto

Autodetect_format=Autodetekter_format

Autogenerate_BibTeX_keys=Autogenerer_BibTeX-nøgler
Expand Down Expand Up @@ -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.=
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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<BR>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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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<BR>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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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_<BR>_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
Expand Down Expand Up @@ -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.=
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=

Auto=

Autodetect_format=

Autogenerate_BibTeX_keys=
Expand Down Expand Up @@ -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.=
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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.<BR>La_définition_automatique_fonctionne_si_un_fichier_dans_votre_répertoire_fichier<BR>ou_dans_un_sous-répertoire_porte_le_même_nom_que_la_clef_d'une_entrée_BibTeX,<BR>_l'extension_en_plus.

Auto=Auto

Autodetect_format=Détection_automatique_du_format

Autogenerate_BibTeX_keys=Création_automatique_des_clefs_BibTeX
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_in.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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<BR>diberi_nama_sama_dengan_kunci_BibTeX,_tambah_ekstensi.

Auto=Otomatis

Autodetect_format=Deteksi_format_otomatis

Autogenerate_BibTeX_keys=Kunci_BibTeX_dibuat_otomatis
Expand Down Expand Up @@ -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.=
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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<BR>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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>or_a_subdirectory_is_named_identically_to_an_entry's_BibTeX_key,_plus_extension.=これは、使用中の項目のファイルリンクを自動設定します。自動設定は、ファイルディレクトリないし下層ディレクトリの<BR>ファイルが、項目のBibTeX鍵と同一名+拡張子として命名されているときのみ、機能します。

Auto=自動

Autodetect_format=書式を自動検出

Autogenerate_BibTeX_keys=BibTeX鍵を自動生成
Expand Down Expand Up @@ -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.=
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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<BR>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
Expand Down Expand Up @@ -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.=
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_no.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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<BR>har_navn_likt_en_enhets_BibTeX-n\u00f8kkel,_pluss_etternavn.

Auto=Auto

Autodetect_format=Autodetekter_format

Autogenerate_BibTeX_keys=Autogenerer_BibTeX-n\u00f8kler
Expand Down Expand Up @@ -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.=
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/l10n/JabRef_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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<BR>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<BR>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
Expand Down Expand Up @@ -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.=
Expand Down
Loading

0 comments on commit 9ec9dee

Please sign in to comment.