fix: save document before creating backup
This commit is contained in:
parent
267dbb63b8
commit
993ca4fe0f
5 changed files with 24 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:dep="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink">
|
<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:dep="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
<identifier value="pro.litvinovg.libreoffice.docsettings"/>
|
<identifier value="pro.litvinovg.libreoffice.docsettings"/>
|
||||||
<version value="0.0.6"/>
|
<version value="0.0.7"/>
|
||||||
<platform value="all"/>
|
<platform value="all"/>
|
||||||
<display-name>
|
<display-name>
|
||||||
<name lang="ru">Управление настройками документов</name>
|
<name lang="ru">Управление настройками документов</name>
|
||||||
|
|
|
@ -163,9 +163,9 @@ public class ODFDocument {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreSettings(Settings settings) {
|
public void restoreSettings(Settings settings) {
|
||||||
closeDocument();
|
close();
|
||||||
restoreFrom(settings);
|
restoreFrom(settings);
|
||||||
reOpenDoc();
|
reopen();
|
||||||
}
|
}
|
||||||
|
|
||||||
public XPropertyContainer getUserDefinedProps(){
|
public XPropertyContainer getUserDefinedProps(){
|
||||||
|
@ -284,7 +284,7 @@ public class ODFDocument {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void reOpenDoc(){
|
public void reopen(){
|
||||||
try {
|
try {
|
||||||
XComponent doc = loader.loadComponentFromURL(url, "_default", 0, new PropertyValue[0]);
|
XComponent doc = loader.loadComponentFromURL(url, "_default", 0, new PropertyValue[0]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -293,7 +293,15 @@ public class ODFDocument {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeDocument() {
|
public void save() {
|
||||||
|
if (context != null) {
|
||||||
|
executedispatch("Save", new PropertyValue[0]);
|
||||||
|
} else {
|
||||||
|
logger.debug("Can't save document. No context.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
executedispatch("CloseDoc", new PropertyValue[0]);
|
executedispatch("CloseDoc", new PropertyValue[0]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -301,7 +309,7 @@ public class ODFDocument {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadDocument() {
|
public void reload() {
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
executedispatch("Reload", new PropertyValue[0]);
|
executedispatch("Reload", new PropertyValue[0]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class BackupPanel extends JPanel {
|
||||||
lst_backups.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
|
lst_backups.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
|
||||||
|
|
||||||
JLabel lb_backups = new JLabel(Localizer.get("backup_panel_description"));
|
JLabel lb_backups = new JLabel(Localizer.get("backup_panel_description"));
|
||||||
|
lb_backups.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
btn_delete = new JButton(Localizer.get("delete_backup_button"));
|
btn_delete = new JButton(Localizer.get("delete_backup_button"));
|
||||||
btn_create = new JButton(Localizer.get("create_backup_button"));
|
btn_create = new JButton(Localizer.get("create_backup_button"));
|
||||||
|
@ -82,18 +83,18 @@ public class BackupPanel extends JPanel {
|
||||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(groupLayout.createSequentialGroup()
|
.addGroup(groupLayout.createSequentialGroup()
|
||||||
.addGap(43)
|
.addGap(43)
|
||||||
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
|
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(lb_backups, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(lb_backups, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addGroup(groupLayout.createSequentialGroup()
|
.addGroup(groupLayout.createSequentialGroup()
|
||||||
.addComponent(lst_backups, GroupLayout.PREFERRED_SIZE, 354, GroupLayout.PREFERRED_SIZE)
|
.addComponent(lst_backups, GroupLayout.PREFERRED_SIZE, 247, GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(26)
|
.addGap(53)
|
||||||
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
|
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
|
||||||
.addComponent(cb_stick_latest_backup, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(cb_stick_latest_backup, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(btn_close, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(btn_close, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(btn_delete, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)
|
.addComponent(btn_delete, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)
|
||||||
.addComponent(btn_create, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(btn_create, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(btn_restore, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
.addComponent(btn_restore, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||||
.addContainerGap(288, Short.MAX_VALUE))
|
.addGap(39))
|
||||||
);
|
);
|
||||||
groupLayout.setVerticalGroup(
|
groupLayout.setVerticalGroup(
|
||||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
|
@ -133,8 +134,10 @@ public class BackupPanel extends JPanel {
|
||||||
if (document == null) {
|
if (document == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
document.save();
|
||||||
backups.create(document.getCurrentSettings());
|
backups.create(document.getCurrentSettings());
|
||||||
document.writeBackups(backups);
|
document.writeBackups(backups);
|
||||||
|
document.save();
|
||||||
populateList();
|
populateList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -152,6 +155,7 @@ public class BackupPanel extends JPanel {
|
||||||
String selected = (String) lst_backups.getSelectedValue();
|
String selected = (String) lst_backups.getSelectedValue();
|
||||||
backups.removeByDateTimeLabel(selected);
|
backups.removeByDateTimeLabel(selected);
|
||||||
document.writeBackups(backups);
|
document.writeBackups(backups);
|
||||||
|
document.save();
|
||||||
populateList();
|
populateList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@ settings_tab_name = Settings
|
||||||
backups_tab_name = Backups
|
backups_tab_name = Backups
|
||||||
backup_panel_description = Manage document settings backups
|
backup_panel_description = Manage document settings backups
|
||||||
no_timestamp_found_error = No backup dates found
|
no_timestamp_found_error = No backup dates found
|
||||||
stick_latest_backup_cb_label = Block settings
|
stick_latest_backup_cb_label = Freeze settings in all documents
|
||||||
no_backup_selected = Select backup and try again
|
no_backup_selected = Select backup and try again
|
||||||
error_document_not_found = Document not found.
|
error_document_not_found = Document not found.
|
||||||
error_document_is_not_saved = Document is not saved. Save document before proceeding.
|
error_document_is_not_saved = Document is not saved. Save document before proceeding.
|
||||||
|
|
|
@ -6,7 +6,7 @@ settings_tab_name = Настройки
|
||||||
backups_tab_name = Резервные копии
|
backups_tab_name = Резервные копии
|
||||||
backup_panel_description = Управление резервными копиями настроек документов
|
backup_panel_description = Управление резервными копиями настроек документов
|
||||||
no_timestamp_found_error = Не найдено дат резервных копий
|
no_timestamp_found_error = Не найдено дат резервных копий
|
||||||
stick_latest_backup_cb_label = Заблокировать изменение настроек
|
stick_latest_backup_cb_label = Замораживать настройки всех документов
|
||||||
no_backup_selected = Выберите резервную копию и попробуйте снова
|
no_backup_selected = Выберите резервную копию и попробуйте снова
|
||||||
error_document_not_found = Ошибка. Документ не найден.
|
error_document_not_found = Ошибка. Документ не найден.
|
||||||
error_document_is_not_saved = Документ не сохранен. Сохраните документ и попробуйте снова.
|
error_document_is_not_saved = Документ не сохранен. Сохраните документ и попробуйте снова.
|
||||||
|
|
Loading…
Add table
Reference in a new issue