From 44bc4e93b7ae0577b5bfb7f0ce2d05f1a80b1426 Mon Sep 17 00:00:00 2001 From: Hoky <303455184@qq.com> Date: Mon, 24 Jan 2022 11:03:24 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E6=97=A0jira=20=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E6=B0=B4=E5=8D=B0npe=201.=E6=96=B0=E5=BB=BA=E5=86=B3=E7=AD=96?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=97=B6=E6=94=B9=E6=88=90=E4=BB=8E=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E8=AF=BB=E5=8F=96=E6=B0=B4=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/designer/layout/FRFitLayoutDefinePane.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java index 6afdad367..341066e88 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java @@ -18,7 +18,6 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.xpane.LayoutStylePane; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormSelectionUtils; @@ -38,9 +37,12 @@ import com.fr.general.act.BorderPacker; import com.fr.log.FineLoggerFactory; import com.fr.report.core.ReportUtils; -import javax.swing.*; -import javax.swing.border.Border; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; /** * Created by ibm on 2017/8/2. @@ -160,7 +162,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane Date: Wed, 9 Feb 2022 14:10:57 +0800 Subject: [PATCH 02/10] =?UTF-8?q?REPORT-66167=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E6=A0=8F=E6=9C=89=E6=97=B6=E5=80=99=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=98=BE=E7=A4=BA=E6=9F=90=E4=BA=9B=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/FormParaWidgetPane.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java index be752777b..9eb11607c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormParaWidgetPane.java @@ -41,10 +41,6 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.SwingConstants; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Cursor; @@ -55,6 +51,10 @@ import java.awt.event.ComponentEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; /** * @author null @@ -196,7 +196,9 @@ public class FormParaWidgetPane extends JPanel { JPanel componentsPara = new JPanel(new FlowLayout(FlowLayout.LEFT)); WidgetOption[] chartOptions = loadChartOptions(); for (WidgetOption chartOption : chartOptions) { - componentsPara.add(new ToolBarButton(chartOption)); + ToolBarButton button = new ToolBarButton(chartOption); + button.setPreferredSize(new Dimension(widgetButtonWidth, widgetButtonHeight)); + componentsPara.add(button); } int x = COMMON_CHAR_NUM * (widgetButtonWidth + smallGAP); int y = (int) Math.ceil(chartOptions.length / ((double) COMMON_CHAR_NUM)) * (widgetButtonHeight + smallGAP); From 16bf1aea01d8e4ff9aa75726c89128c5a19afa3a Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 14 Feb 2022 15:04:16 +0800 Subject: [PATCH 03/10] =?UTF-8?q?DEC-22333=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=B8=80=E6=AE=B5=E6=97=B6=E9=97=B4=E5=90=8E?= =?UTF-8?q?=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ManageDsListenerRegisterListener.java | 49 +++++++++++++++++++ .../design/data/DesignTableDataManager.java | 27 +++++++--- .../fr/design/data/datapane/ChoosePane.java | 13 ++--- .../data/datapane/TableDataComboBox.java | 3 +- .../design/mainframe/chart/ChartEditPane.java | 5 +- 5 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/common/listener/ManageDsListenerRegisterListener.java diff --git a/designer-base/src/main/java/com/fr/common/listener/ManageDsListenerRegisterListener.java b/designer-base/src/main/java/com/fr/common/listener/ManageDsListenerRegisterListener.java new file mode 100644 index 000000000..6baa2e86b --- /dev/null +++ b/designer-base/src/main/java/com/fr/common/listener/ManageDsListenerRegisterListener.java @@ -0,0 +1,49 @@ +package com.fr.common.listener; + +import com.fr.design.data.DesignTableDataManager; +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; +import javax.swing.event.ChangeListener; + +/** + * 管理数据集相关监听的注册 + * + * 原本的监听生命周期注册与销毁: + * + * 创建时组件时进行注册,在模板关闭时进行销毁 + * 但是在模板未关闭的这段时间,如果不断的打开和关闭某些弹窗,次数达到一定程度,会导致出现大量内存占用,除非此时关闭模板 + * + * 改成以下模式: + * + * 当组件可见或者被添加到某个大组件 注册相关监听 + * 当组件不可见或者被移除时 立即移除相关监听 + * 及时清理无效监听,减少实时内存占用 + * + * + * @author hades + * @version 11.0 + * Created by hades on 2022/2/14 + */ +public class ManageDsListenerRegisterListener implements AncestorListener { + + private ChangeListener changeListener; + + public ManageDsListenerRegisterListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + @Override + public void ancestorAdded(AncestorEvent event) { + DesignTableDataManager.addDsChangeListener(changeListener); + } + + @Override + public void ancestorRemoved(AncestorEvent event) { + DesignTableDataManager.removeDsChangeLister(changeListener); + } + + @Override + public void ancestorMoved(AncestorEvent event) { + // do nothing + } +} 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 f1758f068..8a57cca0b 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 @@ -172,23 +172,38 @@ public abstract class DesignTableDataManager { globalDsListeners.add(l); } + private static String getCurrentChangeListenerKey() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + String key = StringUtils.EMPTY; + if (template != null) { + key = template.getPath(); + } + return key; + } + /** * 添加模板数据集改变 监听事件. * * @param l ChangeListener监听器 */ public static void addDsChangeListener(ChangeListener l) { - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - String key = StringUtils.EMPTY; - if (template != null) { - key = template.getPath(); - } + String key = getCurrentChangeListenerKey(); List dsListeners = dsListenersMap.get(key); if (dsListeners == null) { dsListeners = new ArrayList(); dsListenersMap.put(key, dsListeners); } - dsListeners.add(l); + if (!dsListeners.contains(l)) { + dsListeners.add(l); + } + } + + public static void removeDsChangeLister(ChangeListener l) { + String key = getCurrentChangeListenerKey(); + List dsListeners = dsListenersMap.get(key); + if (dsListeners != null) { + dsListeners.remove(l); + } } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index f65610526..6917f4c08 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -1,6 +1,7 @@ package com.fr.design.data.datapane; import com.fr.base.TableData; +import com.fr.common.listener.ManageDsListenerRegisterListener; import com.fr.concurrent.NamedThreadFactory; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.DBUtils; @@ -648,12 +649,12 @@ public class ChoosePane extends BasicBeanPane implements Refresha */ @Override public void registerDSChangeListener() { - DesignTableDataManager.addDsChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - initDsNameComboBox(); - } - }); + this.addAncestorListener(new ManageDsListenerRegisterListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + initDsNameComboBox(); + } + })); } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataComboBox.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataComboBox.java index ebbdbf0f3..140b294bf 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataComboBox.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataComboBox.java @@ -1,5 +1,6 @@ package com.fr.design.data.datapane; +import com.fr.common.listener.ManageDsListenerRegisterListener; import java.awt.Component; import java.awt.event.ItemEvent; import java.util.Iterator; @@ -148,7 +149,7 @@ public class TableDataComboBox extends UIComboBox implements Prepare4DataSourceC TableDataComboBox.this.refresh(DesignTableDataManager.getEditingTableDataSource()); } }; - DesignTableDataManager.addDsChangeListener(changeListener); + this.addAncestorListener(new ManageDsListenerRegisterListener(changeListener)); } public void registerGlobalDSChangeListener() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java index 6b75dff69..902347fb8 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java @@ -4,6 +4,7 @@ package com.fr.design.mainframe.chart; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chartx.attr.ChartProvider; +import com.fr.common.listener.ManageDsListenerRegisterListener; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.data.DesignTableDataManager; @@ -407,14 +408,14 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare * 数据集改变的事件监听 */ public void registerDSChangeListener() { - DesignTableDataManager.addDsChangeListener(new ChangeListener() { + this.addAncestorListener(new ManageDsListenerRegisterListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { AbstractChartAttrPane attrPane = paneList.get(tabsHeaderIconPane.getSelectedIndex()); if (attrPane.isShowing()) { attrPane.refreshChartDataPane(collection); } } - }); + })); } public boolean isInForm() { From b7e5268ee19a3bb8d67812d4cc8d5e935096b9ed Mon Sep 17 00:00:00 2001 From: Hoky <303455184@qq.com> Date: Tue, 22 Feb 2022 11:18:05 +0800 Subject: [PATCH 04/10] =?UTF-8?q?KERNEL-9928=20=E9=87=8D=E6=9E=84=E6=B0=B4?= =?UTF-8?q?=E5=8D=B0=201.=E6=B0=B4=E5=8D=B0=E6=8E=A5=E5=8F=A3=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/report/ReportWatermarkAction.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java index a07f42456..92d14334d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java @@ -1,8 +1,6 @@ package com.fr.design.actions.report; import com.fr.base.iofile.attr.WatermarkAttr; - -import com.fr.base.svg.IconUtils; import com.fr.design.actions.JWorkBookAction; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; @@ -39,7 +37,7 @@ public class ReportWatermarkAction extends JWorkBookAction { return; } final WorkBook wbTpl = jwb.getTarget(); - WatermarkAttr watermark = ReportUtils.getWatermarkAttrFromTemplate(wbTpl); + WatermarkAttr watermark = ReportUtils.getWatermarkAttrFromTemplateAndGlobal(wbTpl); final WatermarkSettingPane watermarkPane = new WatermarkSettingPane(); watermarkPane.populate(watermark); watermarkPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { From 129152ce22f682a9f8390a01d46f70b7d4e5ed2f Mon Sep 17 00:00:00 2001 From: Hoky <303455184@qq.com> Date: Tue, 1 Mar 2022 15:23:10 +0800 Subject: [PATCH 05/10] =?UTF-8?q?REPORT-67359=20=E6=A8=A1=E6=9D=BF-?= =?UTF-8?q?=E6=B0=B4=E5=8D=B0-=E7=82=B9=E5=87=BB=E6=97=A0=E5=8F=8D?= =?UTF-8?q?=E5=BA=94=201.=E6=B0=B4=E5=8D=B0=E6=8E=A5=E5=8F=A3=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/report/ReportWatermarkAction.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java index a07f42456..92d14334d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/report/ReportWatermarkAction.java @@ -1,8 +1,6 @@ package com.fr.design.actions.report; import com.fr.base.iofile.attr.WatermarkAttr; - -import com.fr.base.svg.IconUtils; import com.fr.design.actions.JWorkBookAction; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; @@ -39,7 +37,7 @@ public class ReportWatermarkAction extends JWorkBookAction { return; } final WorkBook wbTpl = jwb.getTarget(); - WatermarkAttr watermark = ReportUtils.getWatermarkAttrFromTemplate(wbTpl); + WatermarkAttr watermark = ReportUtils.getWatermarkAttrFromTemplateAndGlobal(wbTpl); final WatermarkSettingPane watermarkPane = new WatermarkSettingPane(); watermarkPane.populate(watermark); watermarkPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { From a0ab6a8b403fd20ed5d60fc56e6299b6b5a15ffc Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 8 Mar 2022 10:18:13 +0800 Subject: [PATCH 06/10] =?UTF-8?q?REPORT-67119=20=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=BA=93Tab=E9=9D=A2=E6=9D=BF=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 代码合并问题,导致重复添加在线组件库面板 【改动思路】 删除多余的添加逻辑 --- .../main/java/com/fr/design/mainframe/FormWidgetDetailPane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java index 55788ba27..9d1cee894 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -168,7 +168,6 @@ public class FormWidgetDetailPane extends FormDockView{ private void initPaneList() { paneList = new ArrayList<>(); paneList.add(LocalWidgetRepoPane.getInstance()); - paneList.add(OnlineWidgetRepoPane.getInstance()); if (isShowOnlineWidgetRepoPane()) { paneList.add(OnlineWidgetRepoPane.getInstance()); } From 82098262df1974400f4b9b093eda65cd3121566d Mon Sep 17 00:00:00 2001 From: pengda Date: Thu, 10 Mar 2022 14:32:59 +0800 Subject: [PATCH 07/10] =?UTF-8?q?CHART-22972=20HyperlinkProvider=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E5=9B=BE=E8=A1=A8=E8=B6=85=E9=93=BE=E4=B8=8D?= =?UTF-8?q?=E8=B5=B7=E4=BD=9C=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/component/VanChartHyperLinkPane.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java index b5efad3b6..d50d5811c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java @@ -150,17 +150,16 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane { //安装平台内打开插件时,添加相应按钮 Set providers = ExtraDesignClassManager.getInstance().getArray(HyperlinkProvider.XML_TAG); - for (HyperlinkProvider provider : providers) { - NameableCreator nc = provider.createHyperlinkCreator(); - paneMap.put(nc.getHyperlink(), nc.getUpdatePane()); - } - java.util.List list = refreshList(paneMap); - NameObjectCreator[] creators = new NameObjectCreator[list.size()]; - for (int i = 0; list != null && i < list.size(); i++) { + int size = list.size(); + NameObjectCreator[] creators = new NameObjectCreator[list.size() + providers.size()]; + for (int i = 0; i < size; i++) { UIMenuNameableCreator uiMenuNameableCreator = list.get(i); creators[i] = new NameObjectCreator(uiMenuNameableCreator.getName(), uiMenuNameableCreator.getObj().getClass(), uiMenuNameableCreator.getPaneClazz()); - + } + for (HyperlinkProvider provider : providers) { + creators[size] = new NameObjectCreator(provider.text(), provider.target(), provider.appearance()); + size++; } refreshNameableCreator(creators); From b60b8a78f09cd7295d12ea85541225bdc4e524ce Mon Sep 17 00:00:00 2001 From: pengda Date: Wed, 16 Mar 2022 15:27:59 +0800 Subject: [PATCH 08/10] =?UTF-8?q?CHART-22972=20HyperlinkProvider=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E5=9B=BE=E8=A1=A8=E8=B6=85=E9=93=BE=E4=B8=8D?= =?UTF-8?q?=E8=B5=B7=E4=BD=9C=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../van/chart/custom/component/VanChartHyperLinkPane.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java index d50d5811c..7137c180a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java @@ -158,8 +158,11 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane { creators[i] = new NameObjectCreator(uiMenuNameableCreator.getName(), uiMenuNameableCreator.getObj().getClass(), uiMenuNameableCreator.getPaneClazz()); } for (HyperlinkProvider provider : providers) { - creators[size] = new NameObjectCreator(provider.text(), provider.target(), provider.appearance()); - size++; + NameableCreator creator = provider.createHyperlinkCreator(); + if (creator != null) { + creators[size] = new NameObjectCreator(creator.menuName(), creator.getHyperlink(), creator.getUpdatePane()); + size++; + } } refreshNameableCreator(creators); From babc63fff44287edb174722ccced4ecfc2e61371 Mon Sep 17 00:00:00 2001 From: rinoux Date: Thu, 17 Mar 2022 16:55:32 +0800 Subject: [PATCH 09/10] =?UTF-8?q?REPORT-67954=20=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E6=97=B6=E6=95=B0=E6=8D=AE=E9=9B=86=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/connect/ConnectionComboBoxPanel.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java index 5ed53cef4..5ee6654d4 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java @@ -14,14 +14,13 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UILockButton; import com.fr.design.mainframe.DesignerContext; import com.fr.file.ConnectionConfig; -import com.fr.general.ComparatorUtils; +import com.fr.report.LockItem; import com.fr.stable.StringUtils; import com.fr.transaction.CallBackAdaptor; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; import com.fr.workspace.WorkContext; import com.fr.workspace.server.connection.DBConnectAuth; -import com.fr.report.LockItem; import javax.swing.SwingUtilities; import java.awt.Dimension; @@ -103,6 +102,7 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel { continue; } Connection connection = mgr.getConnection(conName); + // nameList依赖items方法初始化,父类ItemEditableComboBoxPanel里异步执行item方法 filterConnection(connection, conName, nameList); } @@ -188,12 +188,10 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel { } else { String s = DesignerEnvManager.getEnvManager().getRecentSelectedConnection(); if (StringUtils.isNotBlank(s)) { - for (int i = 0; i < this.getConnectionSize(); i++) { - String t = this.getConnection(i); - if (ComparatorUtils.equals(s, t)) { - this.setSelectedItem(s); - break; - } + // 之前的写法有多线程问题,nameList异步尚未初始化完成的时候,这里可能无法匹配设置数据连接名称,导致DBTableDataPane打开后连接面板空白 + // 这里的需求无非是设置上一次使用的数据连接,做个简单检查这个连接是否存在即可,存在就设置 + if (ConnectionConfig.getInstance().getConnection(s) != null) { + this.setSelectedItem(s); } } // alex:如果这个ComboBox还是没有选中,那么选中第一个 From 85e00d7e126ba78fa9733fbe41efbeb8b29dae94 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 17 Mar 2022 17:40:04 +0800 Subject: [PATCH 10/10] =?UTF-8?q?REPORT-66767=20=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E6=95=B0=E6=8D=AE=E9=9B=86=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E7=AA=97=E5=8F=A3=E6=B2=A1=E6=9C=89=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wrapper/StoreProcedureDataWrapper.java | 109 +++++++++--------- 1 file changed, 53 insertions(+), 56 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java index 08274fd71..515bd8dd0 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java @@ -63,26 +63,27 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { public StoreProcedureDataWrapper(Component component, StoreProcedure storeProcedure, String storeprocedureName, String dsName) { this(component, storeProcedure, storeprocedureName, dsName, true); } - + /** - * @param: component loadingBar的父弹框(如果不设置父弹框的话,可能出现loadingBar隐藏在一个弹框后的情况) - * @param: storeProcedure 存储过程 - * @param: storeprocedureName 存储过程的名字(某些情况下可以为空) - * @param: dsName 存储过程一个返回数据集的名字 - * @param: needLoad 是否要加载 + * @param component loadingBar的父弹框(如果不设置父弹框的话,可能出现loadingBar隐藏在一个弹框后的情况) + * @param storeProcedure 存储过程 + * @param storeprocedureName 存储过程的名字(某些情况下可以为空) + * @param dsName 存储过程一个返回数据集的名字 + * @param needLoad 是否要加载 **/ public StoreProcedureDataWrapper(Component component, StoreProcedure storeProcedure, String storeprocedureName, String dsName, boolean needLoad) { this.dsName = dsName; this.storeProcedure = storeProcedure; this.storeProcedure.setCalculating(false); this.storeprocedureName = storeprocedureName; - if (needLoad) { - setWorker(); - } if (component == null) { component = new JFrame(); } + if (needLoad) { + setWorker(component); + } loadingBar = new AutoProgressBar(component, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) { + @Override public void doMonitorCanceled() { getWorker().cancel(true); } @@ -93,16 +94,17 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { * 数据集执行结果返回的所有字段 * * @return 数据集执行结果返回的所有字段 - * - * - * @date 2014-12-3-下午7:43:17 - * - */ + * @date 2014-12-3-下午7:43:17 + */ + @Override public List calculateColumnNameList() { if (columnNameList != null) { return columnNameList; } - if (!createStore(false)) { + + try { + createStore(false); + } catch (Exception e) { FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Engine_No_TableData")); return new ArrayList(); } @@ -114,11 +116,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { * 生成子节点 * * @return 节点数组 - * - * - * @date 2014-12-3-下午7:06:47 - * - */ + * @date 2014-12-3-下午7:06:47 + */ + @Override public ExpandMutableTreeNode[] load() { List namelist; if (storeProcedure.isCalculating()) { @@ -134,23 +134,16 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { return res; } - private boolean createStore(boolean needLoadingBar) { - try { - dataModels = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar); - if (dataModels == null || dataModels.length == 0) { - return false; - } - for (int i = 0; i < dataModels.length; i++) { - if (ComparatorUtils.equals(this.dsName, storeprocedureName + "_" + dataModels[i].getName())) { - procedureDataModel = dataModels[i]; + private void createStore(boolean needLoadingBar) throws Exception { + dataModels = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar); + if (dataModels != null && dataModels.length != 0) { + for (ProcedureDataModel dataModel : dataModels) { + if (ComparatorUtils.equals(this.dsName, storeprocedureName + "_" + dataModel.getName())) { + procedureDataModel = dataModel; break; } } - return true; - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); } - return false; } @Override @@ -159,17 +152,15 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { } /** - * 预览数据 - * - * @param previewModel 预览模式, 全部还是一个 - * - * - * @date 2014-12-3-下午7:05:50 - * - */ + * 预览数据 + * + * @param previewModel 预览模式, 全部还是一个 + * @date 2014-12-3-下午7:05:50 + */ public void previewData(final int previewModel) { this.previewModel = previewModel; connectionBar = new AutoProgressBar(new JFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) { + @Override public void doMonitorCanceled() { connectionBar.close(); worker.cancel(true); @@ -178,8 +169,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { worker.execute(); } - private void setWorker() { + private void setWorker(final Component parent) { worker = new SwingWorker() { + @Override protected Void doInBackground() throws Exception { loadingBar.close(); PreviewTablePane.resetPreviewTable(); @@ -195,6 +187,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { return null; } + @Override public void done() { try { get(); @@ -206,13 +199,15 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { case StoreProcedureDataWrapper.PREVIEW_ONE: previewData(); break; + default: + break; } } catch (Exception e) { + loadingBar.close(); if (!(e instanceof CancellationException)) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage()); + FineJOptionPane.showMessageDialog(parent, e.getMessage()); } - loadingBar.close(); } } }; @@ -227,10 +222,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { /** * 预览返回的一个数据集 * - * - * @date 2014-12-3-下午7:42:53 - * - */ + * @date 2014-12-3-下午7:42:53 + */ + @Override public void previewData() { previewData(-1, -1); } @@ -240,13 +234,11 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { /** * 预览返回的一个数据集,带有显示值和实际值的标记结果 * - * @param keyIndex 实际值 - * @param valueIndex 显示值 - * - * - * @date 2014-12-3-下午7:42:27 - * - */ + * @param keyIndex 实际值 + * @param valueIndex 显示值 + * @date 2014-12-3-下午7:42:27 + */ + @Override public void previewData(final int keyIndex, final int valueIndex) { PreviewTablePane.previewStoreData(procedureDataModel, keyIndex, valueIndex); } @@ -257,7 +249,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { */ public void previewAllTable() { if (procedureDataModel == null) { - if (!createStore(true)) { + try { + createStore(true); + } catch (Exception e) { return; } } @@ -269,6 +263,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { return dsName; } + @Override public TableData getTableData() { return storeProcedure; } @@ -282,10 +277,12 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { * * @return 是否异常 */ + @Override public boolean isUnusual() { return false; } + @Override public boolean equals(Object obj) { return obj instanceof StoreProcedureDataWrapper && ComparatorUtils.equals(this.dsName, ((StoreProcedureDataWrapper) obj).getTableDataName())