From 29e1b13d8fdc07600e0152bf539ebd29493400c7 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 19 Jul 2021 09:57:15 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-53633=E3=80=90FR11=E3=80=91=E6=96=B0?= =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=E5=BC=80=E5=8F=91=E8=80=85=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E6=94=AF=E6=8C=81=E8=B0=83=E6=95=B4=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/file/MutilTempalteTabPane.java | 14 ++++++++-- .../com/fr/design/file/TemplateTreePane.java | 26 ++++++++++++------- .../com/fr/design/fun/PreviewProvider.java | 9 +++++++ .../gui/itree/filetree/EnvFileTree.java | 2 +- .../java/com/fr/design/mainframe/JForm.java | 3 +++ .../fr/design/preview/DeveloperPreview.java | 16 ++++++++++-- 6 files changed, 56 insertions(+), 14 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 87b7f2f25..6c3323600 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -731,6 +731,16 @@ public class MutilTempalteTabPane extends JComponent { } } + /** + * 后台关闭当前编辑模板 + */ + public void closeCurrentTpl(){ + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + this.setIsCloseCurrent(true); + this.closeFormat(jTemplate); + this.closeSpecifiedTemplate(jTemplate); + } + /** * 关闭模板 * @@ -765,8 +775,8 @@ public class MutilTempalteTabPane extends JComponent { // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板; // selectIndex 没有变化,但是对应的模板已经变成了前一张模板 if (closeIconIndex == selectedIndex || isCloseCurrent) { - // 如果 closeIconIndex 是最后一个被渲染画出的,那么预览上一个,防止数组越界 - if (closeIconIndex >= maxPaintIndex) { + // 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界 + if (selectedIndex >= maxPaintIndex) { // selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true selectedIndex--; } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 0fc3ca728..f3c85f6fb 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -17,6 +17,7 @@ import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; import com.fr.file.filetree.IOFileNodeFilter; +import com.fr.form.fit.web.editpreview.FileLockStateObservable; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; @@ -47,6 +48,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.Enumeration; import java.util.Objects; +import java.util.Observable; +import java.util.Observer; import static javax.swing.JOptionPane.WARNING_MESSAGE; import static javax.swing.JOptionPane.YES_NO_OPTION; @@ -76,6 +79,13 @@ public class TemplateTreePane extends JPanel implements FileOperations { scrollPane.setBorder(null); contentPane.add(scrollPane, BorderLayout.CENTER); + FileLockStateObservable.getInstance().addObserver(new Observer() { + @Override + public void update(Observable o, Object arg) { + TemplateTreePane.this.refresh(); + } + }); + /* * Tree.MouseAdapter */ @@ -202,15 +212,13 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public void openFile() { // 判断是否是远程设计的锁定文件 - if (!WorkContext.getCurrent().isLocal()) { - FileNode node = reportletsTree.getSelectedFileNode(); - if (node == null) { - return; - } - String lock = node.getLock(); - if (lock != null && !lock.equals(node.getUserID())) { - return; - } + FileNode node = reportletsTree.getSelectedFileNode(); + if (node == null) { + return; + } + String lock = node.getLock(); + if (lock != null && !lock.equals(node.getUserID())) { + return; } String reportPath = reportletsTree.getSelectedTemplatePath(); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath); diff --git a/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java b/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java index c07a4efe0..76b5037ef 100644 --- a/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java @@ -2,6 +2,7 @@ package com.fr.design.fun; import com.fr.design.mainframe.JTemplate; import com.fr.stable.Filter; +import com.fr.stable.StringUtils; import com.fr.stable.fun.mark.Mutable; import java.util.Map; @@ -62,5 +63,13 @@ public interface PreviewProvider extends Mutable, Filter { */ String getActionType(); + /** + * 下拉弹出菜单的提示 + * @return 弹出菜单的提示 + */ + default String tooltipForPopItem() { + return StringUtils.EMPTY; + } + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java index f3771a0f9..a748fa320 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -67,7 +67,7 @@ public class EnvFileTree extends RefreshableJTree { String lock = node.getLock(); String name = node.getName(); if (treeNode.hasFullAuthority()) { - if (lock != null && !node.getUserID().equals(lock)) { + if (lock != null && !lock.equals(node.getUserID())) { name = name + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked", "(", ")"); } this.setIcon(FileTreeIcon.getIcon(node)); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index bc32c5fd9..891ba8893 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -827,6 +827,9 @@ public class JForm extends JTemplate implements BaseJForm jt) { + MutilTempalteTabPane.getInstance().closeCurrentTpl(); + super.onClick(jt); + } + @Override public Map parametersForPreview() { Map map = new HashMap(); - map.put(ParameterConstants.OP, "developer_preview"); + map.put(ParameterConstants.OP, "editable_preview"); return map; }