Browse Source

Merging in latest from upstream (BA/design:refs/heads/9.0)

* commit 'f5d9f2b68b212c22c858372a309496cec2f68b4b':
  bug fix pmd alphafine
  改几个方法名
  alphafine 代码质量 变量命名
  model里加一个count属性,修改本地常用的逻辑,按次数排序 代码质量, 修改部分变量命名
  代码质量
  bug fix
  代码质量
  rt
  rt
  bug fix
  快捷键设置优化
  REPORT-3022 智能搜索619引擎功能改良
  alphafine bug fix
master
ju 8 years ago
parent
commit
03f2725483
  1. 5
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 4
      designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  3. 13
      designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java
  4. 27
      designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java
  5. 11
      designer/src/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java
  6. 9
      designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java
  7. 5
      designer/src/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java
  8. 7
      designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java
  9. 52
      designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java
  10. 31
      designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java
  11. 373
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  12. 9
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  13. 3
      designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java
  14. 16
      designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java
  15. 3
      designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java
  16. 31
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java
  17. 27
      designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  18. 1
      designer_base/src/com/fr/design/locale/designer.properties
  19. 1
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  20. 2
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  21. 1
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties

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

@ -8,11 +8,10 @@ import java.awt.*;
* Created by XiaXiang on 2017/5/10.
*/
public class AlphaFineConstants {
public static final String SAVE_FILE_NAME = "alpha.coco";
public static final int SHOW_SIZE = 5;
public static final int MAX_FILE_SIZE = 100;
public static final int MAX_FILE_SIZE = 1000;
public static final int LATEST_SHOW_SIZE = 3;
@ -30,6 +29,8 @@ public class AlphaFineConstants {
public static final int CELL_HEIGHT = 32;
public static final int CELL_TITLE_HEIGHT = 24;
public static final Dimension FULL_SIZE = new Dimension(680, 460);

4
designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java

@ -19,13 +19,13 @@ public class CellModelHelper {
AlphaCellModel cellModel = null;
switch (CellType.parse(typeValue)) {
case ACTION:
cellModel = ActionSearchManager.getModelFromCloud(object.optString(RESULT));
cellModel = ActionSearchManager.getModelFromCloud(object.optJSONObject(RESULT));
break;
case DOCUMENT:
cellModel = DocumentSearchManager.getModelFromCloud(object.optJSONObject(RESULT));
break;
case FILE:
cellModel = FileSearchManager.getModelFromCloud(object.optString(RESULT));
cellModel = FileSearchManager.getModelFromCloud(object.optJSONObject(RESULT));
break;
case PLUGIN:
case REUSE:

13
designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java

@ -13,10 +13,10 @@ import javax.swing.*;
public class ActionModel extends AlphaCellModel {
private Action action;
private String className;
public ActionModel(String name, String content, CellType type) {
super(name, content, type);
public ActionModel(String name, String description, Action action, int searchCount) {
this(name, description, action);
setSearchCount(searchCount);
}
public ActionModel(String name, String description, Action action) {
@ -55,7 +55,9 @@ public class ActionModel extends AlphaCellModel {
public JSONObject ModelToJson() {
JSONObject object = JSONObject.create();
try {
object.put("result", getAction().getClass().getName()).put("cellType", getType().getTypeValue());
JSONObject modelObject = JSONObject.create();
modelObject.put("className", getAction().getClass().getName()).put("searchCount", getSearchCount());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
}
@ -71,7 +73,4 @@ public class ActionModel extends AlphaCellModel {
return getAction().getClass().getName();
}
public void setClassName(String className) {
this.className = className;
}
}

27
designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java

@ -8,11 +8,12 @@ import com.fr.json.JSONObject;
/**
* Created by XiaXiang on 2017/3/23.
*/
public abstract class AlphaCellModel {
public abstract class AlphaCellModel implements Comparable {
private String name;
private String content;
private String description;
private CellType type;
private int searchCount;
public AlphaCellModel(String name, String content, CellType type) {
this.name = name;
@ -60,6 +61,9 @@ public abstract class AlphaCellModel {
this.description = description;
}
public boolean hasNoResult() {
return false;
}
/**
* model转json
*
@ -75,4 +79,25 @@ public abstract class AlphaCellModel {
*/
abstract public String getStoreInformation();
public int getSearchCount() {
return searchCount;
}
public void setSearchCount(int searchCount) {
this.searchCount = searchCount;
}
public void addSearchCount() {
searchCount++;
}
@Override
public int compareTo(Object o) {
AlphaCellModel cellModel = (AlphaCellModel)o;
int difference = cellModel.getSearchCount() - this.getSearchCount();
if (difference != 0) {
return difference;
}
return this.getName().compareTo(cellModel.getName());
}
}

11
designer/src/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java

@ -14,10 +14,6 @@ public class DocumentModel extends AlphaCellModel {
private String informationUrl;
private int documentId;
public DocumentModel(String name, String content, CellType type) {
super(name, content, type);
}
public DocumentModel(String name, String content, int documentId) {
super(name, content, CellType.DOCUMENT);
this.documentId = documentId;
@ -25,6 +21,11 @@ public class DocumentModel extends AlphaCellModel {
this.documentUrl = AlphaFineConstants.DOCUMENT_DOC_URL + documentId + ".html";
}
public DocumentModel(String name, String content, int documentId, int searchCount) {
this(name, content, documentId);
setSearchCount(searchCount);
}
public String getDocumentUrl() {
return documentUrl;
}
@ -38,7 +39,7 @@ public class DocumentModel extends AlphaCellModel {
JSONObject object = JSONObject.create();
try {
JSONObject modelObject = JSONObject.create();
modelObject.put("title", getName()).put("summary", getContent()).put("did", getDocumentId());
modelObject.put("title", getName()).put("summary", getContent()).put("did", getDocumentId()).put("searchCount", getSearchCount());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FRLogger.getLogger().error("DocumentModel: " + e.getMessage());

9
designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java

@ -12,8 +12,9 @@ import com.fr.json.JSONObject;
public class FileModel extends AlphaCellModel {
private String filePath;
public FileModel(String name, String content, CellType type) {
super(name, content, type);
public FileModel(String name, String filePath, int searchCount) {
this(name, filePath);
setSearchCount(searchCount);
}
public FileModel(String name, String filePath) {
@ -34,7 +35,9 @@ public class FileModel extends AlphaCellModel {
public JSONObject ModelToJson() {
JSONObject object = JSONObject.create();
try {
object.put("result", getFilePath()).put("cellType", getType().getTypeValue());
JSONObject modelObject = JSONObject.create();
modelObject.put("filePath", getFilePath()).put("searchCount", getSearchCount());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
}

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

@ -21,4 +21,9 @@ public class NoResultModel extends AlphaCellModel {
public String getStoreInformation() {
return null;
}
@Override
public boolean hasNoResult() {
return true;
}
}

7
designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java

@ -21,8 +21,9 @@ public class PluginModel extends AlphaCellModel {
private int pluginId;
private int price;
public PluginModel(String name, String content, CellType type) {
super(name, content, type);
public PluginModel(String name, String content, String imageUrl, String version, String jartime, String link, CellType type, int price, int pluginId, int serchCount) {
this(name, content, imageUrl, version, jartime, link, type, price, pluginId);
setSearchCount(serchCount);
}
public PluginModel(String name, String content, String imageUrl, String version, String jartime, String link, CellType type, int price, int pluginId) {
@ -97,7 +98,7 @@ public class PluginModel extends AlphaCellModel {
JSONObject object = JSONObject.create();
try {
JSONObject modelObject = JSONObject.create();
modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("type", getType().getTypeValue()).put("price", getPrice()).put("id", getPluginId()).put("link", getLink());
modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("type", getType().getTypeValue()).put("price", getPrice()).put("id", getPluginId()).put("link", getLink()).put("searchCount", getSearchCount());
object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());

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

@ -2,7 +2,6 @@ package com.fr.design.mainframe.alphafine.cell.render;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.general.IOUtils;
@ -15,46 +14,47 @@ import java.awt.*;
* Created by XiaXiang on 2017/4/20.
*/
public class ContentCellRender implements ListCellRenderer<Object> {
private UILabel name;
private UILabel content;
public ContentCellRender() {
this.name = new UILabel();
this.content = new UILabel();
}
private static final int OFFSET = 30;
private static final int LABEL_OFFSET = 45;
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
UILabel titleLabel = new UILabel();
UILabel detailLabel = new UILabel();
if (value instanceof MoreModel) {
return new TitleCellRender().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
AlphaCellModel model = (AlphaCellModel) value;
JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(Color.white);
if (isSelected) {
panel.setBackground(null);
if (isSelected && !model.hasNoResult()) {
panel.setBackground(AlphaFineConstants.BLUE);
}
panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
AlphaCellModel model = (AlphaCellModel) value;
name.setText(model.getName());
panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
titleLabel.setText(" " + model.getName());
String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png";
name.setIcon(IOUtils.readIcon(iconUrl));
if (model.getType() == CellType.NO_RESULT) {
name.setIcon(null);
name.setForeground(AlphaFineConstants.MEDIUM_GRAY);
if (model.hasNoResult()) {
titleLabel.setIcon(null);
titleLabel.setForeground(AlphaFineConstants.MEDIUM_GRAY);
} else {
name.setIcon(new ImageIcon(getClass().getResource(iconUrl)));
name.setForeground(AlphaFineConstants.BLACK);
titleLabel.setIcon(new ImageIcon(IOUtils.readImage(iconUrl)));
titleLabel.setForeground(AlphaFineConstants.BLACK);
}
name.setFont(AlphaFineConstants.MEDIUM_FONT);
name.setVerticalTextPosition(SwingConstants.CENTER);
name.setHorizontalTextPosition(SwingConstants.RIGHT);
titleLabel.setFont(AlphaFineConstants.MEDIUM_FONT);
String description = model.getDescription();
if (StringUtils.isNotBlank(description)) {
content.setText("-" + description);
content.setForeground(AlphaFineConstants.LIGHT_GRAY);
panel.add(content, BorderLayout.CENTER);
detailLabel.setText("-" + description);
detailLabel.setForeground(AlphaFineConstants.LIGHT_GRAY);
panel.add(detailLabel, BorderLayout.CENTER);
int width = (int) (titleLabel.getPreferredSize().getWidth() + detailLabel.getPreferredSize().getWidth());
if ( width > AlphaFineConstants.LEFT_WIDTH - OFFSET) {
int nameWidth = (int) (AlphaFineConstants.LEFT_WIDTH - detailLabel.getPreferredSize().getWidth() - LABEL_OFFSET);
titleLabel.setPreferredSize(new Dimension(nameWidth, AlphaFineConstants.CELL_HEIGHT));
}
}
panel.add(name, BorderLayout.WEST);
panel.add(titleLabel, BorderLayout.WEST);
panel.setPreferredSize(new Dimension(list.getFixedCellWidth(), AlphaFineConstants.CELL_HEIGHT));
return panel;
}
}

31
designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java

@ -12,39 +12,34 @@ import java.awt.*;
* Created by XiaXiang on 2017/4/20.
*/
public class TitleCellRender implements ListCellRenderer<Object> {
private UILabel name;
private UILabel more;
public TitleCellRender() {
this.name = new UILabel();
this.more = new UILabel();
}
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
UILabel titleLabel = new UILabel();
UILabel showMoreLabel = new UILabel();
MoreModel moreModel = (MoreModel) value;
JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(AlphaFineConstants.WHITE);
panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
name.setText(moreModel.getName());
name.setFont(AlphaFineConstants.SMALL_FONT);
more.setFont(AlphaFineConstants.SMALL_FONT);
more.setText(moreModel.getContent());
name.setForeground(AlphaFineConstants.DARK_GRAY);
more.setForeground(AlphaFineConstants.DARK_GRAY);
panel.add(name, BorderLayout.WEST);
panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
titleLabel.setText(moreModel.getName());
titleLabel.setFont(AlphaFineConstants.SMALL_FONT);
showMoreLabel.setFont(AlphaFineConstants.SMALL_FONT);
showMoreLabel.setText(moreModel.getContent());
titleLabel.setForeground(AlphaFineConstants.DARK_GRAY);
showMoreLabel.setForeground(AlphaFineConstants.DARK_GRAY);
panel.add(titleLabel, BorderLayout.WEST);
if (moreModel.isNeedMore()) {
this.more.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
panel.add(this.more, BorderLayout.EAST);
showMoreLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
panel.add(showMoreLabel, BorderLayout.EAST);
}
if (moreModel.isLoading()) {
ImageIcon imageIcon = (ImageIcon) IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/loading.gif");
//设置cell的加载动画
imageIcon.setImageObserver(list);
UILabel loadingLabel = new UILabel(imageIcon);
panel.add(loadingLabel, BorderLayout.SOUTH);
}
panel.setPreferredSize(new Dimension(list.getFixedCellWidth(), AlphaFineConstants.CELL_TITLE_HEIGHT));
return panel;
}
}

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

@ -27,7 +27,6 @@ import com.fr.form.main.Form;
import com.fr.form.main.FormIO;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.http.HttpClient;
import com.fr.io.TemplateWorkBookIO;
@ -60,29 +59,18 @@ import java.util.concurrent.ExecutionException;
* Created by XiaXiang on 2017/3/21.
*/
public class AlphaFineDialog extends UIDialog {
private static final String ADVANCED_SEARCH_MARK = "k:";
private static final String ACTION_MARK_SHORT = "k:1 ";
private static final String ACTION_MARK = "k:setting ";
private static final String DOCUMENT_MARK_SHORT = "k:2 ";
private static final String DOCUMENT_MARK = "k:help ";
private static final String FILE_MARK_SHORT = "k:3 ";
private static final String FILE_MARK = "k:reportlets ";
private static final String CPT_MARK = "k:cpt ";
private static final String FRM_MARK = "k:frm ";
private static final String DS_MARK = "k:ds ";
private static final String DS_NAME = "dsname=\"";
private static final String PLUGIN_MARK_SHORT = "k:4 ";
private static final String PLUGIN_MARK = "k:shop ";
private AlphaFineTextField searchTextField;
@ -94,30 +82,29 @@ public class AlphaFineDialog extends UIDialog {
private JList searchResultList;
private SearchListModel searchListModel;
private SwingWorker searchWorker;
private SwingWorker showWorker;
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
private boolean forceOpen;
public AlphaFineDialog(Frame parent, boolean forceOpen) {
super(parent);
this.forceOpen = forceOpen;
initProperties();
initListener();
initGlobalListener();
initComponents();
}
/**
* 全局快捷键
*
* @return
*/
public static AWTEventListener listener() {
return new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
if (event instanceof KeyEvent) {
KeyEvent e = (KeyEvent) event;
KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e);
@ -125,39 +112,35 @@ public class AlphaFineDialog extends UIDialog {
if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) {
doClickAction();
}
}
}
};
}
private static void doClickAction() {
AlphaFineHelper.showAlphaFineDialog(false);
}
/**
* 初始化全部组件
*/
private void initComponents() {
searchTextField = new AlphaFineTextField("AlphaFine");
searchTextField.setFont(AlphaFineConstants.GREATER_FONT);
searchTextField.setBackground(Color.white);
searchTextField.setBorderPainted(false);
searchTextField.initKeyListener(this);
JPanel topPane = new JPanel(new BorderLayout());
UILabel iconLabel = new UILabel(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/bigsearch.png"));
UILabel iconLabel = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png")));
iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE);
iconLabel.setOpaque(true);
iconLabel.setBackground(Color.white);
topPane.add(iconLabel, BorderLayout.WEST);
topPane.add(searchTextField, BorderLayout.CENTER);
closeButton = new UIButton() {
@Override
public void paintComponent(Graphics g) {
g.setColor(Color.white);
g.fillRect(0, 0, getSize().width, getSize().height);
super.paintComponent(g);
@ -165,13 +148,11 @@ public class AlphaFineDialog extends UIDialog {
};
closeButton.setContentAreaFilled(false);
closeButton.setPreferredSize(AlphaFineConstants.CLOSE_BUTTON_SIZE);
closeButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/alphafine_close.png"));
closeButton.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/alphafine_close.png")));
closeButton.set4ToolbarButton();
closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
@ -182,38 +163,34 @@ public class AlphaFineDialog extends UIDialog {
topPane.add(borderLabel, BorderLayout.SOUTH);
add(topPane, BorderLayout.CENTER);
searchTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
doSearch(searchTextField.getText());
}
});
}
/**
*
*/
private void initProperties() {
setUndecorated(true);
addComponentListener(new ComponentHandler());
setSize(AlphaFineConstants.FIELD_SIZE);
centerWindow(this);
}
/**
* 设置面板位置
*
* @param win
*/
private void centerWindow(Window win) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension winSize = win.getSize();
if (winSize.height > screenSize.height) {
winSize.height = screenSize.height;
}
@ -223,41 +200,40 @@ public class AlphaFineDialog extends UIDialog {
//这里设置位置:水平居中,竖直偏上
win.setLocation((screenSize.width - winSize.width) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE);
}
// TODO: 2017/5/8 xiaxiang: 窗体圆角setShape()有毛边,重写paint方法可以解决毛边问题,但带来了别的问题,处理比较麻烦,暂用setShape();
// public void paint(Graphics g){
//
// Graphics2D g2 = (Graphics2D) g.create();
// RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
// g2.setRenderingHints(qualityHints);
// g2.setPaint(Color.WHITE);
// g2.fillRoundRect(0, 0, getWidth(), getHeight(), 25, 25);
// g2.fillRoundRect(0, 0, getWidth(), getHeight(), 15, 15);
// g2.dispose();
// }
/**
* 执行搜索
*
* @param text
*/
private void doSearch(String text) {
if (StringUtils.isBlank(text) || text.equals("AlphaFine")) {
if (StringUtils.isBlank(text) || isNeedSearch(text)) {
removeSearchResult();
} else if (text.contains("'")) {
return;
} else {
showSearchResult();
}
}
boolean isNeedSearch(String text) {
return ComparatorUtils.equals("AlphaFine", text) || text.contains("'");
}
/**
* 移除搜索结果
*/
private void removeSearchResult() {
if (searchResultPane != null) {
remove(searchResultPane);
searchResultPane = null;
@ -265,7 +241,7 @@ public class AlphaFineDialog extends UIDialog {
setSize(AlphaFineConstants.FIELD_SIZE);
repaint();
}
/**
* 展示搜索结果
*/
@ -276,12 +252,11 @@ public class AlphaFineDialog extends UIDialog {
}
initSearchWorker();
}
/**
* 初始化搜索面板
*/
private void initSearchResultComponents() {
searchResultList = new JList();
searchListModel = new SearchListModel(new SearchResult());
searchResultList.setModel(searchListModel);
@ -289,8 +264,7 @@ public class AlphaFineDialog extends UIDialog {
searchResultPane.setPreferredSize(AlphaFineConstants.CONTENT_SIZE);
searchResultPane.setLayout(new BorderLayout());
searchResultList.setCellRenderer(new ContentCellRender());
searchResultList.setFixedCellHeight(AlphaFineConstants.CELL_HEIGHT);
leftSearchResultPane = new UIScrollPane(searchResultList);
leftSearchResultPane.setBackground(Color.white);
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
@ -303,7 +277,7 @@ public class AlphaFineDialog extends UIDialog {
add(searchResultPane, BorderLayout.SOUTH);
setSize(AlphaFineConstants.FULL_SIZE);
}
/**
* 异步加载搜索结果
*/
@ -315,15 +289,13 @@ public class AlphaFineDialog extends UIDialog {
this.searchWorker = new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
rebuildList(searchTextField.getText().toLowerCase());
return null;
}
@Override
protected void done() {
if (!isCancelled() && searchListModel.getSize() > 0) {
if (!isCancelled() && searchListModel.getSize() > 1) {
searchResultList.setSelectedIndex(1);
showResult(searchResultList.getSelectedIndex(), searchResultList.getSelectedValue());
}
@ -331,7 +303,7 @@ public class AlphaFineDialog extends UIDialog {
};
this.searchWorker.execute();
}
/**
* 重新构建搜索结果列表
* 先根据输入判断是不是隐藏的搜索功能
@ -339,37 +311,33 @@ public class AlphaFineDialog extends UIDialog {
* @param searchText
*/
private void rebuildList(String searchText) {
searchListModel.removeAllElements();
if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) {
getActionList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
return;
} else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) {
getDocumentList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
return;
} else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) {
getFileList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
return;
} else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) {
getFileList(searchText);
return;
} else if (searchText.startsWith(DS_MARK)) {
getFileList(DS_NAME + searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
return;
} else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) {
getPluginList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
return;
if (searchText.startsWith(ADVANCED_SEARCH_MARK)) {
if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) {
getActionList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
} else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) {
getDocumentList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
} else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) {
getFileList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
} else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) {
getFileList(searchText);
} else if (searchText.startsWith(DS_MARK)) {
getFileList(DS_NAME + searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
} else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) {
getPluginList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()));
}
} else {
doNormalSearch(searchText.trim());
}
doNormalSearch(searchText.trim());
}
/**
* 普通搜索
*
* @param searchText
*/
private void doNormalSearch(String searchText) {
getRecentList(searchText);
getRecommendList(searchText);
getActionList(searchText);
@ -377,116 +345,54 @@ public class AlphaFineDialog extends UIDialog {
getDocumentList(searchText);
getPluginList(searchText);
}
private synchronized void getDocumentList(final String searchText) {
private void getDocumentList(final String searchText) {
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText);
for (Object object : documentModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
private synchronized void getFileList(final String searchText) {
private 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) {
private void getActionList(final String searchText) {
SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText);
for (Object object : actionModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
private synchronized void getPluginList(final String searchText) {
private 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) {
private 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) {
private void getRecentList(final String searchText) {
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText);
for (Object object : recentModelList) {
AlphaFineHelper.checkCancel();
searchListModel.addElement(object);
}
}
/**
* 初始化监听器
*/
private void initListListener() {
/**
* 鼠标监听器
*/
searchResultList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int selectedIndex = searchResultList.getSelectedIndex();
Object selectedValue = searchResultList.getSelectedValue();
if (e.getClickCount() == 2) {
doNavigate(selectedIndex);
if (selectedValue instanceof AlphaCellModel) {
saveHistory((AlphaCellModel) selectedValue);
}
} else if (e.getClickCount() == 1) {
if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) {
HandleMoreOrLessResult(selectedIndex, (MoreModel) selectedValue);
}
}
}
});
/**
*单击时触发右侧面板展示搜索结果
*/
searchResultList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
showResult(searchResultList.getSelectedIndex(), searchResultList.getSelectedValue());
}
}
});
/**
* 键盘监听器
*/
searchResultList.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
Object selectedValue = searchResultList.getSelectedValue();
doNavigate(searchResultList.getSelectedIndex());
if (searchResultList.getSelectedValue() instanceof AlphaCellModel) {
saveHistory((AlphaCellModel) selectedValue);
}
}
}
});
}
private void showResult(int index, final Object selectedValue) {
@ -494,11 +400,8 @@ public class AlphaFineDialog extends UIDialog {
final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
showDefaultPreviewPane();
if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
this.searchWorker = new SwingWorker<BufferedImage, Void>() {
checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() throws Exception {
Form form = FormIO.readForm(FRContext.getCurrentEnv(), fileName);
@ -522,13 +425,10 @@ public class AlphaFineDialog extends UIDialog {
}
};
this.searchWorker.execute();
this.showWorker.execute();
} else if (fileName.endsWith(ProjectConstants.CPT_SUFFIX)) {
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
this.searchWorker = new SwingWorker<BufferedImage, Void>() {
checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() throws Exception {
WorkBook workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName);
@ -553,11 +453,10 @@ public class AlphaFineDialog extends UIDialog {
}
};
this.searchWorker.execute();
this.showWorker.execute();
}
} else if (selectedValue instanceof DocumentModel) {
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new DocumentPreviewPane(((DocumentModel) selectedValue).getName(), ((DocumentModel) selectedValue).getContent()));
@ -565,18 +464,19 @@ public class AlphaFineDialog extends UIDialog {
repaint();
} else if (selectedValue instanceof PluginModel) {
showDefaultPreviewPane();
if (this.searchWorker != null && !this.searchWorker.isDone()) {
this.searchWorker.cancel(true);
this.searchWorker = null;
}
this.searchWorker = new SwingWorker<Image, Void>() {
checkWorker();
this.showWorker = new SwingWorker<Image, Void>() {
@Override
protected Image doInBackground() {
BufferedImage bufferedImage = null;
try {
bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl()));
} catch (IOException e) {
bufferedImage = IOUtils.readImage("/com/fr/design/mainframe/alphafine/images/default_product.png");
try {
bufferedImage = ImageIO.read(getClass().getResource("/com/fr/design/mainframe/alphafine/images/default_product.png"));
} catch (IOException e1) {
FRLogger.getLogger().error(e.getMessage());
}
}
return bufferedImage;
}
@ -598,7 +498,7 @@ public class AlphaFineDialog extends UIDialog {
}
};
this.searchWorker.execute();
this.showWorker.execute();
} else if (selectedValue instanceof ActionModel) {
rightSearchResultPane.removeAll();
@ -609,6 +509,16 @@ public class AlphaFineDialog extends UIDialog {
}
/**
* 检查
*/
private void checkWorker() {
if (this.showWorker != null && !this.showWorker.isDone()) {
this.showWorker.cancel(true);
this.showWorker = null;
}
}
private void HandleMoreOrLessResult(int index, MoreModel selectedValue) {
if (selectedValue.getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"))) {
selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"));
@ -622,41 +532,109 @@ public class AlphaFineDialog extends UIDialog {
private void showDefaultPreviewPane() {
rightSearchResultPane.removeAll();
UILabel label = new UILabel(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/opening.gif"));
label.setBorder(BorderFactory.createEmptyBorder(120,0,0,0));
UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif")));
label.setBorder(BorderFactory.createEmptyBorder(120, 0, 0, 0));
rightSearchResultPane.add(label, BorderLayout.CENTER);
validate();
repaint();
}
private void initListener() {
/**
* 为面板添加全局监听器
*/
private void initGlobalListener() {
initAWTEventListener();
initMouseListener();
}
/**
* 为面板中各组件添加监听器
*/
private void initListListener() {
initListMouseListener();
initListKeyListener();
}
private void initListKeyListener() {
/**
* 为list添加键盘监听器
*/
searchResultList.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
Object selectedValue = searchResultList.getSelectedValue();
doNavigate(searchResultList.getSelectedIndex());
if (searchResultList.getSelectedValue() instanceof AlphaCellModel) {
saveHistory((AlphaCellModel) selectedValue);
}
}
}
});
/**
* 为textField添加键盘监听器按上下方向键时把焦点给list,实现键盘操作
*/
searchTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
searchResultList.requestFocus();
}
}
});
}
private void initListMouseListener() {
/**
* 鼠标监听器
*/
searchResultList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int selectedIndex = searchResultList.getSelectedIndex();
Object selectedValue = searchResultList.getSelectedValue();
if (e.getClickCount() == 2) {
doNavigate(selectedIndex);
if (selectedValue instanceof AlphaCellModel) {
saveHistory((AlphaCellModel) selectedValue);
}
} else if (e.getClickCount() == 1) {
if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) {
HandleMoreOrLessResult(selectedIndex, (MoreModel) selectedValue);
}
}
}
});
/**
*单击时触发右侧面板展示搜索结果
*/
searchResultList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
showResult(searchResultList.getSelectedIndex(), searchResultList.getSelectedValue());
}
}
});
}
/**
* 窗口拖拽
*/
private void initMouseListener() {
addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
doMouseDragged(e);
}
});
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
doMousePressed(e);
}
});
}
@ -787,7 +765,7 @@ public class AlphaFineDialog extends UIDialog {
}
}
/**
* 点击显示更多时添加对应的model到list点击收起是移除model
*
@ -795,7 +773,6 @@ public class AlphaFineDialog extends UIDialog {
* @param selectedValue
*/
private void rebuildShowMoreList(int index, MoreModel selectedValue) {
SearchResult moreResult = getMoreResult(selectedValue);
if ((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) {
for (int i = 0; i < moreResult.size(); i++) {
@ -804,14 +781,14 @@ public class AlphaFineDialog extends UIDialog {
} else {
for (int i = 0; i < moreResult.size(); i++) {
this.searchListModel.remove(index + AlphaFineConstants.SHOW_SIZE + 1);
}
}
this.searchResultList.validate();
this.searchResultList.repaint();
validate();
repaint();
}
private void rebuildList() {
@ -858,16 +835,14 @@ public class AlphaFineDialog extends UIDialog {
public void setSearchWorker(SwingWorker searchWorker) {
this.searchWorker = searchWorker;
}
public boolean isForceOpen() {
return forceOpen;
}
public void setForceOpen(boolean forceOpen) {
this.forceOpen = forceOpen;
}
}

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

@ -11,6 +11,7 @@ import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.design.mainframe.toolbar.UpdateActionModel;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import java.util.List;
@ -35,14 +36,16 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
/**
* 根据类名获取对象
*
* @param actionName
* @param object
* @return
*/
public static ActionModel getModelFromCloud(String actionName) {
public static ActionModel getModelFromCloud(JSONObject object) {
String actionName = object.optString("className");
int searchCount = object.optInt("searchCount");
List<UpdateActionModel> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
for (UpdateActionModel updateActionModel : updateActions) {
if (ComparatorUtils.equals(actionName, updateActionModel.getClassName())) {
return new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction());
return new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction(), searchCount);
}
}
return null;

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

@ -42,7 +42,8 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
String name = object.optString("title");
String content = object.optString("summary");
int documentId = object.optInt("did");
return new DocumentModel(name, content, documentId);
int searchCount = object.optInt("searchCount");
return new DocumentModel(name, content, documentId, searchCount);
}
@Override

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

@ -13,6 +13,7 @@ import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.json.JSONObject;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
@ -27,6 +28,8 @@ import java.util.List;
public class FileSearchManager implements AlphaFineSearchProcessor {
private static final int MARK_LENGTH = 6;
private static final String DS_NAME = "dsname=\"";
private static final String FRM_PREFIX = "k:frm ";
private static final String CPT_PREFIX = "k:cpt ";
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE);
private static FileSearchManager fileSearchManager = null;
private SearchResult filterModelList;
@ -51,22 +54,24 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
/**
* 根据文件路径获取文件模型
*
* @param filePath
* @param object
* @return
*/
public static FileModel getModelFromCloud(String filePath) {
public static FileModel getModelFromCloud(JSONObject object) {
String filePath = object.optString("filePath");
int searchCount = object.optInt("searchCount");
String name = AlphaFineHelper.findFileName(filePath);
return new FileModel(name, filePath);
return new FileModel(name, filePath, searchCount);
}
public synchronized SearchResult getLessSearchResult(String searchText) {
this.filterModelList = new SearchResult();
this.lessModelList = new SearchResult();
this.moreModelList = new SearchResult();
if (searchText.startsWith("k:frm ")) {
if (searchText.startsWith(FRM_PREFIX)) {
isContainCpt = false;
searchText = searchText.substring(MARK_LENGTH, searchText.length());
} else if (searchText.startsWith("k:cpt ")) {
} else if (searchText.startsWith(CPT_PREFIX)) {
isContainFrm = false;
searchText = searchText.substring(MARK_LENGTH, searchText.length());
}
@ -139,6 +144,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
FileModel model = new FileModel(node.getName(), node.getEnvPath());
this.filterModelList.add(model);
}
isr.close();
reader.close();
} catch (FileNotFoundException e) {
FRLogger.getLogger().error(e.getMessage());

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

@ -41,6 +41,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
String name = object.optString("name");
String content = object.optString("description");
int pluginId = object.optInt("id");
int searchCount = object.optInt("searchCount");
String imageUrl = null;
try {
imageUrl = isFromCloud ? AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8") : object.optString("pic");
@ -59,7 +60,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
type = CellType.REUSE;
}
int price = object.optInt("price");
return new PluginModel(name, content, imageUrl, version, jartime, link, type, price, pluginId);
return new PluginModel(name, content, imageUrl, version, jartime, link, type, price, pluginId, searchCount);
}
/**

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

@ -34,7 +34,7 @@ import java.util.*;
*/
public class RecentSearchManager extends XMLFileManager implements AlphaFineSearchProcessor {
private static final String XML_TAG = "AlphafineRecent";
private static final String XML_TAG = "AlphaFineRecent";
private static final int MAX_SIZE = 3;
private static RecentSearchManager recentSearchManager = null;
private static File recentFile = null;
@ -64,7 +64,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
String nodeName = reader.getTagName();
if (nodeName.equals("RecentModelList")) {
String key = reader.getAttrAsString("searchKey", StringUtils.EMPTY);
final ArrayList<AlphaCellModel> list = new ArrayList<AlphaCellModel>();
final ArrayList<AlphaCellModel> list = new ArrayList<>();
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader reader) {
@ -85,16 +85,16 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
if (reader.isChildNode()) {
String nodeName = reader.getTagName();
if (nodeName.equals("model")) {
String name = reader.getAttrAsString("cellModel", StringUtils.EMPTY);
addModelToList(list, name);
String modelValue = reader.getAttrAsString("cellModel", StringUtils.EMPTY);
addModelToList(list, modelValue);
}
}
}
private void addModelToList(List<AlphaCellModel> list, String name) {
private void addModelToList(List<AlphaCellModel> list, String modelValue) {
try {
AlphaCellModel model = CellModelHelper.getModelFromJson(new JSONObject(name));
AlphaCellModel model = CellModelHelper.getModelFromJson(new JSONObject(modelValue));
if (model != null) {
list.add(model);
}
@ -113,9 +113,9 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
writer.attr("searchKey", key);
for (AlphaCellModel model : recentKVModelMap.get(key)) {
try {
String name = model.ModelToJson().toString();
String modelValue = model.ModelToJson().toString();
writer.startTAG("model");
writer.attr("cellModel", name);
writer.attr("cellModel", modelValue);
writer.end();
} catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage());
@ -130,7 +130,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
@Override
public String fileName() {
return "alphafine_recent.xml";
return "AlphaFine_Recent.xml";
}
@ -162,7 +162,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
private void createRecentFile(File envFile) {
try {
FileWriter fileWriter = new FileWriter(envFile);
StringReader stringReader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><AlphafineRecent></AlphafineRecent>");
StringReader stringReader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><AlphaFineRecent></AlphaFineRecent>");
Utils.copyCharTo(stringReader, fileWriter);
stringReader.close();
fileWriter.close();
@ -231,9 +231,10 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
}
}
Collections.sort(resultModelList);
int size = resultModelList.size();
if (size > MAX_SIZE) {
return resultModelList.subList(size - MAX_SIZE, size);
return resultModelList.subList(0, MAX_SIZE);
}
return resultModelList;
}
@ -250,13 +251,13 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
public void addRecentModel(String searchKey, AlphaCellModel cellModel) {
if (recentKVModelMap.keySet().contains(searchKey)) {
List<AlphaCellModel> cellModels = recentKVModelMap.get(searchKey);
if (cellModels.contains(cellModel)) {
cellModels.remove(cellModel);
cellModels.add(cellModel);
int index = cellModels.indexOf(cellModel);
if (index >= 0) {
cellModels.get(index).addSearchCount();
} else {
cellModels.add(cellModel);
}
trimToSize(cellModels);
//trimToSize(cellModels);
} else {
List<AlphaCellModel> list = new ArrayList<>();
list.add(cellModel);

27
designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java

@ -13,10 +13,7 @@ import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.*;
/**
* Created by XiaXiang on 2017/4/6.
@ -100,7 +97,25 @@ public class AlphaFineConfigPane extends BasicPane {
private void createShortcutsPane(JPanel contentPane) {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_AlphaFine_Shortcut_Config"));
shortcutsField = new UITextField();
shortcutsField.setEditable(false);
shortcutsField.selectAll();
shortcutsField.setPreferredSize(new Dimension(100, 20));
initFieldListener();
northPane.add(new UILabel(Inter.getLocText("FR-Designer_Open") + ":"));
northPane.add(shortcutsField);
UILabel label = new UILabel(Inter.getLocText("FR-Designer-AlphaFine_SetShortcuts"));
label.setForeground(Color.RED);
northPane.add(label);
contentPane.add(northPane);
}
private void initFieldListener() {
shortcutsField.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
shortcutsField.selectAll();
}
});
shortcutsField.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
@ -112,11 +127,9 @@ public class AlphaFineConfigPane extends BasicPane {
shortCutKeyStore = KeyStroke.getKeyStroke(keyCode, modifier);
String str = shortCutKeyStore.toString();
shortcutsField.setText(getDisplayShortCut(str));
shortcutsField.selectAll();
}
});
northPane.add(new UILabel(Inter.getLocText("FR-Designer_Open") + ":"));
northPane.add(shortcutsField);
contentPane.add(northPane);
}
private void createOnlinePane(JPanel contentPane) {

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

@ -2085,3 +2085,4 @@ FR-Designer-Plugin-Store_Disconnected=
FR-Designer_AlphaFine_NoResult=no results
FR-Designer_ConnectionFailed=connection failed
FR-Designer_NoResult=No results
FR-Designer-AlphaFine_SetShortcuts=

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

@ -2085,3 +2085,4 @@ FR-Designer_ConnectionFailed=Connection failed
FR-Designer_AlphaFine_EnableAlphaFine=Enable AlphaFine
FR-Designer_AlphaFine_EnableInternet=Internet
FR-Designer_NoResult=No results
FR-Designer-AlphaFine_SetShortcuts=please press two key to set shortcut

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

@ -2082,4 +2082,4 @@ FR-Designer-Plugin-Store_Disconnected=\u65E0\u6CD5\u8FDE\u63A5\u5E94\u7528\u4E2D
FR-Designer_AlphaFine_NoResult=\u6682\u65E0\u76F8\u5173\u5185\u5BB9
FR-Designer_ConnectionFailed=\u94FE\u63A5\u5931\u8D25
FR-Designer_NoResult=\u6682\u4E0D\u652F\u6301\u663E\u793A
>>>>>>> d2de164e77196e797f514ec75b52974b32b99ac5
FR-Designer-AlphaFine_SetShortcuts=\u8BF7\u76F4\u63A5\u5728\u952E\u76D8\u4E0A\u6309\u4E24\u4E2A\u7EC4\u5408\u952E

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

@ -2083,3 +2083,4 @@ FR-Designer-Plugin-Store_Disconnected=
FR-Designer_AlphaFine_NoResult=\u66AB\u7121\u76F8\u95DC\u5167\u5BB9
FR-Designer_ConnectionFailed=\u93C8\u63A5\u5931\u6557
FR-Designer_NoResult=\u66AB\u4E0D\u652F\u6301\u986F\u793A
FR-Designer-AlphaFine_SetShortcuts=\u8ACB\u76F4\u63A5\u5728\u9375\u76E4\u4E0A\u6309\u5169\u500B\u7D44\u5408\u9375

Loading…
Cancel
Save