diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 868b8bcd89..0951faf64e 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -50,7 +50,7 @@ import java.util.concurrent.ExecutionException; * Created by XiaXiang on 2017/3/21. */ public class AlphaFineDialog extends UIDialog { - private AlphaTextField searchTextField; + private AlphaFineTextField searchTextField; private UIButton closeButton; private JPanel searchResultPane; private Point pressedPoint; @@ -68,10 +68,11 @@ public class AlphaFineDialog extends UIDialog { } private void initComponents() { - searchTextField = new AlphaTextField("AlphaFine"); + 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(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png"))); iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE); diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaTextField.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java similarity index 58% rename from designer/src/com/fr/design/mainframe/alphafine/component/AlphaTextField.java rename to designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java index acda5f9073..9cee39ee7a 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaTextField.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java @@ -1,27 +1,30 @@ 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.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionAdapter; +import java.awt.event.*; + +import static java.awt.event.KeyEvent.VK_ESCAPE; /** * Created by XiaXiang on 2017/3/21. */ -public class AlphaTextField extends UITextField { +public class AlphaFineTextField extends UITextField { private String placeHolder; private Image image; - public AlphaTextField(String placeHolder) { + public AlphaFineTextField(String placeHolder) { this.placeHolder = placeHolder; } - public AlphaTextField() { + + public AlphaFineTextField() { this.placeHolder = null; } @@ -59,4 +62,20 @@ public class AlphaTextField extends UITextField { this.image = image; } + public void initKeyListener(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); + } + } + } + }); + } } diff --git a/designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigManager.java b/designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigManager.java index 19e20031f3..4074429c00 100644 --- a/designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigManager.java +++ b/designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigManager.java @@ -24,7 +24,7 @@ public class AlphafineConfigManager implements XMLable { /** * 快捷键设置 */ - private String shortcuts = "meta + F"; + private String shortcuts = OperatingSystem.isMacOS()? "meta + F" : "ctr + F"; /** * 搜索范围