diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toast/SimpleToast.java b/designer-base/src/main/java/com/fr/design/mainframe/toast/SimpleToast.java index b3b49a09fb..f74de6dd99 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toast/SimpleToast.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toast/SimpleToast.java @@ -27,8 +27,8 @@ public class SimpleToast extends UIDialog { private static final TimeUnit DEFAULT_TIME_UNIT = TimeUnit.MILLISECONDS; - private ScheduledExecutorService TIMER; - private int hide_height = 0; + private ScheduledExecutorService timer; + private int hideHeight = 0; private JPanel contentPane; private boolean show = false; private Window parent; @@ -72,7 +72,7 @@ public class SimpleToast extends UIDialog { this.getContentPane().setLayout(null); this.getContentPane().add(contentPane); Dimension dimension = calculatePreferSize(); - hide_height = dimension.height; + hideHeight = dimension.height; setSize(new Dimension(dimension.width, 0)); contentPane.setSize(dimension); setRelativeLocation(dimension); @@ -94,19 +94,19 @@ public class SimpleToast extends UIDialog { } - public void display(JPanel outerJPanel) { + public void display(JPanel outerPanel) { show = true; - outerJPanel.setLocation(0, -hide_height); - ScheduledExecutorService TIP_TOOL_TIMER = createToastScheduleExecutorService(); - TIP_TOOL_TIMER.scheduleAtFixedRate(new Runnable() { + outerPanel.setLocation(0, -hideHeight); + ScheduledExecutorService tipToolTimer = createToastScheduleExecutorService(); + tipToolTimer.scheduleAtFixedRate(new Runnable() { @Override public void run() { - Point point = outerJPanel.getLocation(); - if (point.y >= 0) { - TIP_TOOL_TIMER.shutdown(); + Point point = outerPanel.getLocation(); + if (point.y >= 0 && !tipToolTimer.isShutdown()) { + tipToolTimer.shutdown(); } int showDistance = 5 + point.y < 0 ? 5 : -point.y; - outerJPanel.setLocation(point.x, point.y + showDistance); + outerPanel.setLocation(point.x, point.y + showDistance); Dimension dimension = SimpleToast.this.getSize(); SimpleToast.this.setSize(new Dimension(dimension.width, dimension.height + showDistance)); } @@ -115,8 +115,8 @@ public class SimpleToast extends UIDialog { } private void disappear(JPanel outerJPanel, long delay, TimeUnit timeUnit) { - TIMER = createToastScheduleExecutorService(); - TIMER.schedule(new DisappearMotion(outerJPanel), delay, timeUnit); + timer = createToastScheduleExecutorService(); + timer.schedule(new DisappearMotion(outerJPanel), delay, timeUnit); } /** @@ -131,13 +131,13 @@ public class SimpleToast extends UIDialog { @Override public void run() { - ScheduledExecutorService TIP_TOOL_TIMER = createToastScheduleExecutorService(); - TIP_TOOL_TIMER.scheduleAtFixedRate(new Runnable() { + ScheduledExecutorService tipToolTimer = createToastScheduleExecutorService(); + tipToolTimer.scheduleAtFixedRate(new Runnable() { @Override public void run() { Point point = panel.getLocation(); - if (point.y <= -hide_height) { - TIP_TOOL_TIMER.shutdown(); + if (point.y <= -hideHeight && !tipToolTimer.isShutdown()) { + tipToolTimer.shutdown(); SimpleToast.this.setVisible(false); SimpleToast.this.dispose(); SimpleToast.this.show = false; @@ -151,8 +151,8 @@ public class SimpleToast extends UIDialog { } - private void disappear(JPanel outerJPanel) { - disappear(outerJPanel, DEFAULT_DISAPPEAR_DELAY, DEFAULT_TIME_UNIT); + private void disappear(JPanel outerPanel) { + disappear(outerPanel, DEFAULT_DISAPPEAR_DELAY, DEFAULT_TIME_UNIT); } private ScheduledExecutorService createToastScheduleExecutorService() {