Browse Source

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

* commit '6849e004d304dac47b7de7b26a56b91c6698b2f0':
  bug fix
  bug fix 键盘选择问题修复
master
superman 8 years ago
parent
commit
1dc5e09fef
  1. 7
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  2. 45
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  3. 28
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java
  4. BIN
      designer/src/com/fr/design/mainframe/alphafine/images/remind.png

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

@ -6,6 +6,7 @@ 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.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.RecommendSearchManager;
import com.fr.general.Inter;
@ -81,8 +82,10 @@ public class AlphaFineHelper {
public static List<AlphaCellModel> getFilterResult() {
List<AlphaCellModel> recentList = RecentSearchManager.getRecentSearchManger().getRecentModelList();
List<AlphaCellModel> recommendList = RecommendSearchManager.getRecommendSearchManager().getRecommendModelList();
recentList.addAll(recommendList);
return recentList;
SearchResult filterResult = new SearchResult();
filterResult.addAll(recentList);
filterResult.addAll(recommendList);
return filterResult;
}

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

@ -127,11 +127,7 @@ public class AlphaFineDialog extends UIDialog {
* 初始化全部组件
*/
private void initComponents() {
searchTextField = new AlphaFineTextField("AlphaFine");
searchTextField.setFont(AlphaFineConstants.GREATER_FONT);
searchTextField.setBackground(Color.white);
searchTextField.setBorderPainted(false);
searchTextField.initKeyListener(this);
initSearchTextField();
JPanel topPane = new JPanel(new BorderLayout());
UILabel iconLabel = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png")));
iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE);
@ -171,6 +167,17 @@ public class AlphaFineDialog extends UIDialog {
});
}
/**
* 初始化输入框
*/
private void initSearchTextField() {
searchTextField = new AlphaFineTextField("AlphaFine");
initTextFieldKeyListener();
searchTextField.setFont(AlphaFineConstants.GREATER_FONT);
searchTextField.setBackground(Color.white);
searchTextField.setBorderPainted(false);
}
/**
*
*/
@ -249,7 +256,6 @@ public class AlphaFineDialog extends UIDialog {
private void showSearchResult() {
if (searchResultPane == null) {
initSearchResultComponents();
initTextFieldKeyListener();
}
initSearchWorker();
}
@ -580,18 +586,36 @@ public class AlphaFineDialog extends UIDialog {
initMouseListener();
}
/**
* 为textfield添加键盘监听器
*/
private void initTextFieldKeyListener() {
/**
* 为textField添加键盘监听器按上下方向键时把焦点给list,实现键盘操作
*/
searchTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
searchResultList.requestFocus();
searchResultList.setSelectedIndex(searchResultList.getSelectedIndex() + 1);
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
doNavigate();
saveHistory(searchResultList.getSelectedValue());
}
}
@Override
public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_ESCAPE) {
if (StringUtils.isBlank(searchTextField.getText()) || ComparatorUtils.equals(searchTextField.getText(), searchTextField.getPlaceHolder())) {
AlphaFineDialog.this.setVisible(false);
} else {
searchTextField.setText(null);
}
}
}
});
}
/**
@ -709,11 +733,11 @@ public class AlphaFineDialog extends UIDialog {
para.put("token", CodeUtils.md5Encode(date, "", "MD5"));
para.put("content", object.toString());
HttpClient httpClient = new HttpClient(AlphaFineConstants.CLOUD_SERVER_URL, para, true);
httpClient.setTimeout(5000);
httpClient.asGet();
if (!httpClient.isServerAlive()) {
FRLogger.getLogger().error("Failed to sent data to server!");
}
httpClient.setTimeout(5000);
}
@ -826,6 +850,7 @@ public class AlphaFineDialog extends UIDialog {
}
}
showResult(getSelectedValue());
ensureIndexIsVisible(getSelectedIndex());
}

28
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java

@ -1,15 +1,9 @@
package com.fr.design.mainframe.alphafine.component;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.general.ComparatorUtils;
import com.fr.report.web.button.Image;
import com.fr.stable.StringUtils;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import static java.awt.event.KeyEvent.VK_ESCAPE;
/**
* Created by XiaXiang on 2017/3/21.
@ -63,25 +57,7 @@ public class AlphaFineTextField extends UITextField {
this.image = image;
}
/**
* 添加键盘监听器
*
* @param component
*/
public void initKeyListener(final Component component) {
addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == VK_ESCAPE) {
if (StringUtils.isBlank(getText()) || ComparatorUtils.equals(getText(), placeHolder)) {
component.setVisible(false);
} else {
setText(null);
}
}
}
});
public String getPlaceHolder() {
return placeHolder;
}
}

BIN
designer/src/com/fr/design/mainframe/alphafine/images/remind.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Loading…
Cancel
Save