Browse Source

Merge pull request #495 in DESIGN/design from ~ALEX.SUNG/design:release/10.0 to release/10.0

REPORT-10946 @Sung:离线状态下(断网)alphafine都打不开了

* commit '3847e66b0ba581505ac1a823f749c94e2bc73b97':
  REPORT-11403 @Sung:查询结果出来的横向滚动条位置偏上了 调整高度
  在getNoConnectList里判断isNetworkOk, 对外就一个方法getNoConnectList
  REPORT-10946 @Sung:离线状态下(断网)alphafine都打不开了 之前的断网情况逻辑耦合太严重了,剥离出来
final/10.0
Alex.Sung 6 years ago
parent
commit
a60b0c9ab5
  1. 23
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  2. 23
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  3. 17
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java
  4. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java
  5. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java
  6. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java
  7. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java
  8. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  9. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java
  10. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  11. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java

23
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -16,11 +16,15 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger; import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManeger;
import com.fr.general.ProcessCanceledException; import com.fr.general.ProcessCanceledException;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.json.JSONUtils; import com.fr.json.JSONUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.StatusLine;
import com.fr.third.org.apache.http.client.methods.HttpGet;
import java.util.List; import java.util.List;
@ -30,6 +34,7 @@ import java.util.List;
public class AlphaFineHelper { public class AlphaFineHelper {
public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")); public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed"));
private static AlphaFineDialog alphaFineDialog; private static AlphaFineDialog alphaFineDialog;
private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com";
/** /**
* 弹出alphafine搜索面板 * 弹出alphafine搜索面板
@ -130,6 +135,9 @@ public class AlphaFineHelper {
* @return * @return
*/ */
public static SearchResult getNoConnectList(Object object) { public static SearchResult getNoConnectList(Object object) {
if (isNetworkOk()){
return null;
}
SearchResult result = new SearchResult(); SearchResult result = new SearchResult();
if (object instanceof RecommendSearchManager) { if (object instanceof RecommendSearchManager) {
result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend"))); result.add(0, new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend")));
@ -145,4 +153,19 @@ public class AlphaFineHelper {
result.add(AlphaFineHelper.NO_CONNECTION_MODEL); result.add(AlphaFineHelper.NO_CONNECTION_MODEL);
return result; return result;
} }
/**
* 判断网络是否异常
* @return
*/
public static boolean isNetworkOk(){
HttpGet getHelp = new HttpGet(URL_FOR_TEST_NETWORK);
try {
StatusLine statusLine = HttpToolbox.getHttpClient(URL_FOR_TEST_NETWORK).execute(getHelp).getStatusLine();
return statusLine.getStatusCode() == HttpStatus.SC_OK;
} catch (Exception ignore) {
// 网络异常
return false;
}
}
} }

23
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -39,7 +39,6 @@ import com.fr.form.main.Form;
import com.fr.form.main.FormIO; import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
import com.fr.io.TemplateWorkBookIO; import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter; import com.fr.io.exporter.ImageExporter;
import com.fr.json.JSONException; import com.fr.json.JSONException;
@ -49,7 +48,6 @@ import com.fr.main.impl.WorkBook;
import com.fr.stable.CodeUtils; import com.fr.stable.CodeUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.http.client.methods.HttpGet;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -247,22 +245,19 @@ public class AlphaFineDialog extends UIDialog {
GridLayout gridLayout = new GridLayout(2, 3, 3, 3); GridLayout gridLayout = new GridLayout(2, 3, 3, 3);
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(gridLayout); panel.setLayout(gridLayout);
try { if(AlphaFineHelper.isNetworkOk()) {
HttpGet getHelp = new HttpGet(AlphaFineConstants.ALPHA_HOT_SEARCH);
HttpToolbox.getHttpClient(AlphaFineConstants.ALPHA_HOT_SEARCH).execute(getHelp).getStatusLine();
if (hotData == null) { if (hotData == null) {
hotData = HotIssuesManager.getInstance().getHotIssues(); hotData = HotIssuesManager.getInstance().getHotIssues();
} }
for (int i = 0; i < hotData.length; i++) { for (int i = 0; i < hotData.length; i++) {
panel.add(new HotIssueJpanel(hotData[i], i + 1)); panel.add(new HotIssueJpanel(hotData[i], i + 1));
} }
} catch (Exception e) { }else {
hotData = null; hotData = null;
for (int i = 0; i < AlphaFineConstants.HOT_ITEMS; i++) { for (int i = 0; i < AlphaFineConstants.HOT_ITEMS; i++) {
panel.add(new HotIssueJpanel(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")}, i + 1)); panel.add(new HotIssueJpanel(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")}, i + 1));
} }
} }
hotPane.add(uiLabel, BorderLayout.NORTH); hotPane.add(uiLabel, BorderLayout.NORTH);
hotPane.add(panel, BorderLayout.CENTER); hotPane.add(panel, BorderLayout.CENTER);
add(hotPane, BorderLayout.SOUTH); add(hotPane, BorderLayout.SOUTH);
@ -552,7 +547,7 @@ public class AlphaFineDialog extends UIDialog {
} }
private void buildDocumentList(final String[] searchText) { private void buildDocumentList(final String[] searchText) {
addSearchResult(DocumentSearchManager.getInstance().getLessSearchResult(getHotData(), searchText)); addSearchResult(DocumentSearchManager.getInstance().getLessSearchResult(searchText));
} }
private void buildFileList(String searchStr, final String[] searchText) { private void buildFileList(String searchStr, final String[] searchText) {
@ -560,24 +555,24 @@ public class AlphaFineDialog extends UIDialog {
} }
private void buildActionList(final String[] searchText) { private void buildActionList(final String[] searchText) {
addSearchResult(ActionSearchManager.getInstance().getLessSearchResult(getHotData(), searchText)); addSearchResult(ActionSearchManager.getInstance().getLessSearchResult(searchText));
} }
private void buildPluginList(final String[] searchText) { private void buildPluginList(final String[] searchText) {
addSearchResult(PluginSearchManager.getInstance().getLessSearchResult(getHotData(), searchText)); addSearchResult(PluginSearchManager.getInstance().getLessSearchResult(searchText));
} }
private void buildRecommendList(final String[] searchText) { private void buildRecommendList(final String[] searchText) {
addSearchResult(RecommendSearchManager.getInstance().getLessSearchResult(getHotData(), searchText)); addSearchResult(RecommendSearchManager.getInstance().getLessSearchResult(searchText));
} }
private void buildRecentList(final String[] searchText) { private void buildRecentList(final String[] searchText) {
addSearchResult(RecentSearchManager.getInstance().getLessSearchResult(getHotData(), searchText)); addSearchResult(RecentSearchManager.getInstance().getLessSearchResult(searchText));
} }
private void buildSimilarList(final String[] searchText) { private void buildSimilarList(final String[] searchText) {
addSearchResult(SimilarSearchManeger.getInstance().getLessSearchResult(getHotData(), searchText)); addSearchResult(SimilarSearchManeger.getInstance().getLessSearchResult(searchText));
} }
private synchronized void addSearchResult(SearchResult searchResult) { private synchronized void addSearchResult(SearchResult searchResult) {
@ -740,7 +735,7 @@ public class AlphaFineDialog extends UIDialog {
if (!isCancelled() && rightSearchResultPane != null) { if (!isCancelled() && rightSearchResultPane != null) {
rightSearchResultPane.removeAll(); rightSearchResultPane.removeAll();
try { try {
rightSearchResultPane.add(new RobotPreviewPane((selectedValue).getName(), get())); rightSearchResultPane.add(new RobotPreviewPane(selectedValue, get()));
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("get hot item content error: " + e.getMessage()); FineLoggerFactory.getLogger().error("get hot item content error: " + e.getMessage());
} catch (ExecutionException e) { } catch (ExecutionException e) {

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

@ -4,6 +4,8 @@ package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; 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.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -28,13 +30,14 @@ import java.net.URL;
*/ */
public class RobotPreviewPane extends JPanel { public class RobotPreviewPane extends JPanel {
private static final int TITLE_AREA_HEIGHT = 30; private static final int TITLE_AREA_HEIGHT = 15;
private static final int HOT_TITLE_AREA_HEIGHT = 30;
public RobotPreviewPane(String title, String content) { public RobotPreviewPane(AlphaCellModel model, String content) {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.setBackground(Color.WHITE); this.setBackground(Color.WHITE);
this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT)); this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT));
UITextArea titleArea = new UITextArea(title); UITextArea titleArea = new UITextArea(model.getName());
titleArea.setBorder(null); titleArea.setBorder(null);
titleArea.setEditable(false); titleArea.setEditable(false);
titleArea.setForeground(AlphaFineConstants.BLUE); titleArea.setForeground(AlphaFineConstants.BLUE);
@ -74,9 +77,13 @@ public class RobotPreviewPane extends JPanel {
}); });
editorPane.setEditable(false); editorPane.setEditable(false);
UIScrollPane jScrollPane = new UIScrollPane(editorPane); UIScrollPane jScrollPane = new UIScrollPane(editorPane);
jScrollPane.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); jScrollPane.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder(0, 2, 30, 0));
jScrollPane.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 10, Color.white)); jScrollPane.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 10, Color.white));
this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT - TITLE_AREA_HEIGHT)); if (((RobotModel) model).isHotItemModel()) {
this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT - HOT_TITLE_AREA_HEIGHT));
} else {
this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT - TITLE_AREA_HEIGHT));
}
add(jScrollPane, BorderLayout.CENTER); add(jScrollPane, BorderLayout.CENTER);
} }
} }

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java

@ -12,7 +12,7 @@ public interface AlphaFineSearchProvider {
* @param searchText * @param searchText
* @return * @return
*/ */
SearchResult getLessSearchResult(String[][] data, String[] searchText); SearchResult getLessSearchResult(String[] searchText);
/** /**
* 获取剩余条数 * 获取剩余条数

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

@ -57,7 +57,7 @@ public class ActionSearchManager implements AlphaFineSearchProvider {
} }
@Override @Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) { public SearchResult getLessSearchResult(String[] searchText) {
filterModelList = new SearchResult(); filterModelList = new SearchResult();
lessModelList = new SearchResult(); lessModelList = new SearchResult();
moreModelList = new SearchResult(); moreModelList = new SearchResult();

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

@ -51,15 +51,17 @@ public class DocumentSearchManager implements AlphaFineSearchProvider {
} }
@Override @Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) { public SearchResult getLessSearchResult(String[] searchText) {
lessModelList = new SearchResult(); lessModelList = new SearchResult();
moreModelList = new SearchResult(); moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainDocument()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainDocument()) {
if (ArrayUtils.isEmpty(searchText)) { if (ArrayUtils.isEmpty(searchText)) {
lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"))); lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help")));
return lessModelList; return lessModelList;
} else if (hotData == null) { }
return AlphaFineHelper.getNoConnectList(instance); SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if(noConnectList != null){
return noConnectList;
} }
SearchResult searchResult = new SearchResult(); SearchResult searchResult = new SearchResult();
for (int j = 0; j < searchText.length; j++) { for (int j = 0; j < searchText.length; j++) {

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

@ -96,7 +96,7 @@ public class FileSearchManager implements AlphaFineSearchProvider {
} }
@Override @Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) { public SearchResult getLessSearchResult(String[] searchText) {
return null; return null;
} }

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

@ -96,7 +96,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
} }
@Override @Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) { public SearchResult getLessSearchResult(String[] searchText) {
this.lessModelList = new SearchResult(); this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult(); this.moreModelList = new SearchResult();
SearchResult searchResult = new SearchResult(); SearchResult searchResult = new SearchResult();
@ -104,8 +104,10 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
if (ArrayUtils.isEmpty(searchText)) { if (ArrayUtils.isEmpty(searchText)) {
lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon")));
return lessModelList; return lessModelList;
} else if (hotData == null) { }
return AlphaFineHelper.getNoConnectList(instance); SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if(noConnectList != null){
return noConnectList;
} }
for (int j = 0; j < searchText.length; j++) { for (int j = 0; j < searchText.length; j++) {
try { try {

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

@ -72,7 +72,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
} }
@Override @Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) { public SearchResult getLessSearchResult(String[] searchText) {
this.modelList = new SearchResult(); this.modelList = new SearchResult();
for (int j = 0; j < searchText.length; j++) { for (int j = 0; j < searchText.length; j++) {
recentModelList = getRecentModelList(searchText[j]); recentModelList = getRecentModelList(searchText[j]);

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

@ -46,14 +46,16 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
} }
@Override @Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) { public SearchResult getLessSearchResult(String[] searchText) {
this.modelList = new SearchResult(); this.modelList = new SearchResult();
this.recommendModelList = new SearchResult(); this.recommendModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) {
if (ArrayUtils.isEmpty(searchText)) { if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult(); return new SearchResult();
} else if(hotData == null){ }
return AlphaFineHelper.getNoConnectList(instance); SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if(noConnectList != null){
return noConnectList;
} }
for (int j = 0; j < searchText.length; j++) { for (int j = 0; j < searchText.length; j++) {
searchText[j] = searchText[j].replaceAll(StringUtils.BLANK, StringUtils.EMPTY); searchText[j] = searchText[j].replaceAll(StringUtils.BLANK, StringUtils.EMPTY);

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

@ -37,13 +37,15 @@ public class SimilarSearchManeger implements AlphaFineSearchProvider {
} }
@Override @Override
public SearchResult getLessSearchResult(String[][] hotData, String[] searchText) { public SearchResult getLessSearchResult(String[] searchText) {
lessModelList = new SearchResult(); lessModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) {
if (ArrayUtils.isEmpty(searchText)) { if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult(); return new SearchResult();
} else if (hotData == null) { }
return AlphaFineHelper.getNoConnectList(instance); SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
if(noConnectList != null){
return noConnectList;
} }
SearchResult allModelList = new SearchResult(); SearchResult allModelList = new SearchResult();
for (int j = 0; j < searchText.length; j++) { for (int j = 0; j < searchText.length; j++) {

Loading…
Cancel
Save