litesoft
@ 948
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 |
// This Source Code is in the Public Domain per: http://unlicense.org 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.html.*; import org.litesoft.commonfoundation.typeutils.*; import org.litesoft.core.delayed.*; 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
Revision | Author | Commited | Message |
---|---|---|---|
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
942 Diff | GeorgeS | Mon 02 Jun, 2014 23:41:46 +0000 | Extracting commonfoundation |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
858 Diff | GeorgeS | Sun 04 Nov, 2012 18:40:40 +0000 | |
851 Diff | GeorgeS | Mon 08 Oct, 2012 00:05:32 +0000 | Breaking the code as Temporal changes are implemented... |
819 Diff | GeorgeS | Sat 18 Aug, 2012 18:09:40 +0000 | |
804 Diff | GeorgeS | Wed 15 Aug, 2012 12:48:51 +0000 | |
712 Diff | GeorgeS | Sat 09 Jun, 2012 22:46:04 +0000 | Move PAV stuff into LiteSoft |
154 | GeorgeS | Tue 22 Mar, 2011 20:46:40 +0000 |