Browse Source

alphafine bug fix

master
XiaXiang 8 years ago
parent
commit
db79a6a672
  1. 2
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 6
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  3. 2
      designer/src/com/fr/design/mainframe/alphafine/CellType.java
  4. 24
      designer/src/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java
  5. 10
      designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  6. 164
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  7. 30
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  8. 42
      designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java
  9. 42
      designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java
  10. 40
      designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java
  11. 10
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java
  12. 2
      designer_base/src/com/fr/design/locale/designer.properties
  13. 2
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  14. 2
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  15. 2
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties

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

@ -47,6 +47,8 @@ public class AlphaFineConstants {
public static final Color LIGHT_GRAY = new Color(0xcccccc);
public static final Color MEDIUM_GRAY = new Color(0x999999);
public static final Color BLUE = new Color(0x3394f0);
public static final Color BLACK = new Color(0x222222);

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

@ -1,13 +1,18 @@
package com.fr.design.mainframe.alphafine;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.cell.model.NoResultModel;
import com.fr.design.mainframe.alphafine.component.AlphaFineDialog;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.Inter;
import com.fr.stable.StringUtils;
/**
* Created by XiaXiang on 2017/5/8.
*/
public class AlphaFineHelper {
public static final NoResultModel noResultModel = new NoResultModel(Inter.getLocText("FR-Designere_AlphaFine_NoResult"));
public static final NoResultModel noConnectionModel = new NoResultModel(Inter.getLocText("FR-Designer_ConnectionFailed"));
/**
* 弹出alphafine搜索面板
@ -17,6 +22,7 @@ public class AlphaFineHelper {
dialog.setVisible(true);
}
/**
* 获取文件名上级目录
* @param text

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

@ -4,7 +4,7 @@ package com.fr.design.mainframe.alphafine;
* Created by XiaXiang on 2017/4/27.
*/
public enum CellType {
RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5);
RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5), NO_RESULT(6);
private int typeValue;

24
designer/src/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java

@ -0,0 +1,24 @@
package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
/**
* Created by XiaXiang on 2017/6/8.
*/
public class NoResultModel extends AlphaCellModel {
public NoResultModel(String name) {
super(name, null, CellType.NO_RESULT);
}
@Override
public JSONObject ModelToJson() throws JSONException {
return null;
}
@Override
public String getStoreInformation() {
return null;
}
}

10
designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe.alphafine.cell.render;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.stable.StringUtils;
@ -34,9 +35,14 @@ public class ContentCellRender implements ListCellRenderer<Object> {
AlphaCellModel model = (AlphaCellModel) value;
name.setText(model.getName());
String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png";
name.setIcon(new ImageIcon(getClass().getResource(iconUrl)));
if (model.getType() == CellType.NO_RESULT) {
name.setIcon(null);
name.setForeground(AlphaFineConstants.MEDIUM_GRAY);
} else {
name.setIcon(new ImageIcon(getClass().getResource(iconUrl)));
name.setForeground(AlphaFineConstants.BLACK);
}
name.setFont(AlphaFineConstants.MEDIUM_FONT);
name.setForeground(AlphaFineConstants.BLACK);
name.setVerticalTextPosition(SwingConstants.CENTER);
name.setHorizontalTextPosition(SwingConstants.RIGHT);
String description = model.getDescription();

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

@ -2,6 +2,7 @@ package com.fr.design.mainframe.alphafine.component;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphafineContext;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
@ -27,6 +28,7 @@ import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.ProcessCanceledException;
import com.fr.general.http.HttpClient;
import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter;
@ -39,6 +41,7 @@ import com.fr.stable.project.ProjectConstants;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.Timer;
import javax.swing.event.DocumentEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
@ -50,8 +53,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.*;
import java.util.concurrent.ExecutionException;
/**
@ -69,6 +71,10 @@ public class AlphaFineDialog extends UIDialog {
private SwingWorker searchWorker;
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
private boolean forceOpen;
//。。。
private boolean isSearchCancel;
private boolean waitingForSearch;
private long lastUpdateTime;
public AlphaFineDialog(Frame parent, boolean forceOpen) {
super(parent);
@ -76,6 +82,23 @@ public class AlphaFineDialog extends UIDialog {
initProperties();
initListener();
initComponents();
//initSearcheTimer();
}
private void initSearcheTimer() {
java.util.Timer timer = new java.util.Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
if (waitingForSearch) {
long currentTime = System.currentTimeMillis();
if (currentTime - lastUpdateTime > 1000) {
doSearch(searchTextField.getText());
waitingForSearch = false;
}
}
}
}, 1000, 1000);
}
/**
@ -134,6 +157,7 @@ public class AlphaFineDialog extends UIDialog {
addComponentListener(new ComponentHandler());
setSize(AlphaFineConstants.FIELD_SIZE);
centerWindow(this);
}
/**
@ -166,7 +190,7 @@ public class AlphaFineDialog extends UIDialog {
} else if (text.contains("'")) {
return;
} else {
showSearchResult(text);
showSearchResult();
}
}
@ -198,14 +222,13 @@ public class AlphaFineDialog extends UIDialog {
/**
* 展示搜索结果
* @param searchText
*/
private void showSearchResult(String searchText) {
private void showSearchResult() {
if (searchResultPane == null) {
initSearchResultComponents();
initListListener(searchText);
initListListener();
}
initSearchWorker(searchText);
initSearchWorker();
}
/**
@ -213,6 +236,8 @@ public class AlphaFineDialog extends UIDialog {
*/
private void initSearchResultComponents() {
searchResultList = new JList();
searchListModel = new SearchListModel(new SearchResult());
searchResultList.setModel(searchListModel);
searchResultPane = new JPanel();
searchResultPane.setPreferredSize(AlphaFineConstants.CONTENT_SIZE);
searchResultPane.setLayout(new BorderLayout());
@ -233,56 +258,99 @@ public class AlphaFineDialog extends UIDialog {
}
/**
* 异步加载搜索结构
* @param searchText
* 异步加载搜索结果
*/
private void initSearchWorker(final String searchText) {
searchResultList.setModel(new SearchListModel(AlphaSearchManager.getSearchManager().showDefaultSearchResult()));
private void initSearchWorker() {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
this.searchWorker = new SwingWorker<SearchListModel, String>() {
this.searchWorker = new SwingWorker() {
@Override
protected SearchListModel doInBackground() {
return setListModel(new SearchListModel(AlphaSearchManager.getSearchManager().getLessSearchResult(searchText)));
protected Object doInBackground() throws Exception {
rebuildList(searchTextField.getText());
return null;
}
};
this.searchWorker.execute();
}
@Override
protected void done() {
try {
if (!isCancelled()) {
searchResultList.setModel(get());
searchResultList.validate();
searchResultList.repaint();
validate();
repaint();
/**
* 默认选中第1项第0项为title
*/
if (searchResultList.getModel().getSize() > 0) {
searchResultList.setSelectedIndex(1);
}
private synchronized void rebuildList(String searchText) {
System.out.print("background===" + searchText + "\n");
searchListModel.removeAllElements();
getRecentList(searchText);
getRecommendList(searchText);
getActionList(searchText);
getFileList(searchText);
getDocumentList(searchText);
getPluginList(searchText);
}
}
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
}
private void checkCancel() {
if (Thread.interrupted()) {
throw new ProcessCanceledException();
}
}
private synchronized void getDocumentList(final String searchText) {
}
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText);
checkCancel();
for (Object object : documentModelList) {
};
this.searchWorker.execute();
searchListModel.addElement(object);
}
System.out.print("document" + "-----" + searchText + "\n");
}
private synchronized void getFileList(final String searchText) {
SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText);
for (Object object : fileModelList) {
searchListModel.addElement(object);
}
System.out.print("file" + "-----" + searchText + "\n");
}
private synchronized void getActionList(final String searchText) {
SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText);
for (Object object : actionModelList) {
searchListModel.addElement(object);
}
System.out.print("action" + "-----" + searchText + "\n");
}
private synchronized void getPluginList(final String searchText) {
SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText);
for (Object object : pluginModelList) {
searchListModel.addElement(object);
}
System.out.print("plugin" + "-----" + searchText + "\n");
}
private synchronized void getRecommendList(final String searchText) {
SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText);
for (Object object : recommendModelList) {
searchListModel.addElement(object);
}
System.out.print("recommend" + "-----" + searchText + "\n");
}
private synchronized void getRecentList(final String searchText) {
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText);
for (Object object : recentModelList) {
searchListModel.addElement(object);
}
System.out.print("recent" + "-----" + searchText + "\n");
}
/**
* 初始化监听器
* @param searchText
*/
private void initListListener(final String searchText) {
private void initListListener() {
/**
* 鼠标监听器
*/
@ -663,11 +731,11 @@ public class AlphaFineDialog extends UIDialog {
SearchResult moreResult = getMoreResult(selectedValue);
if((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) {
for (int i = 0; i < moreResult.size(); i++) {
this.searchListModel.insertElementAt(moreResult.get(i), index + AlphaFineConstants.SHOW_SIZE + 1 + i);
this.searchListModel.add(index + AlphaFineConstants.SHOW_SIZE + 1 + i, moreResult.get(i));
}
} else {
for (int i = 0; i < moreResult.size(); i++) {
this.searchListModel.removeElementAt(index + AlphaFineConstants.SHOW_SIZE + 1);
this.searchListModel.remove(index + AlphaFineConstants.SHOW_SIZE + 1);
}
}
@ -701,7 +769,7 @@ public class AlphaFineDialog extends UIDialog {
moreResult = ActionSearchManager.getActionSearchManager().getMoreSearchResult();
break;
default:
moreResult = AlphaSearchManager.getSearchManager().getMoreSearchResult();
moreResult = new SearchResult();
}
return moreResult;
}
@ -731,4 +799,12 @@ public class AlphaFineDialog extends UIDialog {
public void setForceOpen(boolean forceOpen) {
this.forceOpen = forceOpen;
}
public boolean isSearchCancel() {
return isSearchCancel;
}
public void setSearchCancel(boolean searchCancel) {
isSearchCancel = searchCancel;
}
}

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

@ -2,6 +2,7 @@ package com.fr.design.mainframe.alphafine.search.manager;
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.ActionModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
@ -44,21 +45,24 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
}
}
}
if (filterModelList != null && filterModelList.size() > 0) {
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size());
for (int i = 0; i < length; i++) {
lessModelList.add(filterModelList.get(i));
}
for (int i = length; i < filterModelList.size(); i++) {
moreModelList.add(filterModelList.get(i));
}
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION));
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION));
}
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size());
for (int i = 0; i < length; i++) {
lessModelList.add(filterModelList.get(i));
}
for (int i = length; i < filterModelList.size(); i++) {
moreModelList.add(filterModelList.get(i));
}
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION));
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION));
if (lessModelList.size() == 1) {
lessModelList.add(AlphaFineHelper.noResultModel);
}
}
}
return lessModelList;

42
designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java

@ -1,13 +1,17 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphafineContext;
import com.fr.design.actions.help.alphafine.AlphafineListener;
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.DocumentModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.ProcessCanceledException;
import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
@ -20,6 +24,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList;
private SearchResult moreModelList;
private static final MoreModel titleModel = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT);
public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) {
@ -40,13 +45,23 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
httpClient.setTimeout(5000);
httpClient.asGet();
if (!httpClient.isServerAlive()) {
return lessModelList;
return getNoConnectList();
}
if (Thread.interrupted()) {
System.out.print(searchText + "--------崩了1111\n");
throw new ProcessCanceledException();
}
result = httpClient.getResponseText();
if (Thread.interrupted()) {
System.out.print(searchText + "--------崩了22222\n");
throw new ProcessCanceledException();
}
try {
JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = jsonObject.optJSONArray("docdata");
if (jsonArray != null && jsonArray.length() > 0) {
if (jsonArray != null) {
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
for (int i = 0; i < length; i++) {
DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i));
@ -59,7 +74,10 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT));
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT));
lessModelList.add(0, titleModel);
if (lessModelList.size() == 1) {
lessModelList.add(AlphaFineHelper.noResultModel);
}
}
@ -67,14 +85,28 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
return lessModelList;
return getNoResultList();
}
}
return lessModelList;
}
private SearchResult getNoResultList() {
SearchResult result = new SearchResult();
result.add(0, titleModel);
result.add(AlphaFineHelper.noResultModel);
return result;
}
private SearchResult getNoConnectList() {
SearchResult result = new SearchResult();
result.add(0, titleModel);
result.add(AlphaFineHelper.noConnectionModel);
return result;
}
/**
* 根据json信息获取文档model
* @param object

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

@ -44,32 +44,38 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
Env env = FRContext.getCurrentEnv();
fileNodes = new ArrayList<>();
fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true);
for (FileNode node : fileNodes) {
boolean isAlreadyContain = false;
String fileEnvPath = node.getEnvPath();
String filePath = StableUtils.pathJoin(env.getPath(), fileEnvPath);
isAlreadyContain = searchFile(searchText, node, isAlreadyContain);
searchFileContent(searchText, node, isAlreadyContain, filePath);
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) {
Env env = FRContext.getCurrentEnv();
fileNodes = new ArrayList<>();
fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true);
for (FileNode node : fileNodes) {
boolean isAlreadyContain = false;
String fileEnvPath = node.getEnvPath();
String filePath = StableUtils.pathJoin(env.getPath(), fileEnvPath);
isAlreadyContain = searchFile(searchText, node, isAlreadyContain);
searchFileContent(searchText, node, isAlreadyContain, filePath);
}
}
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size());
for (int i = 0; i < length; i++) {
lessModelList.add(filterModelList.get(i));
}
for (int i = length; i< filterModelList.size(); i++) {
moreModelList.add(filterModelList.get(i));
}
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size());
for (int i = 0; i < length; i++) {
lessModelList.add(filterModelList.get(i));
}
for (int i = length; i< filterModelList.size(); i++) {
moreModelList.add(filterModelList.get(i));
}
if (filterModelList.size() > 0) {
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.FILE));
} else {
lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE));
if (lessModelList.size() == 1) {
lessModelList.add(AlphaFineHelper.noResultModel);
}
}
}
return this.lessModelList;
}

40
designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java

@ -1,8 +1,12 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphafineContext;
import com.fr.design.actions.help.alphafine.AlphafineListener;
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.NoResultModel;
import com.fr.design.mainframe.alphafine.cell.model.PluginModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
@ -21,9 +25,14 @@ import java.net.URLEncoder;
*/
public class PluginSearchManager implements AlphaFineSearchProcessor {
private static PluginSearchManager pluginSearchManager = null;
private static final MoreModel titleModel = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN);
private SearchResult lessModelList;
private SearchResult moreModelList;
public synchronized static PluginSearchManager getPluginSearchManager() {
if (pluginSearchManager == null) {
pluginSearchManager = new PluginSearchManager();
@ -34,7 +43,6 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainPlugin()) {
@ -46,12 +54,12 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
httpClient.setTimeout(5000);
httpClient.asGet();
if (!httpClient.isServerAlive()) {
return lessModelList;
return getNoConnectList();
}
result = httpClient.getResponseText();
JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = jsonObject.optJSONArray("result");
if (jsonArray != null && jsonArray.length() > 0) {
if (jsonArray != null) {
int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
for (int i = 0; i < length; i++) {
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false);
@ -64,17 +72,39 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN));
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN));
lessModelList.add(0, titleModel);
if (lessModelList.size() == 1) {
lessModelList.add(AlphaFineHelper.noResultModel);
}
}
} else {
return getNoResultList();
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
return lessModelList;
return getNoResultList();
}
}
return this.lessModelList;
}
private SearchResult getNoResultList() {
SearchResult result = new SearchResult();
result.add(0, titleModel);
result.add(AlphaFineHelper.noResultModel);
return result;
}
private SearchResult getNoConnectList() {
SearchResult result = new SearchResult();
result.add(0, titleModel);
result.add(AlphaFineHelper.noConnectionModel);
return result;
}
private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) {

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

@ -1,6 +1,7 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.cell.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
@ -37,7 +38,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
httpClient.asGet();
httpClient.setTimeout(5000);
if (!httpClient.isServerAlive()) {
return modelList;
return getNoConnectList();
}
result = httpClient.getResponseText();
try {
@ -65,6 +66,13 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
return modelList;
}
private SearchResult getNoConnectList() {
SearchResult result = new SearchResult();
result.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude"), false));
result.add(AlphaFineHelper.noConnectionModel);
return result;
}
@Override
public SearchResult getMoreSearchResult() {
return new SearchResult();

2
designer_base/src/com/fr/design/locale/designer.properties

@ -2007,3 +2007,5 @@ FR-Designer_AlphaFine_Latest=Latest
FR-Designer_AlphaFine_ShowLess=show less
FR-Designer_Alphafine=AlphaFine
FR-Designer-Alphafine_No_Remind=
FR-Designere_AlphaFine_NoResult=no results
FR-Designer_ConnectionFailed=connection failed

2
designer_base/src/com/fr/design/locale/designer_en_US.properties

@ -2005,3 +2005,5 @@ FR-Designer_AlphaFine_Latest=Recent
FR-Designer_AlphaFine_ShowLess=show less
FR-Designer_Alphafine=AlphaFine
FR-Designer-Alphafine_No_Remind=don't remind
FR-Designere_AlphaFine_NoResult=no results
FR-Designer_ConnectionFailed=connection failed

2
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -2003,3 +2003,5 @@ FR-Designer_AlphaFine_Latest=\u672C\u5730\u5E38\u7528
FR-Designer_AlphaFine_ShowLess=\u6536\u8D77
FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22
FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A
FR-Designere_AlphaFine_NoResult=\u6682\u65E0\u76F8\u5173\u5185\u5BB9
FR-Designer_ConnectionFailed=\u94FE\u63A5\u5931\u8D25

2
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -2001,3 +2001,5 @@ FR-Designer_AlphaFine_ShowLess=\u6536\u8D77
FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22
FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8
FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A
FR-Designere_AlphaFine_NoResult=\u66AB\u7121\u76F8\u95DC\u5167\u5BB9
FR-Designer_ConnectionFailed=\u93C8\u63A5\u5931\u6557
Loading…
Cancel
Save