From 34f6292dc27fce63c78bcdbcb521a6a67020d407 Mon Sep 17 00:00:00 2001 From: vito Date: Fri, 27 Sep 2019 17:00:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-19947=20=E5=85=B3=E5=81=9C=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E6=97=B6=E7=BA=BF=E7=A8=8B=E6=AE=8B=E7=95=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 22 ++++++++---- .../design/gui/style/FormatePaneNumField.java | 34 +++++++++++------- .../style/series/ColorPickerPaneNumFiled.java | 36 ++++++++++++------- 3 files changed, 59 insertions(+), 33 deletions(-) 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 44de37ea82..92c30d5bef 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 @@ -2,6 +2,7 @@ package com.fr.design.data; import com.fr.base.StoreProcedureParameter; import com.fr.base.TableData; +import com.fr.concurrent.NamedThreadFactory; import com.fr.data.TableDataSource; import com.fr.data.TableDataSourceTailor; import com.fr.data.core.DataCoreXmlUtils; @@ -30,14 +31,14 @@ import com.fr.general.ComparatorUtils; import com.fr.general.data.DataModel; import com.fr.general.data.TableDataException; import com.fr.log.FineLoggerFactory; +import com.fr.module.ModuleContext; import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; +import javax.swing.event.*; import java.io.ByteArrayOutputStream; import java.text.Collator; import java.util.ArrayList; @@ -48,8 +49,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Timer; -import java.util.TimerTask; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * 设计器管理操作数据集的类: @@ -444,11 +445,18 @@ public abstract class DesignTableDataManager { } catch (Exception e) { throw new TableDataException(e.getMessage(), e); } finally { - new Timer().schedule(new TimerTask() { + ScheduledExecutorService scheduledExecutorService = ModuleContext + .getExecutor() + .newSingleThreadScheduledExecutor(new NamedThreadFactory("")); + scheduledExecutorService.schedule(new Runnable() { + @Override public void run() { - loadingBar.close(); + if (loadingBar != null) { + loadingBar.close(); + } } - }, 100); + }, 100, TimeUnit.MILLISECONDS); + scheduledExecutorService.shutdown(); } } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java b/designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java index ee397d7559..dc706416c6 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java @@ -1,10 +1,14 @@ package com.fr.design.gui.style; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.itextfield.UITextField; +import com.fr.module.ModuleContext; +import com.fr.value.ClearableLazyValue; +import org.jetbrains.annotations.NotNull; -import java.util.Timer; -import java.util.TimerTask; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * Created with IntelliJ IDEA. @@ -14,31 +18,35 @@ import java.util.TimerTask; * To change this template use File | Settings | File Templates. */ public class FormatePaneNumField extends UITextField { - private Timer timer; + private ClearableLazyValue ses = new ClearableLazyValue() { + @NotNull + @Override + protected ScheduledExecutorService compute() { + return ModuleContext.getExecutor() + .newSingleThreadScheduledExecutor(new NamedThreadFactory("FormatePaneNumFieldRunChange")); + } + }; + public FormatePaneNumField() { super(); } + @Override protected void attributeChange() { if (!AbstractAttrNoScrollPane.isHasChangeListener()) { return; } - if(timer != null){ - timer.cancel(); - } - timer = new Timer(); - timer.schedule(new TimerTask() { + ses.getValue().schedule(new Runnable() { @Override public void run() { runChange(); } - },100); - + }, 100, TimeUnit.MILLISECONDS); } - protected void runChange(){ + protected void runChange() { super.attributeChange(); - timer.cancel(); - + ses.getValue().shutdown(); + ses.drop(); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java index 267a8a847f..fcaed6d990 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java @@ -1,9 +1,13 @@ package com.fr.design.mainframe.chart.gui.style.series; -import java.util.Timer; -import java.util.TimerTask; - +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.gui.itextfield.UINumberField; +import com.fr.module.ModuleContext; +import com.fr.value.ClearableLazyValue; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * Created with IntelliJ IDEA. @@ -13,28 +17,34 @@ import com.fr.design.gui.itextfield.UINumberField; * To change this template use File | Settings | File Templates. */ public class ColorPickerPaneNumFiled extends UINumberField { - private Timer timer; + private ClearableLazyValue ses = new ClearableLazyValue() { + @NotNull + @Override + protected ScheduledExecutorService compute() { + return ModuleContext.getExecutor() + .newSingleThreadScheduledExecutor(new NamedThreadFactory("FormatePaneNumFieldRunChange")); + } + }; + public ColorPickerPaneNumFiled() { super(); } + @Override protected void attributeChange() { - if(timer != null){ - timer.cancel(); - } - timer = new Timer(); - timer.schedule(new TimerTask() { + ses.getValue().schedule(new Runnable() { @Override public void run() { + // kuns: 默认修改500, 在地图修改系列颜色text时, 快速响应. runChange(); } - },500);// kuns: 默认修改500, 在地图修改系列颜色text时, 快速响应. - + }, 500, TimeUnit.MILLISECONDS); } - protected void runChange(){ + protected void runChange() { super.attributeChange(); - timer.cancel(); + ses.getValue().shutdown(); + ses.drop(); } From 3ba100d4d022375c9fe7c33e32c6b5d52fb098ee Mon Sep 17 00:00:00 2001 From: vito Date: Fri, 27 Sep 2019 17:03:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-19947=20=E5=85=B3=E5=81=9C=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E6=97=B6=E7=BA=BF=E7=A8=8B=E6=AE=8B=E7=95=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/data/DesignTableDataManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 92c30d5bef..f1e911e7a8 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 @@ -38,7 +38,8 @@ import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; -import javax.swing.event.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.io.ByteArrayOutputStream; import java.text.Collator; import java.util.ArrayList; @@ -521,6 +522,7 @@ public abstract class DesignTableDataManager { if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter. final ParameterInputPane pPane = new ParameterInputPane(inParameters); pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override public void doOk() { parameterMap.putAll(pPane.update()); }