Browse Source

代码质量

final/10.0
alex.sung 6 years ago
parent
commit
2c5649fedb
  1. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java
  2. 7
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java
  3. 14
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  4. 7
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java

4
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java

@ -7,6 +7,7 @@ import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
@ -33,7 +34,6 @@ public class RobotPreviewPane extends JPanel {
private static final int TITLE_AREA_HEIGHT = 15;
private static final int HOT_TITLE_AREA_HEIGHT = 30;
private static final String STRING_ENCODER = "UTF-8";
public RobotPreviewPane(AlphaCellModel model, String content) {
this.setLayout(new BorderLayout());
@ -60,7 +60,7 @@ public class RobotPreviewPane extends JPanel {
.replaceAll("\\('", StringUtils.EMPTY)
.replaceAll("'\\)", StringUtils.EMPTY);
try {
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + URLEncoder.encode(s, STRING_ENCODER)));
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + URLEncoder.encode(s, EncodeConstants.ENCODING_UTF_8)));
} catch (IOException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage());
} catch (URISyntaxException e1) {

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

@ -5,12 +5,9 @@ import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONException;
import com.fr.log.FineLoggerFactory;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
import java.io.IOException;
/**
* @author alex.sung created on 2018/7/23.
@ -47,10 +44,8 @@ public class ComplementAdviceManager {
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
allModelList = AlphaFineHelper.getModelListFromJSONArray(result,"keywords");
} catch(ClassCastException | JSONException e){
} catch(Exception e){
FineLoggerFactory.getLogger().debug("complement advice search error: " + e.getMessage());
} catch (IOException e1) {
FineLoggerFactory.getLogger().debug("complement advice get result error: " + e1.getMessage());
}
}
if (searchResult.isEmpty()) {

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

@ -12,14 +12,12 @@ import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
@ -54,7 +52,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
return new SearchResult();
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if(noConnectList != null){
if (noConnectList != null) {
return noConnectList;
}
for (int j = 0; j < searchText.length; j++) {
@ -76,9 +74,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
}
}
}
} catch (JSONException e) {
FineLoggerFactory.getLogger().debug("recommend search error! :" + e.getMessage());
} catch (IOException e) {
} catch (Exception e) {
FineLoggerFactory.getLogger().debug("recommend search get result error! :" + e.getMessage());
}
}
@ -113,7 +109,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
/**
* 将推荐接口获取的数据分别放入显示部分显示更多的list
*/
private void getRecommendSearchResult(){
private void getRecommendSearchResult() {
if (recommendModelList.size() > AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM) {
if (recommendModelList.size() > AlphaFineConstants.SHOW_SIZE) {
modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND));
@ -131,7 +127,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
/**
* 将补全接口获取的数据分别放入显示部分显示更多的list
*/
private void getComplementAdviceSearchResult(){
private void getComplementAdviceSearchResult() {
if (complementAdviceModelList.size() > AlphaFineConstants.SHOW_SIZE) {
modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND));
modelList.addAll(complementAdviceModelList.subList(0, AlphaFineConstants.SHOW_SIZE));
@ -145,7 +141,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
/**
* 将推荐接口和补全接口获取的数据分别放入显示部分显示更多的list
*/
private void getRecommendAndAdviceSearchResult(){
private void getRecommendAndAdviceSearchResult() {
if (recommendModelList.size() + complementAdviceModelList.size() > AlphaFineConstants.SHOW_SIZE) {
modelList.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_ShowAll"), true, CellType.RECOMMEND));
if (recommendModelList.size() > AlphaFineConstants.RECOMMEND_MAX_ITEM_NUM) {

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

@ -9,14 +9,11 @@ import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
import java.io.IOException;
/**
* Created by alex.sung on 2018/8/3.
*/
@ -55,10 +52,8 @@ public class SimilarSearchManeger implements AlphaFineSearchProvider {
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
allModelList = AlphaFineHelper.getModelListFromJSONArray(result,"title");
} catch (ClassCastException | JSONException e) {
} catch (Exception e) {
FineLoggerFactory.getLogger().debug("similar search error: " + e.getMessage());
} catch (IOException e) {
FineLoggerFactory.getLogger().debug("similar search get result error: " + e.getMessage());
}
}
moreModelList.clear();

Loading…
Cancel
Save