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..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,15 +20,27 @@ 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.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; -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,12 +115,32 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO initOtherComponent(); initAllNames(); - indentationUnitProcessor = ExtraDesignClassManager.getInstance().getSingle(IndentationUnitProcessor.MARK_STRING); - if (null == indentationUnitProcessor) { - indentationUnitProcessor = new DefaultIndentationUnitProcessor(); - } + addPluginListeners(PluginEventType.AfterRun); + addPluginListeners(PluginEventType.AfterStop); + refreshIndentationUnit(); } + private void addPluginListeners(PluginEventType type) { + EventDispatcher.listen(type, new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + refreshIndentationUnit(); + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + return context.contain(IndentationUnitProcessor.MARK_STRING); + } + }); + } + 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); 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 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,7 +169,7 @@ 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); @@ -186,13 +185,11 @@ public class RecentSearchManager implements AlphaFineSearchProvider { UpdateAction action = UpdateActionManager.getUpdateActionManager().getActionByName(model.getName()); if (action != null) { ((ActionModel) model).setAction(action); - recentModelList.add(model); + addModel(model); } } else { - recentModelList.add(model); + addModel(model); } - - } } catch (Exception e) { FineLoggerFactory.getLogger().error("local search error: " + e.getMessage()); @@ -201,5 +198,11 @@ public class RecentSearchManager implements AlphaFineSearchProvider { return recentModelList; } + private void addModel(AlphaCellModel model) { + if (!recentModelList.contains(model)) { + recentModelList.add(model); + } + } + }