Top Description Inners Fields Constructors Methods
org.jabref.gui.exporter

public Class SaveDatabaseAction

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.charset.Charset, .StandardCharsets, .UnsupportedCharsetException, java.nio.file.Files, .Path, java.util.List, .Optional, .Set, java.util.stream.Collectors, javafx.scene.control.ButtonBar, .ButtonType, .DialogPane, .TableColumn, javafx.scene.layout.VBox, javafx.scene.text.Text, org.jabref.gui.DialogService, .LibraryTab, org.jabref.gui.autosaveandbackup.AutosaveManager, .BackupManager, org.jabref.gui.maintable.BibEntryTableViewModel, org.jabref.gui.maintable.columns.MainTableColumn, org.jabref.gui.util.BackgroundTask, .FileDialogConfiguration, org.jabref.logic.exporter.AtomicFileWriter, .BibDatabaseWriter, .BibWriter, .BibtexDatabaseWriter, .SaveException, .SelfContainedSaveConfiguration, org.jabref.logic.l10n.Encodings, .Localization, org.jabref.logic.pdf.search.PdfIndexerManager, org.jabref.logic.shared.DatabaseLocation, org.jabref.logic.shared.prefs.SharedDatabasePreferences, org.jabref.logic.util.StandardFileType, org.jabref.model.database.BibDatabaseContext, org.jabref.model.database.event.ChangePropagation, org.jabref.model.entry.BibEntryTypesManager, org.jabref.model.metadata.SaveOrder, .SelfContainedSaveOrder, org.jabref.preferences.PreferencesService, org.slf4j.Logger, .LoggerFactory

Action for the "Save" and "Save as" operations called from BasePanel. This class is also used for save operations when closing a database or quitting the applications.

The save operation is loaded off of the GUI thread using BackgroundTask. Callers can query whether the operation was canceled, or whether it was successful.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private final DialogService
private final BibEntryTypesManager
private final LibraryTab
private static final Logger
private final PreferencesService

Constructor Summary

AccessConstructor and Description
public
SaveDatabaseAction(LibraryTab libraryTab, DialogService dialogService, PreferencesService preferences, BibEntryTypesManager entryTypesManager)

Method Summary

Modifier and TypeMethod and Description
private Optional<Path>

Returns:

the path set by the user
askForSavePath
()

Asks the user for the path to save to.

private SelfContainedSaveOrder
public boolean
save()

public boolean
private boolean
private boolean
public void
saveAs()

Asks the user for the path and saves afterward

public boolean
saveAs(Path file)

pack-priv boolean

Returns:

true on successful save
saveAs
(Path
the new file name to save the database to. This is stored in the database context of the panel upon successful save.
file
,
SaveDatabaseAction.SaveDatabaseMode mode)

private boolean
saveDatabase(Path file, boolean selectedOnly, Charset encoding, BibDatabaseWriter.SaveType saveType, SelfContainedSaveOrder saveOrder)

public void
private void
saveWithDifferentEncoding(Path file, boolean selectedOnly, Charset encoding, Set<Character> encodingProblems, BibDatabaseWriter.SaveType saveType, SelfContainedSaveOrder saveOrder)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dialogServiceback to summary
private final DialogService dialogService
entryTypesManagerback to summary
private final BibEntryTypesManager entryTypesManager
libraryTabback to summary
private final LibraryTab libraryTab
LOGGERback to summary
private static final Logger LOGGER
preferencesback to summary
private final PreferencesService preferences

Constructor Detail

SaveDatabaseActionback to summary
public SaveDatabaseAction(LibraryTab libraryTab, DialogService dialogService, PreferencesService preferences, BibEntryTypesManager entryTypesManager)

Method Detail

askForSavePathback to summary
private Optional<Path> askForSavePath()

Asks the user for the path to save to. Stores the directory to the preferences, which is used next time when opening the dialog.

Returns:Optional<Path>

the path set by the user

getSaveOrderback to summary
private SelfContainedSaveOrder getSaveOrder()
saveback to summary
public boolean save()
saveback to summary
public boolean save(SaveDatabaseAction.SaveDatabaseMode mode)
saveback to summary
private boolean save(BibDatabaseContext bibDatabaseContext, SaveDatabaseAction.SaveDatabaseMode mode)
saveback to summary
private boolean save(Path targetPath, SaveDatabaseAction.SaveDatabaseMode mode)
saveAsback to summary
public void saveAs()

Asks the user for the path and saves afterward

saveAsback to summary
public boolean saveAs(Path file)
saveAsback to summary
pack-priv boolean saveAs(Path file, SaveDatabaseAction.SaveDatabaseMode mode)
Parameters
file:Path

the new file name to save the database to. This is stored in the database context of the panel upon successful save.

Returns:boolean

true on successful save

saveDatabaseback to summary
private boolean saveDatabase(Path file, boolean selectedOnly, Charset encoding, BibDatabaseWriter.SaveType saveType, SelfContainedSaveOrder saveOrder) throws SaveException
saveSelectedAsPlainback to summary
public void saveSelectedAsPlain()
saveWithDifferentEncodingback to summary
private void saveWithDifferentEncoding(Path file, boolean selectedOnly, Charset encoding, Set<Character> encodingProblems, BibDatabaseWriter.SaveType saveType, SelfContainedSaveOrder saveOrder) throws SaveException
org.jabref.gui.exporter back to summary

public final Enum SaveDatabaseAction.SaveDatabaseMode

extends Enum<SaveDatabaseAction.SaveDatabaseMode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final SaveDatabaseAction.SaveDatabaseMode
public static final SaveDatabaseAction.SaveDatabaseMode

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SaveDatabaseAction.SaveDatabaseMode
public static SaveDatabaseAction.SaveDatabaseMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NORMALback to summary
public static final SaveDatabaseAction.SaveDatabaseMode NORMAL
SILENTback to summary
public static final SaveDatabaseAction.SaveDatabaseMode SILENT

Constructor Detail

SaveDatabaseModeback to summary
private SaveDatabaseMode()

Method Detail

valueOfback to summary
public static SaveDatabaseAction.SaveDatabaseMode valueOf(String name)
valuesback to summary
public static SaveDatabaseAction.SaveDatabaseMode[] values()