Browse Source

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

REPORT-10927 alphafine热门搜索的相关问题

* commit 'b1d5b207a5818b70a35043ef98b6a4f673f2f30b':
  REPORT-10927 alphafine热门搜索的相关问题 1.移到热门问题条目时,增加小手样式。 2.修复点击关键字后,右侧是空白的问题。 3.增加jeditpane加载的html的各种链接响应。
research/10.0
Alex.Sung 6 years ago
parent
commit
80f2d01705
  1. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 19
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java
  3. 31
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  4. 45
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java

8
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java

@ -110,6 +110,10 @@ public class AlphaFineConstants {
public static final String BOTTOM_REGEX_SECOND = "<div class=\"yes_([\\s\\S]*?)帮助</a></div></div>"; public static final String BOTTOM_REGEX_SECOND = "<div class=\"yes_([\\s\\S]*?)帮助</a></div></div>";
public static final String LINK_REGEX = "javascript:;\"([\\s\\S]*?)','";
public static final String LINK_REGEX_ANOTHER = "javascript:([\\s\\S]*?)url=\"";
public static final String ALPHA_ROBOT_SEARCH_TOKEN = "K8dl0Np6l0gs"; public static final String ALPHA_ROBOT_SEARCH_TOKEN = "K8dl0Np6l0gs";
public static final String SIMILAR_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.similar_search"); public static final String SIMILAR_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.similar_search");
@ -122,6 +126,10 @@ public class AlphaFineConstants {
public static final String ALPHA_GO_TO_WEB = CloudCenter.getInstance().acquireUrlByKind("af.go_web"); public static final String ALPHA_GO_TO_WEB = CloudCenter.getInstance().acquireUrlByKind("af.go_web");
public static final String ALPHA_PREVIEW = CloudCenter.getInstance().acquireUrlByKind("af.preview");
public static final String JAVASCRIPT_PREFIX = "javascript:SendJava";
public static final String CHINESE_CHARACTERS = "[\\u4e00-\\u9fa5]"; public static final String CHINESE_CHARACTERS = "[\\u4e00-\\u9fa5]";
public static final String FIRST_PAGE = "-1"; public static final String FIRST_PAGE = "-1";

19
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java

@ -1,16 +1,15 @@
package com.fr.design.mainframe.alphafine.cell.model; package com.fr.design.mainframe.alphafine.cell.model;
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.general.http.HttpClient; import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import java.awt.Desktop; import java.awt.Desktop;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
@ -44,17 +43,17 @@ public class RobotModel extends AlphaCellModel {
} }
public static String getContent(String titleStr) { public static String getContent(String titleStr) {
String result;
String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + titleStr); String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + titleStr);
String url = AlphaFineConstants.ALPHA_GO_TO_WEB + titleStr + "&token=" + token; String url = AlphaFineConstants.ALPHA_GO_TO_WEB + titleStr + "&token=" + token;
HttpClient httpClient = new HttpClient(url);
httpClient.asGet();
result = httpClient.getResponseText();
AlphaFineHelper.checkCancel();
try { try {
String result = HttpToolbox.get(url);
if(StringUtils.isEmpty(result)){
return StringUtils.EMPTY;
}
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
return jsonObject.optString("msg"); return jsonObject.optString("msg");
} catch (JSONException e) { } catch (JSONException | IOException e) {
FineLoggerFactory.getLogger().error("get robotmodel content error: " + e.getMessage()); FineLoggerFactory.getLogger().error("get robotmodel content error: " + e.getMessage());
} }
return null; return null;
@ -86,7 +85,7 @@ public class RobotModel extends AlphaCellModel {
@Override @Override
public void doAction() { public void doAction() {
try { try {
Desktop.getDesktop().browse(new URI("http://robot.finereport.com?send=" + super.getName())); Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + super.getName()));
} catch (IOException e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} catch (URISyntaxException e) { } catch (URISyntaxException e) {

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

@ -11,20 +11,20 @@ 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.AlphaFineHelper; 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.RobotModel;
import com.fr.design.mainframe.alphafine.cell.model.BottomModel;
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.BottomModel;
import com.fr.design.mainframe.alphafine.cell.model.FileModel; import com.fr.design.mainframe.alphafine.cell.model.FileModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
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.RobotModel;
import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.preview.ContainsCirclePane;
import com.fr.design.mainframe.alphafine.preview.DocumentPreviewPane; import com.fr.design.mainframe.alphafine.preview.DocumentPreviewPane;
import com.fr.design.mainframe.alphafine.preview.FilePreviewPane; import com.fr.design.mainframe.alphafine.preview.FilePreviewPane;
import com.fr.design.mainframe.alphafine.preview.NoResultPane; import com.fr.design.mainframe.alphafine.preview.NoResultPane;
import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane; import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane;
import com.fr.design.mainframe.alphafine.preview.RobotPreviewPane; import com.fr.design.mainframe.alphafine.preview.RobotPreviewPane;
import com.fr.design.mainframe.alphafine.preview.ContainsCirclePane;
import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.DocumentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager;
@ -116,6 +116,7 @@ public class AlphaFineDialog extends UIDialog {
private static final String PLACE_HOLDER = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine"); private static final String PLACE_HOLDER = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine");
private static final int MAX_SHOW_SIZE = 12; private static final int MAX_SHOW_SIZE = 12;
private static final int TIMER_DELAY = 300; private static final int TIMER_DELAY = 300;
private static final int ONLY_ONE_AVAILABLE_MODEL = 2;
private AlphaFineTextField searchTextField; private AlphaFineTextField searchTextField;
private UIButton closeButton; private UIButton closeButton;
@ -705,14 +706,20 @@ public class AlphaFineDialog extends UIDialog {
this.showWorker = new SwingWorker<String, Void>() { this.showWorker = new SwingWorker<String, Void>() {
@Override @Override
protected String doInBackground() { protected String doInBackground() {
if(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha_Hot_No_Item").equals((selectedValue).getName())){
return StringUtils.EMPTY;
}
String content = RobotModel.getContent((selectedValue).getName()); String content = RobotModel.getContent((selectedValue).getName());
if(StringUtils.isNotEmpty(content)){ if(StringUtils.isNotEmpty(content)){
//去掉小帆底部的信息 //1.去掉小帆底部的信息。2.修改链接标签,使点击能够正常跳转。
content = content.replaceAll(AlphaFineConstants.BOTTOM_REGEX_FIRST, "") content = content.replaceAll(AlphaFineConstants.BOTTOM_REGEX_FIRST, StringUtils.EMPTY)
.replaceAll(AlphaFineConstants.BOTTOM_REGEX_SECOND, ""); .replaceAll(AlphaFineConstants.BOTTOM_REGEX_SECOND, StringUtils.EMPTY)
.replaceAll(AlphaFineConstants.LINK_REGEX,StringUtils.EMPTY)
.replaceAll("'\\)",StringUtils.EMPTY)
.replaceAll(AlphaFineConstants.LINK_REGEX_ANOTHER,StringUtils.EMPTY);
return content; return content;
}else{ }else{
return ""; return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha_Hot_No_Item");
} }
} }
@ -1185,7 +1192,7 @@ public class AlphaFineDialog extends UIDialog {
final int x = e.getX(); final int x = e.getX();
final int y = e.getY(); final int y = e.getY();
final Rectangle cellBounds = getCellBounds(getModel().getSize() - 1, getModel().getSize() - 1); final Rectangle cellBounds = getCellBounds(getModel().getSize() - 1, getModel().getSize() - 1);
if (cellBounds != null && cellBounds.contains(x, y)) { if (cellBounds != null && cellBounds.contains(x, y) && getModel().getElementAt(getModel().getSize() - 1) instanceof BottomModel) {
setCursor(new Cursor(Cursor.HAND_CURSOR)); setCursor(new Cursor(Cursor.HAND_CURSOR));
} else { } else {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
@ -1323,9 +1330,16 @@ public class AlphaFineDialog extends UIDialog {
protected Object doInBackground() throws Exception { protected Object doInBackground() throws Exception {
resetContainer(); resetContainer();
if(modeList.size() == ONLY_ONE_AVAILABLE_MODEL && "".equals(modeList.get(1).getName())){
RobotModel model = new RobotModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha_Hot_No_Item"), null);
searchListModel.addElement(model);
}else {
for (AlphaCellModel object : modeList) { for (AlphaCellModel object : modeList) {
if(!searchListModel.contains(object)){
searchListModel.addElement(object); searchListModel.addElement(object);
} }
}
}
return null; return null;
} }
@ -1418,6 +1432,7 @@ public class AlphaFineDialog extends UIDialog {
final UILabel subTitle = new UILabel(str[i]); final UILabel subTitle = new UILabel(str[i]);
subTitle.setForeground(AlphaFineConstants.DARK_GRAY); subTitle.setForeground(AlphaFineConstants.DARK_GRAY);
subTitle.setFont(AlphaFineConstants.MEDIUM_FONT_ANOTHER); subTitle.setFont(AlphaFineConstants.MEDIUM_FONT_ANOTHER);
subTitle.setCursor(new Cursor(Cursor.HAND_CURSOR));
subTitle.addMouseListener(new MouseAdapter() { subTitle.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {

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

@ -1,17 +1,26 @@
package com.fr.design.mainframe.alphafine.preview; package com.fr.design.mainframe.alphafine.preview;
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.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JEditorPane; import javax.swing.JEditorPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.HTMLEditorKit;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Desktop;
import java.awt.Dimension; import java.awt.Dimension;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
/** /**
@ -30,11 +39,39 @@ public class RobotPreviewPane extends JPanel {
titleArea.setFont(AlphaFineConstants.LARGE_FONT); titleArea.setFont(AlphaFineConstants.LARGE_FONT);
add(titleArea, BorderLayout.NORTH); add(titleArea, BorderLayout.NORTH);
JEditorPane editorPane = new JEditorPane(); final JEditorPane editorPane = new JEditorPane();
editorPane.setEditorKit(new HTMLEditorKit()); editorPane.setEditorKit(new HTMLEditorKit());
editorPane.setText(content); editorPane.setText(content+"<br><br><br>");
editorPane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
return;
}
if(e.getDescription().startsWith(AlphaFineConstants.JAVASCRIPT_PREFIX)){
String s = e.getDescription().replaceAll(AlphaFineConstants.JAVASCRIPT_PREFIX,StringUtils.EMPTY)
.replaceAll("\\('",StringUtils.EMPTY)
.replaceAll("'\\)",StringUtils.EMPTY);
try {
Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + s));
} catch (IOException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage());
} catch (URISyntaxException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage());
}
}
URL linkUrl = e.getURL();if (linkUrl != null) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
} catch (IOException | URISyntaxException e1) {
FineLoggerFactory.getLogger().error(" Jump to webpage error: " + e1.getMessage());
}
}
}
});
editorPane.setEditable(false); editorPane.setEditable(false);
JScrollPane jScrollPane = new JScrollPane(editorPane); UIScrollPane jScrollPane = new UIScrollPane(editorPane);
jScrollPane.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
jScrollPane.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 10, Color.white)); jScrollPane.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 10, Color.white));
add(jScrollPane, BorderLayout.CENTER); add(jScrollPane, BorderLayout.CENTER);
} }

Loading…
Cancel
Save