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. 8
      designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  6. 156
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  7. 8
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  8. 40
      designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java
  9. 8
      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 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 BLUE = new Color(0x3394f0);
public static final Color BLACK = new Color(0x222222); 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; package com.fr.design.mainframe.alphafine;
import com.fr.design.mainframe.DesignerContext; 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.component.AlphaFineDialog;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.Inter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
/** /**
* Created by XiaXiang on 2017/5/8. * Created by XiaXiang on 2017/5/8.
*/ */
public class AlphaFineHelper { 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搜索面板 * 弹出alphafine搜索面板
@ -17,6 +22,7 @@ public class AlphaFineHelper {
dialog.setVisible(true); dialog.setVisible(true);
} }
/** /**
* 获取文件名上级目录 * 获取文件名上级目录
* @param text * @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. * Created by XiaXiang on 2017/4/27.
*/ */
public enum CellType { 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; 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;
}
}

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

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

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

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

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

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

@ -44,6 +44,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
this.filterModelList = new SearchResult(); this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult(); this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult(); this.moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) {
Env env = FRContext.getCurrentEnv(); Env env = FRContext.getCurrentEnv();
fileNodes = new ArrayList<>(); fileNodes = new ArrayList<>();
fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true); fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true);
@ -63,13 +64,18 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
for (int i = length; i< filterModelList.size(); i++) { for (int i = length; i< filterModelList.size(); i++) {
moreModelList.add(filterModelList.get(i)); moreModelList.add(filterModelList.get(i));
} }
if (filterModelList.size() > 0) {
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) { 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)); lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.FILE));
} else { } else {
lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE)); lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE));
if (lessModelList.size() == 1) {
lessModelList.add(AlphaFineHelper.noResultModel);
}
} }
} }
return this.lessModelList; 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; package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.DesignerEnvManager; 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.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType; 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.PluginModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
@ -21,9 +25,14 @@ import java.net.URLEncoder;
*/ */
public class PluginSearchManager implements AlphaFineSearchProcessor { public class PluginSearchManager implements AlphaFineSearchProcessor {
private static PluginSearchManager pluginSearchManager = null; 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 lessModelList;
private SearchResult moreModelList; private SearchResult moreModelList;
public synchronized static PluginSearchManager getPluginSearchManager() { public synchronized static PluginSearchManager getPluginSearchManager() {
if (pluginSearchManager == null) { if (pluginSearchManager == null) {
pluginSearchManager = new PluginSearchManager(); pluginSearchManager = new PluginSearchManager();
@ -34,7 +43,6 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
@Override @Override
public synchronized SearchResult getLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
this.lessModelList = new SearchResult(); this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult(); this.moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainPlugin()) { if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainPlugin()) {
@ -46,12 +54,12 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
httpClient.setTimeout(5000); httpClient.setTimeout(5000);
httpClient.asGet(); httpClient.asGet();
if (!httpClient.isServerAlive()) { if (!httpClient.isServerAlive()) {
return lessModelList; return getNoConnectList();
} }
result = httpClient.getResponseText(); result = httpClient.getResponseText();
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
JSONArray jsonArray = jsonObject.optJSONArray("result"); JSONArray jsonArray = jsonObject.optJSONArray("result");
if (jsonArray != null && jsonArray.length() > 0) { if (jsonArray != null) {
int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length()); int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length());
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false);
@ -64,17 +72,39 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { 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)); lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN));
} else { } 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) { } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
return lessModelList; return getNoResultList();
} }
} }
return this.lessModelList; 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) { 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; package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.DesignerEnvManager; 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.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
@ -37,7 +38,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
httpClient.asGet(); httpClient.asGet();
httpClient.setTimeout(5000); httpClient.setTimeout(5000);
if (!httpClient.isServerAlive()) { if (!httpClient.isServerAlive()) {
return modelList; return getNoConnectList();
} }
result = httpClient.getResponseText(); result = httpClient.getResponseText();
try { try {
@ -65,6 +66,13 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
return modelList; 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 @Override
public SearchResult getMoreSearchResult() { public SearchResult getMoreSearchResult() {
return new SearchResult(); 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_ShowLess=show less
FR-Designer_Alphafine=AlphaFine FR-Designer_Alphafine=AlphaFine
FR-Designer-Alphafine_No_Remind= 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_ShowLess=show less
FR-Designer_Alphafine=AlphaFine FR-Designer_Alphafine=AlphaFine
FR-Designer-Alphafine_No_Remind=don't remind 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_ShowLess=\u6536\u8D77
FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22 FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22
FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A 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=AlphaFine\u667A\u80FD\u641C\u7D22
FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8 FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8
FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A 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