From 7e8751ecde8e8fb2c44d6665d0905125fc7683a1 Mon Sep 17 00:00:00 2001 From: xiaxiang <1438003374@qq.com> Date: Mon, 25 Apr 2016 16:32:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9B=AE=E5=BD=95=E6=A0=91?= =?UTF-8?q?=E7=9A=84=E5=BF=AB=E9=80=9F=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/TemplateFileTree.java | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer_base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java index a66fe522af..5637181ccf 100644 --- a/designer_base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer_base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -1,15 +1,15 @@ package com.fr.design.gui.itree.filetree; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.tree.TreePath; - import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.file.filetree.FileNode; import com.fr.stable.ArrayUtils; import com.fr.stable.project.ProjectConstants; +import javax.swing.text.Position; +import javax.swing.tree.TreePath; +import java.util.ArrayList; +import java.util.List; + /* * 显示Env下的reportlets目录下面的所有cpt文件 */ @@ -66,4 +66,34 @@ public class TemplateFileTree extends EnvFileTree { return selectedPathList.toArray(new String[0]); } + + public TreePath getNextMatch(String prefix, int startingRow, + Position.Bias bias) { + + int max = getRowCount(); + if (prefix == null) { + throw new IllegalArgumentException(); + } + if (startingRow < 0 || startingRow >= max) { + throw new IllegalArgumentException(); + } + prefix = prefix.toUpperCase(); + + // start search from the next/previous element froom the + // selected element + int increment = (bias == Position.Bias.Forward) ? 1 : -1; + int row = startingRow; + do { + TreePath path = getPathForRow(row); + String text = convertValueToText( + path.getLastPathComponent(), isRowSelected(row), + isExpanded(row), true, row, false); + + if (text.toUpperCase().startsWith(prefix)) { + return path; + } + row = (row + increment + max) % max; + } while (row != startingRow); + return null; + } } \ No newline at end of file