From ab4f4465686579f917794a628389495c2eed5dcd Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 15 Dec 2020 11:37:09 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-6224=20=E6=96=B0=E5=A2=9E=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=93=8D=E4=BD=9C=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 13 ++++++++++++- .../fr/design/mainframe/JTemplateEvent.java | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/JTemplateEvent.java 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 6c6de287e6..316f48fc36 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 @@ -49,6 +49,7 @@ import com.fr.design.menu.ShortCut; import com.fr.design.preview.PagePreview; import com.fr.design.write.submit.DBManipulationInWidgetEventPane; import com.fr.design.write.submit.DBManipulationPane; +import com.fr.event.EventDispatcher; import com.fr.file.FILE; import com.fr.file.FILEChooserPane; import com.fr.file.MemFILE; @@ -107,7 +108,6 @@ public abstract class JTemplate> private DesignModelAdapter designModel; private PreviewProvider previewType; protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); - public int resolution = ScreenResolution.getScreenResolution(); private PluginEventListener pluginListener; @@ -125,6 +125,7 @@ public abstract class JTemplate> public JTemplate(T t, FILE file, boolean isNewFile) { super(t); + beforeInit(); // 判断是否切换设计器状态到禁止拷贝剪切 if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.BAN_COPY_AND_CUT); @@ -301,6 +302,13 @@ public abstract class JTemplate> } + /** + * 模板初始化之前 + */ + private void beforeInit() { + EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_INIT, this); + } + /** * 模板关闭时 */ @@ -309,6 +317,7 @@ public abstract class JTemplate> PluginListenerRegistration.getInstance().stopListen(this.pluginListener); } + /** * 刷新内部资源 * @@ -1083,6 +1092,7 @@ public abstract class JTemplate> * 激活已存在的模板 */ public void activeOldJTemplate() { + EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_ACTIVE, this); DesignerContext.getDesignerFrame().activateJTemplate(this); } @@ -1090,6 +1100,7 @@ public abstract class JTemplate> * 激活新的模板 */ public void activeNewJTemplate() { + EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_ACTIVE, this); DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateEvent.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateEvent.java new file mode 100644 index 0000000000..d60d064743 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateEvent.java @@ -0,0 +1,19 @@ +package com.fr.design.mainframe; + +import com.fr.event.Event; + +/** + * Created by kerry on 2020-12-11 + */ +public enum JTemplateEvent implements Event { + /** + * 模板初始化之前 + */ + BEFORE_TEMPLATE_INIT, + + /** + * 模板激活之前 + */ + BEFORE_TEMPLATE_ACTIVE + +}