use of org.jabref.gui.autosaveandbackup.AutosaveUIManager in project jabref by JabRef.
the class JabRefFrame method addTab.
public void addTab(BasePanel basePanel, boolean raisePanel) {
// add tab
tabbedPane.add(basePanel.getTabTitle(), basePanel);
// update all tab titles
updateAllTabTitles();
if (raisePanel) {
tabbedPane.setSelectedComponent(basePanel);
}
// Register undo/redo listener
basePanel.getUndoManager().registerListener(new UndoRedoEventManager());
BibDatabaseContext context = basePanel.getBibDatabaseContext();
if (readyForAutosave(context)) {
AutosaveManager autosaver = AutosaveManager.start(context);
autosaver.registerListener(new AutosaveUIManager(basePanel));
}
BackupManager.start(context);
// Track opening
trackOpenNewDatabase(basePanel);
}
use of org.jabref.gui.autosaveandbackup.AutosaveUIManager in project jabref by JabRef.
the class SaveDatabaseAction method saveAs.
/**
* Run the "Save as" operation. This method offloads the actual save operation to a background thread, but
* still runs synchronously using Spin (the method returns only after completing the operation).
*/
public void saveAs(File file) throws Exception {
BibDatabaseContext context = panel.getBibDatabaseContext();
if (context.getLocation() == DatabaseLocation.SHARED) {
// Save all properties dependent on the ID. This makes it possible to restore them.
DBMSConnectionProperties properties = context.getDBMSSynchronizer().getDBProcessor().getDBMSConnectionProperties();
new SharedDatabasePreferences(context.getDatabase().generateSharedDatabaseID()).putAllDBMSConnectionProperties(properties);
}
context.setDatabaseFile(file);
if (file.getParent() != null) {
Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, file.getParent());
}
runCommand();
// If the operation failed, revert the file field and return:
if (!success) {
return;
}
try {
panel.setFileMonitorHandle(Globals.getFileUpdateMonitor().addUpdateListener(panel, context.getDatabaseFile().orElse(null)));
} catch (IOException ex) {
LOGGER.error("Problem registering file change notifications", ex);
}
if (readyForAutosave(context)) {
AutosaveManager autosaver = AutosaveManager.start(context);
autosaver.registerListener(new AutosaveUIManager(panel));
}
if (readyForBackup(context)) {
BackupManager.start(context);
}
context.getDatabaseFile().ifPresent(presentFile -> frame.getFileHistory().newFile(presentFile.getPath()));
frame.updateEnabledState();
}
Aggregations