Browse Source

Merge pull request #1157 in DESIGN/design from ~VITO/c-design:feature/10.0 to feature/10.0

* commit '3ba100d4d022375c9fe7c33e32c6b5d52fb098ee':
  REPORT-19947 关停应用时线程残留问题优化
  REPORT-19947 关停应用时线程残留问题优化
research/11.0
vito 5 years ago
parent
commit
7433aa071c
  1. 20
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  2. 34
      designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java
  3. 36
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneNumFiled.java

20
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,6 +31,7 @@ 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;
@ -48,8 +50,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 +446,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();
}
}
@ -513,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());
}

34
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<ScheduledExecutorService> ses = new ClearableLazyValue<ScheduledExecutorService>() {
@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();
}
}

36
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<ScheduledExecutorService> ses = new ClearableLazyValue<ScheduledExecutorService>() {
@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();
}

Loading…
Cancel
Save