Browse Source

代码质量

master
XiaXiang 8 years ago
parent
commit
8b264630c2
  1. 12
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  2. 14
      designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java
  3. 4
      designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java
  4. 3
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  5. 3
      designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java
  6. 20
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java
  7. 7
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java

12
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -366,7 +366,7 @@ public class AlphaFineDialog extends UIDialog {
private void getDocumentList(final String searchText) {
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText);
for (Object object : documentModelList) {
for (AlphaCellModel object : documentModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
@ -374,7 +374,7 @@ public class AlphaFineDialog extends UIDialog {
private void getFileList(final String searchText) {
SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText);
for (Object object : fileModelList) {
for (AlphaCellModel object : fileModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
@ -382,7 +382,7 @@ public class AlphaFineDialog extends UIDialog {
private void getActionList(final String searchText) {
SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText);
for (Object object : actionModelList) {
for (AlphaCellModel object : actionModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
@ -390,7 +390,7 @@ public class AlphaFineDialog extends UIDialog {
private void getPluginList(final String searchText) {
SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText);
for (Object object : pluginModelList) {
for (AlphaCellModel object : pluginModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
@ -398,7 +398,7 @@ public class AlphaFineDialog extends UIDialog {
private void getRecommendList(final String searchText) {
SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText);
for (Object object : recommendModelList) {
for (AlphaCellModel object : recommendModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
@ -406,7 +406,7 @@ public class AlphaFineDialog extends UIDialog {
private void getRecentList(final String searchText) {
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText);
for (Object object : recentModelList) {
for (AlphaCellModel object : recentModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}

14
designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java

@ -1,11 +1,13 @@
package com.fr.design.mainframe.alphafine.model;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import javax.swing.*;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class SearchListModel extends DefaultListModel {
public class SearchListModel extends DefaultListModel<AlphaCellModel> {
SearchResult myDelegate;
public SearchListModel(SearchResult searchResult) {
@ -13,26 +15,26 @@ public class SearchListModel extends DefaultListModel {
}
@Override
public void addElement(Object element) {
public void addElement(AlphaCellModel element) {
int index = myDelegate.size();
myDelegate.add(element);
fireContentsChanged(this, index, index);
}
@Override
public Object getElementAt(int index) {
public AlphaCellModel getElementAt(int index) {
return myDelegate.get(index);
}
@Override
public void add(int index, Object element) {
public void add(int index, AlphaCellModel element) {
myDelegate.add(index, element);
fireIntervalAdded(this, index, index);
}
@Override
public Object remove(int index) {
Object object = myDelegate.get(index);
public AlphaCellModel remove(int index) {
AlphaCellModel object = myDelegate.get(index);
myDelegate.remove(object);
fireIntervalRemoved(this, index, index);
return object;

4
designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java

@ -1,11 +1,13 @@
package com.fr.design.mainframe.alphafine.model;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import java.util.ArrayList;
/**
* Created by XiaXiang on 2017/4/20.
*/
public class SearchResult extends ArrayList<Object> {
public class SearchResult extends ArrayList<AlphaCellModel> {
private boolean needMore;

3
designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java

@ -5,6 +5,7 @@ import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.ActionModel;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.toolbar.UpdateActionManager;
@ -70,7 +71,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
}
}
SearchResult result = new SearchResult();
for (Object object : filterModelList) {
for (AlphaCellModel object : filterModelList) {
if (!AlphaFineHelper.getFilterResult().contains(object)) {
result.add(object);
}

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

@ -6,6 +6,7 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.FileModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
@ -94,7 +95,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
}
SearchResult result = new SearchResult();
for (Object object : filterModelList) {
for (AlphaCellModel object : filterModelList) {
if (!AlphaFineHelper.getFilterResult().contains(object)) {
result.add(object);
}

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

@ -39,8 +39,8 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
private static RecentSearchManager recentSearchManager = null;
private static File recentFile = null;
private SearchResult modelList;
private List<AlphaCellModel> recentModelList = new ArrayList<>();
private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>();
private SearchResult recentModelList;
private Map<String, SearchResult> recentKVModelMap = new HashMap<>();
public synchronized static RecentSearchManager getRecentSearchManger() {
if (recentSearchManager == null) {
@ -64,7 +64,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
String nodeName = reader.getTagName();
if (nodeName.equals("RecentModelList")) {
String key = reader.getAttrAsString("searchKey", StringUtils.EMPTY);
final ArrayList<AlphaCellModel> list = new ArrayList<>();
final SearchResult list = new SearchResult();
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader reader) {
@ -206,23 +206,19 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
return recentModelList;
}
public void setRecentModelList(List<AlphaCellModel> recentModelList) {
this.recentModelList = recentModelList;
}
/**
* 根据搜索字段获取对应的model列表
*
* @param searchText
* @return
*/
public synchronized List<AlphaCellModel> getRecentModelList(String searchText) {
recentModelList = new ArrayList<>();
private synchronized SearchResult getRecentModelList(String searchText) {
recentModelList = new SearchResult();
for (String key : recentKVModelMap.keySet()) {
AlphaFineHelper.checkCancel();
if (ComparatorUtils.equals(key, searchText)) {
recentModelList = recentKVModelMap.get(searchText);
List<AlphaCellModel> resultModelList = new ArrayList<>(recentModelList);
SearchResult resultModelList = recentModelList;
Iterator<AlphaCellModel> modelIterator = resultModelList.iterator();
while (modelIterator.hasNext()) {
AlphaCellModel model = modelIterator.next();
@ -234,7 +230,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
Collections.sort(resultModelList);
int size = resultModelList.size();
if (size > MAX_SIZE) {
return resultModelList.subList(0, MAX_SIZE);
return (SearchResult) resultModelList.subList(0, MAX_SIZE);
}
return resultModelList;
}
@ -259,7 +255,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
}
//trimToSize(cellModels);
} else {
List<AlphaCellModel> list = new ArrayList<>();
SearchResult list = new SearchResult();
list.add(cellModel);
recentKVModelMap.put(searchKey, list);
}

7
designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java

@ -27,7 +27,7 @@ import java.util.List;
public class RecommendSearchManager implements AlphaFineSearchProcessor {
private static RecommendSearchManager recommendSearchManager = null;
private SearchResult modelList;
private List<AlphaCellModel> recommendModelList = new ArrayList<>();
private SearchResult recommendModelList;
public synchronized static RecommendSearchManager getRecommendSearchManager() {
if (recommendSearchManager == null) {
@ -39,7 +39,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
this.modelList = new SearchResult();
this.recommendModelList = new ArrayList<>();
this.recommendModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) {
String result;
HttpClient httpClient = new HttpClient(AlphaFineConstants.SEARCHAPI + CodeUtils.cjkEncode(searchText));
@ -105,7 +105,4 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
return recommendModelList;
}
public void setRecommendModelList(List<AlphaCellModel> recommendModelList) {
this.recommendModelList = recommendModelList;
}
}

Loading…
Cancel
Save