From 378ae2eb0e8b32150787c8b39776d98407dae90a Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 21 Jul 2023 10:54:50 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-101063=20=E3=80=90=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=B8=89=E6=9C=9F=E3=80=91=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=B7=B2=E6=89=93=E5=BC=80=EF=BC=8C=E6=89=93=E5=BC=80=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=AE=A1=E7=90=86=EF=BC=8C=E6=A8=A1=E6=9D=BF=E8=A2=AB?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=85=B3=E9=97=AD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DesignerFrameFileDealerPane.java | 68 +++++++++++++++++-- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index ad65c59acb..ad2980d98d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -46,6 +46,7 @@ import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.event.Event; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; @@ -502,21 +503,31 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); path = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, path); boolean currentEditing = isCurrentEditing(path); - // 如果模板已经打开了,关掉,避免出现2个同名tab(1个是模板,1个是版本) - closeOpenedTemplate(path, currentEditing); if (VcsHelper.getInstance().isLegacyMode()) { + // 如果模板已经打开了,关掉,避免出现2个同名tab(1个是模板,1个是版本) + closeOpenedTemplate(path, currentEditing); FileVersionsPanel fileVersionTablePanel = FileVersionsPanel.getInstance(); fileVersionTablePanel.showFileVersionsPane(); stateChange(); } else { - VcsNewPane panel = new VcsNewPane(path); - BasicDialog dialog = panel.showWindow(DesignerContext.getDesignerFrame(), false); - dialog.setVisible(true); + //如果指定模板已经打开: + //1.如果该模板已保存,则正常打开新版本管理弹窗 + //2.如果该模板未保存,触发保存逻辑 + // a.如果用户选择保存,则保存并不关闭模板,弹出新版本管理弹窗 + // b.如果用户选择不保存,则关闭当前模板,弹出新版本管理弹窗 + // c.如果用户选择取消, 则啥操作都不做 + checkTemplateSavedAndShowVcsNewPane(path, currentEditing); } } + private void showVcsNewPane(String path) { + VcsNewPane panel = new VcsNewPane(path); + BasicDialog dialog = panel.showWindow(DesignerContext.getDesignerFrame(), false); + dialog.setVisible(true); + } + /** * 版本管理可用状态的监控 */ @@ -571,6 +582,53 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } + private void checkTemplateSavedAndShowVcsNewPane(String path, boolean isCurrentEditing) { + for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) { + if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) { + if (!jTemplate.isALLSaved()) { + if (isCurrentEditing) { + MultiTemplateTabPane.getInstance().setIsCloseCurrent(true); + } + MultiTemplateTabPane.getInstance().closeFormat(jTemplate); + confirmCloseAndShowVcsNewPane(jTemplate, path); + return; + } else { + showVcsNewPane(path); + } + } + } + } + + private void confirmCloseAndShowVcsNewPane(JTemplate specifiedTemplate, String path) { + if (specifiedTemplate == null) { + return; + } + if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { + specifiedTemplate.stopEditing(); + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), 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); + if (returnVal == JOptionPane.YES_OPTION) { + CallbackSaveWorker worker = specifiedTemplate.save(); + worker.addSuccessCallback(() -> { + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + showVcsNewPane(path); + }); + worker.start(specifiedTemplate.getRuntimeId()); + } else if (returnVal == JOptionPane.NO_OPTION) { + closeTpl(specifiedTemplate); + showVcsNewPane(path); + } + } else { + showVcsNewPane(path); + } + } + + private void closeTpl(JTemplate specifiedTemplate) { + HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); + MultiTemplateTabPane.getInstance().closeAndFreeLock(specifiedTemplate); + MultiTemplateTabPane.getInstance().activePrevTemplateAfterClose(); + } + } /**