Browse Source

Merge pull request #930 in BA/design from ~XIAOXIA/design:9.0 to 9.0

* commit '4fbe80e858c8d084c838fd8bebeda1ba59668ab5':
  fix pmd
  bug fix 国际化
  代码质量
  alphafine bug fix 去重
  alphafine bug fix
  alphafine bug fix
  bug fix
  bug fix alphafine
  alphafine bug fix
  改了几个类的类名
  alphafine bug fix
  bug fix
  alphafine 异步搜索优化 中断
  alphafine bug fix
  bug fix
  bug fix alphafine
  bug fix
master
superman 8 years ago
parent
commit
f94f7e9f0f
  1. 2
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 32
      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. 137
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  7. 22
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java
  8. 19
      designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java
  9. 32
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  10. 69
      designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java
  11. 51
      designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java
  12. 33
      designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java
  13. 58
      designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java
  14. 67
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java
  15. 32
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java
  16. 2
      designer/src/com/fr/start/Designer.java
  17. 4
      designer_base/src/com/fr/aspectj/designerbase/AlphaFineReminder.aj
  18. 18
      designer_base/src/com/fr/design/DesignerEnvManager.java
  19. 22
      designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineAction.java
  20. 8
      designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  21. 65
      designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  22. 40
      designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java
  23. 18
      designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java
  24. 29
      designer_base/src/com/fr/design/actions/help/alphafine/AlphafineContext.java
  25. 8
      designer_base/src/com/fr/design/actions/help/alphafine/AlphafineListener.java
  26. 3
      designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java
  27. 6
      designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java
  28. 4
      designer_base/src/com/fr/design/locale/designer.properties
  29. 18
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  30. 4
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  31. 4
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  32. 2
      designer_base/src/com/fr/design/mainframe/DesignerFrame.java
  33. 4
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

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);

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

@ -1,22 +1,38 @@
package com.fr.design.mainframe.alphafine; package com.fr.design.mainframe.alphafine;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
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.search.manager.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.RecommendSearchManager;
import com.fr.general.Inter;
import com.fr.general.ProcessCanceledException;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.List;
/** /**
* Created by XiaXiang on 2017/5/8. * Created by XiaXiang on 2017/5/8.
*/ */
public class AlphaFineHelper { public class AlphaFineHelper {
public static final NoResultModel NO_RESULT_MODEL = new NoResultModel(Inter.getLocText("FR-Designer_AlphaFine_NoResult"));
public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(Inter.getLocText("FR-Designer_ConnectionFailed"));
/** /**
* 弹出alphafine搜索面板 * 弹出alphafine搜索面板
*/ */
public static void showAlphaFineDialog(boolean forceOpen) { public static void showAlphaFineDialog(boolean forceOpen) {
AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame(), forceOpen); AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame(), forceOpen);
final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
manager.setNeedRemind(false);
dialog.setVisible(true); dialog.setVisible(true);
} }
/** /**
* 获取文件名上级目录 * 获取文件名上级目录
* @param text * @param text
@ -51,6 +67,22 @@ public class AlphaFineHelper {
return getSplitText(text, 1); return getSplitText(text, 1);
} }
/**
* 中断当前线程的搜索
*/
public static void checkCancel() {
if (Thread.interrupted()) {
throw new ProcessCanceledException();
}
}
public static List<AlphaCellModel> getFilterResult() {
List<AlphaCellModel> recentList = RecentSearchManager.getRecentSearchManger().getRecentModelList();
List<AlphaCellModel> recommendList = RecommendSearchManager.getRecommendSearchManager().getRecommendModelList();
recentList.addAll(recommendList);
return recentList;
}

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();

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

@ -10,8 +10,8 @@ import com.fr.design.mainframe.DesignerContext;
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.render.ContentCellRender;
import com.fr.design.mainframe.alphafine.cell.model.*; import com.fr.design.mainframe.alphafine.cell.model.*;
import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender;
import com.fr.design.mainframe.alphafine.listener.ComponentHandler; import com.fr.design.mainframe.alphafine.listener.ComponentHandler;
import com.fr.design.mainframe.alphafine.listener.DocumentAdapter; import com.fr.design.mainframe.alphafine.listener.DocumentAdapter;
import com.fr.design.mainframe.alphafine.model.SearchListModel; import com.fr.design.mainframe.alphafine.model.SearchListModel;
@ -45,7 +45,7 @@ import javax.swing.event.ListSelectionListener;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
@ -78,6 +78,7 @@ public class AlphaFineDialog extends UIDialog {
initComponents(); initComponents();
} }
/** /**
* 初始化全部组件 * 初始化全部组件
*/ */
@ -134,6 +135,7 @@ public class AlphaFineDialog extends UIDialog {
addComponentListener(new ComponentHandler()); addComponentListener(new ComponentHandler());
setSize(AlphaFineConstants.FIELD_SIZE); setSize(AlphaFineConstants.FIELD_SIZE);
centerWindow(this); centerWindow(this);
} }
/** /**
@ -156,17 +158,17 @@ public class AlphaFineDialog extends UIDialog {
} }
/** /**
* 执行搜索暂时字符要求超过两个才开始搜索 * 执行搜索
* @param text * @param text
*/ */
private void doSearch(String text) { private void doSearch(String text) {
if (text.length() < 2 || text.contains("'")) {
return;
}
if (StringUtils.isBlank(text) || text.equals("AlphaFine")) { if (StringUtils.isBlank(text) || text.equals("AlphaFine")) {
removeSearchResult(); removeSearchResult();
} else if (text.contains("'")) {
return;
} else { } else {
showSearchResult(text); showSearchResult();
} }
} }
@ -198,14 +200,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 +214,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 +236,105 @@ 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;
} }
@Override @Override
protected void done() { protected void done() {
try {
if (!isCancelled()) { if (!isCancelled()) {
searchResultList.setModel(get()); searchResultList.setSelectedIndex(1);
searchResultList.validate(); }
searchResultList.repaint(); }
validate(); };
repaint(); this.searchWorker.execute();
}
/** /**
* 默认选中第1项第0项为title * 重新构建搜索结果列表
* @param searchText
*/ */
if (searchResultList.getModel().getSize() > 0) { private void rebuildList(String searchText) {
searchResultList.setSelectedIndex(1); searchListModel.removeAllElements();
getRecentList(searchText);
getRecommendList(searchText);
getActionList(searchText);
getFileList(searchText);
getDocumentList(searchText);
getPluginList(searchText);
} }
private synchronized void getDocumentList(final String searchText) {
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText);
for (Object object : documentModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
} }
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
} }
private synchronized void getFileList(final String searchText) {
SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText);
for (Object object : fileModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
} }
}; private synchronized void getActionList(final String searchText) {
this.searchWorker.execute(); SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText);
for (Object object : actionModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
} }
private synchronized void getPluginList(final String searchText) {
SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText);
for (Object object : pluginModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
private synchronized void getRecommendList(final String searchText) {
SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText);
for (Object object : recommendModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
private synchronized void getRecentList(final String searchText) {
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText);
for (Object object : recentModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
/** /**
* 初始化监听器 * 初始化监听器
* @param searchText
*/ */
private void initListListener(final String searchText) { private void initListListener() {
/** /**
* 鼠标监听器 * 鼠标监听器
*/ */
@ -536,7 +588,7 @@ public class AlphaFineDialog extends UIDialog {
if (SwingUtilities.isLeftMouseButton(k)) { if (SwingUtilities.isLeftMouseButton(k)) {
Point p = k.getLocationOnScreen(); Point p = k.getLocationOnScreen();
Rectangle dialogRectangle = AlphaFineDialog.this.getBounds(); Rectangle dialogRectangle = AlphaFineDialog.this.getBounds();
Rectangle paneRectangle = new Rectangle(AlphaFinePane.createAlphaFinePane().getLocationOnScreen(), AlphaFinePane.createAlphaFinePane().getSize()); Rectangle paneRectangle = new Rectangle(AlphaFinePane.getAlphaFinePane().getLocationOnScreen(), AlphaFinePane.getAlphaFinePane().getSize());
if (!dialogRectangle.contains(p) && !paneRectangle.contains(p) && !forceOpen) { if (!dialogRectangle.contains(p) && !paneRectangle.contains(p) && !forceOpen) {
AlphaFineDialog.this.dispose(); AlphaFineDialog.this.dispose();
forceOpen = false; forceOpen = false;
@ -559,8 +611,8 @@ public class AlphaFineDialog extends UIDialog {
if (event instanceof KeyEvent) { if (event instanceof KeyEvent) {
KeyEvent e = (KeyEvent) event; KeyEvent e = (KeyEvent) event;
KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e); KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e);
KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphafineConfigManager().getShortCutKeyStore(); KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore();
if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString())) { if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) {
doClickAction(); doClickAction();
} }
@ -663,11 +715,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 +753,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 +783,5 @@ public class AlphaFineDialog extends UIDialog {
public void setForceOpen(boolean forceOpen) { public void setForceOpen(boolean forceOpen) {
this.forceOpen = forceOpen; this.forceOpen = forceOpen;
} }
} }

22
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java

@ -1,12 +1,12 @@
package com.fr.design.mainframe.alphafine.component; package com.fr.design.mainframe.alphafine.component;
import com.fr.base.BaseUtils;
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.AlphaFineContext;
import com.fr.design.actions.help.alphafine.AlphafineListener; import com.fr.design.actions.help.alphafine.AlphaFineListener;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import javax.swing.*; import javax.swing.*;
@ -20,7 +20,7 @@ import java.awt.event.ActionListener;
public class AlphaFinePane extends BasicPane { public class AlphaFinePane extends BasicPane {
private static AlphaFinePane alphaFinePane; private static AlphaFinePane alphaFinePane;
public static AlphaFinePane createAlphaFinePane() { public static AlphaFinePane getAlphaFinePane() {
if (alphaFinePane == null) { if (alphaFinePane == null) {
alphaFinePane = new AlphaFinePane(); alphaFinePane = new AlphaFinePane();
} }
@ -28,12 +28,12 @@ public class AlphaFinePane extends BasicPane {
} }
public AlphaFinePane() { public AlphaFinePane() {
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 14)); setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 14));
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isEnabled()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) {
Toolkit.getDefaultToolkit().addAWTEventListener(AlphaFineDialog.listener(), AWTEvent.KEY_EVENT_MASK); Toolkit.getDefaultToolkit().addAWTEventListener(AlphaFineDialog.listener(), AWTEvent.KEY_EVENT_MASK);
} }
UIButton refreshButton = new UIButton(); UIButton refreshButton = new UIButton();
refreshButton.setIcon(BaseUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); refreshButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png"));
refreshButton.setToolTipText(Inter.getLocText("FR-Designer_Alphafine")); refreshButton.setToolTipText(Inter.getLocText("FR-Designer_AlphaFine"));
refreshButton.set4ToolbarButton(); refreshButton.set4ToolbarButton();
this.add(refreshButton); this.add(refreshButton);
refreshButton.addActionListener(new ActionListener() { refreshButton.addActionListener(new ActionListener() {
@ -42,11 +42,17 @@ public class AlphaFinePane extends BasicPane {
AlphaFineHelper.showAlphaFineDialog(false); AlphaFineHelper.showAlphaFineDialog(false);
} }
}); });
AlphafineContext.addAlphafineContextListener(new AlphafineListener() { AlphaFineContext.addAlphaFineListener(new AlphaFineListener() {
@Override @Override
public void showDialog() { public void showDialog() {
AlphaFineHelper.showAlphaFineDialog(true); AlphaFineHelper.showAlphaFineDialog(true);
} }
@Override
public void setEnable(boolean isEnable) {
alphaFinePane.setVisible(isEnable);
}
}); });
} }

19
designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java

@ -14,7 +14,9 @@ public class SearchListModel extends DefaultListModel {
@Override @Override
public void addElement(Object element) { public void addElement(Object element) {
int index = myDelegate.size();
myDelegate.add(element); myDelegate.add(element);
fireContentsChanged(this, index, index);
} }
@Override @Override
@ -23,17 +25,26 @@ public class SearchListModel extends DefaultListModel {
} }
@Override @Override
public void insertElementAt(Object element, int index) { public void add(int index, Object element) {
this.myDelegate.add(index, element); myDelegate.add(index, element);
fireIntervalAdded(this, index, index);
} }
@Override @Override
public void removeElementAt(int index) { public Object remove(int index) {
this.myDelegate.remove(index); Object object = myDelegate.get(index);
myDelegate.remove(object);
fireIntervalRemoved(this, index, index);
return object;
} }
@Override @Override
public int getSize() { public int getSize() {
return this.myDelegate.size(); return this.myDelegate.size();
} }
@Override
public void removeAllElements() {
this.myDelegate.clear();
}
} }

32
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;
@ -23,6 +24,9 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
private SearchResult lessModelList; private SearchResult lessModelList;
private SearchResult moreModelList; private SearchResult moreModelList;
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION);
private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION);
public synchronized static ActionSearchManager getActionSearchManager() { public synchronized static ActionSearchManager getActionSearchManager() {
if (actionSearchManager == null) { if (actionSearchManager == null) {
actionSearchManager = new ActionSearchManager(); actionSearchManager = new ActionSearchManager();
@ -35,29 +39,33 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
filterModelList = new SearchResult(); filterModelList = new SearchResult();
lessModelList = new SearchResult(); lessModelList = new SearchResult();
moreModelList = new SearchResult(); moreModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainAction()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainAction()) {
List<UpdateActionModel> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); List<UpdateActionModel> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
for (UpdateActionModel updateActionModel : updateActions) { for (UpdateActionModel updateActionModel : updateActions) {
if (StringUtils.isNotBlank(updateActionModel.getSearchKey())) { if (StringUtils.isNotBlank(updateActionModel.getSearchKey())) {
if (updateActionModel.getSearchKey().toLowerCase().contains(searchText.toLowerCase()) ) { if (updateActionModel.getSearchKey().toLowerCase().contains(searchText.toLowerCase()) && updateActionModel.getAction().isEnabled()) {
filterModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction())); filterModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction()));
} }
} }
} }
if (filterModelList != null && filterModelList.size() > 0) { SearchResult result = new SearchResult();
final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size()); for (Object object : filterModelList) {
for (int i = 0; i < length; i++) { if (!AlphaFineHelper.getFilterResult().contains(object)) {
lessModelList.add(filterModelList.get(i)); result.add(object);
} }
for (int i = length; i < filterModelList.size(); i++) {
moreModelList.add(filterModelList.get(i));
} }
if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) { if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION)); lessModelList.add(0, TITLE_MODEL);
if (result.size() == 0) {
lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL);
} else { } else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION)); lessModelList.addAll(result);
} }
} else {
lessModelList.add(0, MORE_MODEL);
lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE));
moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size()));
} }
} }

69
designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java

@ -1,69 +0,0 @@
package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.general.Inter;
/**
* Created by XiaXiang on 2017/3/28.
*/
public class AlphaSearchManager implements AlphaFineSearchProcessor {
private static AlphaSearchManager searchManager;
private static PluginSearchManager pluginSearchManager;
private static DocumentSearchManager documentSearchManager;
private static FileSearchManager fileSearchManager;
private static ActionSearchManager actionSearchManager;
private static RecommendSearchManager recommendSearchManager;
private static RecentSearchManager recentSearchManager;
public synchronized static AlphaSearchManager getSearchManager() {
init();
return searchManager;
}
private synchronized static void init() {
if (searchManager == null) {
searchManager = new AlphaSearchManager();
pluginSearchManager = PluginSearchManager.getPluginSearchManager();
documentSearchManager = DocumentSearchManager.getDocumentSearchManager();
fileSearchManager = FileSearchManager.getFileSearchManager();
actionSearchManager = ActionSearchManager.getActionSearchManager();
recommendSearchManager = RecommendSearchManager.getRecommendSearchManager();
recentSearchManager = RecentSearchManager.getRecentSearchManger();
}
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
SearchResult recentModelList = recentSearchManager.getLessSearchResult(searchText);
SearchResult recommendModelList = recommendSearchManager.getLessSearchResult(searchText);
SearchResult actionModelList = actionSearchManager.getLessSearchResult(searchText);
SearchResult fileModelList = fileSearchManager.getLessSearchResult(searchText);
SearchResult documentModelList = documentSearchManager.getLessSearchResult(searchText);
SearchResult pluginModelList = pluginSearchManager.getLessSearchResult(searchText);
recentModelList.addAll(recommendModelList);
recentModelList.addAll(actionModelList);
recentModelList.addAll(fileModelList);
recentModelList.addAll(documentModelList);
recentModelList.addAll(pluginModelList);
return recentModelList;
}
public SearchResult showDefaultSearchResult() {
SearchResult searchResult = new SearchResult();
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Latest")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_Set")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_Templates")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP")));
searchResult.add(new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon")));
return searchResult;
}
@Override
public SearchResult getMoreSearchResult() {
return null;
}
}

51
designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.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.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;
@ -20,6 +21,8 @@ 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 TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT);
private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT);
public synchronized static DocumentSearchManager getDocumentSearchManager() { public synchronized static DocumentSearchManager getDocumentSearchManager() {
if (documentSearchManager == null) { if (documentSearchManager == null) {
@ -33,48 +36,62 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
public synchronized SearchResult getLessSearchResult(String searchText) { public synchronized 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()) {
String result; String result;
String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText + "-1"; String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText + "-1";
HttpClient httpClient = new HttpClient(url); HttpClient httpClient = new HttpClient(url);
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();
AlphaFineHelper.checkCancel();
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()); SearchResult searchResult = new SearchResult();
for (int i = 0; i < length; i++) { for (int i = 0; i < jsonArray.length(); i++) {
AlphaFineHelper.checkCancel();
DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i));
this.lessModelList.add(cellModel); if (!AlphaFineHelper.getFilterResult().contains(cellModel)) {
searchResult.add(cellModel);
} }
for (int i = length; i < jsonArray.length(); i++) {
DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i));
this.moreModelList.add(cellModel);
} }
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); lessModelList.add(0, TITLE_MODEL);
if (searchResult.size() == 0) {
lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL);
} else { } else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT)); lessModelList.addAll(searchResult);
}
} else {
lessModelList.add(0, MORE_MODEL);
lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE));
moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size()));
} }
} }
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error("document search error: " + e.getMessage());
return lessModelList;
} }
} }
return lessModelList; return lessModelList;
} }
/**
* 无连接
* @return
*/
private SearchResult getNoConnectList() {
SearchResult result = new SearchResult();
result.add(0, TITLE_MODEL);
result.add(AlphaFineHelper.NO_CONNECTION_MODEL);
return result;
}
/** /**
* 根据json信息获取文档model * 根据json信息获取文档model
* @param object * @param object

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

@ -29,6 +29,9 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
private List<FileNode> fileNodes = null; private List<FileNode> fileNodes = null;
private static FileSearchManager fileSearchManager = null; private static FileSearchManager fileSearchManager = null;
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE);
private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.FILE);
public synchronized static FileSearchManager getFileSearchManager() { public synchronized static FileSearchManager getFileSearchManager() {
init(); init();
return fileSearchManager; return fileSearchManager;
@ -44,6 +47,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);
@ -55,19 +59,24 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
searchFileContent(searchText, node, isAlreadyContain, filePath); searchFileContent(searchText, node, isAlreadyContain, filePath);
} }
SearchResult result = new SearchResult();
for (Object object : filterModelList) {
if (!AlphaFineHelper.getFilterResult().contains(object)) {
result.add(object);
}
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++) { if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) {
moreModelList.add(filterModelList.get(i)); lessModelList.add(0, TITLE_MODEL);
if (result.size() == 0) {
lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL);
} else {
lessModelList.addAll(result);
} }
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 { } else {
lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE)); lessModelList.add(0, MORE_MODEL);
lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE));
moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size()));
} }
} }
return this.lessModelList; return this.lessModelList;
@ -81,7 +90,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
* @param filePath * @param filePath
*/ */
private void searchFileContent(String searchText, FileNode node, boolean isAlreadyContain, String filePath) { private void searchFileContent(String searchText, FileNode node, boolean isAlreadyContain, String filePath) {
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainFileContent()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainFileContent()) {
try { try {
BufferedReader reader = new BufferedReader(new FileReader(filePath)); BufferedReader reader = new BufferedReader(new FileReader(filePath));
@ -115,7 +124,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
* @return * @return
*/ */
private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) { private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) {
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) {
if (node.getName().toLowerCase().contains(searchText.toLowerCase())) { if (node.getName().toLowerCase().contains(searchText.toLowerCase())) {
FileModel model = new FileModel(node.getName(), node.getEnvPath()); FileModel model = new FileModel(node.getName(), node.getEnvPath());
this.filterModelList.add(model); this.filterModelList.add(model);
@ -165,7 +174,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
} else { } else {
nodeList.add(fns[i]); nodeList.add(fns[i]);
} }
} else { } else if (fileNode.isFileType("cpt") || fileNode.isFileType("frm")) {
nodeList.add(fileNode); nodeList.add(fileNode);
} }
} }

58
designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.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.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;
@ -11,6 +12,7 @@ import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
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.JSONObject; import com.fr.json.JSONObject;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -21,9 +23,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 TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN);
private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, 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,10 +41,9 @@ 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()) {
String result; String result;
try { try {
String encodedKey = URLEncoder.encode(searchText, "UTF-8"); String encodedKey = URLEncoder.encode(searchText, "UTF-8");
@ -46,35 +52,51 @@ 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();
AlphaFineHelper.checkCancel();
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()); SearchResult searchResult = new SearchResult();
for (int i = 0; i < length; i++) { for (int i = 0; i < jsonArray.length(); i++) {
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false);
this.lessModelList.add(cellModel); if (!AlphaFineHelper.getFilterResult().contains(cellModel)) {
searchResult.add(cellModel);
} }
for (int i = length; i < jsonArray.length(); i++) {
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false);
this.moreModelList.add(cellModel);
} }
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); lessModelList.add(0, TITLE_MODEL);
if (searchResult.size() == 0) {
lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL);
} else { } else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN)); lessModelList.addAll(searchResult);
}
} else {
lessModelList.add(0, MORE_MODEL);
lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE));
moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size()));
} }
} }
} catch (Exception e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error("plugin search json error :" + e.getMessage());
return lessModelList; } catch (UnsupportedEncodingException e) {
FRLogger.getLogger().error("plugin search encode error :" + e.getMessage());
} }
} }
return this.lessModelList; return this.lessModelList;
}
private SearchResult getNoConnectList() {
SearchResult result = new SearchResult();
result.add(0, TITLE_MODEL);
result.add(AlphaFineHelper.NO_CONNECTION_MODEL);
return result;
} }
private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) {
@ -121,8 +143,4 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
} }
} }
} }

67
designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java

@ -3,7 +3,8 @@ package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.Utils; import com.fr.base.Utils;
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.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.AlphaCellModel;
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;
@ -39,10 +40,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
private static RecentSearchManager recentSearchManager = null; private static RecentSearchManager recentSearchManager = null;
private static File recentFile = null; private static File recentFile = null;
private SearchResult modelList; private SearchResult modelList;
private List<AlphaCellModel> fileList = new ArrayList<>();
private List<AlphaCellModel> actionList = new ArrayList<>();
private List<AlphaCellModel> documentList = new ArrayList<>();
private List<AlphaCellModel> pluginList = new ArrayList<>();
private List<AlphaCellModel> recentModelList = new ArrayList<>(); private List<AlphaCellModel> recentModelList = new ArrayList<>();
private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>(); private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>();
@ -98,7 +95,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
private void addModelToList(List<AlphaCellModel> list, String name) { private void addModelToList(List<AlphaCellModel> list, String name) {
try { try {
AlphaCellModel model = getModelFromJson(new JSONObject(name)); AlphaCellModel model = CellModelHelper.getModelFromJson(new JSONObject(name));
if (model != null) { if (model != null) {
list.add(model); list.add(model);
} }
@ -107,60 +104,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
} }
} }
/**
* 转成cellModel
* @param object
* @return
*/
private AlphaCellModel getModelFromJson(JSONObject object) {
int typeValue = object.optInt("cellType");
AlphaCellModel cellModel = null;
switch (CellType.parse(typeValue)) {
case ACTION:
cellModel = ActionSearchManager.getModelFromCloud(object.optString("result"));
if (cellModel != null) {
actionList.add(cellModel);
}
break;
case DOCUMENT:
cellModel = DocumentSearchManager.getModelFromCloud(object.optJSONObject("result"));
if (cellModel != null) {
documentList.add(cellModel);
}
break;
case FILE:
cellModel = FileSearchManager.getModelFromCloud(object.optString("result"));
if (cellModel != null) {
fileList.add(cellModel);
}
break;
case PLUGIN:
case REUSE:
cellModel = PluginSearchManager.getModelFromCloud(object.optJSONObject("result"));
if (cellModel != null) {
pluginList.add(cellModel);
}
break;
}
return cellModel;
}
public List<AlphaCellModel> getFileList() {
return fileList;
}
public List<AlphaCellModel> getActionList() {
return actionList;
}
public List<AlphaCellModel> getDocumentList() {
return documentList;
}
public List<AlphaCellModel> getPluginList() {
return pluginList;
}
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
@ -209,7 +152,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
if (!envFile.exists()) { if (!envFile.exists()) {
createRecentFile(envFile); createRecentFile(envFile);
} }
return envFile; return envFile;
} }
@ -273,9 +215,10 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
* @param searchText * @param searchText
* @return * @return
*/ */
public List<AlphaCellModel> getRecentModelList(String searchText) { public synchronized List<AlphaCellModel> getRecentModelList(String searchText) {
recentModelList = new ArrayList<>(); recentModelList = new ArrayList<>();
for (String key : recentKVModelMap.keySet()) { for (String key : recentKVModelMap.keySet()) {
AlphaFineHelper.checkCancel();
if (ComparatorUtils.equals(key, searchText)) { if (ComparatorUtils.equals(key, searchText)) {
recentModelList = recentKVModelMap.get(searchText); recentModelList = recentKVModelMap.get(searchText);
int size = recentModelList.size(); int size = recentModelList.size();

32
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;
@ -13,12 +14,16 @@ import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.CodeUtils; import com.fr.stable.CodeUtils;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created by XiaXiang on 2017/3/31. * Created by XiaXiang on 2017/3/31.
*/ */
public class RecommendSearchManager implements AlphaFineSearchProcessor { public class RecommendSearchManager implements AlphaFineSearchProcessor {
private static RecommendSearchManager recommendSearchManager = null; private static RecommendSearchManager recommendSearchManager = null;
private SearchResult modelList; private SearchResult modelList;
private List<AlphaCellModel> recommendModelList = new ArrayList<>();
//todo:for test //todo:for test
private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/recommend?searchKey="; private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/recommend?searchKey=";
@ -31,43 +36,60 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
@Override @Override
public synchronized SearchResult getLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
this.modelList = new SearchResult(); this.modelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainRecommend()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) {
String result; String result;
HttpClient httpClient = new HttpClient(SEARCHAPI + CodeUtils.cjkEncode(searchText)); HttpClient httpClient = new HttpClient(SEARCHAPI + CodeUtils.cjkEncode(searchText));
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();
AlphaFineHelper.checkCancel();
try { try {
JSONObject jsonObject = new JSONObject(result); JSONObject jsonObject = new JSONObject(result);
if (jsonObject.optString("status").equals("success")) { if (jsonObject.optString("status").equals("success")) {
JSONArray jsonArray = jsonObject.optJSONArray("result"); JSONArray jsonArray = jsonObject.optJSONArray("result");
if (jsonArray != null && jsonArray.length() > 0) { if (jsonArray != null && jsonArray.length() > 0) {
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
AlphaFineHelper.checkCancel();
AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i));
if (alphaCellModel != null && !RecentSearchManager.getRecentSearchManger().getRecentModelList().contains(alphaCellModel)) { if (alphaCellModel != null && !RecentSearchManager.getRecentSearchManger().getRecentModelList().contains(alphaCellModel)) {
this.modelList.add(alphaCellModel); this.recommendModelList.add(alphaCellModel);
} }
} }
} }
} }
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error("data transform error! :" + e.getMessage()); FRLogger.getLogger().error("recommend search error! :" + e.getMessage());
} }
if (modelList.size() > 0) { if (modelList.size() > 0) {
modelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude"), false)); modelList.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Recommend"), false));
modelList.addAll(recommendModelList);
} }
} }
return modelList; return modelList;
} }
private SearchResult getNoConnectList() {
SearchResult result = new SearchResult();
result.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Recommend"), false));
result.add(AlphaFineHelper.NO_CONNECTION_MODEL);
return result;
}
@Override @Override
public SearchResult getMoreSearchResult() { public SearchResult getMoreSearchResult() {
return new SearchResult(); return new SearchResult();
} }
public List<AlphaCellModel> getRecommendModelList() {
return recommendModelList;
}
public void setRecommendModelList(List<AlphaCellModel> recommendModelList) {
this.recommendModelList = recommendModelList;
}
} }

2
designer/src/com/fr/start/Designer.java

@ -346,7 +346,7 @@ public class Designer extends BaseDesigner {
* @return 面板组件 * @return 面板组件
*/ */
public Component createAlphafinePane() { public Component createAlphafinePane() {
return AlphaFinePane.createAlphaFinePane(); return AlphaFinePane.getAlphaFinePane();
} }

4
designer_base/src/com/fr/aspectj/designerbase/AlphaFineReminder.aj

@ -1,7 +1,7 @@
package com.fr.aspectj.designerbase; package com.fr.aspectj.designerbase;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphafineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.actions.help.alphafine.RemindDialog; import com.fr.design.actions.help.alphafine.RemindDialog;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -30,7 +30,7 @@ public aspect AlphaFineReminder {
* 判断是否弹出广告框 * 判断是否弹出广告框
*/ */
private static void remind() { private static void remind() {
AlphafineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphafineConfigManager(); AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
if (manager.isNeedRemind()) { if (manager.isNeedRemind()) {
if (manager.getOperateCount() > 4) { if (manager.getOperateCount() > 4) {

18
designer_base/src/com/fr/design/DesignerEnvManager.java

@ -5,7 +5,7 @@ package com.fr.design;
import com.fr.base.*; import com.fr.base.*;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
import com.fr.design.actions.help.alphafine.AlphafineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.env.SignIn; import com.fr.env.SignIn;
@ -108,7 +108,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/** /**
* alphafine * alphafine
*/ */
private AlphafineConfigManager alphafineConfigManager = new AlphafineConfigManager(); private AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager();
public static final String CAS_CERTIFICATE_PATH = "certificatePath"; public static final String CAS_CERTIFICATE_PATH = "certificatePath";
@ -1344,7 +1344,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
private void readAlphaFineAttr(XMLableReader reader) { private void readAlphaFineAttr(XMLableReader reader) {
reader.readXMLObject(this.alphafineConfigManager = new AlphafineConfigManager()); reader.readXMLObject(this.alphaFineConfigManager = new AlphaFineConfigManager());
} }
private void readHttpsParas(XMLableReader reader){ private void readHttpsParas(XMLableReader reader){
@ -1551,8 +1551,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
private void writeAlphaFineAttr(XMLPrintWriter writer) { private void writeAlphaFineAttr(XMLPrintWriter writer) {
if (this.alphafineConfigManager != null) { if (this.alphaFineConfigManager != null) {
this.alphafineConfigManager.writeXML(writer); this.alphaFineConfigManager.writeXML(writer);
} }
} }
@ -1830,11 +1830,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
return env; return env;
} }
public AlphafineConfigManager getAlphafineConfigManager() { public AlphaFineConfigManager getAlphaFineConfigManager() {
return alphafineConfigManager; return alphaFineConfigManager;
} }
public void setAlphafineConfigManager(AlphafineConfigManager alphafineConfigManager) { public void setAlphaFineConfigManager(AlphaFineConfigManager alphaFineConfigManager) {
this.alphafineConfigManager = alphafineConfigManager; this.alphaFineConfigManager = alphaFineConfigManager;
} }
} }

22
designer_base/src/com/fr/design/actions/help/alphafine/AlphafineAction.java → designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineAction.java

@ -1,6 +1,6 @@
package com.fr.design.actions.help.alphafine; package com.fr.design.actions.help.alphafine;
import com.fr.base.BaseUtils; import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
@ -17,13 +17,13 @@ import java.awt.event.ActionEvent;
/** /**
* Created by XiaXiang on 2017/4/1. * Created by XiaXiang on 2017/4/1.
*/ */
public class AlphafineAction extends UpdateAction { public class AlphaFineAction extends UpdateAction {
public AlphafineAction() { public AlphaFineAction() {
this.setMenuKeySet(ALPHAFINE); this.setMenuKeySet(ALPHAFINE);
this.setName(getMenuKeySet().getMenuName()); this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png"));
this.setSearchText(new AlphafineConfigPane()); this.setSearchText(new AlphaFineConfigPane());
} }
public static final MenuKeySet ALPHAFINE = new MenuKeySet() { public static final MenuKeySet ALPHAFINE = new MenuKeySet() {
@ -49,15 +49,19 @@ public class AlphafineAction extends UpdateAction {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final AlphafineConfigPane alphafineConfigPane = new AlphafineConfigPane(); final AlphaFineConfigPane alphaFineConfigPane = new AlphaFineConfigPane();
alphafineConfigPane.populate(DesignerEnvManager.getEnvManager().getAlphafineConfigManager()); final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
if (!FRContext.isChineseEnv()) {
manager.setSearchOnLine(false);
}
alphaFineConfigPane.populate(manager);
DialogActionListener dialogActionListener = new DialogActionAdapter() { DialogActionListener dialogActionListener = new DialogActionAdapter() {
public void doOk() { public void doOk() {
alphafineConfigPane.update(); alphaFineConfigPane.update();
designerFrame.refreshToolbar(); AlphaFineContext.fireAlphaFineEnable(manager.isEnabled());
} }
}; };
BasicDialog basicDialog = alphafineConfigPane.showMediumWindow(designerFrame, dialogActionListener); BasicDialog basicDialog = alphaFineConfigPane.showMediumWindow(designerFrame, dialogActionListener);
basicDialog.setVisible(true); basicDialog.setVisible(true);
} }
} }

8
designer_base/src/com/fr/design/actions/help/alphafine/AlphafineConfigManager.java → designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java

@ -11,7 +11,7 @@ import javax.swing.*;
/** /**
* Created by XiaXiang on 2017/4/5. * Created by XiaXiang on 2017/4/5.
*/ */
public class AlphafineConfigManager implements XMLable { public class AlphaFineConfigManager implements XMLable {
/** /**
* 是否开启alphafine * 是否开启alphafine
@ -80,10 +80,10 @@ public class AlphafineConfigManager implements XMLable {
private static AlphafineConfigManager alphafineConfigManager = new AlphafineConfigManager(); private static AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager();
public static AlphafineConfigManager getInstance() { public static AlphaFineConfigManager getInstance() {
return alphafineConfigManager; return alphaFineConfigManager;
} }
@Override @Override

65
designer_base/src/com/fr/design/actions/help/alphafine/AlphafineConfigPane.java → designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java

@ -1,5 +1,6 @@
package com.fr.design.actions.help.alphafine; package com.fr.design.actions.help.alphafine;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
@ -20,7 +21,7 @@ import java.awt.event.KeyEvent;
/** /**
* Created by XiaXiang on 2017/4/6. * Created by XiaXiang on 2017/4/6.
*/ */
public class AlphafineConfigPane extends BasicPane { public class AlphaFineConfigPane extends BasicPane {
private static final String TYPE = "pressed"; private static final String TYPE = "pressed";
private static final String DISPLAY_TYPE = "+"; private static final String DISPLAY_TYPE = "+";
private static final String BACK_SLASH = "BACK_SLASH"; private static final String BACK_SLASH = "BACK_SLASH";
@ -56,7 +57,7 @@ public class AlphafineConfigPane extends BasicPane {
private UICheckBox isEnabledCheckbox, isSearchOnlineCheckbox, isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox, isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox; private UICheckBox isEnabledCheckbox, isSearchOnlineCheckbox, isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox, isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox;
private UITextField shortcutsField; private UITextField shortcutsField;
public AlphafineConfigPane() { public AlphaFineConfigPane() {
this.initComponents(); this.initComponents();
} }
@ -71,7 +72,7 @@ public class AlphafineConfigPane extends BasicPane {
} }
private Component[][] initsearchRangeComponents() { private Component[][] initSearchRangeComponents() {
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox}, new Component[]{isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox},
new Component[]{isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox} new Component[]{isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox}
@ -85,13 +86,13 @@ public class AlphafineConfigPane extends BasicPane {
double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP}; double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP};
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_AlphaFine_SearchRange")); JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_AlphaFine_SearchRange"));
isContainRecommendCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_AlphaFine_Conclude")); isContainRecommendCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_AlphaFine_Recommend"));
isContainActionCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_Set")); isContainActionCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_Set"));
isContainPluginCheckbox = new UICheckBox(Inter.getLocText("FR-Designer-Plugin_Addon")); isContainPluginCheckbox = new UICheckBox(Inter.getLocText("FR-Designer-Plugin_Addon"));
isContainDocumentCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_COMMUNITY_HELP")); isContainDocumentCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_COMMUNITY_HELP"));
isContainTemplateCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_Templates")); isContainTemplateCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_Templates"));
isContainFileContentCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_Templates_Content")); isContainFileContentCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_Templates_Content"));
JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initsearchRangeComponents(), rowSize, columnSize); JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initSearchRangeComponents(), rowSize, columnSize);
northPane.add(searchConfigPane); northPane.add(searchConfigPane);
contentPane.add(northPane); contentPane.add(northPane);
} }
@ -154,34 +155,36 @@ public class AlphafineConfigPane extends BasicPane {
return "AlphaFine"; return "AlphaFine";
} }
public void populate(AlphafineConfigManager alphafineConfigManager) { public void populate(AlphaFineConfigManager alphaFineConfigManager) {
this.isEnabledCheckbox.setSelected(alphafineConfigManager.isEnabled()); this.isEnabledCheckbox.setSelected(alphaFineConfigManager.isEnabled());
this.isSearchOnlineCheckbox.setSelected(alphafineConfigManager.isSearchOnLine()); this.isSearchOnlineCheckbox.setEnabled(FRContext.isChineseEnv());
this.isContainActionCheckbox.setSelected(alphafineConfigManager.isContainAction()); this.isSearchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine());
this.isContainTemplateCheckbox.setSelected(alphafineConfigManager.isContainTemplate()); this.isContainActionCheckbox.setSelected(alphaFineConfigManager.isContainAction());
this.isContainDocumentCheckbox.setSelected(alphafineConfigManager.isContainDocument() && alphafineConfigManager.isSearchOnLine()); this.isContainTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate());
this.isContainDocumentCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine()); this.isContainFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent());
this.isContainPluginCheckbox.setSelected(alphafineConfigManager.isContainPlugin() && alphafineConfigManager.isSearchOnLine()); this.isContainDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine());
this.isContainPluginCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine()); this.isContainDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.isContainRecommendCheckbox.setSelected(alphafineConfigManager.isContainRecommend() && alphafineConfigManager.isSearchOnLine()); this.isContainPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine());
this.isContainRecommendCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine()); this.isContainPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.shortcutsField.setText(getDisplayShortCut(alphafineConfigManager.getShortcuts())); this.isContainRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine());
shortCutKeyStore = convert2KeyStroke(alphafineConfigManager.getShortcuts()); this.isContainRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts()));
shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts());
} }
public void update() { public void update() {
DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager();
AlphafineConfigManager alphafineConfigManager = designerEnvManager.getAlphafineConfigManager(); AlphaFineConfigManager alphaFineConfigManager = designerEnvManager.getAlphaFineConfigManager();
alphafineConfigManager.setContainPlugin(this.isContainPluginCheckbox.isSelected()); alphaFineConfigManager.setContainPlugin(this.isContainPluginCheckbox.isSelected());
alphafineConfigManager.setContainAction(this.isContainActionCheckbox.isSelected()); alphaFineConfigManager.setContainAction(this.isContainActionCheckbox.isSelected());
alphafineConfigManager.setContainDocument(this.isContainDocumentCheckbox.isSelected()); alphaFineConfigManager.setContainDocument(this.isContainDocumentCheckbox.isSelected());
alphafineConfigManager.setContainRecommend(this.isContainRecommendCheckbox.isSelected()); alphaFineConfigManager.setContainRecommend(this.isContainRecommendCheckbox.isSelected());
alphafineConfigManager.setEnabled(this.isEnabledCheckbox.isSelected()); alphaFineConfigManager.setEnabled(this.isEnabledCheckbox.isSelected());
alphafineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected()); alphaFineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected());
alphafineConfigManager.setContainTemplate(this.isContainTemplateCheckbox.isSelected()); alphaFineConfigManager.setContainTemplate(this.isContainTemplateCheckbox.isSelected());
alphafineConfigManager.setContainFileContent(this.isContainFileContentCheckbox.isSelected()); alphaFineConfigManager.setContainFileContent(this.isContainFileContentCheckbox.isSelected());
alphafineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText()); alphaFineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText());
designerEnvManager.setAlphafineConfigManager(alphafineConfigManager); designerEnvManager.setAlphaFineConfigManager(alphaFineConfigManager);
try { try {
DesignerEnvManager.loadLogSetting(); DesignerEnvManager.loadLogSetting();
DesignerEnvManager.getEnvManager().saveXMLFile(); DesignerEnvManager.getEnvManager().saveXMLFile();
@ -192,8 +195,8 @@ public class AlphafineConfigPane extends BasicPane {
} }
private String getDisplayShortCut(String shotrCut) { private String getDisplayShortCut(String shortCut) {
return shotrCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH) return shortCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH)
.replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET) .replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET)
.replace(COMMA, DISPLAY_COMMA).replace(PERIOD, DISPLAY_PERIOD).replace(SEMICOLON, DISPLAY_SEMICOLON).replace(QUOTE, DISPLAY_QUOTE) .replace(COMMA, DISPLAY_COMMA).replace(PERIOD, DISPLAY_PERIOD).replace(SEMICOLON, DISPLAY_SEMICOLON).replace(QUOTE, DISPLAY_QUOTE)
.replace(EQUALS, DISPLAY_EQUALS).replace(MINUS, DISPLAY_MINUS).replace(COMMAND, DISPLAY_COMMAND).replace(SMALL_COMMAND, DISPLAY_COMMAND); .replace(EQUALS, DISPLAY_EQUALS).replace(MINUS, DISPLAY_MINUS).replace(COMMAND, DISPLAY_COMMAND).replace(SMALL_COMMAND, DISPLAY_COMMAND);

40
designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java

@ -0,0 +1,40 @@
package com.fr.design.actions.help.alphafine;
import java.util.ArrayList;
import java.util.List;
/**
* Created by XiaXiang on 2017/5/27.
*/
public class AlphaFineContext {
private static List<AlphaFineListener> fireAlphaFineListener = new ArrayList<AlphaFineListener>();
/**
* 触发AlphaFine弹窗
*/
public static void fireAlphaFineShowDialog() {
for (AlphaFineListener l : fireAlphaFineListener) {
l.showDialog();
}
}
/**
* 触发开启或关闭AlphaFine功能
* @param isEnable
*/
public static void fireAlphaFineEnable(boolean isEnable) {
for (AlphaFineListener l : fireAlphaFineListener) {
l.setEnable(isEnable);
}
}
/**
* 添加一个AlphaFine的监听事件
*
* @param l AlphaFine监听事件
*/
public static void addAlphaFineListener(AlphaFineListener l) {
fireAlphaFineListener.add(l);
}
}

18
designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java

@ -0,0 +1,18 @@
package com.fr.design.actions.help.alphafine;
/**
* Created by XiaXiang on 2017/5/27.
* AlphaFine监听器
*/
public interface AlphaFineListener {
/**
* 显示dialog
*/
void showDialog();
/**
* 设置可用性
* @param isEnable
*/
void setEnable(boolean isEnable);
}

29
designer_base/src/com/fr/design/actions/help/alphafine/AlphafineContext.java

@ -1,29 +0,0 @@
package com.fr.design.actions.help.alphafine;
import java.util.ArrayList;
import java.util.List;
/**
* Created by XiaXiang on 2017/5/27.
*/
public class AlphafineContext {
private static List<AlphafineListener> fireLoginContextListener = new ArrayList<AlphafineListener>();
/**
* 触发AlphaFine弹窗
*/
public static void fireAlphaFineContextListener() {
for (AlphafineListener l : fireLoginContextListener) {
l.showDialog();
}
}
/**
* 添加一个弹出AlphaFine的监听事件
*
* @param l AlphaFine框弹出监听事件
*/
public static void addAlphafineContextListener(AlphafineListener l) {
fireLoginContextListener.add(l);
}
}

8
designer_base/src/com/fr/design/actions/help/alphafine/AlphafineListener.java

@ -1,8 +0,0 @@
package com.fr.design.actions.help.alphafine;
/**
* Created by XiaXiang on 2017/5/27.
*/
public interface AlphafineListener {
void showDialog();
}

3
designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java

@ -8,6 +8,7 @@ import java.awt.*;
/** /**
* Created by XiaXiang on 2017/5/26. * Created by XiaXiang on 2017/5/26.
* 提示弹窗
*/ */
public class RemindDialog extends UIDialog { public class RemindDialog extends UIDialog {
private RemindPane remindPane; private RemindPane remindPane;
@ -22,7 +23,7 @@ public class RemindDialog extends UIDialog {
} }
private void initComponent() { private void initComponent() {
final AlphafineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphafineConfigManager(); final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
remindPane = new RemindPane(manager, this); remindPane = new RemindPane(manager, this);
this.add(remindPane); this.add(remindPane);

6
designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java

@ -42,7 +42,7 @@ public class RemindPane extends JPanel {
} }
}; };
public RemindPane(AlphafineConfigManager manager, UIDialog remindDialog) { public RemindPane(AlphaFineConfigManager manager, UIDialog remindDialog) {
this.setPreferredSize(new Dimension(WIDTH, HEIGHT)); this.setPreferredSize(new Dimension(WIDTH, HEIGHT));
initUI(manager, remindDialog); initUI(manager, remindDialog);
this.setLayout(getAbsoluteLayout()); this.setLayout(getAbsoluteLayout());
@ -53,7 +53,7 @@ public class RemindPane extends JPanel {
* @param manager * @param manager
* @param dialog * @param dialog
*/ */
private void initUI(final AlphafineConfigManager manager, final UIDialog dialog) { private void initUI(final AlphaFineConfigManager manager, final UIDialog dialog) {
openButton = new UIButton(); openButton = new UIButton();
openButton.setIcon(openIcon); openButton.setIcon(openIcon);
@ -63,7 +63,7 @@ public class RemindPane extends JPanel {
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
manager.setOperateCount(0); manager.setOperateCount(0);
dialog.dispose(); dialog.dispose();
AlphafineContext.fireAlphaFineContextListener(); AlphaFineContext.fireAlphaFineShowDialog();
} }
}); });

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

@ -1998,7 +1998,7 @@ FR-Designer_AlphaFine_EnableInternet=Designer_AlphaFine_EnableInternet
FR-Designer_AlphaFine_EnableInternetSearch=SearchOnLine FR-Designer_AlphaFine_EnableInternetSearch=SearchOnLine
FR-Designer_AlphaFine_Shortcut_Config=Shortcut Config FR-Designer_AlphaFine_Shortcut_Config=Shortcut Config
FR-Designer_AlphaFine_SearchRange=Search Range FR-Designer_AlphaFine_SearchRange=Search Range
FR-Designer_AlphaFine_Conclude=Conclude FR-Designer_AlphaFine_Recommend=Recommend
FR-Designer-Plugin_Addon=Plugin Addon FR-Designer-Plugin_Addon=Plugin Addon
FR-Designer_Templates=FR-Designer_Templates FR-Designer_Templates=FR-Designer_Templates
FR-Designer_Templates_Content=Templates Contents FR-Designer_Templates_Content=Templates Contents
@ -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-Designer_AlphaFine_NoResult=no results
FR-Designer_ConnectionFailed=connection failed

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

@ -1993,15 +1993,19 @@ FR-Designer_Permissions=Permissions
FR-Designer_Form_Button=Button FR-Designer_Form_Button=Button
FR-Designer_WF_Name=Name FR-Designer_WF_Name=Name
FR-Designer_AlphaFine_Enable=Enable FR-Designer_AlphaFine_Enable=Enable
FR-Designer_AlphaFine_EnableInternetSearch=SearchOnLine FR-Designer_AlphaFine_EnableInternetSearch=Search OnLine
FR-Designer_AlphaFine_Shortcut_Config=Shortcut Config FR-Designer_AlphaFine_Shortcut_Config=Shortcut Config
FR-Designer_AlphaFine_SearchRange=Search Range FR-Designer_AlphaFine_SearchRange=Search Range
FR-Designer_AlphaFine_Conclude=Conclude FR-Designer_AlphaFine_Recommend=Recommend
FR-Designer-Plugin_Addon=Plugin Addon FR-Designer-Plugin_Addon=Plugin Addon
FR-Designer_Templates=Templates FR-Designer_Templates=Files
FR-Designer_Templates_Content=Template'Contents FR-Designer_Templates_Content=Files'contents
FR-Designer_AlphaFine_ShowAll=show all FR-Designer_AlphaFine_ShowAll=Show all
FR-Designer_AlphaFine_Latest=Recent 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-Designer_AlphaFine_NoResult=No results
FR-Designer_ConnectionFailed=Connection failed
FR-Designer_AlphaFine_EnableAlphaFine=Enable AlphaFine
FR-Designer_AlphaFine_EnableInternet=Internet

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

@ -1998,8 +1998,10 @@ FR-Designer-Plugin_Addon=\u5E94\u7528\u4E2D\u5FC3
FR-Designer_Templates=\u6A21\u677F FR-Designer_Templates=\u6A21\u677F
FR-Designer_Templates_Content=\u6A21\u677F\u5185\u5BB9 FR-Designer_Templates_Content=\u6A21\u677F\u5185\u5BB9
FR-Designer_AlphaFine_ShowAll=\u663E\u793A\u5168\u90E8 FR-Designer_AlphaFine_ShowAll=\u663E\u793A\u5168\u90E8
FR-Designer_AlphaFine_Conclude=\u731C\u60A8\u9700\u8981 FR-Designer_AlphaFine_Recommend=\u731C\u60A8\u9700\u8981
FR-Designer_AlphaFine_Latest=\u672C\u5730\u5E38\u7528 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-Designer_AlphaFine_NoResult=\u6682\u65E0\u76F8\u5173\u5185\u5BB9
FR-Designer_ConnectionFailed=\u94FE\u63A5\u5931\u8D25

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

@ -1992,7 +1992,7 @@ FR-Designer_AlphaFine_EnableAlphaFine=\u958B\u555FAlphaFine\u529F\u80FD
FR-Designer_AlphaFine_EnableInternetSearch=\u806F\u7DB2\u641C\u7D22 FR-Designer_AlphaFine_EnableInternetSearch=\u806F\u7DB2\u641C\u7D22
FR-Designer_AlphaFine_Shortcut_Config=\u5FEB\u6377\u9375\u914D\u7F6E FR-Designer_AlphaFine_Shortcut_Config=\u5FEB\u6377\u9375\u914D\u7F6E
FR-Designer_AlphaFine_SearchRange=\u641C\u7D22\u7BC4\u570D FR-Designer_AlphaFine_SearchRange=\u641C\u7D22\u7BC4\u570D
FR-Designer_AlphaFine_Conclude=\u731C\u60A8\u9700\u8981 FR-Designer_AlphaFine_Recommend=\u731C\u60A8\u9700\u8981
FR-Designer-Plugin_Addon=\u61C9\u7528\u4E2D\u5FC3 FR-Designer-Plugin_Addon=\u61C9\u7528\u4E2D\u5FC3
FR-Designer_Templates=\u6A21\u677F FR-Designer_Templates=\u6A21\u677F
FR-Designer_Templates_Content=\u6A21\u677F\u5167\u5BB9 FR-Designer_Templates_Content=\u6A21\u677F\u5167\u5BB9
@ -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-Designer_AlphaFine_NoResult=\u66AB\u7121\u76F8\u95DC\u5167\u5BB9
FR-Designer_ConnectionFailed=\u93C8\u63A5\u5931\u6557

2
designer_base/src/com/fr/design/mainframe/DesignerFrame.java

@ -197,7 +197,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
}); });
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isEnabled()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) {
northEastPane.add(ad.createAlphafinePane(), BorderLayout.CENTER); northEastPane.add(ad.createAlphafinePane(), BorderLayout.CENTER);
} }
return northEastPane; return northEastPane;

4
designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -11,7 +11,7 @@ import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.community.*; import com.fr.design.actions.community.*;
import com.fr.design.actions.file.*; import com.fr.design.actions.file.*;
import com.fr.design.actions.help.AboutAction; import com.fr.design.actions.help.AboutAction;
import com.fr.design.actions.help.alphafine.AlphafineAction; import com.fr.design.actions.help.alphafine.AlphaFineAction;
import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.TutorialAction;
import com.fr.design.actions.help.WebDemoAction; import com.fr.design.actions.help.WebDemoAction;
import com.fr.design.actions.server.*; import com.fr.design.actions.server.*;
@ -374,7 +374,7 @@ public abstract class ToolBarMenuDock {
shortCuts.add(SeparatorDef.DEFAULT); shortCuts.add(SeparatorDef.DEFAULT);
shortCuts.add(new AboutAction()); shortCuts.add(new AboutAction());
shortCuts.add(SeparatorDef.DEFAULT); shortCuts.add(SeparatorDef.DEFAULT);
shortCuts.add(new AlphafineAction()); shortCuts.add(new AlphaFineAction());
return shortCuts.toArray(new ShortCut[shortCuts.size()]); return shortCuts.toArray(new ShortCut[shortCuts.size()]);
} }

Loading…
Cancel
Save