From 28a21eca1f84ba85f996b60fa8cb5c32070cd00e Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 17 Mar 2020 11:58:43 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-27434=201.15jar=E5=81=87=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E9=97=AE=E9=A2=98=20=E7=9B=91=E5=90=AC=E8=A3=85?= =?UTF-8?q?=E7=BD=AE=E9=9C=80=E8=A6=81=E5=90=8C=E6=AD=A5=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 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 482b0d337..a6d33b3a4 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 @@ -93,6 +93,7 @@ public abstract class JTemplate> protected U authorityUndoState = null; protected T template; // 当前模板 protected TemplateProcessInfo processInfo; // 模板过程的相关信息 + private JComponent centerPane; private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 private DesignModelAdapter designModel; private PreviewProvider previewType; @@ -121,15 +122,15 @@ public abstract class JTemplate> this.template = t; this.previewType = parserPreviewProvider(t.getPreviewType()); this.editingFILE = file; + addCenterPane(); this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder()); - this.add(createCenterPane(), BorderLayout.CENTER); this.undoState = createUndoState(); designModel = createDesignModel(); consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile)); } - + void onGetFocus() { consumeTimer.start(); } @@ -248,17 +249,38 @@ public abstract class JTemplate> /** * 刷新内部资源 + * + * 刷新资源的同时。 + * CenterPane 负责监听改动。 + * 所以需要同步处理 */ public void refreshResource() { try { this.template = JTemplateFactory.asIOFile(this.editingFILE); setTarget(this.template); + + // 先移除旧的。 + removeCenterPane(); + // 加入新的 + addCenterPane(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } - + + private void addCenterPane() { + + this.centerPane = createCenterPane(); + this.add(centerPane, BorderLayout.CENTER); + } + + private void removeCenterPane() { + + JComponent centerPane = this.centerPane; + this.remove(centerPane); + } + /** * 刷新容器 */