Browse Source

REPORT-101608 【版本管理三期】通过版本中心入口进入版本详情,未保存的模板触发还原,选择保存还原会失败

new-design
Destiny.Lin 1 year ago
parent
commit
e50cafdd96
  1. 29
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCloseTemplateHelper.java
  2. 36
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsNewPaneWrapper.java

29
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCloseTemplateHelper.java

@ -14,6 +14,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
/** /**
* 版本管理关闭模板辅助类 * 版本管理关闭模板辅助类
@ -38,17 +39,18 @@ public class VcsCloseTemplateHelper {
* @param dialog 生成的新版本管理的详情面板的父面板 * @param dialog 生成的新版本管理的详情面板的父面板
*/ */
public static void checkTemplateSavedAndShowVcsNewPane(String path, boolean isCurrentEditing, BasicDialog dialog, VcsNewPane pane) { public static void checkTemplateSavedAndShowVcsNewPane(String path, boolean isCurrentEditing, BasicDialog dialog, VcsNewPane pane) {
VcsNewPaneWrapper wrapper = new VcsNewPaneWrapper(path, dialog, pane);
for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) { for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) {
if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) { if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) {
if (!jTemplate.isALLSaved()) { if (!jTemplate.isALLSaved()) {
MultiTemplateTabPane.getInstance().setIsCloseCurrent(isCurrentEditing); MultiTemplateTabPane.getInstance().setIsCloseCurrent(isCurrentEditing);
MultiTemplateTabPane.getInstance().closeFormat(jTemplate); MultiTemplateTabPane.getInstance().closeFormat(jTemplate);
confirmCloseAndShowVcsNewPane(jTemplate, path, dialog, pane); confirmCloseAndShowVcsNewPane(jTemplate, wrapper);
return; return;
} }
} }
} }
showVcsNewPane(path, dialog, pane); wrapper.show();
} }
@ -78,42 +80,31 @@ public class VcsCloseTemplateHelper {
private static void confirmCloseAndShowVcsNewPane(JTemplate<?, ?> specifiedTemplate, String path, BasicDialog dialog, VcsNewPane pane) { private static void confirmCloseAndShowVcsNewPane(JTemplate<?, ?> specifiedTemplate, VcsNewPaneWrapper wrapper) {
if (specifiedTemplate == null) { if (specifiedTemplate == null) {
return; return;
} }
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing(); specifiedTemplate.stopEditing();
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
String.format("%s\"%s\" ?",Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save"), specifiedTemplate.getEditingFILE()),
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) { if (returnVal == JOptionPane.YES_OPTION) {
CallbackSaveWorker worker = specifiedTemplate.save(); CallbackSaveWorker worker = specifiedTemplate.save();
worker.addSuccessCallback(() -> { worker.addSuccessCallback(() -> {
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
showVcsNewPane(path, dialog, pane); SwingUtilities.invokeLater(wrapper::show);
}); });
worker.start(specifiedTemplate.getRuntimeId()); worker.start(specifiedTemplate.getRuntimeId());
} else if (returnVal == JOptionPane.NO_OPTION) { } else if (returnVal == JOptionPane.NO_OPTION) {
closeTpl(specifiedTemplate); closeTpl(specifiedTemplate);
showVcsNewPane(path, dialog, pane); wrapper.show();
} }
} else { } else {
showVcsNewPane(path, dialog, pane); wrapper.show();
} }
} }
private static void showVcsNewPane(String path, BasicDialog dialog, VcsNewPane pane) {
if (pane != null) {
pane.showDialog(dialog);
} else {
VcsNewPane newPane = new VcsNewPane(path);
newPane.showDialog(dialog);
}
}
private static void closeTpl(JTemplate<?, ?> specifiedTemplate) { private static void closeTpl(JTemplate<?, ?> specifiedTemplate) {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
MultiTemplateTabPane.getInstance().closeAndFreeLock(specifiedTemplate); MultiTemplateTabPane.getInstance().closeAndFreeLock(specifiedTemplate);

36
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsNewPaneWrapper.java

@ -0,0 +1,36 @@
package com.fr.design.mainframe.vcs.common;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.mainframe.vcs.ui.VcsNewPane;
/**
* 构建VcsNewPane的包装类
*
* @author Destiny.Lin
* @since 11.0
* Created on 2023/7/27
*/
public class VcsNewPaneWrapper {
private String path;
private BasicDialog dialog;
private VcsNewPane pane;
public VcsNewPaneWrapper(String path, BasicDialog dialog, VcsNewPane pane) {
this.path = path;
this.dialog = dialog;
this.pane = pane;
}
/**
* 显示面板
*/
public void show() {
if (pane != null) {
pane.showDialog(dialog);
} else {
VcsNewPane newPane = new VcsNewPane(path);
newPane.showDialog(dialog);
}
}
}
Loading…
Cancel
Save