From 7760d8331a403e744dfb6a0deb54595d9ef05821 Mon Sep 17 00:00:00 2001 From: zack Date: Fri, 27 Jul 2018 15:50:15 +0800 Subject: [PATCH 1/5] =?UTF-8?q?REPORT-10055=20=E3=80=9010.0=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E3=80=91=E5=AE=89=E8=A3=85=E7=BC=A9=E8=BF=9B=E6=AF=94?= =?UTF-8?q?=E4=BE=8B=E6=8E=A7=E5=88=B6=E6=8E=A7=E4=BB=B6=E5=90=8E=E6=97=A0?= =?UTF-8?q?=E6=95=88=E6=8F=92=E4=BB=B6=E4=B8=8D=E8=83=BD=E5=8D=B3=E6=97=B6?= =?UTF-8?q?=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/style/AlignmentPane.java | 40 +++++++++++++++---- .../com/fr/design/condition/PaddingPane.java | 24 ++++++++++- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java index 2f1f458faf..8cc752cb1c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java @@ -21,14 +21,25 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.ComparatorUtils; - +import com.fr.general.GeneralContext; import com.fr.plugin.ExtraClassManager; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.report.fun.VerticalTextProcessor; import com.fr.report.fun.impl.DefaultVerticalTextProcessor; import com.fr.stable.Constants; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; @@ -103,13 +114,28 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO initOtherComponent(); initAllNames(); - indentationUnitProcessor = ExtraDesignClassManager.getInstance().getSingle(IndentationUnitProcessor.MARK_STRING); - if (null == indentationUnitProcessor) { - indentationUnitProcessor = new DefaultIndentationUnitProcessor(); + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + refreshIndentationUnit(); + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + return context.contain(IndentationUnitProcessor.MARK_STRING); + } + }); + refreshIndentationUnit(); + } + private void refreshIndentationUnit() { + this.indentationUnitProcessor = ExtraDesignClassManager.getInstance().getSingle(IndentationUnitProcessor.MARK_STRING); + if (null == this.indentationUnitProcessor) { + this.indentationUnitProcessor = new DefaultIndentationUnitProcessor(); } } - private void initOtherComponent() { hPaneContainer.add(hAlignmentPane); vPaneContainer.add(vAlignmentPane); diff --git a/designer-realize/src/main/java/com/fr/design/condition/PaddingPane.java b/designer-realize/src/main/java/com/fr/design/condition/PaddingPane.java index c94f8c7a0c..a3c7fe69ab 100644 --- a/designer-realize/src/main/java/com/fr/design/condition/PaddingPane.java +++ b/designer-realize/src/main/java/com/fr/design/condition/PaddingPane.java @@ -7,11 +7,15 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.style.DefaultIndentationUnitProcessor; import com.fr.design.utils.gui.GUICoreUtils; - +import com.fr.general.GeneralContext; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.report.cell.cellattr.highlight.HighlightAction; import com.fr.report.cell.cellattr.highlight.PaddingHighlightAction; -import javax.swing.*; +import javax.swing.SpinnerNumberModel; /** * @author richie @@ -45,7 +49,23 @@ public class PaddingPane extends ConditionAttrSingleConditionPane Date: Fri, 27 Jul 2018 17:19:46 +0800 Subject: [PATCH 2/5] =?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 --- .../java/com/fr/design/gui/style/AlignmentPane.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java index 8cc752cb1c..163fe922dc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java @@ -20,13 +20,14 @@ import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.event.EventDispatcher; import com.fr.general.ComparatorUtils; -import com.fr.general.GeneralContext; import com.fr.plugin.ExtraClassManager; import com.fr.plugin.context.PluginContext; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; +import com.fr.plugin.observer.PluginEventType; import com.fr.report.fun.VerticalTextProcessor; import com.fr.report.fun.impl.DefaultVerticalTextProcessor; import com.fr.stable.Constants; @@ -114,7 +115,13 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO initOtherComponent(); initAllNames(); - GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + addPluginListeners(PluginEventType.AfterRun); + addPluginListeners(PluginEventType.AfterStop); + refreshIndentationUnit(); + } + + private void addPluginListeners(PluginEventType type) { + EventDispatcher.listen(type, new PluginEventListener() { @Override public void on(PluginEvent event) { @@ -127,7 +134,6 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO return context.contain(IndentationUnitProcessor.MARK_STRING); } }); - refreshIndentationUnit(); } private void refreshIndentationUnit() { this.indentationUnitProcessor = ExtraDesignClassManager.getInstance().getSingle(IndentationUnitProcessor.MARK_STRING); From 37e1ddadc244ac8b0e1ccb7a81e7754f64e079ec Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Sun, 29 Jul 2018 18:25:27 +0800 Subject: [PATCH 3/5] =?UTF-8?q?REPORT-9819=20=E3=80=9010.0=E4=BA=8C?= =?UTF-8?q?=E8=BD=AE=E5=9B=9E=E5=BD=92=E3=80=91alphafine=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=89=93=E5=BC=80=E5=90=8E=EF=BC=8C=E5=86=8D?= =?UTF-8?q?=E6=AC=A1=E6=90=9C=E7=B4=A2=E4=BC=9A=E5=A2=9E=E5=8A=A0=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E9=87=8D=E5=A4=8D=E6=A8=A1=E6=9D=BF=E7=9A=84=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/component/AlphaFineDialog.java | 41 +++++++++++++++---- .../manager/impl/RecentSearchManager.java | 21 ++++++---- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index b901f7085c..9dfaa5bba4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -28,10 +28,11 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; +import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; +import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.form.main.Form; import com.fr.form.main.FormIO; import com.fr.general.ComparatorUtils; - import com.fr.general.http.HttpClient; import com.fr.io.TemplateWorkBookIO; import com.fr.io.exporter.ImageExporter; @@ -44,11 +45,28 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import javax.imageio.ImageIO; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import javax.swing.event.DocumentEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import java.awt.*; +import java.awt.AWTEvent; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; import java.awt.event.AWTEventListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -761,11 +779,18 @@ public class AlphaFineDialog extends UIDialog { * * @param cellModel */ - private void saveLocalHistory(AlphaCellModel cellModel) { - RecentSearchManager searchManager = RecentSearchManager.getInstance(); - searchManager.addModel(storeText, cellModel, cellModel.getSearchCount() + 1); - sendDataToServer(storeText, cellModel); - + private void saveLocalHistory(final AlphaCellModel cellModel) { + Thread sendThread = new Thread(new Runnable() { + @Override + public void run() { + RecentSearchManager searchManager = RecentSearchManager.getInstance(); + searchManager.addModel(storeText, cellModel); + sendDataToServer(storeText, cellModel); + TemplateInfoCollector.getInstance().sendTemplateInfo(); + ErrorInfoUploader.getInstance().sendErrorInfo(); + } + }); + sendThread.start(); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java index 68ae4578d6..2f0b695b24 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.design.actions.UpdateAction; +import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; import com.fr.design.mainframe.alphafine.cell.model.ActionModel; @@ -9,7 +10,6 @@ import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; import com.fr.design.mainframe.toolbar.UpdateActionManager; - import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; @@ -18,7 +18,7 @@ import com.fr.third.org.apache.lucene.analysis.Analyzer; import com.fr.third.org.apache.lucene.analysis.standard.StandardAnalyzer; import com.fr.third.org.apache.lucene.document.Document; import com.fr.third.org.apache.lucene.document.Field; -import com.fr.third.org.apache.lucene.document.IntField; +import com.fr.third.org.apache.lucene.document.LongField; import com.fr.third.org.apache.lucene.document.StringField; import com.fr.third.org.apache.lucene.index.DirectoryReader; import com.fr.third.org.apache.lucene.index.IndexReader; @@ -78,7 +78,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider { if (recentModelList != null && recentModelList.size() > 0) { modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_AlphaFine_Latest"))); } - modelList.addAll(recentModelList); + modelList.addAll(recentModelList.subList(0, AlphaFineConstants.LATEST_SHOW_SIZE)); return modelList; } @@ -126,15 +126,14 @@ public class RecentSearchManager implements AlphaFineSearchProvider { * * @param searchKey * @param cellModel - * @param searchCount */ - public void addModel(String searchKey, AlphaCellModel cellModel, int searchCount) { + public void addModel(String searchKey, AlphaCellModel cellModel) { try { initWriter(); Document doc = new Document(); doc.add(new StringField("searchKey", searchKey, Field.Store.YES)); doc.add(new StringField("cellModel", cellModel.ModelToJson().toString(), Field.Store.YES)); - doc.add(new IntField("searchCount", searchCount, Field.Store.YES)); + doc.add(new LongField("time", System.currentTimeMillis(), Field.Store.YES)); writeDoc(doc); } catch (JSONException e) { FineLoggerFactory.getLogger().error("add document error: " + e.getMessage()); @@ -170,12 +169,12 @@ public class RecentSearchManager implements AlphaFineSearchProvider { IndexSearcher searcher = new IndexSearcher(indexReader); //构建排序字段 SortField[] sortField = new SortField[1]; - sortField[0] = new SortField("searchCount", SortField.Type.INT, true); + sortField[0] = new SortField("time", SortField.Type.LONG, true); Sort sortKey = new Sort(sortField); String searchField = "searchKey"; Term term = new Term(searchField, key); Query query = new TermQuery(term); - TopFieldDocs docs = searcher.search(query, MAX_SIZE, sortKey); + TopFieldDocs docs = searcher.search(query, 100, sortKey); ScoreDoc[] scores = docs.scoreDocs; this.recentModelList = new SearchResult(); //遍历结果 @@ -186,9 +185,15 @@ public class RecentSearchManager implements AlphaFineSearchProvider { UpdateAction action = UpdateActionManager.getUpdateActionManager().getActionByName(model.getName()); if (action != null) { ((ActionModel) model).setAction(action); + if (recentModelList.contains(model)) { + continue; + } recentModelList.add(model); } } else { + if (recentModelList.contains(model)) { + continue; + } recentModelList.add(model); } From ba74e900f21df1d60e5fd4f47856aca86440cfd6 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Sun, 29 Jul 2018 18:31:44 +0800 Subject: [PATCH 4/5] rt --- .../manager/impl/RecentSearchManager.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java index 2f0b695b24..5e42929e93 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java @@ -185,19 +185,11 @@ public class RecentSearchManager implements AlphaFineSearchProvider { UpdateAction action = UpdateActionManager.getUpdateActionManager().getActionByName(model.getName()); if (action != null) { ((ActionModel) model).setAction(action); - if (recentModelList.contains(model)) { - continue; - } - recentModelList.add(model); + addModel(model); } } else { - if (recentModelList.contains(model)) { - continue; - } - recentModelList.add(model); + addModel(model); } - - } } catch (Exception e) { FineLoggerFactory.getLogger().error("local search error: " + e.getMessage()); @@ -206,5 +198,11 @@ public class RecentSearchManager implements AlphaFineSearchProvider { return recentModelList; } + private void addModel(AlphaCellModel model) { + if (!recentModelList.contains(model)) { + recentModelList.add(model); + } + } + } From c0569eb29b23804d24e1ba1807d397cbbb3f91a0 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Sun, 29 Jul 2018 18:33:05 +0800 Subject: [PATCH 5/5] rt --- .../alphafine/search/manager/impl/RecentSearchManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java index 5e42929e93..bb1d21ec87 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java @@ -44,7 +44,7 @@ import java.util.List; * Created by XiaXiang on 2018/1/22. */ public class RecentSearchManager implements AlphaFineSearchProvider { - private static final int MAX_SIZE = 3; + private static final int MAX_SIZE = 100; private static RecentSearchManager instance; IndexReader indexReader = null; IndexSearcher indexSearcher = null; @@ -174,7 +174,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider { String searchField = "searchKey"; Term term = new Term(searchField, key); Query query = new TermQuery(term); - TopFieldDocs docs = searcher.search(query, 100, sortKey); + TopFieldDocs docs = searcher.search(query, MAX_SIZE, sortKey); ScoreDoc[] scores = docs.scoreDocs; this.recentModelList = new SearchResult(); //遍历结果