Verified Owner
Top Description Fields Constructors Methods
org.jabref.gui.preferences.journals

public Class JournalAbbreviationsTabViewModel

extends Object
implements PreferenceTabViewModel
Class Inheritance
All Implemented Interfaces
org.jabref.gui.preferences.PreferenceTabViewModel
Imports
java.io.IOException, java.nio.file.Path, java.util.List, java.util.stream.Collectors, javafx.beans.property.SimpleBooleanProperty, .SimpleIntegerProperty, .SimpleListProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ListChangeListener, org.jabref.gui.DialogService, org.jabref.gui.preferences.PreferenceTabViewModel, org.jabref.gui.util.FileDialogConfiguration, org.jabref.logic.journals.Abbreviation, .AbbreviationPreferences, .JournalAbbreviationLoader, .JournalAbbreviationRepository, org.jabref.logic.l10n.Localization, org.jabref.logic.util.BackgroundTask, .StandardFileType, .TaskExecutor, com.airhacks.afterburner.injection.Injector, org.jspecify.annotations.NonNull, org.slf4j.Logger, .LoggerFactory

This class provides a model for managing journal abbreviation lists. It provides all necessary methods to create, modify or delete journal abbreviations and files. To visualize the model one can bind the properties to UI elements.

Field Summary

Modifier and TypeField and Description
private final SimpleListProperty<AbbreviationViewModel>
private final SimpleIntegerProperty
private final AbbreviationPreferences
private final SimpleObjectProperty<AbbreviationViewModel>
private final SimpleObjectProperty<AbbreviationsFileViewModel>
private final DialogService
private final SimpleBooleanProperty
private final SimpleBooleanProperty
private final SimpleBooleanProperty
private final SimpleBooleanProperty
private final JournalAbbreviationRepository
private final SimpleListProperty<AbbreviationsFileViewModel>
private final Logger
private boolean
private final TaskExecutor
private final SimpleBooleanProperty

Constructor Summary

AccessConstructor and Description
public
JournalAbbreviationsTabViewModel(AbbreviationPreferences abbreviationsPreferences, @NonNull DialogService dialogService, @NonNull TaskExecutor taskExecutor, @NonNull JournalAbbreviationRepository journalAbbreviationRepository)

Method Summary

Modifier and TypeMethod and Description
public SimpleIntegerProperty
public SimpleListProperty<AbbreviationViewModel>
public void
addAbbreviation(Abbreviation abbreviationObject)

Method to add a new abbreviation to the abbreviations list property.

public void
public void
addBuiltInList()

This will load the built in abbreviation files and add it to the list of journal abbreviation files.

public void
addNewFile()

This method shall be used to add a new journal abbreviation file to the set of journal abbreviation files.

public void
createFileObjects()

Read all saved file paths and read their abbreviations.

public SimpleObjectProperty<AbbreviationViewModel>
public SimpleObjectProperty<AbbreviationsFileViewModel>
public void
deleteAbbreviation()

Method to delete the abbreviation set in the currentAbbreviation property.

pack-priv void
editAbbreviation(Abbreviation abbreviationObject)

Method to change the currentAbbreviation property to a new abbreviation.

public SimpleBooleanProperty
public SimpleBooleanProperty
public SimpleBooleanProperty
public SimpleBooleanProperty
public SimpleListProperty<AbbreviationsFileViewModel>
private void
openFile(Path
path to the file
filePath
)

Checks whether the file exists or if a new file should be opened.

public void
public void
public void
removeCurrentFile()

This method removes the currently selected file from the set of journal abbreviation files.

public void
saveJournalAbbreviationFiles()

Calls the AbbreviationsFileViewModel#writeOrCreate() method for each file in the journalFiles property which will overwrite the existing files with the content of the abbreviations property of the AbbreviationsFile.

public void
selectLastJournalFile()

This will set the currentFile property to the AbbreviationsFileViewModel object that was added to the journalFiles list property lastly.

private void
public void
setValues()

Implements org.jabref.gui.preferences.PreferenceTabViewModel.setValues.

This method is called when the dialog is opened, or if it is made visible after being hidden.

public void
storeSettings()

Implements org.jabref.gui.preferences.PreferenceTabViewModel.storeSettings.

This method first saves all external files to its internal list, then writes all abbreviations to their files and finally updates the abbreviations auto complete.

public SimpleBooleanProperty
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

abbreviationsback to summary
private final SimpleListProperty<AbbreviationViewModel> abbreviations
abbreviationsCountback to summary
private final SimpleIntegerProperty abbreviationsCount
abbreviationsPreferencesback to summary
private final AbbreviationPreferences abbreviationsPreferences
currentAbbreviationback to summary
private final SimpleObjectProperty<AbbreviationViewModel> currentAbbreviation
currentFileback to summary
private final SimpleObjectProperty<AbbreviationsFileViewModel> currentFile
dialogServiceback to summary
private final DialogService dialogService
isAbbreviationEditableAndRemovableback to summary
private final SimpleBooleanProperty isAbbreviationEditableAndRemovable
isEditableAndRemovableback to summary
private final SimpleBooleanProperty isEditableAndRemovable
isFileRemovableback to summary
private final SimpleBooleanProperty isFileRemovable
isLoadingback to summary
private final SimpleBooleanProperty isLoading
journalAbbreviationRepositoryback to summary
private final JournalAbbreviationRepository journalAbbreviationRepository
journalFilesback to summary
private final SimpleListProperty<AbbreviationsFileViewModel> journalFiles
LOGGERback to summary
private final Logger LOGGER
shouldWriteListsback to summary
private boolean shouldWriteLists
taskExecutorback to summary
private final TaskExecutor taskExecutor
useFJournalback to summary
private final SimpleBooleanProperty useFJournal

Constructor Detail

JournalAbbreviationsTabViewModelback to summary
public JournalAbbreviationsTabViewModel(AbbreviationPreferences abbreviationsPreferences, @NonNull DialogService dialogService, @NonNull TaskExecutor taskExecutor, @NonNull JournalAbbreviationRepository journalAbbreviationRepository)

Method Detail

abbreviationsCountPropertyback to summary
public SimpleIntegerProperty abbreviationsCountProperty()
abbreviationsPropertyback to summary
public SimpleListProperty<AbbreviationViewModel> abbreviationsProperty()
addAbbreviationback to summary
public void addAbbreviation(Abbreviation abbreviationObject)

Method to add a new abbreviation to the abbreviations list property. It also sets the currentAbbreviation property to the new abbreviation.

addAbbreviationback to summary
public void addAbbreviation()
addBuiltInListback to summary
public void addBuiltInList()

This will load the built in abbreviation files and add it to the list of journal abbreviation files.

addNewFileback to summary
public void addNewFile()

This method shall be used to add a new journal abbreviation file to the set of journal abbreviation files. It basically just calls the openFile(Path) method.

createFileObjectsback to summary
public void createFileObjects()

Read all saved file paths and read their abbreviations.

currentAbbreviationPropertyback to summary
public SimpleObjectProperty<AbbreviationViewModel> currentAbbreviationProperty()
currentFilePropertyback to summary
public SimpleObjectProperty<AbbreviationsFileViewModel> currentFileProperty()
deleteAbbreviationback to summary
public void deleteAbbreviation()

Method to delete the abbreviation set in the currentAbbreviation property. The currentAbbreviationProperty will be set to the previous or next abbreviation in the abbreviations property if applicable. Else it will be set to null if there are no abbreviations left.

editAbbreviationback to summary
pack-priv void editAbbreviation(Abbreviation abbreviationObject)

Method to change the currentAbbreviation property to a new abbreviation.

isAbbreviationEditableAndRemovableback to summary
public SimpleBooleanProperty isAbbreviationEditableAndRemovable()
isEditableAndRemovablePropertyback to summary
public SimpleBooleanProperty isEditableAndRemovableProperty()
isFileRemovablePropertyback to summary
public SimpleBooleanProperty isFileRemovableProperty()
isLoadingPropertyback to summary
public SimpleBooleanProperty isLoadingProperty()
journalFilesPropertyback to summary
public SimpleListProperty<AbbreviationsFileViewModel> journalFilesProperty()
openFileback to summary
private void openFile(Path filePath)

Checks whether the file exists or if a new file should be opened. The file will be added to the set of journal abbreviation files. If the file also exists its abbreviations will be read and written to the abbreviations property.

Parameters
filePath:Path

path to the file

openFileback to summary
public void openFile()
removeAbbreviationback to summary
public void removeAbbreviation(@NonNull AbbreviationViewModel abbreviation)
removeCurrentFileback to summary
public void removeCurrentFile()

This method removes the currently selected file from the set of journal abbreviation files. This will not remove existing files from the file system. The activeFile property will always change to the previous file in the journalFiles list property, except the first file is selected. If so the next file will be selected except if there are no more files than the activeFile property will be set to null.

saveJournalAbbreviationFilesback to summary
public void saveJournalAbbreviationFiles()

Calls the AbbreviationsFileViewModel#writeOrCreate() method for each file in the journalFiles property which will overwrite the existing files with the content of the abbreviations property of the AbbreviationsFile. Non-existing files will be created.

selectLastJournalFileback to summary
public void selectLastJournalFile()

This will set the currentFile property to the AbbreviationsFileViewModel object that was added to the journalFiles list property lastly. If there are no files in the list property this method will do nothing as the currentFile property is already null.

setCurrentAbbreviationNameAndAbbreviationIfValidback to summary
private void setCurrentAbbreviationNameAndAbbreviationIfValid(Abbreviation abbreviationObject)
setValuesback to summary
public void setValues()

Implements org.jabref.gui.preferences.PreferenceTabViewModel.setValues.

Doc from org.jabref.gui.preferences.PreferenceTabViewModel.setValues.

This method is called when the dialog is opened, or if it is made visible after being hidden. The tab should update all its values.

This is the ONLY PLACE to set values for the fields in the tab. It is ILLEGAL to set values only at construction time, because the dialog will be reused and updated.

Annotations
@Override
storeSettingsback to summary
public void storeSettings()

Implements org.jabref.gui.preferences.PreferenceTabViewModel.storeSettings.

This method first saves all external files to its internal list, then writes all abbreviations to their files and finally updates the abbreviations auto complete.

Annotations
@Override
useFJournalPropertyback to summary
public SimpleBooleanProperty useFJournalProperty()