Example usage for com.google.gwt.user.client Timer Timer

List of usage examples for com.google.gwt.user.client Timer Timer

Introduction

In this page you can find the example usage for com.google.gwt.user.client Timer Timer.

Prototype

Timer

Source Link

Usage

From source file:cc.alcina.framework.gwt.client.widget.SelectWithSearch.java

License:Apache License

protected void handleFilterBlur() {
    new Timer() {
        @Override/*from   w w  w  . j av a  2  s .c o m*/
        public void run() {
            // https://jira.barnet.com.au/browse/JAD-5053 - IE
            // blur/scrollbar issue
            if (BrowserMod.isInternetExplorer()) {
                Element elt = WidgetUtils.getFocussedDocumentElement();
                if (elt != null && elt.getClassName().contains("scroller")) {
                    return;
                }
            }
            hidePopdown();
        }
    }.schedule(250);
}

From source file:cc.alcina.framework.gwt.persistence.client.ClientSession.java

License:Apache License

public void acquireCrossTabPersistenceLock(final AsyncCallback<Void> callback) {
    if (persistingChunkCookie.isSoleTab()) {
        persistingChunkCookie.setActive(true);
        callback.onSuccess(null);/* w ww  .  j a v  a 2  s. c o  m*/
        return;
    }
    new Timer() {
        @Override
        public void run() {
            acquireCrossTabPersistenceLock(callback);
        }
    }.schedule(1000);
}

From source file:cc.alcina.framework.gwt.persistence.client.ClientSession.java

License:Apache License

/**
 * Callback with true if sole open tab/*  www. j a v a  2  s  . c  o  m*/
 */
public void checkSoleOpenTab(final AsyncCallback<Boolean> callback) {
    if (isSoleOpenTab()) {
        callback.onSuccess(true);
        return;
    }
    new Timer() {
        int retryCount = 4;

        @Override
        public void run() {
            if (retryCount-- == 0) {
                cancel();
                callback.onSuccess(false);
            } else if (isSoleOpenTab()) {
                cancel();
                callback.onSuccess(true);
            }
        }
    }.scheduleRepeating(1000);
}

From source file:cc.kune.chat.client.actions.ChatSitebarActions.java

License:GNU Affero Public License

/**
 * Creates the listener.// w  w w .  j  a v a 2  s . c o m
 */
private void createListener() {
    awayTimer = new Timer() {
        @Override
        public void run() {
            final Presence awayPresence = Presence.build(NO_STATUS, Show.away);
            if (chatClient.isXmppLoggedIn()) {
                presenceManager.changeOwnPresence(awayPresence);
                updateMenuPresence(awayPresence);
            }
        }
    };
    xmppSession.addSessionStateChangedHandler(false, new StateChangedHandler() {
        @Override
        public void onStateChanged(final StateChangedEvent event) {
            if (xmppSession.isReady()) {
                awayTimer.cancel();
                presenceManager.changeOwnPresence(nextPresence);
                updateMenuPresence(nextPresence);
            } else {
                offlineItem.setChecked(true);
            }
        }
    });
    presenceManager.addOwnPresenceChangedHandler(new OwnPresenceChangedHandler() {
        @Override
        public void onOwnPresenceChanged(final OwnPresenceChangedEvent event) {
            updateMenuPresence(event.getCurrentPresence());
        }
    });
    eventBus.addHandler(WindowFocusEvent.getType(), new WindowFocusEvent.WindowFocusHandler() {
        @Override
        public void onWindowFocus(final WindowFocusEvent event) {
            if (event.isHasFocus()) {
                awayTimer.cancel();
                if (chatClient.isXmppLoggedIn()) {
                    new Timer() {
                        @Override
                        public void run() {
                            presenceManager.changeOwnPresence(nextPresence);
                        }
                    }.schedule(1000);
                }
            } else {
                awayTimer.schedule(AWAY_TIMER_MILLSECS);
            }
        }
    });
    ClientEvents.get().addNetworkStatusEventHandler(new NetworkStatusEventHandler() {
        @Override
        public void onNetworkStatus(final NetworkStatusEvent event) {
            switch (event.getStatus()) {
            case CONNECTED:
            case RECONNECTED:
                new Timer() {
                    @Override
                    public void run() {
                        ChatSitebarActions.this.chatClient.loginIfNecessary();
                    }
                }.schedule(2000);
                break;
            default:
            case DISCONNECTED:
            case RECONNECTING:
                break;
            }
        }
    });
}

From source file:cc.kune.client.DefaultUncaughtExceptionHandler.java

License:GNU Affero Public License

private void showErrorMessage(final Throwable unwrapped) {
    Log.error("Error in 'onModuleLoad()' method", unwrapped);

    ErrorHandler.getStackTraceAsync(unwrapped, new Accessor<SafeHtml>() {
        @Override// w  w w  . j  av  a2s  . c o m
        public void use(final SafeHtml stack) {
            final String message = stack.asString().replace("<br>", "\n");
            cc.kune.core.client.errors.ErrorHandler.showGeneralError(message);
            new Timer() {
                @Override
                public void run() {
                    NotifyUser.hideProgress();
                }
            }.schedule(5000);
        }
    });
}

From source file:cc.kune.common.client.msgs.UserMessageWidget.java

License:GNU Affero Public License

/**
 * Instantiates a new user message widget.
 *
 * @param level the level/*from   ww  w  .ja v a2  s.c om*/
 * @param title the title
 * @param message the message
 * @param id the id
 * @param closeable the closeable
 * @param closeCallback the close callback
 */
public UserMessageWidget(final NotifyLevel level, final String title, final String message, final String id,
        final boolean closeable, final CloseCallback closeCallback) {
    this.closeCallback = closeCallback;
    initWidget(uiBinder.createAndBindUi(this));
    getElement().getStyle().setOpacity(0);
    // setVisible(false);
    if (TextUtils.notEmpty(id)) {
        close.ensureDebugId(id);
    }
    if (TextUtils.notEmpty(message)) {
        setMsg(title, message);
        close.setVisible(closeable);
        close.setTitle(closeTitle);
        if (!closeable) {
            time = new Timer() {
                @Override
                public void run() {
                    close();
                }
            };
            time.schedule(fadeMills);
        }
        setIcon(level);
        if (Animations.enabled) {
            $(this).as(Effects).fadeTo(200, 1d);
        } else {
            setVisible(true);
        }

    }
}

From source file:cc.kune.common.client.notify.SimpleUserMessage.java

License:GNU Affero Public License

/**
 * Instantiates a new simple user message.
 *///from   w  ww  . ja v  a  2  s  . com
public SimpleUserMessage() {
    msg = new Label();
    msg.addStyleName("oc-user-msg");
    rp = new FlowPanel();
    timer = new Timer() {
        @Override
        public void run() {
            hide();
        }
    };

}

From source file:cc.kune.common.client.ui.BlinkAnimation.java

License:GNU Affero Public License

/**
 * Instantiates a new blink animation.//  www.  java2  s. com
 *
 * @param obj the object to animate
 * @param interval between blinks
 */
public BlinkAnimation(final UIObject obj, final int interval) {
    this.interval = interval;

    timer = new Timer() {
        @Override
        public void run() {
            if (!blink) {
                obj.addStyleDependentName("blink");
                iteration++;
            } else {
                obj.removeStyleDependentName("blink");
                if (iteration == stopIter) {
                    timer.cancel();
                }
            }
            blink = !blink;
        }
    };
}

From source file:cc.kune.common.client.ui.EditableLabel.java

License:GNU Affero Public License

/**
 * Blink timer./*  www.j  a v  a  2s  . c  o  m*/
 *
 * @param add
 *          the add
 * @param callback
 *          the callback
 */
private void blinkTimer(final boolean add, final SimpleCallback callback) {
    new Timer() {
        @Override
        public void run() {
            if (add) {
                label.addStyleDependentName("high");
            } else {
                label.removeStyleDependentName("high");
            }
            callback.onCallback();
        }
    }.schedule(BLINK_TIME);
}

From source file:cc.kune.common.client.utils.TimerWrapper.java

License:GNU Affero Public License

/**
 * Configure.//from www  . j  a  v  a2s.com
 *
 * @param onTime the on time
 */
public void configure(final Executer onTime) {
    timer = new Timer() {
        @Override
        public void run() {
            isScheduled = false;
            onTime.execute();
        }
    };
}