From c78baf759fcbe29362cefebf1e815679243def4f Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 11 Jun 2020 21:03:22 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-31990=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=8F=B3=E4=BE=A7=E9=9D=A2=E6=9D=BF=E6=96=B0=E5=A2=9Etab?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 57 ++++++++++++++++++- .../fr/design/mainframe/JVirtualTemplate.java | 2 + .../java/com/fr/design/mainframe/JForm.java | 54 +----------------- .../com/fr/design/mainframe/JWorkBook.java | 11 ++++ 4 files changed, 71 insertions(+), 53 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 66d7216c91..f29e22698c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -28,6 +28,7 @@ import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.PreviewProvider; +import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; @@ -55,6 +56,14 @@ import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginRuntime; +import com.fr.plugin.injectable.PluginModule; +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.plugin.observer.PluginListenerRegistration; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.stable.ArrayUtils; @@ -100,7 +109,10 @@ public abstract class JTemplate> protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); public int resolution = ScreenResolution.getScreenResolution(); + private PluginEventListener pluginListener; + public JTemplate() { + initAndStartPlugin(); } public JTemplate(T t, String defaultFileName) { @@ -129,8 +141,50 @@ public abstract class JTemplate> designModel = createDesignModel(); consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile)); + initAndStartPlugin(); + } + + private void initAndStartPlugin() { + initPluginPane(); + startListenPlugin(); + } + + private void startListenPlugin() { + + PluginFilter filter = new PluginFilter() { + @Override + public boolean accept(PluginContext context) { + return context.contain(PropertyItemPaneProvider.XML_TAG); + } + }; + this.pluginListener = new PluginEventListener(PropertyItemPaneProvider.LAST) { + @Override + public void on(PluginEvent event) { + PluginContext context = event.getContext(); + PluginRuntime runtime = context.getRuntime(); + Set providers = runtime.get(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPane(provider); + } + } + }; + PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginListener, filter); + } + + private void initPluginPane() { + + ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = classManager.getArray(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPane(provider); + } } + protected void addPane(PropertyItemPaneProvider provider) { + // do nothing + } + + void onGetFocus() { consumeTimer.start(); } @@ -251,7 +305,8 @@ public abstract class JTemplate> * 模板关闭时 */ public void whenClose() { - // do nothing + // stop的时候 pluginListener 和 PluginFilter 都会移除 + PluginListenerRegistration.getInstance().stopListen(this.pluginListener); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java index 2c18186147..64a10c88f2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java @@ -211,6 +211,8 @@ public class JVirtualTemplate extends JTemplate { List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); historyList.set(index, jt); DesignerContext.getDesignerFrame().addAndActivateJTemplate(jt); + // 虚拟模板JVirtualTemplate被激活后 由真实的JTemplate替换 此时调用whenClose 防止JVirtualTemplate无法释放 + this.whenClose(); } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index e2112f4f37..041705fb6d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -70,14 +70,7 @@ import com.fr.form.ui.container.WLayout; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.page.PaperSettingProvider; -import com.fr.plugin.context.PluginContext; -import com.fr.plugin.context.PluginRuntime; -import com.fr.plugin.injectable.PluginModule; -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.plugin.observer.PluginListenerRegistration; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.report.worksheet.FormElementCase; @@ -104,7 +97,6 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Set; public class JForm extends JTemplate implements BaseJForm
{ private static final String FORM_CARD = "FORM"; @@ -132,51 +124,15 @@ public class JForm extends JTemplate implements BaseJForm providers = runtime.get(PropertyItemPaneProvider.XML_TAG); - for (PropertyItemPaneProvider provider : providers) { - addPane(provider); - } - } - }; - PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginListener, filter); - } - - private void initPluginPane() { - - ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign); - Set providers = classManager.getArray(PropertyItemPaneProvider.XML_TAG); - for (PropertyItemPaneProvider provider : providers) { - addPane(provider); - } } - private void addPane(PropertyItemPaneProvider provider) { + @Override + protected void addPane(PropertyItemPaneProvider provider) { PaneHolder holder = provider.getPaneHolder(FormDesigner.class); if (holder != null) { @@ -1040,10 +996,4 @@ public class JForm extends JTemplate implements BaseJForm { populateReportParameterAttr(); } + @Override + protected void addPane(PropertyItemPaneProvider provider) { + PaneHolder holder = provider.getPaneHolder(JWorkBook.class); + if (holder != null) { + JPanel panel = holder.getInstance(this); + EastRegionContainerPane.getInstance().replaceKeyPane(provider.key(), panel); + } + } + @Override public void refreshEastPropertiesPane() { if (isEditingPolySheet()) { @@ -1191,6 +1201,7 @@ public class JWorkBook extends JTemplate { @Override public void whenClose() { + super.whenClose(); reportComposite.doRemoveAction(); } }