Browse Source

添加类、方法的相关注释

feature/x
roger 2 years ago
parent
commit
ea95d395ec
  1. 11
      designer-base/src/main/java/com/fr/design/actions/file/DelFileAction.java
  2. 8
      designer-base/src/main/java/com/fr/design/actions/file/LocateAction.java
  3. 16
      designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java
  4. 51
      designer-base/src/main/java/com/fr/design/file/DefaultTemplateTreeDefineProcessor.java
  5. 3
      designer-base/src/main/java/com/fr/design/file/TemplateDirTreePane.java
  6. 3
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateDirTree.java
  7. 11
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  8. 3
      designer-base/src/main/java/com/fr/design/mainframe/manager/clip/TemplateTreeClipboard.java
  9. 17
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/TemplateDirTreeSearchManager.java
  10. 17
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/TemplateTreeSearchManager.java
  11. 35
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/TemplateDirTreeSearcher.java
  12. 26
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/TemplateTreeSearcher.java
  13. 6
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/common/TemplateDirSearchCallBack.java
  14. 6
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/common/TemplateSearchCallBack.java
  15. 3
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/common/TemplateSearchResult.java
  16. 3
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/common/TemplateSearchTask.java
  17. 3
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirSearchRemindPane.java
  18. 3
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirTreeSearchPane.java
  19. 16
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateSearchRemindPane.java
  20. 3
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateTreeSearchToolbarPane.java
  21. 3
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pre/TemplateDirPreSearchTask.java
  22. 9
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pre/TemplatePreSearchCallBack.java
  23. 4
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pre/TemplatePreSearchTask.java
  24. 34
      designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

11
designer-base/src/main/java/com/fr/design/actions/file/DelFileAction.java

@ -6,10 +6,13 @@ import com.fr.design.file.FileOperations;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.utils.TemplateUtils;
import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION;
/*
* 删除指定文件
@ -32,6 +35,14 @@ public class DelFileAction extends UpdateAction {
WARNING_MESSAGE);
return;
}
if (TemplateUtils.checkSelectedTemplateIsEditing()) {
if (FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Is_Editing"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return;
}
}
selectedOperation.deleteFile();
DesignerFrameFileDealerPane.getInstance().stateChange();
DesignerContext.getDesignerFrame().setTitle();

8
designer-base/src/main/java/com/fr/design/actions/file/LocateAction.java

@ -19,6 +19,9 @@ import javax.swing.tree.TreePath;
import java.awt.event.ActionEvent;
import java.io.File;
/**
* 模板定位功能
*/
public class LocateAction extends UpdateAction {
public LocateAction() {
@ -32,6 +35,11 @@ public class LocateAction extends UpdateAction {
gotoEditingTemplateLeaf(current.getEditingFILE().getPath());
}
/**
* 在左侧模板树定位到指定模板
*
* @param locatedPath
*/
public static void gotoEditingTemplateLeaf(String locatedPath) {
if (locatedPath == null) {
return;

16
designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java

@ -16,6 +16,7 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.utils.TemplateUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
@ -29,6 +30,7 @@ import com.fr.third.org.apache.commons.io.FilenameUtils;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@ -47,8 +49,11 @@ import java.util.regex.Pattern;
import static javax.swing.JOptionPane.DEFAULT_OPTION;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION;
/**
* 模板/目录重命名操作
*/
public class RenameAction extends UpdateAction {
private FileOperations selectedOperation;
@ -235,6 +240,15 @@ public class RenameAction extends UpdateAction {
private void confirmClose() {
if (TemplateUtils.checkSelectedTemplateIsEditing()) {
if (FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Is_Editing"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
YES_NO_OPTION) == JOptionPane.NO_OPTION) {
return;
}
}
String userInput = nameField.getText().trim();
String path = FilenameUtils.standard(fnf.getPath());

51
designer-base/src/main/java/com/fr/design/file/DefaultTemplateTreeDefineProcessor.java

@ -18,6 +18,7 @@ import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard;
import com.fr.design.mainframe.manager.search.TemplateDirTreeSearchManager;
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager;
import com.fr.design.mainframe.manager.search.searcher.control.pane.TemplateDirTreeSearchPane;
import com.fr.design.utils.TemplateUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
@ -49,6 +50,9 @@ import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION;
/**
* 默认的模板右键处理方式包含重命名复制黏贴删除移动等功能
*/
public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefineProcessor {
private UIPopupMenu popupMenu;
@ -129,6 +133,9 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
return TemplateDirTreePane.getInstance().getTemplateDirTree();
}
/**
* 复制功能
*/
private class CopyAction extends UpdateAction {
public CopyAction() {
@ -153,6 +160,9 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
}
}
/**
* 黏贴功能
*/
private class PasteAction extends UpdateAction {
public PasteAction() {
@ -207,14 +217,20 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
return false;
}
//确定目标目录并检查权限
FileOperations selectedOperation = DesignerFrameFileDealerPane.getInstance().getSelectedOperation();
if (getFileTree().getSelectionCount() != 0 && !selectedOperation.access()) {
if (getDirTree().getSelectionCount() != 0 && !TemplateDirTreePane.getInstance().selectedAccess()) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
WARNING_MESSAGE);
return false;
}
//检测之前复制的文件是否被打开
if (TemplateUtils.checkTemplateIsEditing(treeNodeList.toArray(new ExpandMutableTreeNode[0]))) {
return FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Is_Editing"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
YES_NO_OPTION) == JOptionPane.YES_OPTION;
}
return true;
}
@ -251,6 +267,9 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
}
/**
* 移动功能
*/
private class MoveAction extends UpdateAction {
public MoveAction() {
@ -347,12 +366,8 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
}
private void confirmClose() {
//获取目录数中所选中的文件,并判断是否有权限
if (getFileTree().getSelectionCount() != 0 && !TemplateDirTreePane.getInstance().selectedAccess()) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
WARNING_MESSAGE);
//获取目录树中所选中的文件,并判断是否有权限
if (!checkBeforeMove()) {
return;
}
boolean moveSuccess = doMove();
@ -372,9 +387,27 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
}
}
private boolean checkBeforeMove() {
if (getDirTree().getSelectionCount() != 0 && !TemplateDirTreePane.getInstance().selectedAccess()) {
FineJOptionPane.showMessageDialog(this,
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
WARNING_MESSAGE);
return false;
}
if (TemplateUtils.checkSelectedTemplateIsEditing()) {
return FineJOptionPane.showConfirmDialog(this,
Toolkit.i18nText("Fine-Design_Basic_Template_Is_Editing"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
YES_NO_OPTION) == JOptionPane.YES_OPTION;
}
return true;
}
private boolean doMove() {
FileNode fileNode = getDirTree().getSelectedFileNode();
fileNode = fileNode == null ? (FileNode) getFileTree().getModel().getRoot() : fileNode;
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) getDirTree().getModel().getRoot();
fileNode = fileNode == null ? (FileNode) rootTreeNode.getUserObject() : fileNode;
boolean moveSuccess = true;
try {
//待移动的文件可以有多个

3
designer-base/src/main/java/com/fr/design/file/TemplateDirTreePane.java

@ -17,6 +17,9 @@ import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.Color;
/**
* 目录树面板
*/
public class TemplateDirTreePane extends JPanel {
public static TemplateDirTreePane getInstance() {

3
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateDirTree.java

@ -3,7 +3,6 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.mainframe.manager.search.TemplateDirTreeSearchManager;
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager;
import com.fr.file.filetree.FileNode;
import java.util.Arrays;
@ -40,7 +39,7 @@ public class TemplateDirTree extends TemplateFileTree {
return;
}
currentTreeMode.clear();
allTreeNode = TemplateTreeSearchManager.getInstance().allFileNodes().entrySet().stream().collect(
allTreeNode = TemplateDirTreeSearchManager.getInstance().allFileNodes().entrySet().stream().collect(
Collectors.toMap(Map.Entry::getKey, entry -> fileNodeArray2TreeNodeArray(new FileNode[]{entry.getValue()})[0]));
root.removeAllChildren();

11
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -261,6 +261,9 @@ public class TemplateFileTree extends EnvFileTree {
return new FileNode[0];
}
/**
* 搜索时更新搜索结果
*/
@Override
public void refresh4TreeSearch() {
ExpandMutableTreeNode root = (ExpandMutableTreeNode) this.getModel().getRoot();
@ -313,6 +316,12 @@ public class TemplateFileTree extends EnvFileTree {
}
}
/**
* 将搜索匹配到的模板添加到搜索结果树里面
*
* @param root
* @param treeNode
*/
protected void addToTreeModel(ExpandMutableTreeNode root, ExpandMutableTreeNode treeNode) {
FileNode fileNode = (FileNode) treeNode.getUserObject();
@ -357,7 +366,7 @@ public class TemplateFileTree extends EnvFileTree {
return result;
}
protected void removePending(ExpandMutableTreeNode treeNode) {
private void removePending(ExpandMutableTreeNode treeNode) {
if (treeNode.getChildCount() >= 1 && ((ExpandMutableTreeNode) treeNode.getFirstChild()).getUserObject() == PENDING) {
treeNode.remove(0);
}

3
designer-base/src/main/java/com/fr/design/mainframe/manager/clip/TemplateTreeClipboard.java

@ -5,6 +5,9 @@ import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import java.util.ArrayList;
import java.util.List;
/**
* 模板复制黏贴
*/
public class TemplateTreeClipboard {
private List<ExpandMutableTreeNode> clip = new ArrayList<>();

17
designer-base/src/main/java/com/fr/design/mainframe/manager/search/TemplateDirTreeSearchManager.java

@ -140,7 +140,7 @@ public class TemplateDirTreeSearchManager {
FineLoggerFactory.getLogger().info("out of template search");
lastSearchText = null;
if (treeSearcher != null) {
treeSearcher.afterSearch();
treeSearcher.exitSearch();
}
if (rendererHelper != null) {
rendererHelper.restore(getCurrentTemplateDirTree());
@ -155,14 +155,25 @@ public class TemplateDirTreeSearchManager {
return treeSearcher.getMatchSets().toArray(new FileNode[0]);
}
/**
* 当前目录树中搜索的目录节点
* @return
*/
public Map<String, FileNode> allFileNodes() {
return treeSearcher.getAllTemplates();
}
/**
* 搜索结果是否为空
* @return
*/
public boolean isMatchSetsEmpty() {
return treeSearcher.isMatchSetsEmpty();
}
/**
* 恢复到模板树面板
*/
public void restoreTreePane() {
setTreeSearchStatus(TreeSearchStatus.SEARCH_NOT_BEGIN);
lastSearchText = null;
@ -184,6 +195,10 @@ public class TemplateDirTreeSearchManager {
return repeat;
}
/**
* 当前是否处于搜索模式
* @return
*/
public boolean isInSearchMode() {
return getTreeSearchStatus() != TreeSearchStatus.NOT_IN_SEARCH_MODE;
}

17
designer-base/src/main/java/com/fr/design/mainframe/manager/search/TemplateTreeSearchManager.java

@ -170,7 +170,7 @@ public class TemplateTreeSearchManager {
setTreeSearchStatus(TreeSearchStatus.NOT_IN_SEARCH_MODE);
FineLoggerFactory.getLogger().info("out of template search");
if (treeSearcher != null) {
treeSearcher.afterSearch();
treeSearcher.exitSearch();
}
lastSearchText = null;
if (rendererHelper != null) {
@ -200,18 +200,33 @@ public class TemplateTreeSearchManager {
return treeSearcher.getMatchSets().toArray(new FileNode[0]);
}
/**
* 当前模板树中的所有模板节点
* @return
*/
public Map<String, FileNode> allFileNodes() {
return treeSearcher.getAllTemplates();
}
/**
* 是否处于搜索模式
* @return
*/
public boolean isInSearchMode() {
return getTreeSearchStatus() != TreeSearchStatus.NOT_IN_SEARCH_MODE;
}
/**
* 退出搜索模式
*/
public void outOfSearchMode() {
restoreToolBarAndTreePane();
}
/**
* 搜索结果数是否处于更新状态
* @return
*/
public boolean isRefreshing() {
return isRefreshing.get();
}

35
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/TemplateDirTreeSearcher.java

@ -23,7 +23,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
* 目录搜索器
*/
public class TemplateDirTreeSearcher extends TemplateTreeSearcher {
private ExecutorService executorService;
@ -60,6 +62,11 @@ public class TemplateDirTreeSearcher extends TemplateTreeSearcher {
return this.calculatedSets.size();
}
/**
* 将模板添加到已经计算过的集合中不管模板是不是匹配
*
* @param templateNames
*/
public synchronized void addToCalculatedSets(List<String> templateNames) {
for (String templateName : templateNames) {
FileNode fileNode = allDirs.get(templateName);
@ -70,10 +77,20 @@ public class TemplateDirTreeSearcher extends TemplateTreeSearcher {
}
}
/**
* 将搜索匹配的目录添加到匹配的集合中
*
* @param matchNodes
*/
public synchronized void addToMatchSets(List<FileNode> matchNodes) {
matchSets.addAll(matchNodes);
}
/**
* 将目录添加到未计算的集合中
*
* @param fileNodes
*/
public void addToNotCalculatedSets(List<FileNode> fileNodes) {
synchronized (lock) {
Map<String, FileNode> chileMap = fileNodes.stream().collect(Collectors.toMap(FileNode::getEnvPath, treeNode -> treeNode));
@ -117,6 +134,11 @@ public class TemplateDirTreeSearcher extends TemplateTreeSearcher {
allDirs.putAll(fileNodeMap);
}
/**
* 开始搜索
*
* @param searchText
*/
@Override
public void startSearch(String searchText) {
reset();
@ -141,11 +163,17 @@ public class TemplateDirTreeSearcher extends TemplateTreeSearcher {
} while (outLayerDirCount.get() != 0);
}
/**
* 停止搜索
*/
@Override
public void stopSearch() {
}
/**
* 完成搜索
*/
@Override
public void completeSearch() {
@ -157,7 +185,10 @@ public class TemplateDirTreeSearcher extends TemplateTreeSearcher {
notCalculatedSets.addAll(allDirs.keySet());
}
public void afterSearch() {
/**
* 退出搜索时的处理
*/
public void exitSearch() {
allDirs.clear();
executorService.shutdownNow();
}

26
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/TemplateTreeSearcher.java

@ -68,10 +68,20 @@ public class TemplateTreeSearcher implements TreeSearcher {
}
}
/**
* 将搜索匹配的模板添加到匹配的集合中
*
* @param matchNodes
*/
public synchronized void addToMatchSets(List<FileNode> matchNodes) {
matchSets.addAll(matchNodes);
}
/**
* 将模板添加到未计算的集合中
*
* @param fileNodes
*/
public void addToNotCalculatedSets(List<FileNode> fileNodes) {
synchronized (lock) {
Map<String, FileNode> chileMap = fileNodes.stream().collect(Collectors.toMap(FileNode::getEnvPath, treeNode -> treeNode));
@ -116,6 +126,11 @@ public class TemplateTreeSearcher implements TreeSearcher {
allTemplates.putAll(fileNodeMap);
}
/**
* 开始搜索
*
* @param searchText
*/
@Override
public void startSearch(String searchText) {
reset();
@ -140,11 +155,17 @@ public class TemplateTreeSearcher implements TreeSearcher {
} while (outLayerDirCount.get() != 0);
}
/**
* 停止搜索
*/
@Override
public void stopSearch() {
}
/**
* 完成搜索
*/
@Override
public void completeSearch() {
@ -156,7 +177,10 @@ public class TemplateTreeSearcher implements TreeSearcher {
notCalculatedSets.addAll(allTemplates.keySet());
}
public void afterSearch() {
/**
* 退出搜索模式
*/
public void exitSearch() {
allTemplates.clear();
executorService.shutdownNow();
}

6
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/common/TemplateDirSearchCallBack.java

@ -8,6 +8,9 @@ import com.fr.design.search.control.TreeSearchResult;
import javax.swing.SwingUtilities;
/**
* 目录树搜索回调处理
*/
public class TemplateDirSearchCallBack implements TreeSearchCallback {
protected TemplateDirTreeSearcher treeSearcher;
@ -30,6 +33,9 @@ public class TemplateDirSearchCallBack implements TreeSearchCallback {
}
}
/**
* 更新目录树搜索结果
*/
protected void updateTemplateTree() {
SwingUtilities.invokeLater(() -> {
if (TemplateDirTreeSearchManager.getInstance().getTreeSearchStatus() != TreeSearchStatus.SEARCHING) {

6
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/common/TemplateSearchCallBack.java

@ -7,6 +7,9 @@ import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager;
import com.fr.design.mainframe.manager.search.searcher.TemplateTreeSearcher;
import javax.swing.SwingUtilities;
/**
* 模板搜索回调处理
*/
public class TemplateSearchCallBack implements TreeSearchCallback {
protected TemplateTreeSearcher treeSearcher;
@ -28,6 +31,9 @@ public class TemplateSearchCallBack implements TreeSearchCallback {
updateTemplateTree();
}
/**
* 更新目录树搜索结果
*/
protected void updateTemplateTree() {
int calculatedCount = treeSearcher.getCalculatedCount();
boolean allCalculated = calculatedCount == treeSearcher.getAllTemplateSize();

3
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/common/TemplateSearchResult.java

@ -6,6 +6,9 @@ import com.fr.file.filetree.FileNode;
import java.util.ArrayList;
import java.util.List;
/**
* 模板搜索结果
*/
public class TemplateSearchResult implements TreeSearchResult {
private boolean success;

3
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/common/TemplateSearchTask.java

@ -9,6 +9,9 @@ import com.fr.log.FineLoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
/**
* 模板搜索任务比较模板路径与搜索关键字是否匹配
*/
public class TemplateSearchTask implements TreeSearchTask {
/**

3
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirSearchRemindPane.java

@ -23,6 +23,9 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.FlowLayout;
/**
* 目录树搜索提示面板整合了目录树面板和搜索时的提示面板
*/
public class TemplateDirSearchRemindPane extends JPanel implements TreeSearchStatusChangeListener {
private TemplateDirSearchRemindPane.RemindPane remindPane;

3
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirTreeSearchPane.java

@ -26,6 +26,9 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* 目录树搜索面板
*/
public class TemplateDirTreeSearchPane extends JPanel implements TreeSearchStatusChangeListener {
/**

16
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateSearchRemindPane.java

@ -24,6 +24,9 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.FlowLayout;
/**
* 模板搜索提示面板整合了模板树和提示面板
*/
public class TemplateSearchRemindPane extends JPanel implements TreeSearchStatusChangeListener {
private TemplateSearchRemindPane.RemindPane remindPane;
@ -67,12 +70,25 @@ public class TemplateSearchRemindPane extends JPanel implements TreeSearchStatus
private interface TreeSearchStatusChange {
/**
* 搜索未开始时
*/
void onNotBegin();
/**
* 搜索中
*/
void onInSearching();
/**
* 停止搜索
*/
void onStoppedSearching();
/**
* 搜索结束
* @param matchSetsEmpty
*/
void onDoneSearching(boolean matchSetsEmpty);
}

3
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateTreeSearchToolbarPane.java

@ -30,6 +30,9 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* 模板搜索工具栏
*/
public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchStatusChangeListener {
public static final String TOOLBAR_PANE = "toolbarPane";

3
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pre/TemplateDirPreSearchTask.java

@ -6,6 +6,9 @@ import com.fr.file.filetree.FileNode;
import java.util.List;
/**
* 目录树搜索时的前置处理跟模板搜索前置处理类似
*/
public class TemplateDirPreSearchTask extends TemplatePreSearchTask {
public TemplateDirPreSearchTask(TreeSearchCallback callback, FileNode fileNode) {

9
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pre/TemplatePreSearchCallBack.java

@ -5,6 +5,10 @@ import com.fr.design.mainframe.manager.search.searcher.control.common.TemplateSe
import com.fr.design.search.control.TreeSearchResult;
import com.fr.design.mainframe.manager.search.searcher.TemplateTreeSearcher;
/**
* 模板搜索前置回调处理
* 主要是将最外层目录下的所有模板添加到未计算的集合中
*/
public class TemplatePreSearchCallBack extends TemplateSearchCallBack {
public TemplatePreSearchCallBack(TemplateTreeSearcher treeSearcher) {
@ -18,6 +22,11 @@ public class TemplatePreSearchCallBack extends TemplateSearchCallBack {
}
}
/**
* 将结果添加到未计算的集合中
*
* @param searchResult
*/
@Override
protected void addToTreeSearcher(TreeSearchResult searchResult) {
TemplateSearchResult templateSearchResult = (TemplateSearchResult) searchResult;

4
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pre/TemplatePreSearchTask.java

@ -11,6 +11,10 @@ import com.fr.log.FineLoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
* 模板搜索前置任务
* 主要是计算最外层目录下面所有的子节点并记录到结果集中
*/
public class TemplatePreSearchTask implements TreeSearchTask {
protected TreeSearchCallback callback;

34
designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

@ -3,12 +3,14 @@ package com.fr.design.utils;
import com.fr.base.extension.FileExtension;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.save.SaveFailureHandler;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.filetree.FileNode;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
@ -19,6 +21,8 @@ import com.fr.workspace.server.lock.TplOperator;
import javax.swing.SwingWorker;
import java.io.OutputStream;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author hades
@ -134,4 +138,34 @@ public class TemplateUtils {
}
return name.substring(0, index) + Toolkit.i18nText("Fine_Design_Template_Has_Been_Locked") + name.substring(index);
}
/**
* 检测当前所选模板是否已经被打开
*
* @return
*/
public static boolean checkSelectedTemplateIsEditing() {
return checkTemplateIsEditing(TemplateTreePane.getInstance().getTemplateFileTree().getSelectedTreeNodes());
}
/**
* 检测指定模板节点是否已经被打开
*
* @param treeNodes
* @return
*/
public static boolean checkTemplateIsEditing(ExpandMutableTreeNode[] treeNodes) {
if (ArrayUtils.isEmpty(treeNodes)) {
return false;
}
List<JTemplate<?, ?>> jTemplates = HistoryTemplateListCache.getInstance().getHistoryList();
List<String> openedFile = jTemplates.stream().map(JTemplate::getPath).collect(Collectors.toList());
for (ExpandMutableTreeNode treeNode : treeNodes) {
String templatePath = ((FileNode) (treeNode.getUserObject())).getEnvPath();
if (openedFile.contains(templatePath)) {
return true;
}
}
return false;
}
}

Loading…
Cancel
Save