diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java index 6b5f9e324b..64e28eabf4 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java @@ -100,8 +100,7 @@ public class MultiTemplateTabMenuFactory { closeOther.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - - MultiTemplateTabPane.getInstance().closeAllByOperatorType(currentOperator); + MultiTemplateTabPane.getInstance().closeOtherByOperatorType(currentOperator); } }); if (MultiTemplateTabPane.getInstance().getOpenedJTemplatesByOperator(currentOperator).size() <= 1) { diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 4f292ecfe7..901a12154e 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -384,7 +384,8 @@ public class MultiTemplateTabPane extends JComponent { * 关闭所有指定模板tab操作类型的模板 * @param operatorType */ - public void closeAllByOperatorType(String operatorType){ + public void closeOtherByOperatorType(String operatorType){ + JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); if (saveSomeTempaltePane.showSavePane()) { List> openedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); @@ -393,26 +394,24 @@ public class MultiTemplateTabPane extends JComponent { for (int i = 0; i < openedTemplate.size(); i++) { templates[i] = openedTemplate.get(i); } - closeTemplate(templates, operatorType); + closeTemplate(templates, currentEditingTemplate, operatorType); - if (openedTemplate.size() == 0) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(); - } else { - DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(0)); - } + DesignerContext.getDesignerFrame().activateJTemplate(currentEditingTemplate); MultiTemplateTabPane.getInstance().repaint(); } } /** - * 关闭指定模板 + * 关闭指定的非当前编辑模板 * @param templates * @param operatorType */ - private static void closeTemplate(JTemplate[] templates, String operatorType) { + private static void closeTemplate(JTemplate[] templates, JTemplate currentEditingTemplate, String operatorType) { for (int i = 0; i < templates.length; i++) { JTemplate jTemplate = templates[i]; - if (!ComparatorUtils.equals(operatorType, jTemplate.getTemplateTabOperatorType())){ + boolean needClose = ComparatorUtils.equals(operatorType, jTemplate.getTemplateTabOperatorType()) + && jTemplate != currentEditingTemplate; + if (!needClose) { continue; } MultiTemplateTabPane.getInstance().closeFormat(jTemplate); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 37812c106f..3372e2ad13 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -416,7 +416,9 @@ public abstract class ToolBarMenuDock { menuDef.addShortCut(new OpenRecentReportMenuDef()); - addCloseCurrentTemplateAction(menuDef); + if (!DesignModeContext.isDuchampMode()) { + addCloseCurrentTemplateAction(menuDef); + } scs = plus.shortcut4FileMenu(); if (!ArrayUtils.isEmpty(scs)) {