Browse Source

REPORT-39757 AlphaFine无法搜索含空格的模板名称

feature/big-screen
Yyming 4 years ago
parent
commit
e5db574c46
  1. 11
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 2
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  3. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java
  4. 80
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  5. 5
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  6. 79
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java

11
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -218,14 +218,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (needCheckEnv) {
checkNameEnvMap();
}
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX);
designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME);
}
GeneralContext.addEnvChangedListener(() -> {
designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX);
designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME);
});
}

2
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -218,7 +218,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText());
paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery);
List<ParameterProvider> existParameterList = editorPane.update();
Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]);
Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[0]);
editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps));
}

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java

@ -49,9 +49,7 @@ public class BottomModel extends AlphaCellModel {
public void doAction() {
try {
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_GO_TO_FORUM));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} catch (URISyntaxException e) {
} catch (IOException | URISyntaxException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}

80
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -819,56 +819,52 @@ public class AlphaFineDialog extends UIDialog {
}
});
Timer timer = new Timer(TIMER_DELAY, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!alreadyInitHot && StringUtils.isEmpty(searchTextField.getText())) {
alreadyInitHot = true;
Timer timer = new Timer(TIMER_DELAY, e -> {
if (!alreadyInitHot && StringUtils.isEmpty(searchTextField.getText())) {
alreadyInitHot = true;
removeSearchResult();
refreshContainer();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) {
initHotPane();
setSize(AlphaFineConstants.FULL_SIZE);
} else {
setSize(AlphaFineConstants.FIELD_SIZE);
}
refreshContainer();
return;
} else if (beforeSearchStr.equals(searchTextField.getText()) && StringUtils.isNotEmpty(beforeSearchStr)) {
if (alreadySearch) {
return;
} else {
removeHotPane();
removeSearchResult();
refreshContainer();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) {
initHotPane();
setSize(AlphaFineConstants.FULL_SIZE);
} else {
setSize(AlphaFineConstants.FIELD_SIZE);
}
refreshContainer();
return;
} else if (beforeSearchStr.equals(searchTextField.getText()) && StringUtils.isNotEmpty(beforeSearchStr)) {
if (alreadySearch) {
return;
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedSegmentationCheckbox()) {
//是高级搜索
if (searchTextField.getText().toLowerCase().startsWith(ADVANCED_SEARCH_MARK)) {
segmentationResult = SegmentationManager.getInstance().startSegmentation(getStoreText(searchTextField.getText().toLowerCase()));
}
//是普通搜索
else {
segmentationResult = SegmentationManager.getInstance().startSegmentation(searchTextField.getText().toLowerCase());
}
} else {
removeHotPane();
removeSearchResult();
refreshContainer();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedSegmentationCheckbox()) {
//是高级搜索
if (searchTextField.getText().toLowerCase().startsWith(ADVANCED_SEARCH_MARK)) {
segmentationResult = SegmentationManager.getInstance().startSegmentation(getStoreText(searchTextField.getText().toLowerCase()));
}
//是普通搜索
else {
segmentationResult = SegmentationManager.getInstance().startSegmentation(searchTextField.getText().toLowerCase());
}
if (StringUtils.isEmpty(getRealSearchText(searchTextField.getText()))) {
segmentationResult = null;
} else {
if (StringUtils.isEmpty(getRealSearchText(searchTextField.getText()))) {
segmentationResult = null;
} else {
segmentationResult = new String[]{getRealSearchText(searchTextField.getText())};
}
segmentationResult = new String[]{getRealSearchText(searchTextField.getText())};
}
doSearch(searchTextField.getText().toLowerCase());
alreadySearch = true;
}
} else {
beforeSearchStr = searchTextField.getText();
alreadySearch = false;
}
if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) {
alreadyInitHot = false;
doSearch(searchTextField.getText().toLowerCase());
alreadySearch = true;
}
} else {
beforeSearchStr = searchTextField.getText();
alreadySearch = false;
}
if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) {
alreadyInitHot = false;
}
});
timer.start();
}

5
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java

@ -108,14 +108,15 @@ public class FileSearchManager implements AlphaFineSearchProvider {
private void doSearch(String searchText) {
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) {
for (FileNode node : fileNodes) {
if (node.getName().toLowerCase().contains(searchText)) {
String name = node.getName().toLowerCase();
name = name.replaceAll(StringUtils.BLANK,StringUtils.EMPTY);
if (name.contains(searchText)) {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
if (!AlphaFineHelper.getFilterResult().contains(model)) {
AlphaFineHelper.checkCancel();
filterModelList.add(model);
}
}
}
}
}

79
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java

@ -0,0 +1,79 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.filetree.FileNode;
import com.fr.invoke.Reflect;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.core.SessionPoolManager;
import com.fr.web.utils.WebUtils;
import org.easymock.EasyMock;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
/**
* @author Yyming
* @version 10.0
* Created by Yyming on 2020/9/15
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({AlphaFineHelper.class,DesignerEnvManager.class})
@SuppressStaticInitializationFor("com.fr.design.mainframe.alphafine.AlphaFineHelper")
public class FileSearchManagerTest {
@Test
public void doSearch() {
String searchText = "workb";
FileSearchManager instance = FileSearchManager.getInstance();
FileNode fileNode1 = EasyMock.createMock(FileNode.class);
FileNode fileNode2 = EasyMock.createMock(FileNode.class);
EasyMock.expect(fileNode1.getName()).andReturn("workbook").anyTimes();
EasyMock.expect(fileNode2.getName()).andReturn("work book").anyTimes();
EasyMock.expect(fileNode1.getEnvPath()).andReturn("").anyTimes();
EasyMock.expect(fileNode2.getEnvPath()).andReturn("").anyTimes();
EasyMock.replay(fileNode1,fileNode2);
FileNode[] fileNodes = { fileNode1, fileNode2 };
Reflect.on(instance).set("fileNodes",fileNodes);
AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class);
EasyMock.expect(configManager.isContainTemplate()).andReturn(true).anyTimes();
EasyMock.replay(configManager);
DesignerEnvManager manager = EasyMock.createMock(DesignerEnvManager.class);
EasyMock.expect(manager.getAlphaFineConfigManager()).andReturn(configManager).anyTimes();
EasyMock.replay(manager);
PowerMock.mockStatic(DesignerEnvManager.class);
DesignerEnvManager.getEnvManager();
PowerMock.expectLastCall().andReturn(manager).anyTimes();
PowerMock.replay(DesignerEnvManager.class);
List<AlphaCellModel> list = new ArrayList<>();
PowerMock.mockStatic(AlphaFineHelper.class);
AlphaFineHelper.getFilterResult();
PowerMock.expectLastCall().andReturn(list).anyTimes();
AlphaFineHelper.findFolderName("");
PowerMock.expectLastCall().andReturn("").anyTimes();
AlphaFineHelper.checkCancel();
PowerMock.expectLastCall().andVoid().anyTimes();
PowerMock.replay(AlphaFineHelper.class);
SearchResult alphaCellModels = new SearchResult();
Reflect.on(instance).set("filterModelList",alphaCellModels);
Reflect.on(instance).call("doSearch",searchText);
assertEquals(alphaCellModels.size(),2);
}
}
Loading…
Cancel
Save