From 68c23280ec9c013eb753bb158d59d6837dd4221e Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Mon, 5 Jun 2017 19:31:23 +0800 Subject: [PATCH 01/17] bug fix --- .../mainframe/alphafine/component/AlphaFineDialog.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 9dfba7af6e..15d6133048 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -156,15 +156,15 @@ public class AlphaFineDialog extends UIDialog { } /** - * 执行搜索,暂时字符要求超过两个才开始搜索 + * 执行搜索 * @param text */ private void doSearch(String text) { - if (text.length() < 2 || text.contains("'")) { - return; - } + if (StringUtils.isBlank(text) || text.equals("AlphaFine")) { removeSearchResult(); + } else if (text.contains("'")) { + return; } else { showSearchResult(text); } From 3629b13723aec662dbc8df31a64fbbf91997bd4a Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Tue, 6 Jun 2017 18:43:07 +0800 Subject: [PATCH 02/17] bug fix alphafine --- .../fr/design/mainframe/alphafine/model/SearchListModel.java | 5 +++++ 1 file changed, 5 insertions(+) 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 4369633e6b..f030f2240c 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java @@ -36,4 +36,9 @@ public class SearchListModel extends DefaultListModel { public int getSize() { return this.myDelegate.size(); } + + @Override + public void removeAllElements() { + this.myDelegate.clear(); + } } From d5e54e07f93b03497c8a2357fe76edb1403b09ee Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Tue, 6 Jun 2017 21:00:17 +0800 Subject: [PATCH 03/17] bug fix --- .../mainframe/alphafine/model/SearchListModel.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 f030f2240c..2f3dd48c0f 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/model/SearchListModel.java @@ -14,7 +14,9 @@ public class SearchListModel extends DefaultListModel { @Override public void addElement(Object element) { + int index = myDelegate.size(); myDelegate.add(element); + fireContentsChanged(this, index, index); } @Override @@ -23,13 +25,17 @@ public class SearchListModel extends DefaultListModel { } @Override - public void insertElementAt(Object element, int index) { - this.myDelegate.add(index, element); + public void add(int index, Object element) { + myDelegate.add(index, element); + fireIntervalAdded(this, index, index); } @Override - public void removeElementAt(int index) { - this.myDelegate.remove(index); + public Object remove(int index) { + Object object = myDelegate.get(index); + myDelegate.remove(object); + fireIntervalRemoved(this, index, index); + return object; } @Override From db79a6a67248afd3e4b84fa7f68bbb743e0d8e6e Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 13:06:47 +0800 Subject: [PATCH 04/17] alphafine bug fix --- .../alphafine/AlphaFineConstants.java | 2 + .../mainframe/alphafine/AlphaFineHelper.java | 6 + .../design/mainframe/alphafine/CellType.java | 2 +- .../alphafine/cell/model/NoResultModel.java | 24 +++ .../cell/render/ContentCellRender.java | 10 +- .../alphafine/component/AlphaFineDialog.java | 166 +++++++++++++----- .../search/manager/ActionSearchManager.java | 30 ++-- .../search/manager/DocumentSearchManager.java | 42 ++++- .../search/manager/FileSearchManager.java | 42 +++-- .../search/manager/PluginSearchManager.java | 40 ++++- .../manager/RecommendSearchManager.java | 10 +- .../com/fr/design/locale/designer.properties | 4 +- .../design/locale/designer_en_US.properties | 4 +- .../design/locale/designer_zh_CN.properties | 4 +- .../design/locale/designer_zh_TW.properties | 4 +- 15 files changed, 296 insertions(+), 94 deletions(-) create mode 100644 designer/src/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java index b258cd727f..5d91ef5ccc 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineConstants.java @@ -47,6 +47,8 @@ public class AlphaFineConstants { public static final Color LIGHT_GRAY = new Color(0xcccccc); + public static final Color MEDIUM_GRAY = new Color(0x999999); + 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/AlphaFineHelper.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 3507978d24..993a7cc034 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -1,13 +1,18 @@ package com.fr.design.mainframe.alphafine; import com.fr.design.mainframe.DesignerContext; +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.general.Inter; import com.fr.stable.StringUtils; /** * Created by XiaXiang on 2017/5/8. */ public class AlphaFineHelper { + public static final NoResultModel noResultModel = new NoResultModel(Inter.getLocText("FR-Designere_AlphaFine_NoResult")); + public static final NoResultModel noConnectionModel = new NoResultModel(Inter.getLocText("FR-Designer_ConnectionFailed")); /** * 弹出alphafine搜索面板 @@ -17,6 +22,7 @@ public class AlphaFineHelper { dialog.setVisible(true); } + /** * 获取文件名上级目录 * @param text diff --git a/designer/src/com/fr/design/mainframe/alphafine/CellType.java b/designer/src/com/fr/design/mainframe/alphafine/CellType.java index 96b7db6096..d196a01388 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/CellType.java +++ b/designer/src/com/fr/design/mainframe/alphafine/CellType.java @@ -4,7 +4,7 @@ package com.fr.design.mainframe.alphafine; * Created by XiaXiang on 2017/4/27. */ public enum CellType { - RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5); + RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5), NO_RESULT(6); private int typeValue; diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java b/designer/src/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java new file mode 100644 index 0000000000..1dbdb450b1 --- /dev/null +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/model/NoResultModel.java @@ -0,0 +1,24 @@ +package com.fr.design.mainframe.alphafine.cell.model; + +import com.fr.design.mainframe.alphafine.CellType; +import com.fr.json.JSONException; +import com.fr.json.JSONObject; + +/** + * Created by XiaXiang on 2017/6/8. + */ +public class NoResultModel extends AlphaCellModel { + public NoResultModel(String name) { + super(name, null, CellType.NO_RESULT); + } + + @Override + public JSONObject ModelToJson() throws JSONException { + return null; + } + + @Override + public String getStoreInformation() { + return null; + } +} 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 e358df8c16..3380d092bf 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 @@ -2,6 +2,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.CellType; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.stable.StringUtils; @@ -34,9 +35,14 @@ public class ContentCellRender implements ListCellRenderer { AlphaCellModel model = (AlphaCellModel) value; name.setText(model.getName()); String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png"; - name.setIcon(new ImageIcon(getClass().getResource(iconUrl))); + if (model.getType() == CellType.NO_RESULT) { + name.setIcon(null); + name.setForeground(AlphaFineConstants.MEDIUM_GRAY); + } else { + name.setIcon(new ImageIcon(getClass().getResource(iconUrl))); + name.setForeground(AlphaFineConstants.BLACK); + } name.setFont(AlphaFineConstants.MEDIUM_FONT); - name.setForeground(AlphaFineConstants.BLACK); name.setVerticalTextPosition(SwingConstants.CENTER); name.setHorizontalTextPosition(SwingConstants.RIGHT); String description = model.getDescription(); 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 15d6133048..3daa354d6b 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphafineContext; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; @@ -27,6 +28,7 @@ import com.fr.form.main.FormIO; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpClient; import com.fr.io.TemplateWorkBookIO; import com.fr.io.exporter.ImageExporter; @@ -39,6 +41,7 @@ import com.fr.stable.project.ProjectConstants; import javax.imageio.ImageIO; import javax.swing.*; +import javax.swing.Timer; import javax.swing.event.DocumentEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -50,8 +53,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.HashMap; +import java.util.*; import java.util.concurrent.ExecutionException; /** @@ -69,6 +71,10 @@ public class AlphaFineDialog extends UIDialog { private SwingWorker searchWorker; //是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 private boolean forceOpen; + //。。。 + private boolean isSearchCancel; + private boolean waitingForSearch; + private long lastUpdateTime; public AlphaFineDialog(Frame parent, boolean forceOpen) { super(parent); @@ -76,6 +82,23 @@ public class AlphaFineDialog extends UIDialog { initProperties(); initListener(); initComponents(); + //initSearcheTimer(); + } + + private void initSearcheTimer() { + java.util.Timer timer = new java.util.Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + if (waitingForSearch) { + long currentTime = System.currentTimeMillis(); + if (currentTime - lastUpdateTime > 1000) { + doSearch(searchTextField.getText()); + waitingForSearch = false; + } + } + } + }, 1000, 1000); } /** @@ -134,6 +157,7 @@ public class AlphaFineDialog extends UIDialog { addComponentListener(new ComponentHandler()); setSize(AlphaFineConstants.FIELD_SIZE); centerWindow(this); + } /** @@ -164,9 +188,9 @@ public class AlphaFineDialog extends UIDialog { if (StringUtils.isBlank(text) || text.equals("AlphaFine")) { removeSearchResult(); } else if (text.contains("'")) { - return; + return; } else { - showSearchResult(text); + showSearchResult(); } } @@ -198,14 +222,13 @@ public class AlphaFineDialog extends UIDialog { /** * 展示搜索结果 - * @param searchText */ - private void showSearchResult(String searchText) { + private void showSearchResult() { if (searchResultPane == null) { initSearchResultComponents(); - initListListener(searchText); + initListListener(); } - initSearchWorker(searchText); + initSearchWorker(); } /** @@ -213,6 +236,8 @@ public class AlphaFineDialog extends UIDialog { */ private void initSearchResultComponents() { searchResultList = new JList(); + searchListModel = new SearchListModel(new SearchResult()); + searchResultList.setModel(searchListModel); searchResultPane = new JPanel(); searchResultPane.setPreferredSize(AlphaFineConstants.CONTENT_SIZE); searchResultPane.setLayout(new BorderLayout()); @@ -233,56 +258,99 @@ public class AlphaFineDialog extends UIDialog { } /** - * 异步加载搜索结构 - * @param searchText + * 异步加载搜索结果 */ - private void initSearchWorker(final String searchText) { - searchResultList.setModel(new SearchListModel(AlphaSearchManager.getSearchManager().showDefaultSearchResult())); + private void initSearchWorker() { if (this.searchWorker != null && !this.searchWorker.isDone()) { this.searchWorker.cancel(true); this.searchWorker = null; } - this.searchWorker = new SwingWorker() { - + this.searchWorker = new SwingWorker() { @Override - protected SearchListModel doInBackground() { - return setListModel(new SearchListModel(AlphaSearchManager.getSearchManager().getLessSearchResult(searchText))); + protected Object doInBackground() throws Exception { + rebuildList(searchTextField.getText()); + return null; } + }; + this.searchWorker.execute(); + } - @Override - protected void done() { - try { - if (!isCancelled()) { - searchResultList.setModel(get()); - searchResultList.validate(); - searchResultList.repaint(); - validate(); - repaint(); - /** - * 默认选中第1项,第0项为title - */ - if (searchResultList.getModel().getSize() > 0) { - searchResultList.setSelectedIndex(1); - } + private synchronized void rebuildList(String searchText) { + System.out.print("background===" + searchText + "\n"); + searchListModel.removeAllElements(); + getRecentList(searchText); + getRecommendList(searchText); + getActionList(searchText); + getFileList(searchText); + getDocumentList(searchText); + getPluginList(searchText); + } - } - } catch (InterruptedException e) { - FRLogger.getLogger().error(e.getMessage()); - } catch (ExecutionException e) { - FRLogger.getLogger().error(e.getMessage()); - } + private void checkCancel() { + if (Thread.interrupted()) { + throw new ProcessCanceledException(); + } + } + private synchronized void getDocumentList(final String searchText) { - } + SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); + checkCancel(); + for (Object object : documentModelList) { - }; - this.searchWorker.execute(); + searchListModel.addElement(object); + } + System.out.print("document" + "-----" + searchText + "\n"); + + + + + } + + private synchronized void getFileList(final String searchText) { + SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText); + for (Object object : fileModelList) { + searchListModel.addElement(object); + } + System.out.print("file" + "-----" + searchText + "\n"); + } + + private synchronized void getActionList(final String searchText) { + SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText); + for (Object object : actionModelList) { + searchListModel.addElement(object); + } + System.out.print("action" + "-----" + searchText + "\n"); + } + + private synchronized void getPluginList(final String searchText) { + SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText); + for (Object object : pluginModelList) { + searchListModel.addElement(object); + } + System.out.print("plugin" + "-----" + searchText + "\n"); } + private synchronized void getRecommendList(final String searchText) { + SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText); + for (Object object : recommendModelList) { + searchListModel.addElement(object); + } + System.out.print("recommend" + "-----" + searchText + "\n"); + } + + private synchronized void getRecentList(final String searchText) { + SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText); + for (Object object : recentModelList) { + searchListModel.addElement(object); + } + System.out.print("recent" + "-----" + searchText + "\n"); + } + + /** * 初始化监听器 - * @param searchText */ - private void initListListener(final String searchText) { + private void initListListener() { /** * 鼠标监听器 */ @@ -663,11 +731,11 @@ public class AlphaFineDialog extends UIDialog { SearchResult moreResult = getMoreResult(selectedValue); if((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) { for (int i = 0; i < moreResult.size(); i++) { - this.searchListModel.insertElementAt(moreResult.get(i), index + AlphaFineConstants.SHOW_SIZE + 1 + i); + this.searchListModel.add(index + AlphaFineConstants.SHOW_SIZE + 1 + i, moreResult.get(i)); } } else { for (int i = 0; i < moreResult.size(); i++) { - this.searchListModel.removeElementAt(index + AlphaFineConstants.SHOW_SIZE + 1); + this.searchListModel.remove(index + AlphaFineConstants.SHOW_SIZE + 1); } } @@ -701,7 +769,7 @@ public class AlphaFineDialog extends UIDialog { moreResult = ActionSearchManager.getActionSearchManager().getMoreSearchResult(); break; default: - moreResult = AlphaSearchManager.getSearchManager().getMoreSearchResult(); + moreResult = new SearchResult(); } return moreResult; } @@ -731,4 +799,12 @@ public class AlphaFineDialog extends UIDialog { public void setForceOpen(boolean forceOpen) { this.forceOpen = forceOpen; } + + public boolean isSearchCancel() { + return isSearchCancel; + } + + public void setSearchCancel(boolean searchCancel) { + isSearchCancel = searchCancel; + } } \ No newline at end of file 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 b174e0b73a..4ab43181b4 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 @@ -2,6 +2,7 @@ package com.fr.design.mainframe.alphafine.search.manager; 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.ActionModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; @@ -44,21 +45,24 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { } } } - if (filterModelList != null && filterModelList.size() > 0) { - final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size()); - for (int i = 0; i < length; i++) { - lessModelList.add(filterModelList.get(i)); - } - for (int i = length; i < filterModelList.size(); i++) { - moreModelList.add(filterModelList.get(i)); - } - if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION)); - } else { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION)); - } + final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size()); + for (int i = 0; i < length; i++) { + lessModelList.add(filterModelList.get(i)); + } + for (int i = length; i < filterModelList.size(); i++) { + moreModelList.add(filterModelList.get(i)); } + if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) { + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION)); + } else { + lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION)); + if (lessModelList.size() == 1) { + lessModelList.add(AlphaFineHelper.noResultModel); + } + } + + } return lessModelList; 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 8065554bcc..1ccee441eb 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 @@ -1,13 +1,17 @@ package com.fr.design.mainframe.alphafine.search.manager; import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphafineContext; +import com.fr.design.actions.help.alphafine.AlphafineListener; 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.DocumentModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONException; @@ -20,6 +24,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { private static DocumentSearchManager documentSearchManager = null; private SearchResult lessModelList; private SearchResult moreModelList; + private static final MoreModel titleModel = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT); public synchronized static DocumentSearchManager getDocumentSearchManager() { if (documentSearchManager == null) { @@ -40,13 +45,23 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { httpClient.setTimeout(5000); httpClient.asGet(); if (!httpClient.isServerAlive()) { - return lessModelList; + return getNoConnectList(); + } + if (Thread.interrupted()) { + System.out.print(searchText + "--------崩了1111\n"); + throw new ProcessCanceledException(); + } result = httpClient.getResponseText(); + if (Thread.interrupted()) { + System.out.print(searchText + "--------崩了22222\n"); + throw new ProcessCanceledException(); + + } try { JSONObject jsonObject = new JSONObject(result); JSONArray jsonArray = jsonObject.optJSONArray("docdata"); - if (jsonArray != null && jsonArray.length() > 0) { + if (jsonArray != null) { final int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length()); for (int i = 0; i < length; i++) { DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); @@ -59,7 +74,10 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); } else { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT)); + lessModelList.add(0, titleModel); + if (lessModelList.size() == 1) { + lessModelList.add(AlphaFineHelper.noResultModel); + } } @@ -67,14 +85,28 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { } catch (JSONException e) { FRLogger.getLogger().error(e.getMessage()); - return lessModelList; + return getNoResultList(); } - } return lessModelList; } + private SearchResult getNoResultList() { + SearchResult result = new SearchResult(); + result.add(0, titleModel); + result.add(AlphaFineHelper.noResultModel); + return result; + + } + + private SearchResult getNoConnectList() { + SearchResult result = new SearchResult(); + result.add(0, titleModel); + result.add(AlphaFineHelper.noConnectionModel); + return result; + } + /** * 根据json信息获取文档model * @param object diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java index 712331826d..63020b54bd 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java @@ -44,32 +44,38 @@ public class FileSearchManager implements AlphaFineSearchProcessor { this.filterModelList = new SearchResult(); this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); - Env env = FRContext.getCurrentEnv(); - fileNodes = new ArrayList<>(); - fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true); - for (FileNode node : fileNodes) { - boolean isAlreadyContain = false; - String fileEnvPath = node.getEnvPath(); - String filePath = StableUtils.pathJoin(env.getPath(), fileEnvPath); - isAlreadyContain = searchFile(searchText, node, isAlreadyContain); - searchFileContent(searchText, node, isAlreadyContain, filePath); + if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) { + Env env = FRContext.getCurrentEnv(); + fileNodes = new ArrayList<>(); + fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true); + for (FileNode node : fileNodes) { + boolean isAlreadyContain = false; + String fileEnvPath = node.getEnvPath(); + String filePath = StableUtils.pathJoin(env.getPath(), fileEnvPath); + isAlreadyContain = searchFile(searchText, node, isAlreadyContain); + searchFileContent(searchText, node, isAlreadyContain, filePath); - } + } + + final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size()); + for (int i = 0; i < length; i++) { + lessModelList.add(filterModelList.get(i)); + } + for (int i = length; i< filterModelList.size(); i++) { + moreModelList.add(filterModelList.get(i)); + } - final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size()); - for (int i = 0; i < length; i++) { - lessModelList.add(filterModelList.get(i)); - } - for (int i = length; i< filterModelList.size(); i++) { - moreModelList.add(filterModelList.get(i)); - } - if (filterModelList.size() > 0) { if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) { lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.FILE)); } else { lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE)); + if (lessModelList.size() == 1) { + lessModelList.add(AlphaFineHelper.noResultModel); + } } } + + return this.lessModelList; } 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 7e4f6b3589..65717dda8d 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 @@ -1,8 +1,12 @@ package com.fr.design.mainframe.alphafine.search.manager; import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphafineContext; +import com.fr.design.actions.help.alphafine.AlphafineListener; 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.NoResultModel; import com.fr.design.mainframe.alphafine.cell.model.PluginModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; @@ -21,9 +25,14 @@ import java.net.URLEncoder; */ public class PluginSearchManager implements AlphaFineSearchProcessor { private static PluginSearchManager pluginSearchManager = null; + + private static final MoreModel titleModel = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN); + + private SearchResult lessModelList; private SearchResult moreModelList; + public synchronized static PluginSearchManager getPluginSearchManager() { if (pluginSearchManager == null) { pluginSearchManager = new PluginSearchManager(); @@ -34,7 +43,6 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { @Override public synchronized SearchResult getLessSearchResult(String searchText) { - this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainPlugin()) { @@ -46,12 +54,12 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { httpClient.setTimeout(5000); httpClient.asGet(); if (!httpClient.isServerAlive()) { - return lessModelList; + return getNoConnectList(); } result = httpClient.getResponseText(); JSONObject jsonObject = new JSONObject(result); JSONArray jsonArray = jsonObject.optJSONArray("result"); - if (jsonArray != null && jsonArray.length() > 0) { + if (jsonArray != null) { int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length()); for (int i = 0; i < length; i++) { PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); @@ -64,17 +72,39 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); } else { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN)); + lessModelList.add(0, titleModel); + if (lessModelList.size() == 1) { + lessModelList.add(AlphaFineHelper.noResultModel); + } } + } else { + return getNoResultList(); } } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); - return lessModelList; + return getNoResultList(); } } return this.lessModelList; + + + } + + private SearchResult getNoResultList() { + SearchResult result = new SearchResult(); + result.add(0, titleModel); + result.add(AlphaFineHelper.noResultModel); + return result; + + } + + private SearchResult getNoConnectList() { + SearchResult result = new SearchResult(); + result.add(0, titleModel); + result.add(AlphaFineHelper.noConnectionModel); + return result; } private static PluginModel getPluginModel(JSONObject object, boolean isFromCloud) { 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 94f718be2e..3421487192 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 @@ -1,6 +1,7 @@ package com.fr.design.mainframe.alphafine.search.manager; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; @@ -37,7 +38,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { httpClient.asGet(); httpClient.setTimeout(5000); if (!httpClient.isServerAlive()) { - return modelList; + return getNoConnectList(); } result = httpClient.getResponseText(); try { @@ -65,6 +66,13 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { return modelList; } + private SearchResult getNoConnectList() { + SearchResult result = new SearchResult(); + result.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude"), false)); + result.add(AlphaFineHelper.noConnectionModel); + return result; + } + @Override public SearchResult getMoreSearchResult() { return new SearchResult(); diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index e632fafd2c..a4c185e6f6 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2006,4 +2006,6 @@ FR-Designer_AlphaFine_ShowAll=show all FR-Designer_AlphaFine_Latest=Latest FR-Designer_AlphaFine_ShowLess=show less FR-Designer_Alphafine=AlphaFine -FR-Designer-Alphafine_No_Remind= \ No newline at end of file +FR-Designer-Alphafine_No_Remind= +FR-Designere_AlphaFine_NoResult=no results +FR-Designer_ConnectionFailed=connection failed \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 774beedf58..c47970e1d2 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2004,4 +2004,6 @@ FR-Designer_AlphaFine_ShowAll=show all FR-Designer_AlphaFine_Latest=Recent FR-Designer_AlphaFine_ShowLess=show less FR-Designer_Alphafine=AlphaFine -FR-Designer-Alphafine_No_Remind=don't remind \ No newline at end of file +FR-Designer-Alphafine_No_Remind=don't remind +FR-Designere_AlphaFine_NoResult=no results +FR-Designer_ConnectionFailed=connection failed \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 008f2df8d5..749dba173c 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2002,4 +2002,6 @@ FR-Designer_AlphaFine_Conclude=\u731C\u60A8\u9700\u8981 FR-Designer_AlphaFine_Latest=\u672C\u5730\u5E38\u7528 FR-Designer_AlphaFine_ShowLess=\u6536\u8D77 FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22 -FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A \ No newline at end of file +FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A +FR-Designere_AlphaFine_NoResult=\u6682\u65E0\u76F8\u5173\u5185\u5BB9 +FR-Designer_ConnectionFailed=\u94FE\u63A5\u5931\u8D25 \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 4a8a86d71d..0e0e2ee32d 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2000,4 +2000,6 @@ FR-Designer_AlphaFine_Latest=\u6700\u8FD1\u5E38\u7528 FR-Designer_AlphaFine_ShowLess=\u6536\u8D77 FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22 FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8 -FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A \ No newline at end of file +FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A +FR-Designere_AlphaFine_NoResult=\u66AB\u7121\u76F8\u95DC\u5167\u5BB9 +FR-Designer_ConnectionFailed=\u93C8\u63A5\u5931\u6557 \ No newline at end of file From 1efe1eefcadcdbdc9008358da7d15731cbea5f81 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 16:45:54 +0800 Subject: [PATCH 05/17] =?UTF-8?q?alphafine=20=E5=BC=82=E6=AD=A5=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E4=BC=98=E5=8C=96=20=E4=B8=AD=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/alphafine/AlphaFineHelper.java | 10 +++ .../alphafine/component/AlphaFineDialog.java | 33 ++++----- .../search/manager/AlphaSearchManager.java | 69 ------------------- .../search/manager/DocumentSearchManager.java | 13 +--- .../search/manager/PluginSearchManager.java | 4 ++ .../search/manager/RecentSearchManager.java | 4 +- .../manager/RecommendSearchManager.java | 2 + 7 files changed, 39 insertions(+), 96 deletions(-) delete mode 100644 designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 993a7cc034..1f0aa84529 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -5,6 +5,7 @@ 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.general.Inter; +import com.fr.general.ProcessCanceledException; import com.fr.stable.StringUtils; /** @@ -57,6 +58,15 @@ public class AlphaFineHelper { return getSplitText(text, 1); } + /** + * 中断当前线程的搜索 + */ + public static void checkCancel() { + if (Thread.interrupted()) { + throw new ProcessCanceledException(); + } + } + 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 3daa354d6b..9c88aef1ad 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -2,7 +2,6 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; -import com.fr.design.actions.help.alphafine.AlphafineContext; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; @@ -93,6 +92,7 @@ public class AlphaFineDialog extends UIDialog { if (waitingForSearch) { long currentTime = System.currentTimeMillis(); if (currentTime - lastUpdateTime > 1000) { + System.out.print(searchTextField.getText() + "............\n"); doSearch(searchTextField.getText()); waitingForSearch = false; } @@ -144,6 +144,8 @@ public class AlphaFineDialog extends UIDialog { searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { +// lastUpdateTime = System.currentTimeMillis(); +// waitingForSearch = true; doSearch(searchTextField.getText()); } }); @@ -275,8 +277,11 @@ public class AlphaFineDialog extends UIDialog { this.searchWorker.execute(); } - private synchronized void rebuildList(String searchText) { - System.out.print("background===" + searchText + "\n"); + /** + * 重新构建搜索结果列表 + * @param searchText + */ + private void rebuildList(String searchText) { searchListModel.removeAllElements(); getRecentList(searchText); getRecommendList(searchText); @@ -286,20 +291,15 @@ public class AlphaFineDialog extends UIDialog { getPluginList(searchText); } - private void checkCancel() { - if (Thread.interrupted()) { - throw new ProcessCanceledException(); - } - } + + private synchronized void getDocumentList(final String searchText) { SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); - checkCancel(); for (Object object : documentModelList) { - + AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } - System.out.print("document" + "-----" + searchText + "\n"); @@ -309,41 +309,42 @@ public class AlphaFineDialog extends UIDialog { private synchronized void getFileList(final String searchText) { SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText); for (Object object : fileModelList) { + AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } - System.out.print("file" + "-----" + searchText + "\n"); } private synchronized void getActionList(final String searchText) { SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText); for (Object object : actionModelList) { + AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } - System.out.print("action" + "-----" + searchText + "\n"); } private synchronized void getPluginList(final String searchText) { SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText); for (Object object : pluginModelList) { + AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } - System.out.print("plugin" + "-----" + searchText + "\n"); } private synchronized void getRecommendList(final String searchText) { SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText); for (Object object : recommendModelList) { + AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } - System.out.print("recommend" + "-----" + searchText + "\n"); } private synchronized void getRecentList(final String searchText) { SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText); for (Object object : recentModelList) { + AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } - System.out.print("recent" + "-----" + searchText + "\n"); + } diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java deleted file mode 100644 index cb60f9aa13..0000000000 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/AlphaSearchManager.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.fr.design.mainframe.alphafine.search.manager; - -import com.fr.design.mainframe.alphafine.cell.model.MoreModel; -import com.fr.design.mainframe.alphafine.model.SearchResult; -import com.fr.general.Inter; - -/** - * Created by XiaXiang on 2017/3/28. - */ -public class AlphaSearchManager implements AlphaFineSearchProcessor { - private static AlphaSearchManager searchManager; - private static PluginSearchManager pluginSearchManager; - private static DocumentSearchManager documentSearchManager; - private static FileSearchManager fileSearchManager; - private static ActionSearchManager actionSearchManager; - private static RecommendSearchManager recommendSearchManager; - private static RecentSearchManager recentSearchManager; - - public synchronized static AlphaSearchManager getSearchManager() { - init(); - return searchManager; - - } - - private synchronized static void init() { - if (searchManager == null) { - searchManager = new AlphaSearchManager(); - pluginSearchManager = PluginSearchManager.getPluginSearchManager(); - documentSearchManager = DocumentSearchManager.getDocumentSearchManager(); - fileSearchManager = FileSearchManager.getFileSearchManager(); - actionSearchManager = ActionSearchManager.getActionSearchManager(); - recommendSearchManager = RecommendSearchManager.getRecommendSearchManager(); - recentSearchManager = RecentSearchManager.getRecentSearchManger(); - } - } - - @Override - public synchronized SearchResult getLessSearchResult(String searchText) { - SearchResult recentModelList = recentSearchManager.getLessSearchResult(searchText); - SearchResult recommendModelList = recommendSearchManager.getLessSearchResult(searchText); - SearchResult actionModelList = actionSearchManager.getLessSearchResult(searchText); - SearchResult fileModelList = fileSearchManager.getLessSearchResult(searchText); - SearchResult documentModelList = documentSearchManager.getLessSearchResult(searchText); - SearchResult pluginModelList = pluginSearchManager.getLessSearchResult(searchText); - recentModelList.addAll(recommendModelList); - recentModelList.addAll(actionModelList); - recentModelList.addAll(fileModelList); - recentModelList.addAll(documentModelList); - recentModelList.addAll(pluginModelList); - return recentModelList; - } - - public SearchResult showDefaultSearchResult() { - SearchResult searchResult = new SearchResult(); - searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Latest"))); - searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude"))); - searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_Set"))); - searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_Templates"))); - searchResult.add(new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"))); - searchResult.add(new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"))); - return searchResult; - } - - @Override - public SearchResult getMoreSearchResult() { - return null; - } - -} 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 1ccee441eb..45076ae185 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 @@ -47,27 +47,20 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { if (!httpClient.isServerAlive()) { return getNoConnectList(); } - if (Thread.interrupted()) { - System.out.print(searchText + "--------崩了1111\n"); - throw new ProcessCanceledException(); - - } result = httpClient.getResponseText(); - if (Thread.interrupted()) { - System.out.print(searchText + "--------崩了22222\n"); - throw new ProcessCanceledException(); - - } + AlphaFineHelper.checkCancel(); try { JSONObject jsonObject = new JSONObject(result); JSONArray jsonArray = jsonObject.optJSONArray("docdata"); if (jsonArray != null) { final int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length()); for (int i = 0; i < length; i++) { + AlphaFineHelper.checkCancel(); DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); this.lessModelList.add(cellModel); } for (int i = length; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); this.moreModelList.add(cellModel); } 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 65717dda8d..3ce21d9fe9 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 @@ -13,6 +13,7 @@ import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONObject; @@ -57,15 +58,18 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { return getNoConnectList(); } result = httpClient.getResponseText(); + AlphaFineHelper.checkCancel(); JSONObject jsonObject = new JSONObject(result); JSONArray jsonArray = jsonObject.optJSONArray("result"); if (jsonArray != null) { int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length()); for (int i = 0; i < length; i++) { + AlphaFineHelper.checkCancel(); PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); this.lessModelList.add(cellModel); } for (int i = length; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); this.moreModelList.add(cellModel); } 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 535d6b1a6a..8f818fd9d6 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 @@ -3,6 +3,7 @@ package com.fr.design.mainframe.alphafine.search.manager; import com.fr.base.FRContext; import com.fr.base.Utils; 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.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; @@ -273,9 +274,10 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear * @param searchText * @return */ - public List getRecentModelList(String searchText) { + public synchronized List getRecentModelList(String searchText) { recentModelList = new ArrayList<>(); for (String key : recentKVModelMap.keySet()) { + AlphaFineHelper.checkCancel(); if (ComparatorUtils.equals(key, searchText)) { recentModelList = recentKVModelMap.get(searchText); int size = recentModelList.size(); 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 3421487192..bc0f66eaf8 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 @@ -41,12 +41,14 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { return getNoConnectList(); } result = httpClient.getResponseText(); + AlphaFineHelper.checkCancel(); try { JSONObject jsonObject = new JSONObject(result); if (jsonObject.optString("status").equals("success")) { JSONArray jsonArray = jsonObject.optJSONArray("result"); if (jsonArray != null && jsonArray.length() > 0) { for (int i = 0; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); if (alphaCellModel != null && !RecentSearchManager.getRecentSearchManger().getRecentModelList().contains(alphaCellModel)) { this.modelList.add(alphaCellModel); From e9edf6f37455f6a37bd08704320555b09b4fc3cc Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 16:47:40 +0800 Subject: [PATCH 06/17] bug fix --- .../src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 1f0aa84529..1b7b20a5de 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -3,7 +3,6 @@ package com.fr.design.mainframe.alphafine; import com.fr.design.mainframe.DesignerContext; 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.general.Inter; import com.fr.general.ProcessCanceledException; import com.fr.stable.StringUtils; From d32472299981b5f825b7e88fc5d2ee0396a60f37 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 17:21:06 +0800 Subject: [PATCH 07/17] alphafine bug fix --- .../mainframe/alphafine/AlphaFineHelper.java | 4 ++ .../alphafine/component/AlphaFineDialog.java | 44 +++++-------------- 2 files changed, 15 insertions(+), 33 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 1b7b20a5de..22336aec09 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.alphafine; +import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphafineConfigManager; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.alphafine.cell.model.NoResultModel; import com.fr.design.mainframe.alphafine.component.AlphaFineDialog; @@ -19,6 +21,8 @@ public class AlphaFineHelper { */ public static void showAlphaFineDialog(boolean forceOpen) { AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame(), forceOpen); + final AlphafineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphafineConfigManager(); + manager.setNeedRemind(false); dialog.setVisible(true); } 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 9c88aef1ad..f742c5e7ed 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -10,8 +10,8 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; -import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; import com.fr.design.mainframe.alphafine.cell.model.*; +import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; import com.fr.design.mainframe.alphafine.listener.ComponentHandler; import com.fr.design.mainframe.alphafine.listener.DocumentAdapter; import com.fr.design.mainframe.alphafine.model.SearchListModel; @@ -27,7 +27,6 @@ import com.fr.form.main.FormIO; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpClient; import com.fr.io.TemplateWorkBookIO; import com.fr.io.exporter.ImageExporter; @@ -40,19 +39,19 @@ import com.fr.stable.project.ProjectConstants; import javax.imageio.ImageIO; import javax.swing.*; -import javax.swing.Timer; import javax.swing.event.DocumentEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.Calendar; +import java.util.HashMap; import java.util.concurrent.ExecutionException; /** @@ -70,10 +69,6 @@ public class AlphaFineDialog extends UIDialog { private SwingWorker searchWorker; //是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 private boolean forceOpen; - //。。。 - private boolean isSearchCancel; - private boolean waitingForSearch; - private long lastUpdateTime; public AlphaFineDialog(Frame parent, boolean forceOpen) { super(parent); @@ -81,25 +76,8 @@ public class AlphaFineDialog extends UIDialog { initProperties(); initListener(); initComponents(); - //initSearcheTimer(); } - private void initSearcheTimer() { - java.util.Timer timer = new java.util.Timer(); - timer.schedule(new TimerTask() { - @Override - public void run() { - if (waitingForSearch) { - long currentTime = System.currentTimeMillis(); - if (currentTime - lastUpdateTime > 1000) { - System.out.print(searchTextField.getText() + "............\n"); - doSearch(searchTextField.getText()); - waitingForSearch = false; - } - } - } - }, 1000, 1000); - } /** * 初始化全部组件 @@ -273,6 +251,13 @@ public class AlphaFineDialog extends UIDialog { rebuildList(searchTextField.getText()); return null; } + + @Override + protected void done() { + if (!isCancelled()) { + searchResultList.setSelectedIndex(1); + } + } }; this.searchWorker.execute(); } @@ -801,11 +786,4 @@ public class AlphaFineDialog extends UIDialog { this.forceOpen = forceOpen; } - public boolean isSearchCancel() { - return isSearchCancel; - } - - public void setSearchCancel(boolean searchCancel) { - isSearchCancel = searchCancel; - } } \ No newline at end of file From 7ba402254493ab4a0fccb34e69bfa114cbd7185e Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 17:49:42 +0800 Subject: [PATCH 08/17] =?UTF-8?q?=E6=94=B9=E4=BA=86=E5=87=A0=E4=B8=AA?= =?UTF-8?q?=E7=B1=BB=E7=9A=84=E7=B1=BB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/alphafine/AlphaFineHelper.java | 4 +- .../alphafine/component/AlphaFineDialog.java | 2 +- .../alphafine/component/AlphaFinePane.java | 8 +-- .../search/manager/ActionSearchManager.java | 2 +- .../search/manager/DocumentSearchManager.java | 5 +- .../search/manager/FileSearchManager.java | 6 +- .../search/manager/PluginSearchManager.java | 6 +- .../manager/RecommendSearchManager.java | 2 +- .../design/mainframe/bbs/UserInfoLabel.java | 18 +++--- .../aspectj/designerbase/AlphaFineReminder.aj | 4 +- .../src/com/fr/design/DesignerEnvManager.java | 18 +++--- ...hafineAction.java => AlphaFineAction.java} | 15 +++-- ...nager.java => AlphaFineConfigManager.java} | 8 +-- ...nfigPane.java => AlphaFineConfigPane.java} | 61 ++++++++++--------- ...fineContext.java => AlphaFineContext.java} | 8 +-- ...neListener.java => AlphaFineListener.java} | 2 +- .../actions/help/alphafine/RemindDialog.java | 2 +- .../actions/help/alphafine/RemindPane.java | 6 +- .../fr/design/mainframe/DesignerFrame.java | 2 +- .../mainframe/toolbar/ToolBarMenuDock.java | 4 +- 20 files changed, 88 insertions(+), 95 deletions(-) rename designer_base/src/com/fr/design/actions/help/alphafine/{AlphafineAction.java => AlphaFineAction.java} (77%) rename designer_base/src/com/fr/design/actions/help/alphafine/{AlphafineConfigManager.java => AlphaFineConfigManager.java} (96%) rename designer_base/src/com/fr/design/actions/help/alphafine/{AlphafineConfigPane.java => AlphaFineConfigPane.java} (80%) rename designer_base/src/com/fr/design/actions/help/alphafine/{AlphafineContext.java => AlphaFineContext.java} (63%) rename designer_base/src/com/fr/design/actions/help/alphafine/{AlphafineListener.java => AlphaFineListener.java} (75%) diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 22336aec09..53b60c6b2c 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine; import com.fr.design.DesignerEnvManager; -import com.fr.design.actions.help.alphafine.AlphafineConfigManager; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.alphafine.cell.model.NoResultModel; import com.fr.design.mainframe.alphafine.component.AlphaFineDialog; @@ -21,7 +21,7 @@ public class AlphaFineHelper { */ public static void showAlphaFineDialog(boolean forceOpen) { AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame(), forceOpen); - final AlphafineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphafineConfigManager(); + final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); manager.setNeedRemind(false); dialog.setVisible(true); } 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 f742c5e7ed..81188d9f4e 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -613,7 +613,7 @@ public class AlphaFineDialog extends UIDialog { if (event instanceof KeyEvent) { KeyEvent e = (KeyEvent) event; KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e); - KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphafineConfigManager().getShortCutKeyStore(); + KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore(); if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString())) { doClickAction(); } 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 6c23ab4039..754ceab1c9 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java @@ -2,8 +2,8 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.base.BaseUtils; import com.fr.design.DesignerEnvManager; -import com.fr.design.actions.help.alphafine.AlphafineContext; -import com.fr.design.actions.help.alphafine.AlphafineListener; +import com.fr.design.actions.help.alphafine.AlphaFineContext; +import com.fr.design.actions.help.alphafine.AlphaFineListener; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.alphafine.AlphaFineHelper; @@ -28,7 +28,7 @@ public class AlphaFinePane extends BasicPane { } public AlphaFinePane() { setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 14)); - if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isEnabled()) { + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { Toolkit.getDefaultToolkit().addAWTEventListener(AlphaFineDialog.listener(), AWTEvent.KEY_EVENT_MASK); } UIButton refreshButton = new UIButton(); @@ -42,7 +42,7 @@ public class AlphaFinePane extends BasicPane { AlphaFineHelper.showAlphaFineDialog(false); } }); - AlphafineContext.addAlphafineContextListener(new AlphafineListener() { + AlphaFineContext.addAlphafineContextListener(new AlphaFineListener() { @Override public void showDialog() { AlphaFineHelper.showAlphaFineDialog(true); 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 4ab43181b4..aefb274321 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 @@ -36,7 +36,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { filterModelList = new SearchResult(); lessModelList = new SearchResult(); moreModelList = new SearchResult(); - if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainAction()) { + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainAction()) { List updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); for (UpdateActionModel updateActionModel : updateActions) { if (StringUtils.isNotBlank(updateActionModel.getSearchKey())) { 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 45076ae185..1468d36e7b 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 @@ -1,8 +1,6 @@ package com.fr.design.mainframe.alphafine.search.manager; import com.fr.design.DesignerEnvManager; -import com.fr.design.actions.help.alphafine.AlphafineContext; -import com.fr.design.actions.help.alphafine.AlphafineListener; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; @@ -11,7 +9,6 @@ import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONException; @@ -38,7 +35,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { public synchronized SearchResult getLessSearchResult(String searchText) { lessModelList = new SearchResult(); moreModelList = new SearchResult(); - if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainDocument()) { + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainDocument()) { String result; String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText + "-1"; HttpClient httpClient = new HttpClient(url); diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java index 63020b54bd..96bdba265b 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java @@ -44,7 +44,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { this.filterModelList = new SearchResult(); this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); - if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) { + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) { Env env = FRContext.getCurrentEnv(); fileNodes = new ArrayList<>(); fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true); @@ -87,7 +87,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { * @param filePath */ private void searchFileContent(String searchText, FileNode node, boolean isAlreadyContain, String filePath) { - if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainFileContent()) { + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainFileContent()) { try { BufferedReader reader = new BufferedReader(new FileReader(filePath)); @@ -121,7 +121,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { * @return */ private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) { - if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) { + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) { if (node.getName().toLowerCase().contains(searchText.toLowerCase())) { FileModel model = new FileModel(node.getName(), node.getEnvPath()); this.filterModelList.add(model); 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 3ce21d9fe9..fe2e0d8cec 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 @@ -1,19 +1,15 @@ package com.fr.design.mainframe.alphafine.search.manager; import com.fr.design.DesignerEnvManager; -import com.fr.design.actions.help.alphafine.AlphafineContext; -import com.fr.design.actions.help.alphafine.AlphafineListener; 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.NoResultModel; import com.fr.design.mainframe.alphafine.cell.model.PluginModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; -import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONObject; @@ -46,7 +42,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { public synchronized SearchResult getLessSearchResult(String searchText) { this.lessModelList = new SearchResult(); this.moreModelList = new SearchResult(); - if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainPlugin()) { + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainPlugin()) { String result; try { String encodedKey = URLEncoder.encode(searchText, "UTF-8"); 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 bc0f66eaf8..7e887dd3a4 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 @@ -32,7 +32,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { @Override public synchronized SearchResult getLessSearchResult(String searchText) { this.modelList = new SearchResult(); - if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainRecommend()) { + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) { String result; HttpClient httpClient = new HttpClient(SEARCHAPI + CodeUtils.cjkEncode(searchText)); httpClient.asGet(); diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java index 90d84059b3..a2c11639ab 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -213,15 +213,15 @@ public class UserInfoLabel extends UILabel { para.put("username", encode(encode(userName))); HttpClient getMessage = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.message"), para); getMessage.asGet(); - if (getMessage.isServerAlive()) { - try { - String res = getMessage.getResponseText(); - if (StringUtils.isNotEmpty(res)) { - setMessageCount(Integer.parseInt(res)); - } - } catch (Exception e) { - } - } +// if (getMessage.isServerAlive()) { +// try { +// String res = getMessage.getResponseText(); +// if (StringUtils.isNotEmpty(res)) { +// setMessageCount(Integer.parseInt(res)); +// } +// } catch (Exception e) { +// } +// } sleep(CHECK_MESSAGE_TIME); } } diff --git a/designer_base/src/com/fr/aspectj/designerbase/AlphaFineReminder.aj b/designer_base/src/com/fr/aspectj/designerbase/AlphaFineReminder.aj index 48701f7640..aef3d7a404 100644 --- a/designer_base/src/com/fr/aspectj/designerbase/AlphaFineReminder.aj +++ b/designer_base/src/com/fr/aspectj/designerbase/AlphaFineReminder.aj @@ -1,7 +1,7 @@ package com.fr.aspectj.designerbase; import com.fr.design.DesignerEnvManager; -import com.fr.design.actions.help.alphafine.AlphafineConfigManager; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.RemindDialog; import com.fr.design.mainframe.DesignerContext; @@ -30,7 +30,7 @@ public aspect AlphaFineReminder { * 判断是否弹出广告框 */ private static void remind() { - AlphafineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphafineConfigManager(); + AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); if (manager.isNeedRemind()) { if (manager.getOperateCount() > 4) { diff --git a/designer_base/src/com/fr/design/DesignerEnvManager.java b/designer_base/src/com/fr/design/DesignerEnvManager.java index 75b4749d83..2dd6bef373 100644 --- a/designer_base/src/com/fr/design/DesignerEnvManager.java +++ b/designer_base/src/com/fr/design/DesignerEnvManager.java @@ -5,7 +5,7 @@ package com.fr.design; import com.fr.base.*; import com.fr.dav.LocalEnv; -import com.fr.design.actions.help.alphafine.AlphafineConfigManager; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.constants.UIConstants; import com.fr.env.RemoteEnv; import com.fr.env.SignIn; @@ -108,7 +108,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { /** * alphafine */ - private AlphafineConfigManager alphafineConfigManager = new AlphafineConfigManager(); + private AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager(); public static final String CAS_CERTIFICATE_PATH = "certificatePath"; @@ -1344,7 +1344,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } private void readAlphaFineAttr(XMLableReader reader) { - reader.readXMLObject(this.alphafineConfigManager = new AlphafineConfigManager()); + reader.readXMLObject(this.alphaFineConfigManager = new AlphaFineConfigManager()); } private void readHttpsParas(XMLableReader reader){ @@ -1551,8 +1551,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } private void writeAlphaFineAttr(XMLPrintWriter writer) { - if (this.alphafineConfigManager != null) { - this.alphafineConfigManager.writeXML(writer); + if (this.alphaFineConfigManager != null) { + this.alphaFineConfigManager.writeXML(writer); } } @@ -1830,11 +1830,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { return env; } - public AlphafineConfigManager getAlphafineConfigManager() { - return alphafineConfigManager; + public AlphaFineConfigManager getAlphaFineConfigManager() { + return alphaFineConfigManager; } - public void setAlphafineConfigManager(AlphafineConfigManager alphafineConfigManager) { - this.alphafineConfigManager = alphafineConfigManager; + public void setAlphaFineConfigManager(AlphaFineConfigManager alphaFineConfigManager) { + this.alphaFineConfigManager = alphaFineConfigManager; } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineAction.java b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineAction.java similarity index 77% rename from designer_base/src/com/fr/design/actions/help/alphafine/AlphafineAction.java rename to designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineAction.java index 23cf7de758..ea10361b1d 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineAction.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineAction.java @@ -1,6 +1,5 @@ package com.fr.design.actions.help.alphafine; -import com.fr.base.BaseUtils; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; @@ -17,13 +16,13 @@ import java.awt.event.ActionEvent; /** * Created by XiaXiang on 2017/4/1. */ -public class AlphafineAction extends UpdateAction { - public AlphafineAction() { +public class AlphaFineAction extends UpdateAction { + public AlphaFineAction() { this.setMenuKeySet(ALPHAFINE); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); - this.setSearchText(new AlphafineConfigPane()); + this.setSearchText(new AlphaFineConfigPane()); } public static final MenuKeySet ALPHAFINE = new MenuKeySet() { @@ -49,15 +48,15 @@ public class AlphafineAction extends UpdateAction { public void actionPerformed(ActionEvent e) { final DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); - final AlphafineConfigPane alphafineConfigPane = new AlphafineConfigPane(); - alphafineConfigPane.populate(DesignerEnvManager.getEnvManager().getAlphafineConfigManager()); + final AlphaFineConfigPane alphaFineConfigPane = new AlphaFineConfigPane(); + alphaFineConfigPane.populate(DesignerEnvManager.getEnvManager().getAlphaFineConfigManager()); DialogActionListener dialogActionListener = new DialogActionAdapter() { public void doOk() { - alphafineConfigPane.update(); + alphaFineConfigPane.update(); designerFrame.refreshToolbar(); } }; - BasicDialog basicDialog = alphafineConfigPane.showMediumWindow(designerFrame, dialogActionListener); + BasicDialog basicDialog = alphaFineConfigPane.showMediumWindow(designerFrame, dialogActionListener); basicDialog.setVisible(true); } } 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 similarity index 96% rename from designer_base/src/com/fr/design/actions/help/alphafine/AlphafineConfigManager.java rename to designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index c119e09b99..5df9691adb 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 @@ -11,7 +11,7 @@ import javax.swing.*; /** * Created by XiaXiang on 2017/4/5. */ -public class AlphafineConfigManager implements XMLable { +public class AlphaFineConfigManager implements XMLable { /** * 是否开启alphafine @@ -80,10 +80,10 @@ public class AlphafineConfigManager implements XMLable { - private static AlphafineConfigManager alphafineConfigManager = new AlphafineConfigManager(); + private static AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager(); - public static AlphafineConfigManager getInstance() { - return alphafineConfigManager; + public static AlphaFineConfigManager getInstance() { + return alphaFineConfigManager; } @Override 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 similarity index 80% rename from designer_base/src/com/fr/design/actions/help/alphafine/AlphafineConfigPane.java rename to designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index d982cbeece..79d887dc6b 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 @@ -20,7 +20,7 @@ import java.awt.event.KeyEvent; /** * Created by XiaXiang on 2017/4/6. */ -public class AlphafineConfigPane extends BasicPane { +public class AlphaFineConfigPane extends BasicPane { private static final String TYPE = "pressed"; private static final String DISPLAY_TYPE = "+"; private static final String BACK_SLASH = "BACK_SLASH"; @@ -56,7 +56,7 @@ public class AlphafineConfigPane extends BasicPane { private UICheckBox isEnabledCheckbox, isSearchOnlineCheckbox, isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox, isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox; private UITextField shortcutsField; - public AlphafineConfigPane() { + public AlphaFineConfigPane() { this.initComponents(); } @@ -71,7 +71,7 @@ public class AlphafineConfigPane extends BasicPane { } - private Component[][] initsearchRangeComponents() { + private Component[][] initSearchRangeComponents() { Component[][] components = new Component[][]{ new Component[]{isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox}, new Component[]{isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox} @@ -91,7 +91,7 @@ public class AlphafineConfigPane extends BasicPane { isContainDocumentCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_COMMUNITY_HELP")); isContainTemplateCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_Templates")); isContainFileContentCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_Templates_Content")); - JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initsearchRangeComponents(), rowSize, columnSize); + JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initSearchRangeComponents(), rowSize, columnSize); northPane.add(searchConfigPane); contentPane.add(northPane); } @@ -154,34 +154,35 @@ public class AlphafineConfigPane extends BasicPane { return "AlphaFine"; } - public void populate(AlphafineConfigManager alphafineConfigManager) { - this.isEnabledCheckbox.setSelected(alphafineConfigManager.isEnabled()); - this.isSearchOnlineCheckbox.setSelected(alphafineConfigManager.isSearchOnLine()); - this.isContainActionCheckbox.setSelected(alphafineConfigManager.isContainAction()); - this.isContainTemplateCheckbox.setSelected(alphafineConfigManager.isContainTemplate()); - this.isContainDocumentCheckbox.setSelected(alphafineConfigManager.isContainDocument() && alphafineConfigManager.isSearchOnLine()); - this.isContainDocumentCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine()); - this.isContainPluginCheckbox.setSelected(alphafineConfigManager.isContainPlugin() && alphafineConfigManager.isSearchOnLine()); - this.isContainPluginCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine()); - this.isContainRecommendCheckbox.setSelected(alphafineConfigManager.isContainRecommend() && alphafineConfigManager.isSearchOnLine()); - this.isContainRecommendCheckbox.setEnabled(alphafineConfigManager.isSearchOnLine()); - this.shortcutsField.setText(getDisplayShortCut(alphafineConfigManager.getShortcuts())); - shortCutKeyStore = convert2KeyStroke(alphafineConfigManager.getShortcuts()); + public void populate(AlphaFineConfigManager alphaFineConfigManager) { + this.isEnabledCheckbox.setSelected(alphaFineConfigManager.isEnabled()); + this.isSearchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine()); + this.isContainActionCheckbox.setSelected(alphaFineConfigManager.isContainAction()); + this.isContainTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate()); + this.isContainFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent()); + this.isContainDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine()); + this.isContainDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.isContainPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine()); + this.isContainPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.isContainRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine()); + this.isContainRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts())); + shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts()); } public void update() { DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); - AlphafineConfigManager alphafineConfigManager = designerEnvManager.getAlphafineConfigManager(); - alphafineConfigManager.setContainPlugin(this.isContainPluginCheckbox.isSelected()); - alphafineConfigManager.setContainAction(this.isContainActionCheckbox.isSelected()); - alphafineConfigManager.setContainDocument(this.isContainDocumentCheckbox.isSelected()); - alphafineConfigManager.setContainRecommend(this.isContainRecommendCheckbox.isSelected()); - alphafineConfigManager.setEnabled(this.isEnabledCheckbox.isSelected()); - alphafineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected()); - alphafineConfigManager.setContainTemplate(this.isContainTemplateCheckbox.isSelected()); - alphafineConfigManager.setContainFileContent(this.isContainFileContentCheckbox.isSelected()); - alphafineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText()); - designerEnvManager.setAlphafineConfigManager(alphafineConfigManager); + AlphaFineConfigManager alphaFineConfigManager = designerEnvManager.getAlphaFineConfigManager(); + alphaFineConfigManager.setContainPlugin(this.isContainPluginCheckbox.isSelected()); + alphaFineConfigManager.setContainAction(this.isContainActionCheckbox.isSelected()); + alphaFineConfigManager.setContainDocument(this.isContainDocumentCheckbox.isSelected()); + alphaFineConfigManager.setContainRecommend(this.isContainRecommendCheckbox.isSelected()); + alphaFineConfigManager.setEnabled(this.isEnabledCheckbox.isSelected()); + alphaFineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected()); + alphaFineConfigManager.setContainTemplate(this.isContainTemplateCheckbox.isSelected()); + alphaFineConfigManager.setContainFileContent(this.isContainFileContentCheckbox.isSelected()); + alphaFineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText()); + designerEnvManager.setAlphaFineConfigManager(alphaFineConfigManager); try { DesignerEnvManager.loadLogSetting(); DesignerEnvManager.getEnvManager().saveXMLFile(); @@ -192,8 +193,8 @@ public class AlphafineConfigPane extends BasicPane { } - private String getDisplayShortCut(String shotrCut) { - return shotrCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH) + private String getDisplayShortCut(String shortCut) { + return shortCut.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(COMMAND, DISPLAY_COMMAND).replace(SMALL_COMMAND, DISPLAY_COMMAND); diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineContext.java b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java similarity index 63% rename from designer_base/src/com/fr/design/actions/help/alphafine/AlphafineContext.java rename to designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java index 429f299d6c..ef14b0753e 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineContext.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java @@ -6,14 +6,14 @@ import java.util.List; /** * Created by XiaXiang on 2017/5/27. */ -public class AlphafineContext { - private static List fireLoginContextListener = new ArrayList(); +public class AlphaFineContext { + private static List fireLoginContextListener = new ArrayList(); /** * 触发AlphaFine弹窗 */ public static void fireAlphaFineContextListener() { - for (AlphafineListener l : fireLoginContextListener) { + for (AlphaFineListener l : fireLoginContextListener) { l.showDialog(); } } @@ -23,7 +23,7 @@ public class AlphafineContext { * * @param l AlphaFine框弹出监听事件 */ - public static void addAlphafineContextListener(AlphafineListener l) { + public static void addAlphafineContextListener(AlphaFineListener l) { fireLoginContextListener.add(l); } } diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineListener.java b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java similarity index 75% rename from designer_base/src/com/fr/design/actions/help/alphafine/AlphafineListener.java rename to designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java index 01c7905d61..c7c5931266 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/AlphafineListener.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java @@ -3,6 +3,6 @@ package com.fr.design.actions.help.alphafine; /** * Created by XiaXiang on 2017/5/27. */ -public interface AlphafineListener { +public interface AlphaFineListener { void showDialog(); } diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java b/designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java index 9ae6f864a4..eca6eab55f 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java @@ -22,7 +22,7 @@ public class RemindDialog extends UIDialog { } private void initComponent() { - final AlphafineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphafineConfigManager(); + final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); remindPane = new RemindPane(manager, this); this.add(remindPane); diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java b/designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java index 1e8261965c..acecfb08be 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java @@ -42,7 +42,7 @@ public class RemindPane extends JPanel { } }; - public RemindPane(AlphafineConfigManager manager, UIDialog remindDialog) { + public RemindPane(AlphaFineConfigManager manager, UIDialog remindDialog) { this.setPreferredSize(new Dimension(WIDTH, HEIGHT)); initUI(manager, remindDialog); this.setLayout(getAbsoluteLayout()); @@ -53,7 +53,7 @@ public class RemindPane extends JPanel { * @param manager * @param dialog */ - private void initUI(final AlphafineConfigManager manager, final UIDialog dialog) { + private void initUI(final AlphaFineConfigManager manager, final UIDialog dialog) { openButton = new UIButton(); openButton.setIcon(openIcon); @@ -63,7 +63,7 @@ public class RemindPane extends JPanel { public void mousePressed(MouseEvent e) { manager.setOperateCount(0); dialog.dispose(); - AlphafineContext.fireAlphaFineContextListener(); + AlphaFineContext.fireAlphaFineContextListener(); } }); diff --git a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java index f67608aca0..c3b6abee24 100644 --- a/designer_base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer_base/src/com/fr/design/mainframe/DesignerFrame.java @@ -197,7 +197,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } }); - if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isEnabled()) { + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { northEastPane.add(ad.createAlphafinePane(), BorderLayout.CENTER); } return northEastPane; diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 9c9a356310..d71bd9b5f1 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -11,7 +11,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.actions.community.*; import com.fr.design.actions.file.*; import com.fr.design.actions.help.AboutAction; -import com.fr.design.actions.help.alphafine.AlphafineAction; +import com.fr.design.actions.help.alphafine.AlphaFineAction; import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.WebDemoAction; import com.fr.design.actions.server.*; @@ -374,7 +374,7 @@ public abstract class ToolBarMenuDock { shortCuts.add(SeparatorDef.DEFAULT); shortCuts.add(new AboutAction()); shortCuts.add(SeparatorDef.DEFAULT); - shortCuts.add(new AlphafineAction()); + shortCuts.add(new AlphaFineAction()); return shortCuts.toArray(new ShortCut[shortCuts.size()]); } From bbd221fd9878a8edade1bd6513297f86ac4206d0 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 18:20:33 +0800 Subject: [PATCH 09/17] alphafine bug fix --- .../mainframe/alphafine/search/manager/FileSearchManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java index 96bdba265b..b3d8ee9415 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java @@ -171,7 +171,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { } else { nodeList.add(fns[i]); } - } else { + } else if (fileNode.isFileType("cpt") || fileNode.isFileType("frm")) { nodeList.add(fileNode); } } From aeec29f711896ecd7daf6c8b6206017134dd1da2 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 18:36:54 +0800 Subject: [PATCH 10/17] bug fix alphafine --- .../alphafine/search/manager/ActionSearchManager.java | 2 +- .../alphafine/search/manager/DocumentSearchManager.java | 8 ++++---- .../alphafine/search/manager/PluginSearchManager.java | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) 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 aefb274321..a38c52b434 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 @@ -40,7 +40,7 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { List updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); for (UpdateActionModel updateActionModel : updateActions) { if (StringUtils.isNotBlank(updateActionModel.getSearchKey())) { - if (updateActionModel.getSearchKey().toLowerCase().contains(searchText.toLowerCase()) ) { + if (updateActionModel.getSearchKey().toLowerCase().contains(searchText.toLowerCase()) && updateActionModel.getAction().isEnabled()) { filterModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction())); } } 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 1468d36e7b..7d5d4a6dfa 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 @@ -21,7 +21,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { private static DocumentSearchManager documentSearchManager = null; private SearchResult lessModelList; private SearchResult moreModelList; - private static final MoreModel titleModel = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT); + private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT); public synchronized static DocumentSearchManager getDocumentSearchManager() { if (documentSearchManager == null) { @@ -64,7 +64,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); } else { - lessModelList.add(0, titleModel); + lessModelList.add(0, TITLE_MODEL); if (lessModelList.size() == 1) { lessModelList.add(AlphaFineHelper.noResultModel); } @@ -84,7 +84,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { private SearchResult getNoResultList() { SearchResult result = new SearchResult(); - result.add(0, titleModel); + result.add(0, TITLE_MODEL); result.add(AlphaFineHelper.noResultModel); return result; @@ -92,7 +92,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { private SearchResult getNoConnectList() { SearchResult result = new SearchResult(); - result.add(0, titleModel); + result.add(0, TITLE_MODEL); result.add(AlphaFineHelper.noConnectionModel); return result; } 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 fe2e0d8cec..44266cad27 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 @@ -23,7 +23,7 @@ import java.net.URLEncoder; public class PluginSearchManager implements AlphaFineSearchProcessor { private static PluginSearchManager pluginSearchManager = null; - private static final MoreModel titleModel = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN); + private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN); private SearchResult lessModelList; @@ -72,7 +72,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); } else { - lessModelList.add(0, titleModel); + lessModelList.add(0, TITLE_MODEL); if (lessModelList.size() == 1) { lessModelList.add(AlphaFineHelper.noResultModel); } @@ -94,7 +94,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { private SearchResult getNoResultList() { SearchResult result = new SearchResult(); - result.add(0, titleModel); + result.add(0, TITLE_MODEL); result.add(AlphaFineHelper.noResultModel); return result; @@ -102,7 +102,7 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { private SearchResult getNoConnectList() { SearchResult result = new SearchResult(); - result.add(0, titleModel); + result.add(0, TITLE_MODEL); result.add(AlphaFineHelper.noConnectionModel); return result; } From e65dda5529702ac0eb5f5d9bb3bd8b9e605fdeb9 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 20:00:55 +0800 Subject: [PATCH 11/17] bug fix --- .../fr/design/mainframe/bbs/UserInfoLabel.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java index a2c11639ab..90d84059b3 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -213,15 +213,15 @@ public class UserInfoLabel extends UILabel { para.put("username", encode(encode(userName))); HttpClient getMessage = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("bbs.message"), para); getMessage.asGet(); -// if (getMessage.isServerAlive()) { -// try { -// String res = getMessage.getResponseText(); -// if (StringUtils.isNotEmpty(res)) { -// setMessageCount(Integer.parseInt(res)); -// } -// } catch (Exception e) { -// } -// } + if (getMessage.isServerAlive()) { + try { + String res = getMessage.getResponseText(); + if (StringUtils.isNotEmpty(res)) { + setMessageCount(Integer.parseInt(res)); + } + } catch (Exception e) { + } + } sleep(CHECK_MESSAGE_TIME); } } From be32292bbdd72bddee878276498eb0f3fabcf0e9 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 21:48:58 +0800 Subject: [PATCH 12/17] alphafine bug fix --- .../alphafine/component/AlphaFineDialog.java | 6 ++---- .../alphafine/component/AlphaFinePane.java | 16 +++++++++++----- designer/src/com/fr/start/Designer.java | 2 +- .../actions/help/alphafine/AlphaFineAction.java | 9 +++++++-- .../help/alphafine/AlphaFineContext.java | 17 ++++++++++++----- .../help/alphafine/AlphaFineListener.java | 1 + .../actions/help/alphafine/RemindPane.java | 2 +- 7 files changed, 35 insertions(+), 18 deletions(-) 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 81188d9f4e..1b975f948f 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -122,8 +122,6 @@ public class AlphaFineDialog extends UIDialog { searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { -// lastUpdateTime = System.currentTimeMillis(); -// waitingForSearch = true; doSearch(searchTextField.getText()); } }); @@ -590,7 +588,7 @@ public class AlphaFineDialog extends UIDialog { if (SwingUtilities.isLeftMouseButton(k)) { Point p = k.getLocationOnScreen(); Rectangle dialogRectangle = AlphaFineDialog.this.getBounds(); - Rectangle paneRectangle = new Rectangle(AlphaFinePane.createAlphaFinePane().getLocationOnScreen(), AlphaFinePane.createAlphaFinePane().getSize()); + Rectangle paneRectangle = new Rectangle(AlphaFinePane.getAlphaFinePane().getLocationOnScreen(), AlphaFinePane.getAlphaFinePane().getSize()); if (!dialogRectangle.contains(p) && !paneRectangle.contains(p) && !forceOpen) { AlphaFineDialog.this.dispose(); forceOpen = false; @@ -614,7 +612,7 @@ public class AlphaFineDialog extends UIDialog { KeyEvent e = (KeyEvent) event; KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e); KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore(); - if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString())) { + if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) { doClickAction(); } 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 754ceab1c9..3d4173bc5c 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java @@ -1,12 +1,12 @@ package com.fr.design.mainframe.alphafine.component; -import com.fr.base.BaseUtils; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.help.alphafine.AlphaFineContext; import com.fr.design.actions.help.alphafine.AlphaFineListener; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.alphafine.AlphaFineHelper; +import com.fr.general.IOUtils; import com.fr.general.Inter; import javax.swing.*; @@ -20,7 +20,7 @@ import java.awt.event.ActionListener; public class AlphaFinePane extends BasicPane { private static AlphaFinePane alphaFinePane; - public static AlphaFinePane createAlphaFinePane() { + public static AlphaFinePane getAlphaFinePane() { if (alphaFinePane == null) { alphaFinePane = new AlphaFinePane(); } @@ -32,8 +32,8 @@ public class AlphaFinePane extends BasicPane { Toolkit.getDefaultToolkit().addAWTEventListener(AlphaFineDialog.listener(), AWTEvent.KEY_EVENT_MASK); } UIButton refreshButton = new UIButton(); - refreshButton.setIcon(BaseUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); - refreshButton.setToolTipText(Inter.getLocText("FR-Designer_Alphafine")); + refreshButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); + refreshButton.setToolTipText(Inter.getLocText("AlphaFine")); refreshButton.set4ToolbarButton(); this.add(refreshButton); refreshButton.addActionListener(new ActionListener() { @@ -42,11 +42,17 @@ public class AlphaFinePane extends BasicPane { AlphaFineHelper.showAlphaFineDialog(false); } }); - AlphaFineContext.addAlphafineContextListener(new AlphaFineListener() { + AlphaFineContext.addAlphaFineListener(new AlphaFineListener() { @Override public void showDialog() { AlphaFineHelper.showAlphaFineDialog(true); } + + @Override + public void setEnable(boolean isEnable) { + alphaFinePane.setVisible(isEnable); + + } }); } diff --git a/designer/src/com/fr/start/Designer.java b/designer/src/com/fr/start/Designer.java index 276c11b96f..b6855fdb01 100644 --- a/designer/src/com/fr/start/Designer.java +++ b/designer/src/com/fr/start/Designer.java @@ -346,7 +346,7 @@ public class Designer extends BaseDesigner { * @return 面板组件 */ public Component createAlphafinePane() { - return AlphaFinePane.createAlphaFinePane(); + return AlphaFinePane.getAlphaFinePane(); } diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineAction.java b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineAction.java index ea10361b1d..221354108f 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineAction.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineAction.java @@ -1,5 +1,6 @@ package com.fr.design.actions.help.alphafine; +import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; @@ -49,11 +50,15 @@ public class AlphaFineAction extends UpdateAction { final DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); final AlphaFineConfigPane alphaFineConfigPane = new AlphaFineConfigPane(); - alphaFineConfigPane.populate(DesignerEnvManager.getEnvManager().getAlphaFineConfigManager()); + final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); + if (!FRContext.isChineseEnv()) { + manager.setSearchOnLine(false); + } + alphaFineConfigPane.populate(manager); DialogActionListener dialogActionListener = new DialogActionAdapter() { public void doOk() { alphaFineConfigPane.update(); - designerFrame.refreshToolbar(); + AlphaFineContext.fireAlphaFineEnable(manager.isEnabled()); } }; BasicDialog basicDialog = alphaFineConfigPane.showMediumWindow(designerFrame, dialogActionListener); diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java index ef14b0753e..77ff93c1d7 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java @@ -7,23 +7,30 @@ import java.util.List; * Created by XiaXiang on 2017/5/27. */ public class AlphaFineContext { - private static List fireLoginContextListener = new ArrayList(); + private static List fireAlphaFineListener = new ArrayList(); /** * 触发AlphaFine弹窗 */ - public static void fireAlphaFineContextListener() { - for (AlphaFineListener l : fireLoginContextListener) { + public static void fireAlphaFineShowDialog() { + for (AlphaFineListener l : fireAlphaFineListener) { l.showDialog(); } } + public static void fireAlphaFineEnable(boolean isEnable) { + for (AlphaFineListener l : fireAlphaFineListener) { + l.setEnable(isEnable); + } + } + /** * 添加一个弹出AlphaFine的监听事件 * * @param l AlphaFine框弹出监听事件 */ - public static void addAlphafineContextListener(AlphaFineListener l) { - fireLoginContextListener.add(l); + public static void addAlphaFineListener(AlphaFineListener l) { + fireAlphaFineListener.add(l); } + } diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java index c7c5931266..b11696640d 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java @@ -5,4 +5,5 @@ package com.fr.design.actions.help.alphafine; */ public interface AlphaFineListener { void showDialog(); + void setEnable(boolean isEnable); } diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java b/designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java index acecfb08be..dce47b97a2 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/RemindPane.java @@ -63,7 +63,7 @@ public class RemindPane extends JPanel { public void mousePressed(MouseEvent e) { manager.setOperateCount(0); dialog.dispose(); - AlphaFineContext.fireAlphaFineContextListener(); + AlphaFineContext.fireAlphaFineShowDialog(); } }); From 9df5b1442942ea556a11cad556785962b63cff9e Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 8 Jun 2017 22:10:44 +0800 Subject: [PATCH 13/17] alphafine bug fix --- .../manager/RecommendSearchManager.java | 4 ++-- .../help/alphafine/AlphaFineConfigPane.java | 4 +++- .../com/fr/design/locale/designer.properties | 2 +- .../design/locale/designer_en_US.properties | 20 ++++++++++--------- .../design/locale/designer_zh_CN.properties | 2 +- .../design/locale/designer_zh_TW.properties | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) 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 7e887dd3a4..b632418680 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 @@ -61,7 +61,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { FRLogger.getLogger().error("data transform error! :" + e.getMessage()); } if (modelList.size() > 0) { - modelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude"), false)); + modelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Recommend"), false)); } } @@ -70,7 +70,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { private SearchResult getNoConnectList() { SearchResult result = new SearchResult(); - result.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Conclude"), false)); + result.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Recommend"), false)); result.add(AlphaFineHelper.noConnectionModel); return result; } 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 79d887dc6b..59fef59523 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 @@ -1,5 +1,6 @@ package com.fr.design.actions.help.alphafine; +import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; @@ -85,7 +86,7 @@ public class AlphaFineConfigPane extends BasicPane { double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP}; JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_AlphaFine_SearchRange")); - isContainRecommendCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_AlphaFine_Conclude")); + isContainRecommendCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_AlphaFine_Recommend")); isContainActionCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_Set")); isContainPluginCheckbox = new UICheckBox(Inter.getLocText("FR-Designer-Plugin_Addon")); isContainDocumentCheckbox = new UICheckBox(Inter.getLocText("FR-Designer_COMMUNITY_HELP")); @@ -156,6 +157,7 @@ public class AlphaFineConfigPane extends BasicPane { public void populate(AlphaFineConfigManager alphaFineConfigManager) { this.isEnabledCheckbox.setSelected(alphaFineConfigManager.isEnabled()); + this.isSearchOnlineCheckbox.setEnabled(FRContext.isChineseEnv()); this.isSearchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine()); this.isContainActionCheckbox.setSelected(alphaFineConfigManager.isContainAction()); this.isContainTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate()); diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index a4c185e6f6..3dda9c1dd9 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -1998,7 +1998,7 @@ FR-Designer_AlphaFine_EnableInternet=Designer_AlphaFine_EnableInternet FR-Designer_AlphaFine_EnableInternetSearch=SearchOnLine FR-Designer_AlphaFine_Shortcut_Config=Shortcut Config FR-Designer_AlphaFine_SearchRange=Search Range -FR-Designer_AlphaFine_Conclude=Conclude +FR-Designer_AlphaFine_Recommend=Recommend FR-Designer-Plugin_Addon=Plugin Addon FR-Designer_Templates=FR-Designer_Templates FR-Designer_Templates_Content=Templates Contents diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index c47970e1d2..5afd87f465 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -1993,17 +1993,19 @@ FR-Designer_Permissions=Permissions FR-Designer_Form_Button=Button FR-Designer_WF_Name=Name FR-Designer_AlphaFine_Enable=Enable -FR-Designer_AlphaFine_EnableInternetSearch=SearchOnLine +FR-Designer_AlphaFine_EnableInternetSearch=Search OnLine FR-Designer_AlphaFine_Shortcut_Config=Shortcut Config FR-Designer_AlphaFine_SearchRange=Search Range -FR-Designer_AlphaFine_Conclude=Conclude +FR-Designer_AlphaFine_Recommend=Recommend FR-Designer-Plugin_Addon=Plugin Addon -FR-Designer_Templates=Templates -FR-Designer_Templates_Content=Template'Contents -FR-Designer_AlphaFine_ShowAll=show all +FR-Designer_Templates=Files +FR-Designer_Templates_Content=Files'contents +FR-Designer_AlphaFine_ShowAll=Show all FR-Designer_AlphaFine_Latest=Recent -FR-Designer_AlphaFine_ShowLess=show less +FR-Designer_AlphaFine_ShowLess=Show less FR-Designer_Alphafine=AlphaFine -FR-Designer-Alphafine_No_Remind=don't remind -FR-Designere_AlphaFine_NoResult=no results -FR-Designer_ConnectionFailed=connection failed \ No newline at end of file +FR-Designer-Alphafine_No_Remind=Don't remind +FR-Designere_AlphaFine_NoResult=No results +FR-Designer_ConnectionFailed=Connection failed +FR-Designer_AlphaFine_EnableAlphaFine=Enable AlphaFine +FR-Designer_AlphaFine_EnableInternet=Internet \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 749dba173c..104508b776 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -1998,7 +1998,7 @@ FR-Designer-Plugin_Addon=\u5E94\u7528\u4E2D\u5FC3 FR-Designer_Templates=\u6A21\u677F FR-Designer_Templates_Content=\u6A21\u677F\u5185\u5BB9 FR-Designer_AlphaFine_ShowAll=\u663E\u793A\u5168\u90E8 -FR-Designer_AlphaFine_Conclude=\u731C\u60A8\u9700\u8981 +FR-Designer_AlphaFine_Recommend=\u731C\u60A8\u9700\u8981 FR-Designer_AlphaFine_Latest=\u672C\u5730\u5E38\u7528 FR-Designer_AlphaFine_ShowLess=\u6536\u8D77 FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22 diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 0e0e2ee32d..2380dfe76b 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -1992,7 +1992,7 @@ FR-Designer_AlphaFine_EnableAlphaFine=\u958B\u555FAlphaFine\u529F\u80FD FR-Designer_AlphaFine_EnableInternetSearch=\u806F\u7DB2\u641C\u7D22 FR-Designer_AlphaFine_Shortcut_Config=\u5FEB\u6377\u9375\u914D\u7F6E FR-Designer_AlphaFine_SearchRange=\u641C\u7D22\u7BC4\u570D -FR-Designer_AlphaFine_Conclude=\u731C\u60A8\u9700\u8981 +FR-Designer_AlphaFine_Recommend=\u731C\u60A8\u9700\u8981 FR-Designer-Plugin_Addon=\u61C9\u7528\u4E2D\u5FC3 FR-Designer_Templates=\u6A21\u677F FR-Designer_Templates_Content=\u6A21\u677F\u5167\u5BB9 From ee6890d7bc04653811cbac57ea2701456c3d5b83 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Fri, 9 Jun 2017 17:17:40 +0800 Subject: [PATCH 14/17] =?UTF-8?q?alphafine=20bug=20fix=20=E5=8E=BB?= =?UTF-8?q?=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/alphafine/AlphaFineHelper.java | 17 ++++- .../alphafine/component/AlphaFinePane.java | 2 +- .../search/manager/ActionSearchManager.java | 33 +++++----- .../search/manager/DocumentSearchManager.java | 42 +++++-------- .../search/manager/FileSearchManager.java | 33 +++++----- .../search/manager/PluginSearchManager.java | 54 +++++++--------- .../search/manager/RecentSearchManager.java | 62 +------------------ .../manager/RecommendSearchManager.java | 20 ++++-- 8 files changed, 107 insertions(+), 156 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 53b60c6b2c..1cfe25c4da 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -3,18 +3,24 @@ package com.fr.design.mainframe.alphafine; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; 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.search.manager.RecentSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.RecommendSearchManager; import com.fr.general.Inter; import com.fr.general.ProcessCanceledException; import com.fr.stable.StringUtils; +import java.util.ArrayList; +import java.util.List; + /** * Created by XiaXiang on 2017/5/8. */ public class AlphaFineHelper { - public static final NoResultModel noResultModel = new NoResultModel(Inter.getLocText("FR-Designere_AlphaFine_NoResult")); - public static final NoResultModel noConnectionModel = new NoResultModel(Inter.getLocText("FR-Designer_ConnectionFailed")); + public static final NoResultModel NO_RESULT_MODEL = new NoResultModel(Inter.getLocText("FR-Designer_AlphaFine_NoResult")); + public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(Inter.getLocText("FR-Designer_ConnectionFailed")); /** * 弹出alphafine搜索面板 @@ -70,6 +76,13 @@ public class AlphaFineHelper { } } + public static List getFilterResult() { + List recentList = RecentSearchManager.getRecentSearchManger().getRecentModelList(); + List recommendList = RecommendSearchManager.getRecommendSearchManager().getRecommendModelList(); + recentList.addAll(recommendList); + return recentList; + } + 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 3d4173bc5c..e5ea8e2588 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java @@ -33,7 +33,7 @@ public class AlphaFinePane extends BasicPane { } UIButton refreshButton = new UIButton(); refreshButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); - refreshButton.setToolTipText(Inter.getLocText("AlphaFine")); + refreshButton.setToolTipText(Inter.getLocText("FR-Designer_AlphaFine")); refreshButton.set4ToolbarButton(); this.add(refreshButton); refreshButton.addActionListener(new ActionListener() { 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 a38c52b434..8d21c239de 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 @@ -12,6 +12,7 @@ import com.fr.design.mainframe.toolbar.UpdateActionModel; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.StringUtils; +import com.fr.third.com.lowagie.text.pdf.PRAcroForm; import java.util.List; @@ -24,6 +25,9 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { private SearchResult lessModelList; private SearchResult moreModelList; + private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION); + private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION); + public synchronized static ActionSearchManager getActionSearchManager() { if (actionSearchManager == null) { actionSearchManager = new ActionSearchManager(); @@ -45,25 +49,24 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { } } } - - final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size()); - for (int i = 0; i < length; i++) { - lessModelList.add(filterModelList.get(i)); - } - for (int i = length; i < filterModelList.size(); i++) { - moreModelList.add(filterModelList.get(i)); + SearchResult result = new SearchResult(); + for (Object object : filterModelList) { + if (!AlphaFineHelper.getFilterResult().contains(object)) + result.add(object); } - if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION)); - } else { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION)); - if (lessModelList.size() == 1) { - lessModelList.add(AlphaFineHelper.noResultModel); + if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { + lessModelList.add(0, TITLE_MODEL); + if (result.size() == 0) { + lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); + } else { + lessModelList.addAll(result); } + } else { + lessModelList.add(0, MORE_MODEL); + lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size())); } - - } return lessModelList; } 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 7d5d4a6dfa..2c4e5546f9 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 @@ -22,6 +22,7 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { private SearchResult lessModelList; private SearchResult moreModelList; private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT); + private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT); public synchronized static DocumentSearchManager getDocumentSearchManager() { if (documentSearchManager == null) { @@ -50,50 +51,41 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { JSONObject jsonObject = new JSONObject(result); JSONArray jsonArray = jsonObject.optJSONArray("docdata"); if (jsonArray != null) { - final int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length()); - for (int i = 0; i < length; i++) { + SearchResult searchResult = new SearchResult(); + for (int i = 0; i < jsonArray.length(); i++) { AlphaFineHelper.checkCancel(); DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); - this.lessModelList.add(cellModel); - } - for (int i = length; i < jsonArray.length(); i++) { - AlphaFineHelper.checkCancel(); - DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i)); - this.moreModelList.add(cellModel); + if (!AlphaFineHelper.getFilterResult().contains(cellModel)) { + searchResult.add(cellModel); + } } - if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); - } else { + if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { lessModelList.add(0, TITLE_MODEL); - if (lessModelList.size() == 1) { - lessModelList.add(AlphaFineHelper.noResultModel); + if (searchResult.size() == 0) { + lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); + } else { + lessModelList.addAll(searchResult); } + } else { + lessModelList.add(0, MORE_MODEL); + lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } - - } } catch (JSONException e) { - FRLogger.getLogger().error(e.getMessage()); - return getNoResultList(); + FRLogger.getLogger().error("document search error: " + e.getMessage()); } } return lessModelList; } - private SearchResult getNoResultList() { - SearchResult result = new SearchResult(); - result.add(0, TITLE_MODEL); - result.add(AlphaFineHelper.noResultModel); - return result; - - } private SearchResult getNoConnectList() { SearchResult result = new SearchResult(); result.add(0, TITLE_MODEL); - result.add(AlphaFineHelper.noConnectionModel); + result.add(AlphaFineHelper.NO_CONNECTION_MODEL); return result; } diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java index b3d8ee9415..99e76ada1f 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java @@ -29,6 +29,9 @@ public class FileSearchManager implements AlphaFineSearchProcessor { private List fileNodes = null; private static FileSearchManager fileSearchManager = null; + private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE); + private static final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.FILE); + public synchronized static FileSearchManager getFileSearchManager() { init(); return fileSearchManager; @@ -56,26 +59,24 @@ public class FileSearchManager implements AlphaFineSearchProcessor { searchFileContent(searchText, node, isAlreadyContain, filePath); } - - final int length = Math.min(AlphaFineConstants.SHOW_SIZE, filterModelList.size()); - for (int i = 0; i < length; i++) { - lessModelList.add(filterModelList.get(i)); - } - for (int i = length; i< filterModelList.size(); i++) { - moreModelList.add(filterModelList.get(i)); + SearchResult result = new SearchResult(); + for (Object object : filterModelList) { + if (!AlphaFineHelper.getFilterResult().contains(object)) + result.add(object); } - - if (filterModelList.size() > AlphaFineConstants.SHOW_SIZE) { - lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.FILE)); - } else { - lessModelList.add(0,new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE)); - if (lessModelList.size() == 1) { - lessModelList.add(AlphaFineHelper.noResultModel); + if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { + lessModelList.add(0, TITLE_MODEL); + if (result.size() == 0) { + lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); + } else { + lessModelList.addAll(result); } + } else { + lessModelList.add(0, MORE_MODEL); + lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(result.subList(AlphaFineConstants.SHOW_SIZE, result.size())); } } - - return this.lessModelList; } 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 44266cad27..53fc0bb17d 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 @@ -12,6 +12,7 @@ import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; +import com.fr.json.JSONException; import com.fr.json.JSONObject; import java.io.UnsupportedEncodingException; @@ -24,7 +25,7 @@ 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 final MoreModel MORE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN); private SearchResult lessModelList; private SearchResult moreModelList; @@ -58,33 +59,32 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { JSONObject jsonObject = new JSONObject(result); JSONArray jsonArray = jsonObject.optJSONArray("result"); if (jsonArray != null) { - int length = Math.min(AlphaFineConstants.SHOW_SIZE, jsonArray.length()); - for (int i = 0; i < length; i++) { - AlphaFineHelper.checkCancel(); - PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); - this.lessModelList.add(cellModel); - } - for (int i = length; i < jsonArray.length(); i++) { - AlphaFineHelper.checkCancel(); + SearchResult searchResult = new SearchResult(); + for (int i = 0; i < jsonArray.length(); i++) { PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); - this.moreModelList.add(cellModel); + if (!AlphaFineHelper.getFilterResult().contains(cellModel)) { + searchResult.add(cellModel); + } } - if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) { - lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); - } else { + if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { lessModelList.add(0, TITLE_MODEL); - if (lessModelList.size() == 1) { - lessModelList.add(AlphaFineHelper.noResultModel); + if (searchResult.size() == 0) { + lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); + } else { + lessModelList.addAll(searchResult); } + } else { + lessModelList.add(0, MORE_MODEL); + lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); + moreModelList.addAll(searchResult.subList(AlphaFineConstants.SHOW_SIZE, searchResult.size())); } - } else { - return getNoResultList(); } - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - return getNoResultList(); + } catch (JSONException e) { + FRLogger.getLogger().error("plugin search json error :" + e.getMessage()); + } catch (UnsupportedEncodingException e) { + FRLogger.getLogger().error("plugin search encode error :" + e.getMessage()); } } return this.lessModelList; @@ -92,18 +92,10 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { } - private SearchResult getNoResultList() { - SearchResult result = new SearchResult(); - result.add(0, TITLE_MODEL); - result.add(AlphaFineHelper.noResultModel); - return result; - - } - private SearchResult getNoConnectList() { SearchResult result = new SearchResult(); result.add(0, TITLE_MODEL); - result.add(AlphaFineHelper.noConnectionModel); + result.add(AlphaFineHelper.NO_CONNECTION_MODEL); return result; } @@ -151,8 +143,4 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { } } - - - - } 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 8f818fd9d6..2d88acbe43 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 @@ -5,6 +5,7 @@ import com.fr.base.Utils; 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.CellModelHelper; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; @@ -40,10 +41,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear private static RecentSearchManager recentSearchManager = null; private static File recentFile = null; private SearchResult modelList; - private List fileList = new ArrayList<>(); - private List actionList = new ArrayList<>(); - private List documentList = new ArrayList<>(); - private List pluginList = new ArrayList<>(); private List recentModelList = new ArrayList<>(); private Map> recentKVModelMap = new HashMap<>(); @@ -99,7 +96,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear private void addModelToList(List list, String name) { try { - AlphaCellModel model = getModelFromJson(new JSONObject(name)); + AlphaCellModel model = CellModelHelper.getModelFromJson(new JSONObject(name)); if (model != null) { list.add(model); } @@ -108,60 +105,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear } } - /** - * 转成cellModel - * @param object - * @return - */ - private AlphaCellModel getModelFromJson(JSONObject object) { - int typeValue = object.optInt("cellType"); - AlphaCellModel cellModel = null; - switch (CellType.parse(typeValue)) { - case ACTION: - cellModel = ActionSearchManager.getModelFromCloud(object.optString("result")); - if (cellModel != null) { - actionList.add(cellModel); - } - break; - case DOCUMENT: - cellModel = DocumentSearchManager.getModelFromCloud(object.optJSONObject("result")); - if (cellModel != null) { - documentList.add(cellModel); - } - break; - case FILE: - cellModel = FileSearchManager.getModelFromCloud(object.optString("result")); - if (cellModel != null) { - fileList.add(cellModel); - } - break; - case PLUGIN: - case REUSE: - cellModel = PluginSearchManager.getModelFromCloud(object.optJSONObject("result")); - if (cellModel != null) { - pluginList.add(cellModel); - } - break; - - } - return cellModel; - } - - public List getFileList() { - return fileList; - } - - public List getActionList() { - return actionList; - } - - public List getDocumentList() { - return documentList; - } - - public List getPluginList() { - return pluginList; - } @Override public void writeXML(XMLPrintWriter writer) { @@ -210,7 +153,6 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear if (!envFile.exists()) { createRecentFile(envFile); } - return envFile; } 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 b632418680..051c8e66ee 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 @@ -14,12 +14,16 @@ import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.stable.CodeUtils; +import java.util.ArrayList; +import java.util.List; + /** * Created by XiaXiang on 2017/3/31. */ public class RecommendSearchManager implements AlphaFineSearchProcessor { 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="; @@ -51,17 +55,18 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { AlphaFineHelper.checkCancel(); AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); if (alphaCellModel != null && !RecentSearchManager.getRecentSearchManger().getRecentModelList().contains(alphaCellModel)) { - this.modelList.add(alphaCellModel); + this.recommendModelList.add(alphaCellModel); } } } } } catch (JSONException e) { - FRLogger.getLogger().error("data transform error! :" + e.getMessage()); + FRLogger.getLogger().error("recommend search error! :" + e.getMessage()); } if (modelList.size() > 0) { - modelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Recommend"), false)); + modelList.add(new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Recommend"), false)); + modelList.addAll(recommendModelList); } } @@ -71,7 +76,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { private SearchResult getNoConnectList() { SearchResult result = new SearchResult(); result.add(0, new MoreModel(Inter.getLocText("FR-Designer_AlphaFine_Recommend"), false)); - result.add(AlphaFineHelper.noConnectionModel); + result.add(AlphaFineHelper.NO_CONNECTION_MODEL); return result; } @@ -80,4 +85,11 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { return new SearchResult(); } + public List getRecommendModelList() { + return recommendModelList; + } + + public void setRecommendModelList(List recommendModelList) { + this.recommendModelList = recommendModelList; + } } From 785b0749f32d5a297c2ee6967fd164b7bfa9e71b Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Fri, 9 Jun 2017 17:26:37 +0800 Subject: [PATCH 15/17] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/search/manager/ActionSearchManager.java | 1 - .../alphafine/search/manager/DocumentSearchManager.java | 5 ++++- .../alphafine/search/manager/RecentSearchManager.java | 1 - .../design/actions/help/alphafine/AlphaFineContext.java | 8 ++++++-- .../design/actions/help/alphafine/AlphaFineListener.java | 9 +++++++++ .../fr/design/actions/help/alphafine/RemindDialog.java | 1 + 6 files changed, 20 insertions(+), 5 deletions(-) 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 8d21c239de..e2ecebb802 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 @@ -12,7 +12,6 @@ import com.fr.design.mainframe.toolbar.UpdateActionModel; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.StringUtils; -import com.fr.third.com.lowagie.text.pdf.PRAcroForm; import java.util.List; 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 2c4e5546f9..4fb8a060d3 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 @@ -81,7 +81,10 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { return lessModelList; } - + /** + * 无连接 + * @return + */ private SearchResult getNoConnectList() { SearchResult result = new SearchResult(); result.add(0, TITLE_MODEL); 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 2d88acbe43..76de3b84e4 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 @@ -4,7 +4,6 @@ import com.fr.base.FRContext; import com.fr.base.Utils; 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.CellModelHelper; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java index 77ff93c1d7..4dd92bc3d6 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineContext.java @@ -18,6 +18,10 @@ public class AlphaFineContext { } } + /** + * 触发开启或关闭AlphaFine功能 + * @param isEnable + */ public static void fireAlphaFineEnable(boolean isEnable) { for (AlphaFineListener l : fireAlphaFineListener) { l.setEnable(isEnable); @@ -25,9 +29,9 @@ public class AlphaFineContext { } /** - * 添加一个弹出AlphaFine的监听事件 + * 添加一个AlphaFine的监听事件 * - * @param l AlphaFine框弹出监听事件 + * @param l AlphaFine监听事件 */ public static void addAlphaFineListener(AlphaFineListener l) { fireAlphaFineListener.add(l); diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java index b11696640d..078bbdfd5c 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/AlphaFineListener.java @@ -2,8 +2,17 @@ package com.fr.design.actions.help.alphafine; /** * Created by XiaXiang on 2017/5/27. + * AlphaFine监听器 */ public interface AlphaFineListener { + /** + * 显示dialog + */ void showDialog(); + + /** + * 设置可用性 + * @param isEnable + */ void setEnable(boolean isEnable); } diff --git a/designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java b/designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java index eca6eab55f..fe894437d7 100644 --- a/designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java +++ b/designer_base/src/com/fr/design/actions/help/alphafine/RemindDialog.java @@ -8,6 +8,7 @@ import java.awt.*; /** * Created by XiaXiang on 2017/5/26. + * 提示弹窗 */ public class RemindDialog extends UIDialog { private RemindPane remindPane; From f3f841487cf8534550809af9fe9587fe1ba1f278 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Fri, 9 Jun 2017 17:33:50 +0800 Subject: [PATCH 16/17] =?UTF-8?q?bug=20fix=20=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java | 2 +- designer_base/src/com/fr/design/locale/designer.properties | 2 +- .../src/com/fr/design/locale/designer_en_US.properties | 2 +- .../src/com/fr/design/locale/designer_zh_CN.properties | 2 +- .../src/com/fr/design/locale/designer_zh_TW.properties | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 1cfe25c4da..c294218dc7 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -12,7 +12,7 @@ import com.fr.general.Inter; import com.fr.general.ProcessCanceledException; import com.fr.stable.StringUtils; -import java.util.ArrayList; + import java.util.List; /** diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 3dda9c1dd9..1453ff2df4 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2007,5 +2007,5 @@ FR-Designer_AlphaFine_Latest=Latest FR-Designer_AlphaFine_ShowLess=show less FR-Designer_Alphafine=AlphaFine FR-Designer-Alphafine_No_Remind= -FR-Designere_AlphaFine_NoResult=no results +FR-Designer_AlphaFine_NoResult=no results FR-Designer_ConnectionFailed=connection failed \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index 5afd87f465..6277a96faa 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2005,7 +2005,7 @@ FR-Designer_AlphaFine_Latest=Recent FR-Designer_AlphaFine_ShowLess=Show less FR-Designer_Alphafine=AlphaFine FR-Designer-Alphafine_No_Remind=Don't remind -FR-Designere_AlphaFine_NoResult=No results +FR-Designer_AlphaFine_NoResult=No results FR-Designer_ConnectionFailed=Connection failed FR-Designer_AlphaFine_EnableAlphaFine=Enable AlphaFine FR-Designer_AlphaFine_EnableInternet=Internet \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 104508b776..27046e608a 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2003,5 +2003,5 @@ FR-Designer_AlphaFine_Latest=\u672C\u5730\u5E38\u7528 FR-Designer_AlphaFine_ShowLess=\u6536\u8D77 FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22 FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A -FR-Designere_AlphaFine_NoResult=\u6682\u65E0\u76F8\u5173\u5185\u5BB9 +FR-Designer_AlphaFine_NoResult=\u6682\u65E0\u76F8\u5173\u5185\u5BB9 FR-Designer_ConnectionFailed=\u94FE\u63A5\u5931\u8D25 \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 2380dfe76b..4f75594bc9 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2001,5 +2001,5 @@ FR-Designer_AlphaFine_ShowLess=\u6536\u8D77 FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22 FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8 FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A -FR-Designere_AlphaFine_NoResult=\u66AB\u7121\u76F8\u95DC\u5167\u5BB9 +FR-Designer_AlphaFine_NoResult=\u66AB\u7121\u76F8\u95DC\u5167\u5BB9 FR-Designer_ConnectionFailed=\u93C8\u63A5\u5931\u6557 \ No newline at end of file From 4fbe80e858c8d084c838fd8bebeda1ba59668ab5 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Fri, 9 Jun 2017 17:36:54 +0800 Subject: [PATCH 17/17] fix pmd --- .../alphafine/search/manager/ActionSearchManager.java | 4 +++- .../alphafine/search/manager/FileSearchManager.java | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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 e2ecebb802..85c43b794b 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 @@ -50,8 +50,10 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { } SearchResult result = new SearchResult(); for (Object object : filterModelList) { - if (!AlphaFineHelper.getFilterResult().contains(object)) + if (!AlphaFineHelper.getFilterResult().contains(object)) { result.add(object); + } + } if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { lessModelList.add(0, TITLE_MODEL); diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java index 99e76ada1f..6fe9f5d231 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java @@ -61,8 +61,10 @@ public class FileSearchManager implements AlphaFineSearchProcessor { } SearchResult result = new SearchResult(); for (Object object : filterModelList) { - if (!AlphaFineHelper.getFilterResult().contains(object)) - result.add(object); + if (!AlphaFineHelper.getFilterResult().contains(object)) { + result.add(object); + } + } if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { lessModelList.add(0, TITLE_MODEL);