diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java index 5d91ef5ccc..c0ca472c60 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java @@ -57,21 +57,13 @@ public class AlphaFineConstants { 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); - - public static final Font LARGE_FONT = new Font("Song_TypeFace",0,18); - - public static final Font GREATER_FONT = new Font("Song_TypeFace",0,20); - - - - - + public static final Font SMALL_FONT = new Font("Song_TypeFace", 0, 10); + public static final Font MEDIUM_FONT = new Font("Song_TypeFace", 0, 12); + public static final Font LARGE_FONT = new Font("Song_TypeFace", 0, 18); + public static final Font GREATER_FONT = new Font("Song_TypeFace", 0, 20); public static final String PLUGIN_SEARCH_URL = SiteCenter.getInstance().acquireUrlByKind("plugin.searchAPI"); diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index c294218dc7..0e36d371db 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -12,7 +12,6 @@ import com.fr.general.Inter; import com.fr.general.ProcessCanceledException; import com.fr.stable.StringUtils; - import java.util.List; /** @@ -35,15 +34,17 @@ public class AlphaFineHelper { /** * 获取文件名上级目录 + * * @param text * @return */ - public static String findFolderName (String text) { + public static String findFolderName(String text) { return getSplitText(text, 2); } /** * 分割字符串,获取文件名,文件名上级目录等 + * * @param text * @param index * @return @@ -60,10 +61,11 @@ public class AlphaFineHelper { /** * 获取文件名 + * * @param text * @return */ - public static String findFileName (String text) { + public static String findFileName(String text) { return getSplitText(text, 1); } @@ -84,6 +86,4 @@ public class AlphaFineHelper { } - - } diff --git a/designer/src/com/fr/design/mainframe/alphafine/CellType.java b/designer/src/com/fr/design/mainframe/alphafine/CellType.java index d196a01388..23c6cc6998 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/CellType.java +++ b/designer/src/com/fr/design/mainframe/alphafine/CellType.java @@ -21,6 +21,7 @@ public enum CellType { return FILE; } + public int getTypeValue() { return typeValue; } diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java b/designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java index e8380cb816..52a8fafd4b 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.cell; import com.fr.design.mainframe.alphafine.CellType; -import com.fr.design.mainframe.alphafine.cell.model.*; +import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.search.manager.ActionSearchManager; import com.fr.design.mainframe.alphafine.search.manager.DocumentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.FileSearchManager; @@ -13,6 +13,7 @@ import com.fr.json.JSONObject; */ public class CellModelHelper { private static final String RESULT = "result"; + public static AlphaCellModel getModelFromJson(JSONObject object) { int typeValue = object.optInt("cellType"); AlphaCellModel cellModel = null; diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java b/designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java index 12b19fe12b..2850e01568 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java @@ -19,6 +19,12 @@ public class ActionModel extends AlphaCellModel { super(name, content, type); } + public ActionModel(String name, String description, Action action) { + super(name, null, CellType.ACTION); + this.action = action; + this.setDescription(description); + } + @Override public boolean equals(Object o) { if (this == o) { @@ -37,12 +43,6 @@ public class ActionModel extends AlphaCellModel { return action != null ? action.hashCode() : 0; } - public ActionModel(String name, String description, Action action) { - super(name, null, CellType.ACTION); - this.action = action; - this.setDescription(description); - } - public Action getAction() { return action; } diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java b/designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java index 082f1f8e72..5241fee0e8 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/model/AlphaCellModel.java @@ -62,6 +62,7 @@ public abstract class AlphaCellModel { /** * model转json + * * @return * @throws JSONException */ @@ -69,6 +70,7 @@ public abstract class AlphaCellModel { /** * 获取需要保存到云中心的信息 + * * @return */ abstract public String getStoreInformation(); diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java b/designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java index 6961962b72..3d5289cca3 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/model/FileModel.java @@ -9,7 +9,7 @@ import com.fr.json.JSONObject; /** * Created by XiaXiang on 2017/4/20. */ -public class FileModel extends AlphaCellModel{ +public class FileModel extends AlphaCellModel { private String filePath; public FileModel(String name, String content, CellType type) { diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java b/designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java index de9b4fd2e5..79281d04d1 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java @@ -29,6 +29,7 @@ public class MoreModel { this.name = name; this.isLoading = true; } + public MoreModel(String name, boolean isLoading) { this.name = name; this.isLoading = isLoading; diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java b/designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java index c8c4d65dc2..dce1dd2816 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java @@ -10,6 +10,8 @@ import com.fr.json.JSONObject; * Created by XiaXiang on 2017/4/20. */ public class PluginModel extends AlphaCellModel { + private static final String PLUGIN_INFORMATION_URL = "http://shop.finereport.com/ShopServer?pg=plugin&pid="; + private static final String REUSE_INFORMATION_URL = "http://shop.finereport.com/reuses/"; private String pluginUrl; private String imageUrl; private String version; @@ -18,12 +20,11 @@ public class PluginModel extends AlphaCellModel { private String informationUrl; private int pluginId; private int price; - private static final String PLUGIN_INFORMATION_URL = "http://shop.finereport.com/ShopServer?pg=plugin&pid="; - private static final String REUSE_INFORMATION_URL = "http://shop.finereport.com/reuses/"; 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) { super(name, content); this.link = link; @@ -130,7 +131,6 @@ public class PluginModel extends AlphaCellModel { } - public int getPluginId() { return pluginId; } diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java index 3380d092bf..98dd3abb4f 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java @@ -16,6 +16,7 @@ import java.awt.*; public class ContentCellRender implements ListCellRenderer { private UILabel name; private UILabel content; + public ContentCellRender() { this.name = new UILabel(); this.content = new UILabel(); @@ -24,14 +25,14 @@ public class ContentCellRender implements ListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof MoreModel) { - return new TitleCellRender().getListCellRendererComponent(list, value,index,isSelected,cellHasFocus); + return new TitleCellRender().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.white); if (isSelected) { panel.setBackground(AlphaFineConstants.BLUE); } - panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0)); + panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); AlphaCellModel model = (AlphaCellModel) value; name.setText(model.getName()); String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png"; diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java index 84784ecdb3..a03b68a6e6 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java @@ -3,6 +3,7 @@ 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.cell.model.MoreModel; + import javax.swing.*; import java.awt.*; @@ -17,12 +18,13 @@ public class TitleCellRender implements ListCellRenderer { this.name = new UILabel(); this.more = new UILabel(); } + @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - MoreModel moreModel = (MoreModel)value; + MoreModel moreModel = (MoreModel) value; JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(AlphaFineConstants.WHITE); - panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0)); + panel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); name.setText(moreModel.getName()); name.setFont(AlphaFineConstants.SMALL_FONT); more.setFont(AlphaFineConstants.SMALL_FONT); @@ -31,7 +33,7 @@ public class TitleCellRender implements ListCellRenderer { more.setForeground(AlphaFineConstants.DARK_GRAY); panel.add(name, BorderLayout.WEST); if (moreModel.isNeedMore()) { - this.more.setBorder(BorderFactory.createEmptyBorder(0,0,0,10)); + this.more.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); panel.add(this.more, BorderLayout.EAST); } if (moreModel.isLoading()) { 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 eb986cb131..42336a9c88 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -59,18 +59,6 @@ import java.util.concurrent.ExecutionException; * Created by XiaXiang on 2017/3/21. */ public class AlphaFineDialog extends UIDialog { - private AlphaFineTextField searchTextField; - private UIButton closeButton; - private JPanel searchResultPane; - private Point pressedPoint; - private UIScrollPane leftSearchResultPane; - private JPanel rightSearchResultPane; - private JList searchResultList; - private SearchListModel searchListModel; - private SwingWorker searchWorker; - //是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 - private boolean forceOpen; - 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 "; @@ -83,6 +71,17 @@ public class AlphaFineDialog extends UIDialog { 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; + private UIButton closeButton; + private JPanel searchResultPane; + private Point pressedPoint; + private UIScrollPane leftSearchResultPane; + private JPanel rightSearchResultPane; + private JList searchResultList; + private SearchListModel searchListModel; + private SwingWorker searchWorker; + //是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 + private boolean forceOpen; public AlphaFineDialog(Frame parent, boolean forceOpen) { @@ -93,6 +92,32 @@ public class AlphaFineDialog extends UIDialog { 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); + KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore(); + if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) { + doClickAction(); + } + + } + } + }; + } + + private static void doClickAction() { + AlphaFineHelper.showAlphaFineDialog(false); + } /** * 初始化全部组件 @@ -113,7 +138,7 @@ public class AlphaFineDialog extends UIDialog { closeButton = new UIButton() { @Override public void paintComponent(Graphics g) { - g.setColor( Color.white ); + g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); super.paintComponent(g); } @@ -155,6 +180,7 @@ public class AlphaFineDialog extends UIDialog { /** * 设置面板位置 + * * @param win */ private void centerWindow(Window win) { @@ -169,11 +195,24 @@ public class AlphaFineDialog extends UIDialog { winSize.width = screenSize.width; } //这里设置位置:水平居中,竖直偏上 - win.setLocation((screenSize.width - winSize.width ) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE); + 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.dispose(); +// } + /** * 执行搜索 + * * @param text */ private void doSearch(String text) { @@ -181,7 +220,7 @@ public class AlphaFineDialog extends UIDialog { if (StringUtils.isBlank(text) || text.equals("AlphaFine")) { removeSearchResult(); } else if (text.contains("'")) { - return; + return; } else { showSearchResult(); } @@ -200,19 +239,6 @@ public class AlphaFineDialog extends UIDialog { repaint(); } - // 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.dispose(); -// } - - /** * 展示搜索结果 */ @@ -239,7 +265,7 @@ public class AlphaFineDialog extends UIDialog { leftSearchResultPane = new UIScrollPane(searchResultList); leftSearchResultPane.setBackground(Color.white); - leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); + leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); leftSearchResultPane.setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT)); rightSearchResultPane = new JPanel(); rightSearchResultPane.setBackground(Color.white); @@ -279,6 +305,7 @@ public class AlphaFineDialog extends UIDialog { /** * 重新构建搜索结果列表 * 先根据输入判断是不是隐藏的搜索功能 + * * @param searchText */ private void rebuildList(String searchText) { @@ -311,6 +338,7 @@ public class AlphaFineDialog extends UIDialog { /** * 普通搜索 + * * @param searchText */ private void doNormalSearch(String searchText) { @@ -322,7 +350,6 @@ public class AlphaFineDialog extends UIDialog { getPluginList(searchText); } - private synchronized void getDocumentList(final String searchText) { SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); for (Object object : documentModelList) { @@ -373,7 +400,6 @@ public class AlphaFineDialog extends UIDialog { } - /** * 初始化监听器 */ @@ -567,7 +593,7 @@ public class AlphaFineDialog extends UIDialog { private void showDefaultPreviewPane() { rightSearchResultPane.removeAll(); UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif"))); - label.setBorder(BorderFactory.createEmptyBorder(120,0,0,0)); + label.setBorder(BorderFactory.createEmptyBorder(120, 0, 0, 0)); rightSearchResultPane.add(label, BorderLayout.CENTER); validate(); repaint(); @@ -642,36 +668,9 @@ public class AlphaFineDialog extends UIDialog { } } } - }, AWTEvent.MOUSE_EVENT_MASK|AWTEvent.KEY_EVENT_MASK); + }, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK); } - /** - * 全局快捷键 - * @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); - KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore(); - if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) { - doClickAction(); - } - - } - } - }; - } - - private static void doClickAction() { - AlphaFineHelper.showAlphaFineDialog(false); - } - - @Override public void checkValid() throws Exception { @@ -683,7 +682,7 @@ public class AlphaFineDialog extends UIDialog { if (value instanceof ActionModel) { ((ActionModel) value).getAction().actionPerformed(null); } else if (value instanceof FileModel) { - DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(((FileModel)value).getFilePath(), false))); + DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(((FileModel) value).getFilePath(), false))); } else if (value instanceof PluginModel) { String url = ((PluginModel) value).getPluginUrl(); try { @@ -709,6 +708,7 @@ public class AlphaFineDialog extends UIDialog { /** * 保存本地(本地常用) + * * @param cellModel */ private void saveHistory(AlphaCellModel cellModel) { @@ -722,6 +722,7 @@ public class AlphaFineDialog extends UIDialog { /** * 上传数据到服务器 + * * @param searchKey * @param cellModel */ @@ -754,12 +755,13 @@ public class AlphaFineDialog extends UIDialog { /** * 点击显示更多时,添加对应的model到list;点击收起是移除model + * * @param index * @param selectedValue */ private void rebuildShowMoreList(int index, MoreModel 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++) { this.searchListModel.add(index + AlphaFineConstants.SHOW_SIZE + 1 + i, moreResult.get(i)); } diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java index e5ea8e2588..0aab6a7d4d 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java @@ -20,12 +20,6 @@ import java.awt.event.ActionListener; public class AlphaFinePane extends BasicPane { private static AlphaFinePane alphaFinePane; - public static AlphaFinePane getAlphaFinePane() { - if (alphaFinePane == null) { - alphaFinePane = new AlphaFinePane(); - } - return alphaFinePane; - } public AlphaFinePane() { setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 14)); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { @@ -56,6 +50,13 @@ public class AlphaFinePane extends BasicPane { }); } + public static AlphaFinePane getAlphaFinePane() { + if (alphaFinePane == null) { + alphaFinePane = new AlphaFinePane(); + } + return alphaFinePane; + } + @Override protected String title4PopupWindow() { return "AlphaFine"; 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 a1ef67df53..f75f9dec57 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java @@ -6,7 +6,8 @@ import com.fr.report.web.button.Image; import com.fr.stable.StringUtils; import java.awt.*; -import java.awt.event.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import static java.awt.event.KeyEvent.VK_ESCAPE; @@ -64,6 +65,7 @@ public class AlphaFineTextField extends UITextField { /** * 添加键盘监听器 + * * @param component */ public void initKeyListener(final Component component) { diff --git a/designer/src/com/fr/design/mainframe/alphafine/listener/DocumentAdapter.java b/designer/src/com/fr/design/mainframe/alphafine/listener/DocumentAdapter.java index 086fd70348..a34ae9f7ae 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/listener/DocumentAdapter.java +++ b/designer/src/com/fr/design/mainframe/alphafine/listener/DocumentAdapter.java @@ -25,17 +25,17 @@ public abstract class DocumentAdapter implements DocumentListener { @Override public void insertUpdate(DocumentEvent e) { - textChanged(e); + textChanged(e); } @Override public void removeUpdate(DocumentEvent e) { - textChanged(e); + textChanged(e); } @Override public void changedUpdate(DocumentEvent e) { - textChanged(e); + textChanged(e); } protected abstract void textChanged(DocumentEvent e); diff --git a/designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java b/designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java index 2f3dd48c0f..05eb401de1 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java @@ -8,7 +8,7 @@ import javax.swing.*; public class SearchListModel extends DefaultListModel { SearchResult myDelegate; - public SearchListModel( SearchResult searchResult) { + public SearchListModel(SearchResult searchResult) { this.myDelegate = searchResult; } diff --git a/designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java b/designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java index 9efb2d59c3..523ead7e03 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java +++ b/designer/src/com/fr/design/mainframe/alphafine/model/SearchResult.java @@ -9,7 +9,6 @@ public class SearchResult extends ArrayList { private boolean needMore; - public boolean isNeedMore() { return needMore; } diff --git a/designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java b/designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java index 416c9512bb..c7286850f8 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java @@ -14,13 +14,14 @@ import java.awt.*; * Created by XiaXiang on 2017/5/5. */ public class ActionPreviewPane extends JPanel { - private static final Font NAME = new Font("Song_TypeFace",0,14); + private static final Font NAME = new Font("Song_TypeFace", 0, 14); + public ActionPreviewPane() { setLayout(new BorderLayout()); setBackground(null); - setBorder(BorderFactory.createEmptyBorder(135,0,0,0)); + setBorder(BorderFactory.createEmptyBorder(135, 0, 0, 0)); UILabel image = new UILabel(); - image.setPreferredSize(new Dimension(150,111)); + image.setPreferredSize(new Dimension(150, 111)); image.setHorizontalAlignment(SwingConstants.CENTER); image.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); image.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/noresult.png")); diff --git a/designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java b/designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java index 8464a8e416..89ed813872 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java @@ -20,7 +20,7 @@ public class DocumentPreviewPane extends JPanel { UITextArea contentArea = new UITextArea(summary); titleArea.setOpaque(false); contentArea.setOpaque(false); - titleArea.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); + titleArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); titleArea.setForeground(AlphaFineConstants.BLUE); contentArea.setForeground(AlphaFineConstants.BLACK); titleArea.setPreferredSize(new Dimension(360, 30)); diff --git a/designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java b/designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java index 6b8af31cbf..5df3b8ac2e 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java @@ -15,7 +15,7 @@ import java.awt.*; public class PluginPreviewPane extends JPanel { public PluginPreviewPane(String title, Image image, String version, String jartime, CellType type, int price) { setLayout(new BorderLayout()); - setBorder(BorderFactory.createEmptyBorder(50,0,0,0)); + setBorder(BorderFactory.createEmptyBorder(50, 0, 0, 0)); setBackground(Color.white); UILabel imageLabel = new UILabel(); image = image.getScaledInstance(200, 200, Image.SCALE_SMOOTH); @@ -26,17 +26,17 @@ public class PluginPreviewPane extends JPanel { nameLabel.setBackground(Color.yellow); nameLabel.setHorizontalAlignment(SwingConstants.CENTER); JPanel line = new JPanel(); - line.setPreferredSize(new Dimension(200,1)); + line.setPreferredSize(new Dimension(200, 1)); line.setBackground(AlphaFineConstants.GRAY); JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.white); JPanel bottomPane = new JPanel(new BorderLayout()); bottomPane.setBackground(Color.white); - bottomPane.setBorder(BorderFactory.createEmptyBorder(10,0,0,0)); + bottomPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); if (type == CellType.PLUGIN) { UILabel versionLabel = new UILabel("V" + version); versionLabel.setHorizontalAlignment(SwingConstants.CENTER); - versionLabel.setBorder(BorderFactory.createEmptyBorder(0,0,10,0)); + versionLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); versionLabel.setForeground(AlphaFineConstants.DARK_GRAY); versionLabel.setFont(AlphaFineConstants.MEDIUM_FONT); panel.add(versionLabel, BorderLayout.CENTER); @@ -47,7 +47,7 @@ public class PluginPreviewPane extends JPanel { } nameLabel.setFont(AlphaFineConstants.LARGE_FONT); nameLabel.setBackground(AlphaFineConstants.BLUE); - nameLabel.setBorder(BorderFactory.createEmptyBorder(20,20,10,20)); + 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); diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java index 928f68a3dc..c52c8b938d 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java @@ -19,11 +19,11 @@ import java.util.List; * Created by XiaXiang on 2017/3/27. */ public class ActionSearchManager implements AlphaFineSearchProcessor { + private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION); private static ActionSearchManager actionSearchManager = null; private SearchResult filterModelList; private SearchResult lessModelList; private SearchResult moreModelList; - private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION); public synchronized static ActionSearchManager getActionSearchManager() { if (actionSearchManager == null) { @@ -32,6 +32,22 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { return actionSearchManager; } + /** + * 根据类名获取对象 + * + * @param actionName + * @return + */ + public static ActionModel getModelFromCloud(String actionName) { + List updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); + for (UpdateActionModel updateActionModel : updateActions) { + if (ComparatorUtils.equals(actionName, updateActionModel.getClassName()) && updateActionModel.getAction().isEnabled()) { + return new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction()); + } + } + return null; + } + @Override public synchronized SearchResult getLessSearchResult(String searchText) { filterModelList = new SearchResult(); @@ -78,19 +94,4 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { public SearchResult getMoreSearchResult() { return moreModelList; } - - /** - * 根据类名获取对象 - * @param actionName - * @return - */ - public static ActionModel getModelFromCloud(String actionName ) { - List updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); - for (UpdateActionModel updateActionModel : updateActions) { - if (ComparatorUtils.equals(actionName, updateActionModel.getClassName()) && updateActionModel.getAction().isEnabled()) { - return new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction()); - } - } - return null; - } } diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaFineSearchProcessor.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaFineSearchProcessor.java index 26ed7c128d..df5b36c09f 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaFineSearchProcessor.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaFineSearchProcessor.java @@ -8,6 +8,7 @@ import com.fr.design.mainframe.alphafine.model.SearchResult; public interface AlphaFineSearchProcessor { /** * 获取默认显示条数 + * * @param searchText * @return */ @@ -15,6 +16,7 @@ public interface AlphaFineSearchProcessor { /** * 获取剩余条数 + * * @return */ SearchResult getMoreSearchResult(); diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java index fc10e8f9c7..b56b975aa8 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java @@ -19,10 +19,10 @@ import com.fr.stable.StringUtils; * Created by XiaXiang on 2017/3/27. */ public class DocumentSearchManager implements AlphaFineSearchProcessor { + private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT); private static DocumentSearchManager documentSearchManager = null; private SearchResult lessModelList; private SearchResult moreModelList; - private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT); public synchronized static DocumentSearchManager getDocumentSearchManager() { if (documentSearchManager == null) { @@ -32,6 +32,19 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { return documentSearchManager; } + /** + * 根据json信息获取文档model + * + * @param object + * @return + */ + public static DocumentModel getModelFromCloud(JSONObject object) { + String name = object.optString("title"); + String content = object.optString("summary"); + int documentId = object.optInt("did"); + return new DocumentModel(name, content, documentId); + } + @Override public synchronized SearchResult getLessSearchResult(String searchText) { lessModelList = new SearchResult(); @@ -71,7 +84,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { lessModelList.addAll(searchResult); } } else { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.DOCUMENT)); lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } @@ -86,6 +99,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { /** * 无连接 + * * @return */ private SearchResult getNoConnectList() { @@ -95,18 +109,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { return result; } - /** - * 根据json信息获取文档model - * @param object - * @return - */ - public static DocumentModel getModelFromCloud(JSONObject object) { - String name = object.optString("title"); - String content = object.optString("summary"); - int documentId = object.optInt("did"); - return new DocumentModel(name, content, documentId); - } - @Override public SearchResult getMoreSearchResult() { return moreModelList; diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java index cadbbe1190..569ae79367 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java @@ -4,8 +4,8 @@ import com.fr.design.DesignerEnvManager; 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.cell.model.PluginModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.design.mainframe.alphafine.cell.model.PluginModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; @@ -23,8 +23,8 @@ import java.net.URLEncoder; * Created by XiaXiang on 2017/3/27. */ public class PluginSearchManager implements AlphaFineSearchProcessor { - private static PluginSearchManager pluginSearchManager = null; private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN); + private static PluginSearchManager pluginSearchManager = null; private SearchResult lessModelList; private SearchResult moreModelList; @@ -37,6 +37,47 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { } + private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { + String name = object.optString("name"); + String content = object.optString("description"); + int pluginId = object.optInt("id"); + 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"); + } catch (UnsupportedEncodingException e) { + FRLogger.getLogger().error(e.getMessage()); + } + String version = null; + String jartime = null; + CellType type; + String link = object.optString("link"); + if (ComparatorUtils.equals(link, "plugin")) { + version = isFromCloud ? object.optString("pluginversion") : object.optString("version"); + jartime = object.optString("jartime"); + type = CellType.PLUGIN; + } else { + type = CellType.REUSE; + } + int price = object.optInt("price"); + return new PluginModel(name, content, imageUrl, version, jartime, link, type, price, pluginId); + } + + /** + * 根据json获取对应的插件model + * + * @param object + * @return + */ + public static PluginModel getModelFromCloud(JSONObject object) { + JSONObject jsonObject = object.optJSONObject("result"); + if (jsonObject != null) { + return getPluginModel(jsonObject, true); + } else { + return getPluginModel(object, false); + } + + } + @Override public synchronized SearchResult getLessSearchResult(String searchText) { this.lessModelList = new SearchResult(); @@ -76,7 +117,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { lessModelList.addAll(searchResult); } } else { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.PLUGIN)); lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } @@ -97,48 +138,8 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { return result; } - private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { - String name = object.optString("name"); - String content = object.optString("description"); - int pluginId = object.optInt("id"); - 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"); - } catch (UnsupportedEncodingException e) { - FRLogger.getLogger().error(e.getMessage()); - } - String version = null; - String jartime = null; - CellType type; - String link = object.optString("link"); - if (ComparatorUtils.equals(link, "plugin")) { - version = isFromCloud? object.optString("pluginversion") : object.optString("version"); - jartime = object.optString("jartime"); - type = CellType.PLUGIN; - } else { - type = CellType.REUSE; - } - int price = object.optInt("price"); - return new PluginModel(name, content, imageUrl, version, jartime, link, type, price, pluginId); - } - @Override public SearchResult getMoreSearchResult() { return this.moreModelList; } - - /** - * 根据json获取对应的插件model - * @param object - * @return - */ - public static PluginModel getModelFromCloud(JSONObject object) { - JSONObject jsonObject = object.optJSONObject("result"); - if (jsonObject != null) { - return getPluginModel(jsonObject, true); - } else { - return getPluginModel(object, false); - } - - } } diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java index 76de3b84e4..7e97c6ecd8 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java @@ -135,9 +135,9 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear } - /** * 获取xml + * * @return */ private File getRecentFile() { @@ -157,6 +157,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear /** * 创建XML + * * @param envFile */ private void createRecentFile(File envFile) { @@ -212,6 +213,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear /** * 根据搜索字段获取对应的model列表 + * * @param searchText * @return */ @@ -233,6 +235,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear /** * 将搜索结果加入到当前MAP中 + * * @param searchKey * @param cellModel */ diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java index 9b38f71443..053eac54e1 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java @@ -13,7 +13,6 @@ import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.stable.CodeUtils; -import com.fr.stable.StringUtils; import java.util.ArrayList; import java.util.List; @@ -22,11 +21,11 @@ import java.util.List; * Created by XiaXiang on 2017/3/31. */ public class RecommendSearchManager implements AlphaFineSearchProcessor { + //todo:for test + private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/recommend?searchKey="; private static RecommendSearchManager recommendSearchManager = null; private SearchResult modelList; private List recommendModelList = new ArrayList<>(); - //todo:for test - private static final String SEARCHAPI = "http://localhost:8080/monitor/alphafine/search/recommend?searchKey="; public synchronized static RecommendSearchManager getRecommendSearchManager() { if (recommendSearchManager == null) { @@ -34,6 +33,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { } return recommendSearchManager; } + @Override public synchronized SearchResult getLessSearchResult(String searchText) { this.modelList = new SearchResult();