From b112a98c33e68b5b6fe218d62b65c422dba61ed7 Mon Sep 17 00:00:00 2001 From: roger Date: Thu, 25 Aug 2022 15:07:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-78864=20=E6=94=B6=E8=B5=B7=E6=89=80?= =?UTF-8?q?=E6=9C=89=E6=93=8D=E4=BD=9C=E5=90=8E=E5=85=B6=E4=BB=96=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=B2=A1=E6=9C=89=E7=BD=AE=E7=81=B0=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/file/LocateAction.java | 27 ++++++++++++---- .../fr/design/file/MutilTempalteTabPane.java | 31 ++++++++++++++++++- .../DesignerFrameFileDealerPane.java | 1 + 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/LocateAction.java b/designer-base/src/main/java/com/fr/design/actions/file/LocateAction.java index 8c5955bcdc..db308181dc 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/LocateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/LocateAction.java @@ -3,6 +3,7 @@ package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.TemplateTreePane; +import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.RefreshableJTree; import com.fr.design.i18n.Toolkit; @@ -32,7 +33,7 @@ public class LocateAction extends UpdateAction { @Override public void actionPerformed(ActionEvent e) { JTemplate current = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - gotoEditingTemplateLeaf(current.getEditingFILE().getPath()); + gotoEditingTemplateLeaf(current.getEditingFILE().getPath(), false); } /** @@ -41,20 +42,34 @@ public class LocateAction extends UpdateAction { * @param locatedPath */ public static void gotoEditingTemplateLeaf(String locatedPath) { + gotoEditingTemplateLeaf(locatedPath, true); + } + + private static void gotoEditingTemplateLeaf(String locatedPath, boolean needRefreshMode) { if (locatedPath == null) { return; } - DefaultTreeModel model = (DefaultTreeModel) TemplateTreePane.getInstance().getTemplateFileTree().getModel(); + DefaultTreeModel model = (DefaultTreeModel) getTemplateFileTree().getModel(); ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) model.getRoot(); + if (needRefreshMode) { + treeNode.removeAllChildren(); + ExpandMutableTreeNode[] childTreeNodes = getTemplateFileTree().loadChildTreeNodes(treeNode); + treeNode.addChildTreeNodes(childTreeNodes); + model.reload(treeNode); + } recursiveSelectPath(treeNode, locatedPath, model); - TreePath selectedTreePath = TemplateTreePane.getInstance().getTemplateFileTree().getSelectionPath(); + TreePath selectedTreePath = getTemplateFileTree().getSelectionPath(); if (selectedTreePath != null) { - TemplateTreePane.getInstance().getTemplateFileTree().scrollPathToVisible(selectedTreePath); + getTemplateFileTree().scrollPathToVisible(selectedTreePath); } } + private static TemplateFileTree getTemplateFileTree() { + return TemplateTreePane.getInstance().getTemplateFileTree(); + } + private static void recursiveSelectPath(TreeNode treeNode, String currentPath, DefaultTreeModel m_model) { for (int i = 0, len = treeNode.getChildCount(); i < len; i++) { TreeNode node = treeNode.getChildAt(i); @@ -90,7 +105,7 @@ public class LocateAction extends UpdateAction { // 如果equals,说明找到了,不必再找下去了 if (ComparatorUtils.equals(new File(currentTreePath), new File(filePath))) { - TemplateTreePane.getInstance().getTemplateFileTree().setSelectionPath(new TreePath(model.getPathToRoot(currentTreeNode))); + getTemplateFileTree().setSelectionPath(new TreePath(model.getPathToRoot(currentTreeNode))); result = true; } // 如果当前路径是currentFilePath的ParentFile,则expandTreeNode,并继续往下找 @@ -122,7 +137,7 @@ public class LocateAction extends UpdateAction { // 删除所有的节点. currentTreeNode.removeAllChildren(); - ExpandMutableTreeNode[] children = TemplateTreePane.getInstance().getTemplateFileTree().loadChildTreeNodes(currentTreeNode); + ExpandMutableTreeNode[] children = getTemplateFileTree().loadChildTreeNodes(currentTreeNode); for (ExpandMutableTreeNode c : children) { currentTreeNode.add(c); } 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 aabb6ef751..818ebe8b3b 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 @@ -68,6 +68,9 @@ import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; import java.util.List; +import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; +import static javax.swing.JOptionPane.*; + /** * Author : daisy * Date: 13-8-5 @@ -265,7 +268,33 @@ public class MutilTempalteTabPane extends JComponent { TemplateTreePane.getInstance().refreshDockingView(); } JTemplate template = openedTemplate.get(this.tplIndex); - super.gotoEditingTemplateLeaf(template.getPath()); + locateTemplate(template); + } + + private void locateTemplate(JTemplate template) { + FILE currentTemplate = template.getEditingFILE(); + //模板不属于当前环境,跟预览一样先提示保存,再定位模板 + if (!currentTemplate.exists()) { + int selVal = showConfirmDialog( + DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), + Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), + OK_CANCEL_OPTION, + WARNING_MESSAGE + ); + if (OK_OPTION == selVal) { + CallbackSaveWorker worker = template.saveAs(); + worker.start(template.getRuntimeId()); + worker.addSuccessCallback(new Runnable() { + @Override + public void run() { + gotoEditingTemplateLeaf(template.getPath()); + } + }); + } + } else { + gotoEditingTemplateLeaf(template.getPath()); + } } } 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 c2a2a9c600..e6bfff633c 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 @@ -476,6 +476,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt @Override public void actionPerformed(ActionEvent e) { TemplateTreePane.getInstance().refreshDockingView(); + refreshDockingView(); } } From d00cabb1cd34db8732daef5d4fdb5454b6b2754d Mon Sep 17 00:00:00 2001 From: roger Date: Thu, 25 Aug 2022 15:10:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8E=BB=E6=8E=89import=20*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/file/MutilTempalteTabPane.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 818ebe8b3b..480edea346 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 @@ -69,7 +69,9 @@ import java.awt.geom.RoundRectangle2D; import java.util.List; import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.*; +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.OK_OPTION; +import static javax.swing.JOptionPane.WARNING_MESSAGE; /** * Author : daisy