|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|