Browse Source

Pull request #8310: REPORT-68355 【迭代】【数据集管理优化】搜索关键字匹配数据列,数据列所在数据集没有展开

Merge in DESIGN/design from ~YVAN/design:feature/x to feature/x

* commit '72a13f4acd12ab715a7fbf29f179c32da1cd867e':
  REPORT-68355 【迭代】【数据集管理优化】搜索关键字匹配数据列,数据列所在数据集没有展开 【问题原因】之前把切换回工具栏的调用放在TableDataTreePane的refreshDockingView里又因为TableDataTreePane的每一次getInstance都会去调用一次refreshDockingView,搜索任务过程中会经常调用到TableDataTreePane.getInstance,所以造成了搜索状态上的紊乱 【改动思路】1. 扩展TreeSearchStatus,新增Not_In_Search_Mode,视为非搜索模式,其它的状态(搜索中,搜索中止,搜索完成等)统统视为搜索模式 2. 在需要退出搜索模式的地方(切换数据集Tab和新打开一个模板),加上退出的逻辑;不把逻辑放到refreshDockingView里 3. 部分代码质量问题 【review建议】上面改动的第二点,分布在需要退出的场景里,会显得比较松散,但是我没找到一个好的地方可以统一搞。有思路的可以帮忙提供下,感谢~
feature/x
Yvan 3 years ago
parent
commit
f3029b94d7
  1. 6
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  2. 24
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java
  3. 5
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/pre/TableDataPreSearchTask.java
  4. 12
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TableDataSearchRemindPane.java
  5. 28
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java
  6. 2
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TreeSearchStatus.java
  7. 4
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

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

@ -588,9 +588,6 @@ public class TableDataTreePane extends BasicTableDataTreePane {
private void populate(TableDataSourceOP op) {
this.op = op;
if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() == TreeSearchStatus.SEARCHING) {
TableDataTreeSearchManager.getInstance().switchBackToolBar();
}
tableDataTree.populate(op);
checkButtonEnabled();
}
@ -744,6 +741,9 @@ public class TableDataTreePane extends BasicTableDataTreePane {
if (op != null) {
op.setDataMode(modeArray[buttonGroup.getSelectedIndex()]);
addMenuDef.setEnabled(modeArray[buttonGroup.getSelectedIndex()] == TEMPLATE_TABLE_DATA);
if (TableDataTreeSearchManager.getInstance().isInSearchMode()) {
TableDataTreeSearchManager.getInstance().outOfSearchMode();
}
refreshDockingView();
}

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

@ -64,7 +64,7 @@ public class TableDataTreeSearchManager {
}
private void init() {
this.treeSearchStatus = TreeSearchStatus.SEARCH_NOT_BEGIN;
this.treeSearchStatus = TreeSearchStatus.NOT_IN_SEARCH_MODE;
}
private static class Holder {
@ -194,12 +194,20 @@ public class TableDataTreeSearchManager {
/**
* 切换回工具栏
*/
public void switchBackToolBar() {
setTreeSearchStatus(TreeSearchStatus.SEARCH_NOT_BEGIN);
lastSearchText = null;
public void restoreToolBarAndTreePane() {
setTreeSearchStatus(TreeSearchStatus.NOT_IN_SEARCH_MODE);
if (treeSearcher != null) {
treeSearcher.afterSearch();
}
restoreTreePane();
}
public void restoreTreePane() {
lastSearchText = null;
if (rendererHelper != null) {
rendererHelper.restore(getCurrentTableDataTree());
}
}
/**
* 节点是否应该添加到搜索结果树的根节点中
@ -264,4 +272,12 @@ public class TableDataTreeSearchManager {
}
return false;
}
public boolean isInSearchMode() {
return getTreeSearchStatus() != TreeSearchStatus.NOT_IN_SEARCH_MODE;
}
public void outOfSearchMode() {
restoreToolBarAndTreePane();
}
}

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

@ -1,9 +1,11 @@
package com.fr.design.data.datapane.management.search.control.pre;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.datapane.management.search.control.TreeSearchTask;
import com.fr.design.data.datapane.management.search.control.common.TableDataSearchResult;
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.searcher.TreeSearchStatus;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.log.FineLoggerFactory;
@ -27,6 +29,9 @@ 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)

12
designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TableDataSearchRemindPane.java

@ -50,7 +50,7 @@ public class TableDataSearchRemindPane extends JPanel implements TreeSearchStatu
@Override
public void updateTreeSearchChange(TreeSearchStatusChangeEvent event) {
TreeSearchStatus status = event.getTreeSearchStatus();
if (status == TreeSearchStatus.SEARCH_NOT_BEGIN) {
if (status == TreeSearchStatus.SEARCH_NOT_BEGIN || status == TreeSearchStatus.NOT_IN_SEARCH_MODE) {
remindPane.onNotBegin();
treePane.onNotBegin();
} else if (status == TreeSearchStatus.SEARCHING) {
@ -147,12 +147,12 @@ public class TableDataSearchRemindPane extends JPanel implements TreeSearchStatu
}
}
private class RemindPane extends JPanel implements TreeSearchStatusChange {
private static class RemindPane extends JPanel implements TreeSearchStatusChange {
private static final String IN_SEARCHING = "Fine-Design_Tree_Search_In_Searching";
private static final String STOP_SEARCHING = "Fine-Design_Tree_Search_Stop_Search";
private static final String SEARCHING_STOPPED = "Fine-Design_Tree_Search_Search_Stopped";
private static final String DONE_SEARCHING = "Fine-Design_Tree_Search_Search_Completed";
private static final String IN_SEARCHING = Toolkit.i18nText("Fine-Design_Tree_Search_In_Searching");
private static final String STOP_SEARCHING = Toolkit.i18nText("Fine-Design_Tree_Search_Stop_Search");
private static final String SEARCHING_STOPPED = Toolkit.i18nText("Fine-Design_Tree_Search_Search_Stopped");
private static final String DONE_SEARCHING = Toolkit.i18nText("Fine-Design_Tree_Search_Search_Completed");
private UILabel textLabel;

28
designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java

@ -5,6 +5,8 @@ import com.fr.design.DesignModelAdapter;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.datapane.management.search.event.TreeSearchStatusChangeEvent;
import com.fr.design.data.datapane.management.search.event.TreeSearchStatusChangeListener;
import com.fr.design.data.datapane.management.search.searcher.TreeSearchStatus;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
@ -32,7 +34,7 @@ import java.awt.event.MouseEvent;
/**
* @author Yvan
*/
public class TreeSearchToolbarPane extends Panel {
public class TreeSearchToolbarPane extends Panel implements TreeSearchStatusChangeListener {
public static final String TOOLBAR_PANE = "toolbarPane";
@ -85,6 +87,7 @@ public class TreeSearchToolbarPane extends Panel {
initContentPane();
add(contentPane, BorderLayout.CENTER);
setPreferredSize(new Dimension(240, 30));
TableDataTreeSearchManager.getInstance().registerTreeSearchStatusChangeListener(this);
}
private void initContentPane() {
@ -147,7 +150,7 @@ public class TreeSearchToolbarPane extends Panel {
@Override
public void mouseClicked(MouseEvent e) {
searchTextField.setText(StringUtils.EMPTY);
TableDataTreeSearchManager.getInstance().switchBackToolBar();
TableDataTreeSearchManager.getInstance().outOfSearchMode();
switchPane(TOOLBAR_PANE);
}
});
@ -158,12 +161,10 @@ public class TreeSearchToolbarPane extends Panel {
}
private void dealWithTextChange() {
// 判断搜索是否正在进行
if (StringUtils.isEmpty(searchTextField.getText()) && TableDataTreeSearchManager.getInstance().getTreeSearchStatus() != TreeSearchStatus.SEARCH_NOT_BEGIN) {
TableDataTreeSearchManager.getInstance().setTreeSearchStatus(TreeSearchStatus.SEARCH_NOT_BEGIN);
DesignModelAdapter<?, ?> currentModelAdapter = DesignModelAdapter.getCurrentModelAdapter();
TableDataTreePane tableDataTreePane = (TableDataTreePane) TableDataTreePane.getInstance(currentModelAdapter);
tableDataTreePane.refreshDockingView();
if (StringUtils.isEmpty(searchTextField.getText()) && TableDataTreeSearchManager.getInstance().isInSearchMode()) {
// 如果是搜索模式下,看作是用户删除输入框文字,仅复原TableDataTreePane
TableDataTreeSearchManager.getInstance().restoreTreePane();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView();
}
}
@ -189,4 +190,15 @@ public class TreeSearchToolbarPane extends Panel {
public void setPlaceHolder(String placeHolder) {
this.searchTextField.setPlaceholder(placeHolder);
}
/**
* 根据搜索状态变化来调整自身面板的显示
*
* @param event
*/
@Override
public void updateTreeSearchChange(TreeSearchStatusChangeEvent event) {
TreeSearchStatus treeSearchStatus = event.getTreeSearchStatus();
switchPane(treeSearchStatus == TreeSearchStatus.NOT_IN_SEARCH_MODE ? TOOLBAR_PANE : SEARCH_PANE);
}
}

2
designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TreeSearchStatus.java

@ -5,6 +5,8 @@ package com.fr.design.data.datapane.management.search.searcher;
*/
public enum TreeSearchStatus {
NOT_IN_SEARCH_MODE,
/**
* 搜索未开始
*/

4
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -11,6 +11,7 @@ import com.fr.design.actions.UpdateAction;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.FileOperations;
@ -244,6 +245,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
DesignModelAdapter.setCurrentModelAdapter(jt.getModel());
fireDSChanged();
if (TableDataTreeSearchManager.getInstance().isInSearchMode()) {
TableDataTreeSearchManager.getInstance().outOfSearchMode();
}
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt);
//处理自动新建的模板

Loading…
Cancel
Save