Browse Source

REPORT-111690 A用户断网,B用户打开模板,A用户联网保存,副本保存异常

release/11.0
roger 11 months ago
parent
commit
965baddd46
  1. 64
      designer-base/src/main/java/com/fr/design/lock/LockFileReSaveEnum.java
  2. 46
      designer-base/src/main/java/com/fr/design/lock/LockInfoDialog.java
  3. 32
      designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java

64
designer-base/src/main/java/com/fr/design/lock/LockFileReSaveEnum.java

@ -0,0 +1,64 @@
package com.fr.design.lock;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.TemplateUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
/**
* 被锁住的文件重新保存副本时的处理枚举类
*
* @author Roger
* @since 11.0
* Created on 2023/12/21
*/
public enum LockFileReSaveEnum {
/**
* 保存目录树里面的模板副本
*/
TEMPLATE_TREE() {
@Override
public void action() {
FileNode node = TemplateTreePane.getInstance().getFileNode();
if (node == null) {
return;
}
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, TemplateTreePane.getInstance().getFilePath());
TemplateUtils.createAndReOpenTemplate(
Toolkit.i18nText("Fine_Design_Template_Lock_Copy"),
new FileNodeFILE(new FileNode(selectedFilePath, false)),
false,
true);
}
},
/**
* 保存设计器里面已经打开的模板副本
*/
HISTORY_TEMPLATE_CACHE() {
@Override
public void action() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(template)) {
TemplateUtils.createAndOpenTemplate(
Toolkit.i18nText("Fine_Design_Template_Backup"),
new FileNodeFILE(new FileNode(template.getPath(), false)),
true,
true,
//另存之后需要关闭的模板
template);
}
}
};
/**
* 如何保存模板副本
*/
public abstract void action();
}

46
designer-base/src/main/java/com/fr/design/lock/LockInfoDialog.java

@ -8,15 +8,14 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.utils.TemplateUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.IOUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.base.UserInfo;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
@ -24,9 +23,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JPanel;
/**
* @author hades
@ -37,8 +33,11 @@ public class LockInfoDialog extends JDialog {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
public LockInfoDialog(UserInfo userInfo) {
private final LockFileReSaveEnum saveEnum;
public LockInfoDialog(UserInfo userInfo, LockFileReSaveEnum saveEnum) {
super(DesignerContext.getDesignerFrame());
this.saveEnum = saveEnum;
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
panel.add(createContentPane(userInfo), BorderLayout.CENTER);
@ -94,16 +93,7 @@ public class LockInfoDialog extends JDialog {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
FileNode node = TemplateTreePane.getInstance().getFileNode();
if (node == null) {
return;
}
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, TemplateTreePane.getInstance().getFilePath());
TemplateUtils.createAndReOpenTemplate(
Toolkit.i18nText("Fine_Design_Template_Lock_Copy"),
new FileNodeFILE(new FileNode(selectedFilePath, false)),
false,
true);
saveEnum.action();
}
});
cancelButton.addActionListener(new ActionListener() {
@ -118,9 +108,25 @@ public class LockInfoDialog extends JDialog {
}
/**
* 显示模板被人锁住了的弹窗信息
*
* @param userInfo 拥有锁的用户信息
*/
public static void show(UserInfo userInfo) {
DesignerFrameFileDealerPane.getInstance().refreshRightToolBarBy(TemplateTreePane.getInstance().getFileNode());
new LockInfoDialog(userInfo);
new LockInfoDialog(userInfo, LockFileReSaveEnum.TEMPLATE_TREE);
}
/**
* 显示模板被人锁住了的弹窗信息,并以指定方式保存副本模板
*
* @param userInfo 拥有锁的用户信息
* @param saveEnum 指定保存副本模板的处理方式
*/
public static void show(UserInfo userInfo, LockFileReSaveEnum saveEnum) {
DesignerFrameFileDealerPane.getInstance().refreshRightToolBarBy(TemplateTreePane.getInstance().getFileNode());
new LockInfoDialog(userInfo, saveEnum);
}
}

32
designer-base/src/main/java/com/fr/design/worker/save/SaveFailureHandler.java

@ -2,21 +2,17 @@ package com.fr.design.worker.save;
import com.fr.common.exception.ThrowableHandler;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.design.lock.LockFileReSaveEnum;
import com.fr.design.lock.LockInfoDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.TemplateUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.IOUtils;
import com.fr.report.InconsistentLockException;
import com.fr.report.LockedException;
import com.fr.report.UnLockedException;
import com.fr.workspace.base.UserInfo;
import com.fr.workspace.exception.DiskSpaceFullException;
import com.fr.report.InconsistentLockException;
import java.awt.Frame;
import javax.swing.JOptionPane;
@ -104,7 +100,7 @@ public class SaveFailureHandler implements ThrowableHandler {
}
if (exception != null) {
UserInfo userInfo = exception.getUserInfo();
LockInfoDialog.show(userInfo);
LockInfoDialog.show(userInfo, LockFileReSaveEnum.HISTORY_TEMPLATE_CACHE);
return true;
}
return false;
@ -134,16 +130,7 @@ public class SaveFailureHandler implements ThrowableHandler {
IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png"),
new Object[] {Toolkit.i18nText("Fine_Design_Template_SaveAs_Backup"), Toolkit.i18nText("Fine-Design_Basic_Button_Cancel")}, null);
if (option == JOptionPane.YES_OPTION) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(template)) {
TemplateUtils.createAndOpenTemplate(
Toolkit.i18nText("Fine_Design_Template_Backup"),
new FileNodeFILE(new FileNode(template.getPath(), false)),
true,
true,
//另存之后需要关闭的模板
template);
}
LockFileReSaveEnum.HISTORY_TEMPLATE_CACHE.action();
}
}
@ -156,16 +143,7 @@ public class SaveFailureHandler implements ThrowableHandler {
IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png"),
new Object[] {Toolkit.i18nText("Fine_Design_Template_SaveAs_Backup"), Toolkit.i18nText("Fine-Design_Basic_Button_Cancel")}, null);
if (option == JOptionPane.YES_OPTION) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(template)) {
TemplateUtils.createAndOpenTemplate(
Toolkit.i18nText("Fine_Design_Template_Backup"),
new FileNodeFILE(new FileNode(template.getPath(), false)),
true,
true,
//另存之后需要关闭的模板
template);
}
LockFileReSaveEnum.HISTORY_TEMPLATE_CACHE.action();
}
}

Loading…
Cancel
Save