From 5c61c160c4225eac2e9e2bf584c93752239298d1 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 11 May 2017 10:16:47 +0800 Subject: [PATCH 1/6] rt --- .../alphafine/AlphaFineConstants.java | 4 ++++ .../previewPane/PluginPreviewPane.java | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java index 15c9055d7..c8604ed40 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java @@ -45,6 +45,10 @@ public class AlphaFineConstants { public static final Color BLACK = new Color(0x222222); + public static final Color DARK_GRAY = new Color(0x666666); + + public static final Color RED = new Color(0xf46c4c); + public static final Font SMALL_FONT = new Font("Song_TypeFace",0,10); public static final Font MEDIUM_FONT = new Font("Song_TypeFace",0,12); diff --git a/designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java b/designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java index 784fa5c37..b6ec50c31 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.alphafine.previewPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.general.Inter; @@ -26,7 +27,7 @@ public class PluginPreviewPane extends JPanel { nameLabel.setHorizontalAlignment(SwingConstants.CENTER); JPanel line = new JPanel(); line.setPreferredSize(new Dimension(200,1)); - line.setBackground(new Color(0xd2d2d2)); + line.setBackground(AlphaFineConstants.GRAY); JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.white); JPanel bottomPane = new JPanel(new BorderLayout()); @@ -36,26 +37,26 @@ public class PluginPreviewPane extends JPanel { UILabel versionLabel = new UILabel("V" + version); versionLabel.setHorizontalAlignment(SwingConstants.CENTER); versionLabel.setBorder(BorderFactory.createEmptyBorder(0,0,10,0)); - versionLabel.setForeground(new Color(0x666666)); - versionLabel.setFont(new Font("Song_TypeFace",0,12)); + versionLabel.setForeground(AlphaFineConstants.DARK_GRAY); + versionLabel.setFont(AlphaFineConstants.MEDIUM_FONT); panel.add(versionLabel, BorderLayout.CENTER); UILabel jartimeLabel = new UILabel(jartime.substring(0, 10)); - jartimeLabel.setForeground(new Color(0x222222)); - jartimeLabel.setFont(new Font("Song_TypeFace",0,12)); + jartimeLabel.setForeground(AlphaFineConstants.BLACK); + jartimeLabel.setFont(AlphaFineConstants.MEDIUM_FONT); bottomPane.add(jartimeLabel, BorderLayout.EAST); } nameLabel.setFont(new Font("Song_TypeFace",0,18)); - nameLabel.setBackground(new Color(0x3394f0)); + nameLabel.setBackground(AlphaFineConstants.BLUE); nameLabel.setBorder(BorderFactory.createEmptyBorder(20,20,10,20)); line.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0)); String price0 = price == 0 ? Inter.getLocText("FR-Designer-Collect_Information_free") : String.valueOf(price); UILabel priceLabel = new UILabel(price0); - priceLabel.setForeground(new Color(0xf46c4c)); - priceLabel.setFont(new Font("Song_TypeFace",0,10)); + priceLabel.setForeground(AlphaFineConstants.RED); + priceLabel.setFont(AlphaFineConstants.SMALL_FONT); bottomPane.add(priceLabel, BorderLayout.WEST); panel.add(nameLabel, BorderLayout.NORTH); panel.add(line, BorderLayout.SOUTH); - nameLabel.setForeground(new Color(0x3394f0)); + nameLabel.setForeground(AlphaFineConstants.BLUE); add(imageLabel, BorderLayout.NORTH); add(panel, BorderLayout.CENTER); add(bottomPane, BorderLayout.SOUTH); From 200bedcc9a137b3fde3d7e77d62d338e79c78cb6 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 11 May 2017 10:25:14 +0800 Subject: [PATCH 2/6] rt --- .../alphafine/cell/cellRender/ContentCellRender.java | 4 ++-- .../mainframe/alphafine/previewPane/PluginPreviewPane.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java index cf3c16573..b5cf24d25 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java @@ -27,7 +27,7 @@ public class ContentCellRender implements ListCellRenderer { JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.white); if (isSelected) { - panel.setBackground(new Color(0x3394f0)); + panel.setBackground(AlphaFineConstants.BLUE); } panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0)); AlphaCellModel model = (AlphaCellModel) value; @@ -35,7 +35,7 @@ public class ContentCellRender implements ListCellRenderer { String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getCellType() + ".png"; name.setIcon(new ImageIcon(getClass().getResource(iconUrl))); name.setFont(AlphaFineConstants.MEDIUM_FONT); - name.setForeground(new Color(0x222222)); + name.setForeground(AlphaFineConstants.BLACK); name.setVerticalTextPosition(SwingConstants.CENTER); name.setHorizontalTextPosition(SwingConstants.RIGHT); if (model.getDescription() != null) { diff --git a/designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java b/designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java index b6ec50c31..5ae2f5c00 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/previewPane/PluginPreviewPane.java @@ -45,7 +45,7 @@ public class PluginPreviewPane extends JPanel { jartimeLabel.setFont(AlphaFineConstants.MEDIUM_FONT); bottomPane.add(jartimeLabel, BorderLayout.EAST); } - nameLabel.setFont(new Font("Song_TypeFace",0,18)); + nameLabel.setFont(AlphaFineConstants.LARGE_FONT); nameLabel.setBackground(AlphaFineConstants.BLUE); nameLabel.setBorder(BorderFactory.createEmptyBorder(20,20,10,20)); line.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0)); From 2475c5e55351d47b4beba9b08ab814cbc8f690c0 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 11 May 2017 10:31:55 +0800 Subject: [PATCH 3/6] rt --- .../fr/design/mainframe/alphafine/AlphaFineConstants.java | 4 ++++ .../alphafine/cell/cellRender/ContentCellRender.java | 2 +- .../alphafine/cell/cellRender/TitleCellRender.java | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java index c8604ed40..dd4aadcbc 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java @@ -39,8 +39,12 @@ public class AlphaFineConstants { public static final Dimension CLOSE_BUTTON_SIZE = new Dimension(40, 40); + public static final Color WHITE = new Color(0xf9f9f9); + public static final Color GRAY = new Color(0xd2d2d2); + public static final Color LIGHT_GRAY = new Color(0xcccccc); + public static final Color BLUE = new Color(0x3394f0); public static final Color BLACK = new Color(0x222222); diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java index b5cf24d25..6f9a967cb 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java @@ -40,7 +40,7 @@ public class ContentCellRender implements ListCellRenderer { name.setHorizontalTextPosition(SwingConstants.RIGHT); if (model.getDescription() != null) { content.setText("-" + model.getDescription()); - content.setForeground(new Color(0xcccccc)); + content.setForeground(AlphaFineConstants.LIGHT_GRAY); panel.add(content, BorderLayout.CENTER); } panel.add(name, BorderLayout.WEST); diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/TitleCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/TitleCellRender.java index 1c0c3e159..9e401de49 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/TitleCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/TitleCellRender.java @@ -21,14 +21,14 @@ public class TitleCellRender implements ListCellRenderer { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { MoreModel moreModel = (MoreModel)value; JPanel panel = new JPanel(new BorderLayout()); - panel.setBackground(new Color(0xf9f9f9)); + 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(new Color(0x666666)); - more.setForeground(new Color(0x666666)); + name.setForeground(AlphaFineConstants.DARK_GRAY); + more.setForeground(AlphaFineConstants.DARK_GRAY); panel.add(name, BorderLayout.WEST); if (moreModel.isNeedMore()) { this.more.setBorder(BorderFactory.createEmptyBorder(0,0,0,10)); From c473346c9271fdcf4c540553021fee2131b73da8 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 11 May 2017 11:52:33 +0800 Subject: [PATCH 4/6] rt --- .../alphafine/component/AlphaFineDialog.java | 5 +-- ...TextField.java => AlphaFineTextField.java} | 31 +++++++++++++++---- .../AlphaFine/AlphafineConfigManager.java | 2 +- 3 files changed, 29 insertions(+), 9 deletions(-) rename designer/src/com/fr/design/mainframe/alphafine/component/{AlphaTextField.java => AlphaFineTextField.java} (58%) 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 868b8bcd8..0951faf64 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 acda5f907..9cee39ee7 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 19e20031f..4074429c0 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"; /** * 搜索范围 From cb2d8a6303389563e2e7f53fb5c3a7d84b776c19 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 11 May 2017 15:13:17 +0800 Subject: [PATCH 5/6] RT --- .../help/AlphaFine/AlphafineConfigManager.java | 17 +++++++++++++---- .../help/AlphaFine/AlphafineConfigPane.java | 9 +++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) 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 4074429c0..0dd4d9117 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 @@ -1,6 +1,7 @@ package com.fr.design.actions.help.AlphaFine; import com.fr.stable.OperatingSystem; +import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; @@ -11,6 +12,7 @@ import javax.swing.*; * Created by XiaXiang on 2017/4/5. */ public class AlphafineConfigManager implements XMLable { + /** * 是否开启alphafine */ @@ -19,12 +21,12 @@ public class AlphafineConfigManager implements XMLable { /** * 是否联网搜索 */ - private boolean isSearchOnLine; + private boolean isSearchOnLine = true; /** * 快捷键设置 */ - private String shortcuts = OperatingSystem.isMacOS()? "meta + F" : "ctr + F"; + private String shortcuts; /** * 搜索范围 @@ -43,7 +45,7 @@ public class AlphafineConfigManager implements XMLable { /** * 帮助文档 */ - private boolean isContainDocument; + private boolean isContainDocument = true; /** * 模板 @@ -58,7 +60,7 @@ public class AlphafineConfigManager implements XMLable { /** * 应用中心 */ - private boolean isContainPlugin; + private boolean isContainPlugin = true; /** * 快捷键 @@ -122,9 +124,16 @@ public class AlphafineConfigManager implements XMLable { } public String getShortcuts() { + if (StringUtils.isBlank(shortcuts)) { + return getDefaultShortCuts(); + } return shortcuts; } + private String getDefaultShortCuts() { + return OperatingSystem.isMacOS()? "meta + F" : "ctrl + F"; + } + public void setShortcuts(String shortcuts) { this.shortcuts = shortcuts; this.shortCutKeyStore = convert2KeyStroke(this.shortcuts); diff --git a/designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigPane.java b/designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigPane.java index d2f774532..45e712771 100644 --- a/designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigPane.java +++ b/designer_base/src/com/fr/design/actions/help/AlphaFine/AlphafineConfigPane.java @@ -45,6 +45,11 @@ public class AlphafineConfigPane extends BasicPane { private static final String DISPLAY_EQUALS = "+"; private static final String MINUS = "MINUS"; private static final String DISPLAY_MINUS = "-"; + private static final String COMMAND = "META"; + private static final String SMALL_COMMAND = "meta"; + private static final String DISPLAY_COMMAND = "\u2318"; + + private static final double COLUMN_GAP = 180; private static final double ROW_GAP = 25; private KeyStroke shortCutKeyStore = null; @@ -160,7 +165,7 @@ public class AlphafineConfigPane extends BasicPane { this.isContainPluginCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine()); this.isContainConcludeCheckbox.setSelected(alphafineConfigManager.isContainConclude() && alphafineConfigManager.isSearchOnLine()); this.isContainConcludeCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine()); - this.shortcutsField.setText(alphafineConfigManager.getShortcuts()); + this.shortcutsField.setText(getDisplayShortCut(alphafineConfigManager.getShortcuts())); shortCutKeyStore = convert2KeyStroke(alphafineConfigManager.getShortcuts()); } @@ -191,7 +196,7 @@ public class AlphafineConfigPane extends BasicPane { return shotrCut.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(COMMA, DISPLAY_COMMA).replace(PERIOD, DISPLAY_PERIOD).replace(SEMICOLON, DISPLAY_SEMICOLON).replace(QUOTE, DISPLAY_QUOTE) - .replace(EQUALS, DISPLAY_EQUALS).replace(MINUS, DISPLAY_MINUS); + .replace(EQUALS, DISPLAY_EQUALS).replace(MINUS, DISPLAY_MINUS).replace(COMMAND, DISPLAY_COMMAND).replace(SMALL_COMMAND, DISPLAY_COMMAND); } From fc3fbcbd37c9f912a76f7a3f599c510908475358 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 11 May 2017 15:21:32 +0800 Subject: [PATCH 6/6] rt --- .../mainframe/alphafine/component/AlphaFineTextField.java | 4 ++++ .../design/actions/help/AlphaFine/AlphafineConfigManager.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java index 9cee39ee7..715d3ccb6 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java @@ -62,6 +62,10 @@ public class AlphaFineTextField extends UITextField { this.image = image; } + /** + * 添加键盘监听器 + * @param component + */ public void initKeyListener(Component component) { addKeyListener(new KeyAdapter() { @Override 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 0dd4d9117..be1ff3386 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 @@ -130,6 +130,10 @@ public class AlphafineConfigManager implements XMLable { return shortcuts; } + /** + * 返回默认快捷键 + * @return + */ private String getDefaultShortCuts() { return OperatingSystem.isMacOS()? "meta + F" : "ctrl + F"; }