From fb13a402d2447f211b2c5c1d448f1225c22477e2 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 19 Mar 2020 20:59:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-28459=20JWorkBook=E6=9C=AA=E9=87=8A?= =?UTF-8?q?=E6=94=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 1 + .../com/fr/design/event/RemoveListener.java | 11 ++++++++++ .../com/fr/design/mainframe/JWorkBook.java | 5 +++++ .../mainframe/ReportComponentComposite.java | 8 ++++++- .../fr/design/mainframe/SheetNameTabPane.java | 21 ++++++++++++++----- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/event/RemoveListener.java diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 25492c55ed..a84e1337b7 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -114,6 +114,7 @@ public abstract class DesignTableDataManager { public static void closeTemplate(JTemplate template) { if (template != null) { + template.whenClose(); columnCache.remove(getEditingTableDataSource()); dsListenersMap.remove(template.getPath()); } diff --git a/designer-base/src/main/java/com/fr/design/event/RemoveListener.java b/designer-base/src/main/java/com/fr/design/event/RemoveListener.java new file mode 100644 index 0000000000..ff3eae3055 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/event/RemoveListener.java @@ -0,0 +1,11 @@ +package com.fr.design.event; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/19 + */ +public interface RemoveListener { + + void doRemoveAction(); +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 621d3f40b6..0759ddf983 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -1188,4 +1188,9 @@ public class JWorkBook extends JTemplate { provider.addChooseFileFilter(fileChooser, this.suffix()); } } + + @Override + public void whenClose() { + reportComposite.doRemoveAction(); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index 71fb275029..0299899a06 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.ScreenResolution; import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.designer.EditingState; +import com.fr.design.event.RemoveListener; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icontainer.UIModeControlContainer; @@ -30,7 +31,7 @@ import java.util.ArrayList; * @editor zhou * @since 2012-3-27下午12:12:05 */ -public class ReportComponentComposite extends JComponent { +public class ReportComponentComposite extends JComponent implements RemoveListener { private static final int MAX = 400; private static final int HUND = 100; @@ -250,4 +251,9 @@ public class ReportComponentComposite extends JComponent { public void fireTargetModified() { parent.fireTargetModified(); } + + @Override + public void doRemoveAction() { + sheetNameTab.doRemoveAction(); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java index 747789cdbe..74443e831c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java @@ -5,6 +5,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -27,6 +28,7 @@ import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.RemoveListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; @@ -44,7 +46,6 @@ import com.fr.poly.PolyDesigner; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.report.TemplateReport; import com.fr.report.worksheet.WorkSheet; -import com.fr.stable.ProductConstants; /** * NameTabPane of sheets @@ -52,7 +53,7 @@ import com.fr.stable.ProductConstants; * @editor zhou * @since 2012-3-26下午1:45:53 */ -public class SheetNameTabPane extends JComponent implements MouseListener, MouseMotionListener { +public class SheetNameTabPane extends JComponent implements MouseListener, MouseMotionListener, RemoveListener { private static final Color LINE_COLOR = new Color(0xababab); @@ -140,6 +141,10 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse private boolean isAuthorityEditing = false; + private ComponentListener listener; + + private DesignerFrame designerFrame; + public SheetNameTabPane(ReportComponentComposite reportCompositeX) { this.reportComposite = reportCompositeX; this.setLayout(new BorderLayout(0, 0)); @@ -203,14 +208,20 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse } } }); - - DesignerContext.getDesignerFrame().addComponentListener(new ComponentAdapter(){ + listener = new ComponentAdapter(){ @Override public void componentResized(ComponentEvent e) { for (int i = 0; i < lastOneIndex * NUM; i++) { moveLeft(); } } - }); + }; + designerFrame = DesignerContext.getDesignerFrame(); + designerFrame.addComponentListener(listener); + } + + @Override + public void doRemoveAction() { + designerFrame.removeComponentListener(listener); } private ActionListener createLeftButtonActionListener() { From 6c9c51e5e2cf5087f377ee7f74fe66171e25e0b4 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 19 Mar 2020 21:06:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=BC=8F=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/JTemplate.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 ef125dc18f..29c1dcb539 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 @@ -247,6 +247,13 @@ public abstract class JTemplate> } + /** + * 模板关闭时 + */ + public void whenClose() { + // do nothing + } + /** * 刷新内部资源 *