Browse Source

Merge remote-tracking branch 'origin/feature/x' into feature/x

feature/x
pengda 3 years ago
parent
commit
9d9f265ec5
  1. 149
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java
  2. 27
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  3. 66
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java
  4. 31
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/common/TableDataSearchTask.java
  5. 3
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/pre/TableDataPreSearchTask.java
  6. 64
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java
  7. 22
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimerTask.java

149
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java

@ -1,8 +1,10 @@
package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree;
@ -19,7 +21,9 @@ import javax.swing.tree.TreePath;
import java.awt.Color;
import java.awt.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* TableData Tree
@ -27,6 +31,10 @@ import java.util.List;
public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
private static final long serialVersionUID = 1L;
private static final String TABLE_DATA_NODE = "tableData";
private static final String COLUMN_NODE = "column";
/**
* Constructor.
*/
@ -87,6 +95,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
this.tableDataTreeCellRenderer = tableDataTreeCellRenderer;
}
@Override
protected void refreshTreeNode(ExpandMutableTreeNode eTreeNode, String childName) {
if (interceptRefresh(eTreeNode)) {
return;
@ -178,11 +187,11 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
ExpandMutableTreeNode[] dsTreeNodes = loadChildTreeNodes(root);
root.removeAllChildren();
for (ExpandMutableTreeNode dsTreeNode : dsTreeNodes) {
if (TableDataTreeSearchManager.getInstance().nodeMatches(dsTreeNode)) {
if (TableDataTreeSearchManager.getInstance().nodeNameMatches(dsTreeNode.getUserObject().toString())) {
// 加载数据列节点
loadAndAddChildTreeChild(dsTreeNode);
// 处理子节点的展开
TableDataTreeSearchManager.getInstance().dealWithNodeExpand(dsTreeNode);
dealWithNodeExpand(dsTreeNode);
// 添加数据集子节点
root.add(dsTreeNode);
}
@ -196,7 +205,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
* @return
*/
private ExpandMutableTreeNode loadAndAddChildTreeChild(ExpandMutableTreeNode treeNode) {
if (TableDataTreeSearchManager.getInstance().isTreeNodeStoreProcedure(treeNode)) {
if (isTreeNodeStoreProcedure(treeNode)) {
// 如果是存储过程,则再加载一次其子表节点,这里比较坑的就是存储过程不能使用loadChildTreeNodes
int tableChildCounts = treeNode.getChildCount();
ExpandMutableTreeNode[] childs = new ExpandMutableTreeNode[tableChildCounts];
@ -215,9 +224,36 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
return treeNode;
}
/**
* 处理节点的展开如果此节点是存储过程还会处理其子表节点的展开
* 只针对数据集节点
*
* @param treeNode
* @return
*/
public ExpandMutableTreeNode dealWithNodeExpand(ExpandMutableTreeNode treeNode) {
String tableDataName = treeNode.getUserObject().toString();
// 主要还是处理存储过程
if (isTreeNodeStoreProcedure(treeNode)) {
int childCount = treeNode.getChildCount();
for (int i = 0; i < childCount; i++) {
ExpandMutableTreeNode child = (ExpandMutableTreeNode) treeNode.getChildAt(i);
String nodeName = tableDataName + "_" + child.getUserObject().toString();
if (TableDataTreeSearchManager.getInstance().nodeCanExpand(nodeName)) {
child.setExpanded(true);
}
}
}
if (TableDataTreeSearchManager.getInstance().nodeCanExpand(treeNode.getUserObject().toString())) {
treeNode.setExpanded(true);
}
return treeNode;
}
/*
* p:获得选中的NameObject = name + tabledata.
*/
@Override
public NameObject getSelectedNameObject() {
TreePath selectedTreePath = this.getSelectionPath();
if (selectedTreePath == null) {
@ -248,27 +284,47 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
}
/**
* 获得选中的NameObject的list只会返回数据集节点的NameObject
* 获得选中的数据集节点的NameObject的数组只会返回数据集节点的NameObject
* 当多选了数据集或数据列时也只返回选中的数据集
*/
public NameObject[] getSelectedNameObjects() {
public NameObject[] getSelectedTableDataNameObjects() {
Map<String, List<ExpandMutableTreeNode>> tableDataNodesAndColumnNodes = getSelectedTableDataNodesAndColumnNodes();
List<ExpandMutableTreeNode> tableDataNodes = tableDataNodesAndColumnNodes.get(TABLE_DATA_NODE);
if (tableDataNodes == null) {
return new NameObject[0];
}
return tableDataNodes.stream().map(node -> (NameObject) node.getUserObject()).toArray(NameObject[]::new);
}
/**
* 获取选中的数据集节点和列名节点
* 其中存储过程的子表节点不计入数据集节点中仅存储过程节点本身计入数据集节点
* @return
*/
private Map<String, List<ExpandMutableTreeNode>> getSelectedTableDataNodesAndColumnNodes() {
TreePath[] selectedTreePaths = this.getSelectionPaths();
if (selectedTreePaths == null) {
return new NameObject[0];
return new HashMap<>();
}
List<NameObject> result = new ArrayList<>();
Map<String, List<ExpandMutableTreeNode>> resultMap = new HashMap<>();
List<ExpandMutableTreeNode> tableDataNodes = new ArrayList<>();
List<ExpandMutableTreeNode> columnNodes = new ArrayList<>();
resultMap.put(TABLE_DATA_NODE, tableDataNodes);
resultMap.put(COLUMN_NODE, columnNodes);
for (TreePath selectedTreePath : selectedTreePaths) {
if (selectedTreePath == null) {
continue;
}
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
Object selectedUserObject = selectedTreeNode.getUserObject();
// 只考虑数据集节点
if (selectedUserObject instanceof NameObject && ((NameObject) selectedUserObject).getObject() instanceof TableDataWrapper) {
result.add((NameObject) selectedUserObject);
if (isTableDataNodes(selectedTreeNode)) {
// 数据集节点
tableDataNodes.add(selectedTreeNode);
} else {
// 列名节点
columnNodes.add(selectedTreeNode);
}
}
return result.toArray(new NameObject[0]);
return resultMap;
}
/**
@ -276,8 +332,57 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
*
* @return
*/
public int getSelectedDsCounts() {
return getSelectedNameObjects().length;
public int getSelectedTableDataCounts() {
return getSelectedTableDataNameObjects().length;
}
/**
* 是否存在单独选了数据列节点但没选其对应数据集的情况
* @return
*/
public boolean hasSelectedIndependentColumns() {
Map<String, List<ExpandMutableTreeNode>> tableDataNodesAndColumnNodes = getSelectedTableDataNodesAndColumnNodes();
List<ExpandMutableTreeNode> tableDataNodes = tableDataNodesAndColumnNodes.get(TABLE_DATA_NODE);
List<ExpandMutableTreeNode> columnNodes = tableDataNodesAndColumnNodes.get(COLUMN_NODE);
if (columnNodes == null || columnNodes.size() == 0) {
// 未选中数据列
return false;
}
if (tableDataNodes == null || tableDataNodes.size() == 0) {
// 选中数据列而未选中数据集
return true;
}
boolean result = false;
for (ExpandMutableTreeNode columnNode : columnNodes) {
ExpandMutableTreeNode tableDataNode = getBelongedTableDataNodes(columnNode);
if (!tableDataNodes.contains(tableDataNode)) {
result = true;
}
}
return result;
}
/**
* 获取一个节点归属的数据集层级父节点
* @param treeNode
* @return
*/
private ExpandMutableTreeNode getBelongedTableDataNodes(ExpandMutableTreeNode treeNode) {
if (isTableDataNodes(treeNode)) {
return treeNode;
}
return getBelongedTableDataNodes((ExpandMutableTreeNode) treeNode.getParent());
}
private boolean isTableDataNodes(ExpandMutableTreeNode treeNode) {
if (treeNode == null) {
return false;
}
Object userObject = treeNode.getUserObject();
if (userObject instanceof NameObject && ((NameObject) userObject).getObject() instanceof AbstractTableDataWrapper) {
return true;
}
return false;
}
public TableDataWrapper[] getSelectedDatas() {
@ -345,4 +450,20 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
treeModel.reload(root);
}
/**
* 判断此节点是否为存储过程
*
* @param treeNode
* @return
*/
public boolean isTreeNodeStoreProcedure(ExpandMutableTreeNode treeNode) {
Object userObject = treeNode.getUserObject();
if (userObject instanceof NameObject) {
NameObject nameObject = (NameObject) userObject;
TableDataWrapper tableDataWrapper = (TableDataWrapper) nameObject.getObject();
return tableDataWrapper.getTableData() instanceof StoreProcedure;
}
return false;
}
}

27
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java

@ -18,7 +18,6 @@ import com.fr.design.data.datapane.management.search.pane.TableDataSearchRemindP
import com.fr.design.data.datapane.management.search.pane.TreeSearchToolbarPane;
import com.fr.design.data.datapane.management.search.searcher.TableDataSearchMode;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus;
import com.fr.design.data.tabledata.StoreProcedureWorkerListener;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.DBTableDataPane;
@ -386,6 +385,10 @@ public class TableDataTreePane extends BasicTableDataTreePane {
*/
@Override
public void dgEdit(final AbstractTableDataPane<?> tableDataPane, String originalName, boolean isUpdate) {
// 编辑时如果正在搜索,跳回原树
if (TableDataTreeSearchManager.getInstance().isInSearchMode()) {
TableDataTreeSearchManager.getInstance().outOfSearchMode();
}
tableDataPane.addStoreProcedureWorkerListener(new StoreProcedureWorkerListener() {
public void fireDoneAction() {
if (tableDataTree.getSelectionPath() == null) {
@ -629,10 +632,10 @@ public class TableDataTreePane extends BasicTableDataTreePane {
return;
}
// 获取选中的数据集数量
int selectioncount = getDataTree().getSelectedDsCounts();
int selectioncount = getDataTree().getSelectedTableDataCounts();
if (op.getDataMode() == SERVER_TABLE_DATA) {
// 服务器数据集下,选中数据集数量为1时,可以预览
if (selectioncount == 1) {
if (selectioncount == 1 && !getDataTree().hasSelectedIndependentColumns()) {
previewTableDataAction.setEnabled(true);
}
// 其它保持false状态
@ -640,12 +643,12 @@ public class TableDataTreePane extends BasicTableDataTreePane {
}
// 模板数据集时,粘贴可用
pasteAction.setEnabled(true);
if (selectioncount == 0) {
// 其它保持false状态
if (selectioncount == 0 || getDataTree().hasSelectedIndependentColumns()) {
// 未选中数据集,或存在单独选中的数据列时,其它保持false状态
return;
}
if (selectioncount == 1) {
// 选中单个数据集时,才可以编译、预览
// 选中单个数据集时,才可以编译、预览
editAction.setEnabled(true);
previewTableDataAction.setEnabled(true);
}
@ -1013,7 +1016,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
@Override
public void actionPerformed(ActionEvent e) {
NameObject[] selectedNameObjects = tableDataTree.getSelectedNameObjects();
NameObject[] selectedNameObjects = tableDataTree.getSelectedTableDataNameObjects();
if (selectedNameObjects == null || selectedNameObjects.length == 0) {
FineLoggerFactory.getLogger().error("Table Data to remove is null or not selected");
return;
@ -1032,6 +1035,10 @@ public class TableDataTreePane extends BasicTableDataTreePane {
@Override
public void doOk() {
Object[] selectedValues = checkBoxList.getSelectedValues();
// 删除时如果正在搜索,跳回原树
if (TableDataTreeSearchManager.getInstance().isInSearchMode()) {
TableDataTreeSearchManager.getInstance().outOfSearchMode();
}
for (Object toRemove : selectedValues) {
doRemove((NameObject) toRemove);
}
@ -1077,7 +1084,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
@Override
public void actionPerformed(ActionEvent e) {
NameObject[] selectedNameObjects = tableDataTree.getSelectedNameObjects();
NameObject[] selectedNameObjects = tableDataTree.getSelectedTableDataNameObjects();
Map<String, AbstractTableDataWrapper> dataWrapperMap = TableDataTreeClipboard.getInstance().transferNameObjectArray2Map(selectedNameObjects);
TableDataTreeClipboard.getInstance().addToClip(dataWrapperMap);
}
@ -1093,6 +1100,10 @@ public class TableDataTreePane extends BasicTableDataTreePane {
@Override
public void actionPerformed(ActionEvent e) {
// 粘贴时如果正在搜索,跳回原树
if (TableDataTreeSearchManager.getInstance().isInSearchMode()) {
TableDataTreeSearchManager.getInstance().outOfSearchMode();
}
Map<String, AbstractTableDataWrapper> dataWrapperMap = TableDataTreeClipboard.getInstance().takeFromClip();
for (Map.Entry<String, AbstractTableDataWrapper> dataWrapperEntry : dataWrapperMap.entrySet()) {
// 处理数据集名称

66
designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java

@ -1,7 +1,6 @@
package com.fr.design.data.datapane.management.search;
import com.fr.data.TableDataSource;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.DesignModelAdapter;
import com.fr.design.data.datapane.TableDataTree;
import com.fr.design.data.datapane.TableDataTreePane;
@ -10,11 +9,7 @@ import com.fr.design.data.datapane.management.search.event.TreeSearchStatusChang
import com.fr.design.data.datapane.management.search.searcher.TableDataSearchMode;
import com.fr.design.data.datapane.management.search.searcher.TableDataTreeSearcher;
import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus;
import com.fr.design.data.datapane.management.search.time.TableDataSearchTimer;
import com.fr.design.data.datapane.management.search.view.TreeSearchRendererHelper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.general.NameObject;
import com.fr.stable.StringUtils;
import javax.swing.SwingUtilities;
@ -137,8 +132,6 @@ public class TableDataTreeSearchManager {
setTreeSearchStatus(TreeSearchStatus.SEARCHING);
rendererHelper.replaceTreeRenderer(getCurrentTableDataTree(), searchText);
count = new AtomicInteger(treeSearcher.getAllWrappersSize());
// 计时开始
TableDataSearchTimer.getInstance().startClock();
treeSearcher.startSearch(searchText);
}
@ -176,7 +169,6 @@ public class TableDataTreeSearchManager {
*/
public void stopSearch() {
setTreeSearchStatus(TreeSearchStatus.SEARCH_STOPPED);
TableDataSearchTimer.getInstance().stopClock();
count = null;
treeSearcher.stopSearch();
}
@ -186,7 +178,6 @@ public class TableDataTreeSearchManager {
*/
public void completeSearch() {
setTreeSearchStatus(TreeSearchStatus.SEARCH_COMPLETED);
TableDataSearchTimer.getInstance().stopClock();
count = null;
treeSearcher.completeSearch();
}
@ -196,7 +187,6 @@ public class TableDataTreeSearchManager {
*/
public void restoreToolBarAndTreePane() {
setTreeSearchStatus(TreeSearchStatus.NOT_IN_SEARCH_MODE);
TableDataSearchTimer.getInstance().stopClock();
if (treeSearcher != null) {
treeSearcher.afterSearch();
}
@ -211,7 +201,6 @@ public class TableDataTreeSearchManager {
*/
public void restoreTreePane() {
setTreeSearchStatus(TreeSearchStatus.SEARCH_NOT_BEGIN);
TableDataSearchTimer.getInstance().stopClock();
lastSearchText = null;
if (rendererHelper != null) {
rendererHelper.restore(getCurrentTableDataTree());
@ -222,64 +211,21 @@ public class TableDataTreeSearchManager {
* 节点是否应该添加到搜索结果树的根节点中
* 只针对数据集节点
*
* @param treeNode 数据集节点
* @param treeNodeName 数据集节点名称
* @return
*/
public boolean nodeMatches(ExpandMutableTreeNode treeNode) {
String nodeName = treeNode.getUserObject().toString();
return treeSearcher.nodeMatches(nodeName);
public boolean nodeNameMatches(String treeNodeName) {
return treeSearcher.nodeMatches(treeNodeName);
}
/**
* 节点是否应该展开
*
* @param treeNode
* @param treeNodeName 节点名称
* @return
*/
public boolean nodeCanExpand(ExpandMutableTreeNode treeNode) {
String dsName = treeNode.getUserObject().toString();
return treeSearcher.nodeCanExpand(dsName);
}
/**
* 处理节点的展开如果此节点是存储过程还会处理其子表节点的展开
* 只针对数据集节点
*
* @param treeNode
* @return
*/
public ExpandMutableTreeNode dealWithNodeExpand(ExpandMutableTreeNode treeNode) {
String tableDataName = treeNode.getUserObject().toString();
// 主要还是处理存储过程
if (isTreeNodeStoreProcedure(treeNode)) {
int childCount = treeNode.getChildCount();
for (int i = 0; i < childCount; i++) {
ExpandMutableTreeNode child = (ExpandMutableTreeNode) treeNode.getChildAt(i);
if (treeSearcher.nodeCanExpand(tableDataName + "_" + child.getUserObject().toString())) {
child.setExpanded(true);
}
}
}
if (nodeCanExpand(treeNode)) {
treeNode.setExpanded(true);
}
return treeNode;
}
/**
* 判断此节点是否为存储过程
*
* @param treeNode
* @return
*/
public boolean isTreeNodeStoreProcedure(ExpandMutableTreeNode treeNode) {
Object userObject = treeNode.getUserObject();
if (userObject instanceof NameObject) {
NameObject nameObject = (NameObject) userObject;
TableDataWrapper tableDataWrapper = (TableDataWrapper) nameObject.getObject();
return tableDataWrapper.getTableData() instanceof StoreProcedure;
}
return false;
public boolean nodeCanExpand(String treeNodeName) {
return treeSearcher.nodeCanExpand(treeNodeName);
}
public boolean isInSearchMode() {

31
designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/common/TableDataSearchTask.java

@ -1,10 +1,8 @@
package com.fr.design.data.datapane.management.search.control.common;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.datapane.management.search.control.TreeSearchCallback;
import com.fr.design.data.datapane.management.search.control.TreeSearchResult;
import com.fr.design.data.datapane.management.search.control.TreeSearchTask;
import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus;
import com.fr.design.data.tabledata.wrapper.StoreProcedureDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.log.FineLoggerFactory;
@ -40,18 +38,16 @@ public class TableDataSearchTask implements TreeSearchTask {
public void run() {
TreeSearchResult result;
try {
if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() != TreeSearchStatus.SEARCHING) {
return;
}
if (isTableDataStoreProcedure(tableDataWrapper)) {
dealWithStoreProcedureTableDataWrapper((StoreProcedureDataWrapper) tableDataWrapper);
result = dealWithStoreProcedureTableDataWrapper((StoreProcedureDataWrapper) tableDataWrapper);
} else {
dealWithCommonTableDataWrapper(tableDataWrapper);
result = dealWithCommonTableDataWrapper(tableDataWrapper);
}
} catch (Throwable e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
dealWithErrorTableDataWrapper(tableDataWrapper);
result = dealWithErrorTableDataWrapper(tableDataWrapper);
}
callback.done(result);
}
/**
@ -59,8 +55,8 @@ public class TableDataSearchTask implements TreeSearchTask {
*
* @param tableDataWrapper
*/
private void dealWithErrorTableDataWrapper(TableDataWrapper tableDataWrapper) {
callback.done(new TableDataSearchResult.Builder().buildSuccess(false).build());
private TreeSearchResult dealWithErrorTableDataWrapper(TableDataWrapper tableDataWrapper) {
return new TableDataSearchResult.Builder().buildSuccess(false).build();
}
/**
@ -68,18 +64,21 @@ public class TableDataSearchTask implements TreeSearchTask {
*
* @param tableDataWrapper
*/
private void dealWithCommonTableDataWrapper(TableDataWrapper tableDataWrapper) {
private TreeSearchResult dealWithCommonTableDataWrapper(TableDataWrapper tableDataWrapper) {
String tableDataName = tableDataWrapper.getTableDataName();
boolean isTableDataNameMatch = isMatchSearch(tableDataName, searchText);
List<String> columnNameList = tableDataWrapper.calculateColumnNameList();
// 没取到列名的话,代表取数那边出错了,就不添加数据集了
if (columnNameList.size() == 0) {
return new TableDataSearchResult.Builder().buildSuccess(false).build();
}
boolean isColumnMatch = columnNameList.stream().anyMatch(columnName -> isMatchSearch(columnName, searchText));
TableDataSearchResult result = new TableDataSearchResult.Builder()
return new TableDataSearchResult.Builder()
.buildSuccess(true)
.buildAddToMatch(isTableDataNameMatch || isColumnMatch ? Arrays.asList(tableDataName) : new ArrayList<>())
.buildAddToExpand(isColumnMatch ? Arrays.asList(tableDataName) : new ArrayList<>())
.buildAddToCalculated(Arrays.asList(tableDataName))
.build();
callback.done(result);
}
/**
@ -87,7 +86,7 @@ public class TableDataSearchTask implements TreeSearchTask {
*
* @param procedureDataWrapper
*/
private void dealWithStoreProcedureTableDataWrapper(StoreProcedureDataWrapper procedureDataWrapper) {
private TreeSearchResult dealWithStoreProcedureTableDataWrapper(StoreProcedureDataWrapper procedureDataWrapper) {
// 存储过程数据集名称,例如 Proc1_Table1
String tableDataName = procedureDataWrapper.getTableDataName();
// 存储过程名称,例如 Proc1
@ -116,13 +115,13 @@ public class TableDataSearchTask implements TreeSearchTask {
addToExpand.add(tableDataName);
}
addToCalculated.add(tableDataName);
TableDataSearchResult result = new TableDataSearchResult.Builder()
return new TableDataSearchResult.Builder()
.buildSuccess(true)
.buildAddToMatch(new ArrayList<>(addToMatch))
.buildAddToExpand(new ArrayList<>(addToExpand))
.buildAddToCalculated(new ArrayList<>(addToCalculated))
.build();
callback.done(result);
}
/**

3
designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/pre/TableDataPreSearchTask.java

@ -29,9 +29,6 @@ public class TableDataPreSearchTask implements TreeSearchTask {
public void run() {
TreeSearchResult result;
try {
if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() != TreeSearchStatus.SEARCH_NOT_BEGIN) {
return;
}
tableDataWrapper.calculateColumnNameList();
result = new TableDataSearchResult.Builder()
.buildSuccess(true)

64
designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java

@ -1,64 +0,0 @@
package com.fr.design.data.datapane.management.search.time;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.general.ComparatorUtils;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* 搜索任务定时器
*
* @author Yvan
*/
public class TableDataSearchTimer {
/**
* 定时器
*/
private static ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory(TableDataSearchTimer.class));
/**
* 定时任务
*/
private TableDataSearchTimerTask timeTask;
/**
* 最大单次startSearch的时间
*/
public static final long MAX_SEARCH_TIME = 5000;
private TableDataSearchTimer() {
}
private static class Holder {
private static final TableDataSearchTimer INSTANCE = new TableDataSearchTimer();
}
public static TableDataSearchTimer getInstance() {
return Holder.INSTANCE;
}
public void startClock() {
this.timeTask = new TableDataSearchTimerTask();
scheduler.schedule(timeTask, MAX_SEARCH_TIME, TimeUnit.MILLISECONDS);
}
public void stopClock() {
this.timeTask = null;
}
public void shutdown() {
scheduler.shutdown();
}
/**
* 判断是不是当前的Timer中的task为了避免shutdownNow()之后原task仍在执行可能会
* @param task
* @return
*/
public boolean isCurrentTask(TableDataSearchTimerTask task) {
return ComparatorUtils.equals(this.timeTask, task);
}
}

22
designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimerTask.java

@ -1,22 +0,0 @@
package com.fr.design.data.datapane.management.search.time;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus;
/**
* @author Yvan
*/
public class TableDataSearchTimerTask implements Runnable {
public TableDataSearchTimerTask() {
}
@Override
public void run() {
// 最大单次搜索时间过后,将结束搜索
if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() == TreeSearchStatus.SEARCHING &&
TableDataSearchTimer.getInstance().isCurrentTask(this)) {
TableDataTreeSearchManager.getInstance().completeSearch();
}
}
}
Loading…
Cancel
Save