Browse Source

Merge pull request #895 in BA/design from ~XIAOXIA/design:9.0 to 9.0

* commit '016396ce78c6b1765dce56fcdac3f6855cf45b5c':
  rt
  代码质量
  rt
  rt
  RT
  rt
master
superman 8 years ago
parent
commit
806732465b
  1. 2
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  2. 6
      designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java
  3. 13
      designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java
  4. 6
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java

2
designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -34,7 +34,7 @@ public class AlphaFineHelper {
*/ */
private static String getSplitText(String text, int index) { private static String getSplitText(String text, int index) {
if (StringUtils.isNotBlank(text)) { if (StringUtils.isNotBlank(text)) {
String[] textArray = text.split("/"); String[] textArray = text.replaceAll("\\\\", "/").split("/");
if (textArray != null && textArray.length > 1) { if (textArray != null && textArray.length > 1) {
return textArray[textArray.length - index]; return textArray[textArray.length - index];
} }

6
designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java

@ -16,10 +16,10 @@ public class FileModel extends AlphaCellModel{
super(name, content, type); super(name, content, type);
} }
public FileModel(String name, String content, String filePath) { public FileModel(String name, String filePath) {
super(name, content, CellType.FILE); super(name, null, CellType.FILE);
this.filePath = filePath; this.filePath = filePath;
setDescription(AlphaFineHelper.findFolderName(content)); setDescription(AlphaFineHelper.findFolderName(filePath));
} }
public String getFilePath() { public String getFilePath() {

13
designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java

@ -87,15 +87,15 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
BufferedReader reader = new BufferedReader(new FileReader(filePath)); BufferedReader reader = new BufferedReader(new FileReader(filePath));
String line; String line;
int columnNumber; int columnNumber;
boolean test = false; boolean isFoundInContent = false;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
columnNumber = line.toLowerCase().indexOf(searchText); columnNumber = line.toLowerCase().indexOf(searchText);
if (columnNumber != -1) { if (columnNumber != -1) {
test = true; isFoundInContent = true;
} }
} }
if (test && !isAlreadyContain) { if (isFoundInContent && !isAlreadyContain) {
FileModel model = new FileModel(node.getName(), node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length()), node.getEnvPath()); FileModel model = new FileModel(node.getName(), node.getEnvPath());
this.filterModelList.add(model); this.filterModelList.add(model);
} }
reader.close(); reader.close();
@ -117,7 +117,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) { private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) {
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) { if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) {
if (node.getName().toLowerCase().contains(searchText.toLowerCase())) { if (node.getName().toLowerCase().contains(searchText.toLowerCase())) {
FileModel model = new FileModel(node.getName(), node.getEnvPath().substring(node.getName().length(), node.getEnvPath().length()),node.getEnvPath()); FileModel model = new FileModel(node.getName(), node.getEnvPath());
this.filterModelList.add(model); this.filterModelList.add(model);
isAlreadyContain = true; isAlreadyContain = true;
} }
@ -178,8 +178,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
*/ */
public static FileModel getModelFromCloud(String filePath) { public static FileModel getModelFromCloud(String filePath) {
String name = AlphaFineHelper.findFileName(filePath); String name = AlphaFineHelper.findFileName(filePath);
String content = AlphaFineHelper.findFolderName(filePath); return new FileModel(name, filePath);
return new FileModel(name, content, filePath);
} }
} }

6
designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java

@ -35,6 +35,7 @@ import java.util.Map;
public class RecentSearchManager extends XMLFileManager implements AlphaFineSearchProcessor { public class RecentSearchManager extends XMLFileManager implements AlphaFineSearchProcessor {
private static final String XML_TAG = "AlphafineRecent"; private static final String XML_TAG = "AlphafineRecent";
private static final int MAX_SIZE = 3;
private static RecentSearchManager recentSearchManager = null; private static RecentSearchManager recentSearchManager = null;
private static File recentFile = null; private static File recentFile = null;
private List<String> fileList; private List<String> fileList;
@ -248,8 +249,9 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
for (String key : recentKVModelMap.keySet()) { for (String key : recentKVModelMap.keySet()) {
if (ComparatorUtils.equals(key, searchText)) { if (ComparatorUtils.equals(key, searchText)) {
recentModelList = recentKVModelMap.get(searchText); recentModelList = recentKVModelMap.get(searchText);
if (recentModelList.size() > 3) { int size = recentModelList.size();
return recentModelList.subList(0, 2); if (size > MAX_SIZE) {
return recentModelList.subList(size - MAX_SIZE, size);
} }
return recentModelList; return recentModelList;
} }

Loading…
Cancel
Save