/
DelayFadeInHelper.java
71 lines (63 loc) · 1.79 KB
/
DelayFadeInHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* DelayFadeInHelper.java
*
* Copyright (C) 2009-11 by RStudio, Inc.
*
* This program is licensed to you under the terms of version 3 of the
* GNU Affero General Public License. This program is distributed WITHOUT
* ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
* AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
*
*/
package org.rstudio.core.client.layout;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Widget;
public class DelayFadeInHelper
{
public DelayFadeInHelper(Widget widget)
{
widget_ = widget;
}
public void beginShow()
{
hide();
final Object nonce = new Object();
nonce_ = nonce;
new Timer()
{
@Override
public void run()
{
if (nonce_ == nonce)
{
animation_ = new FadeInAnimation(
widget_, 1, null);
animation_.run(250);
}
}
}.schedule(750);
}
public void hide()
{
stopPending();
widget_.setVisible(false);
// jcheng: The next line shouldn't be necessary since we just set visible
// to false, but there was an annoying bug where it seemed the Stop
// button's visibility was being set to true when the Compile PDF panel is
// introduced. For some reason opacity is not affected, so this fixes it.
widget_.getElement().getStyle().setOpacity(0.0);
}
private void stopPending()
{
nonce_ = null;
if (animation_ != null)
{
animation_.cancel();
animation_ = null;
}
}
private Object nonce_;
private FadeInAnimation animation_;
private final Widget widget_;
}