Subversion Repository Public Repository

litesoft

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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt
package org.litesoft.GWT.client.view;

import org.litesoft.GWT.client.*;
import org.litesoft.GWT.client.nonpublic.*;
import org.litesoft.GWT.client.widgets.Button;
import org.litesoft.GWT.client.widgets.*;
import org.litesoft.commonfoundation.typeutils.*;
import org.litesoft.core.delayed.*;
import org.litesoft.core.util.*;

import com.google.gwt.core.client.*;
import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;

public class LogoutSuspendDialog extends AbstractDialogAutoInitialized implements TimedRunnable
{
    private static final String LABEL_STYLE = "LogoutDialogText";

    private static final String SEC = "second.";
    private static final String SECS = "seconds.";

    private LogoutCallBack mLogoutCallBack;
    private SuspendCallBack mSuspendCallBack;
    private boolean mCountingDown = false;
    private long mNext;
    private int mSeconds = 30;
    private Label mLabelPrefix = new OurLabel( "Logout will proceed automatically in", false ).style( LABEL_STYLE );
    private Label mLabelSecsLefts = new OurLabel( "" + mSeconds ).style( LABEL_STYLE );
    private Label mLabelSeconds = new OurLabel( SECS ).style( LABEL_STYLE );

    public LogoutSuspendDialog( LogoutCallBack pLogoutCallBack, SuspendCallBack pSuspendCallBack )
    {
        super( "Logout", Opaqueness.Semi );

        Objects.assertNotNull( "LogoutCallBack", mLogoutCallBack = pLogoutCallBack );
        Objects.assertNotNull( "SuspendCallBack", mSuspendCallBack = pSuspendCallBack );
    }

    @Override
    protected Widget createBodyPanel()
    {
        SizeableVerticalPanel zPanel = new SizeableVerticalPanel().stretchable();
        zPanel.add( new Spacer( 5 ) );
        zPanel.add( secondsLine1() );
        zPanel.add( secondsLine2() );
        zPanel.add( new SizeableSpacer( 20 ).stretchable() );
        zPanel.add( actions() );
        return zPanel;
    }

    private Widget secondsLine1()
    {
        LeftCenterRightHorizontalPanel zPanel = new LeftCenterRightHorizontalPanel();
        zPanel.addLeft( new Spacer().width( 20 ) );
        zPanel.addCenter( mLabelPrefix );
        zPanel.addCenter( new HTML( HTMLConstants.NBSP ) );
        zPanel.addCenter( mLabelSecsLefts );
        zPanel.addRight( new Spacer().width( 20 ) );
        return zPanel;
    }

    private Widget secondsLine2()
    {
        CenterHorizontalPanel zPanel = new CenterHorizontalPanel();
        zPanel.add( mLabelSeconds );
        return zPanel;
    }

    private Widget actions()
    {
        LeftCenterRightHorizontalPanel zActionPanel = new LeftCenterRightHorizontalPanel();
        zActionPanel.addLeft( createCancelButton() );
        zActionPanel.addCenter( Button.named( "Suspend" ).green().text().add( new ClickHandler()
        {
            @Override
            public void onClick( ClickEvent event )
            {
                suspendRequested();
            }
        } ).create() );
        zActionPanel.addRight( LogoutGreenButton.factory().add( new ClickHandler()
        {
            @Override
            public void onClick( ClickEvent event )
            {
                logoutConfirmed();
            }
        } ).create() );
        return zActionPanel;
    }

    private void startTimer()
    {
        mCountingDown = true;
        TimedRunnableManager.INSTANCE.runOnOrAfter( this, mNext = System.currentTimeMillis() + 1000 );
    }

    @Override
    public Again runOnce()
    {
        if ( mCountingDown )
        {
            switch ( --mSeconds )
            {
                case 1:
                    mLabelSeconds.setText( SEC );
                    // fall thru
                default:
                    mLabelSecsLefts.setText( "" + mSeconds );
                    return new RunAgainOnOrAfter( mNext += 1000 );
                case 0:
                    logoutConfirmed();
                    break;
            }
        }
        return null;
    }

    private void logoutConfirmed()
    {
        hide();
        Scheduler.get().scheduleDeferred( new Command()
        {
            @Override
            public void execute()
            {
                mLogoutCallBack.logoutConfirmed();
            }
        } );
    }

    private void suspendRequested()
    {
        hide();
        Scheduler.get().scheduleDeferred( new Command()
        {
            @Override
            public void execute()
            {
                mSuspendCallBack.suspendRequested();
            }
        } );
    }

    private void stopTimer()
    {
        mCountingDown = false;
        TimedRunnableManager.INSTANCE.cancel( this );
    }

    @Override
    protected void onAttach()
    {
        super.onAttach();
        startTimer();
    }

    @Override
    public void hide()
    {
        stopTimer();
        super.hide();
    }

    protected final ButtonBase createCancelButton()
    {
        return CancelButton.factory().add( new HideCommand() ).create();
    }
}

Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/view/LogoutSuspendDialog.java

Diff revisions: vs.
Revision Author Commited Message
939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

858 Diff Diff GeorgeS picture GeorgeS Sun 04 Nov, 2012 18:40:40 +0000
851 Diff Diff GeorgeS picture GeorgeS Mon 08 Oct, 2012 00:05:32 +0000

Breaking the code as Temporal changes are implemented...

819 Diff Diff GeorgeS picture GeorgeS Sat 18 Aug, 2012 18:09:40 +0000
804 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 12:48:51 +0000
712 Diff Diff GeorgeS picture GeorgeS Sat 09 Jun, 2012 22:46:04 +0000

Move PAV stuff into LiteSoft

154 Diff Diff GeorgeS picture GeorgeS Tue 22 Mar, 2011 20:46:40 +0000
141 Diff Diff GeorgeS picture GeorgeS Sun 13 Mar, 2011 21:13:37 +0000
135 Diff Diff GeorgeS picture GeorgeS Wed 09 Mar, 2011 15:19:54 +0000
133 GeorgeS picture GeorgeS Wed 09 Mar, 2011 00:33:28 +0000