/** Set whether or not resize checking is enabled. If disabled, elements will still be resized on window events, but the timer * will not check their dimensions periodically. * * @param enabled true to enable the resize checking timer */ public void setResizeCheckingEnabled (boolean enabled) { if (enabled && !resizeCheckingEnabled) { resizeCheckingEnabled = true; if (windowHandler == null) { windowHandler = Window.addResizeHandler(this); } resizeCheckTimer.schedule(resizeCheckDelay); } else if (!enabled && resizeCheckingEnabled) { resizeCheckingEnabled = false; if (windowHandler != null) { windowHandler.removeHandler(); windowHandler = null; } resizeCheckTimer.cancel(); } }
/** Set whether or not resize checking is enabled. If disabled, elements will still be resized on window events, but the timer * will not check their dimensions periodically. * * @param enabled true to enable the resize checking timer */ public void setResizeCheckingEnabled (boolean enabled) { if (enabled && !resizeCheckingEnabled) { resizeCheckingEnabled = true; if (windowHandler == null) { windowHandler = Window.addResizeHandler(this); } resizeCheckTimer.schedule(resizeCheckDelay); } else if (!enabled && resizeCheckingEnabled) { resizeCheckingEnabled = false; if (windowHandler != null) { windowHandler.removeHandler(); windowHandler = null; } resizeCheckTimer.cancel(); } }
@Override public AnimationHandle requestAnimationFrame(final AnimationCallback callback, Element element) { // Save the animation frame request. AnimationHandleImpl requestId = new AnimationHandleImpl(callback); animationRequests.add(requestId); // Start the timer if it isn't started. if (animationRequests.size() == 1) { timer.schedule(DEFAULT_FRAME_DELAY); } // Return the request id. return requestId; }
private boolean throttleMessages(final List<Message> txMessages) { final int window = throttleOutgoing(); if (window <= 0) { heldMessages.addAll(txMessages); throttleTimer.schedule(-window); return true; } else { return false; } }
/** * Display the notification, but after a delay. * * @param delay delay in milliseconds. */ public void showDelayed(int delay) { if (showAttempts == 0) { if (delay == 0) { show(); } else { ++showAttempts; showTimer.schedule(delay); } } }
/** * Constructs an instance of the Request object. * * @param xmlHttpRequest JavaScript XmlHttpRequest object instance * @param timeoutMillis number of milliseconds to wait for a response * @param callback callback interface to use for notification * * @throws IllegalArgumentException if timeoutMillis < 0 * @throws NullPointerException if xmlHttpRequest, or callback are null */ Request(XMLHttpRequest xmlHttpRequest, int timeoutMillis, RequestCallback callback) { if (xmlHttpRequest == null) { throw new NullPointerException(); } if (callback == null) { throw new NullPointerException(); } if (timeoutMillis < 0) { throw new IllegalArgumentException(); } this.callback = callback; this.timeoutMillis = timeoutMillis; this.xmlHttpRequest = xmlHttpRequest; if (timeoutMillis > 0) { timer.schedule(timeoutMillis); } }
/** * Starts the dispatch timer if there are commands to dispatch and we are not * waiting for a dispatch timer and we are not actively dispatching. */ protected void maybeStartExecutionTimer() { if (!commands.isEmpty() && !isExecutionTimerPending() && !isExecuting()) { setExecutionTimerPending(true); executionTimer.schedule(1); } }
/** * Iterate over all animations and update them. */ private void updateAnimations() { // Copy the animation requests to avoid concurrent modifications. AnimationHandleImpl[] curAnimations = new AnimationHandleImpl[animationRequests.size()]; curAnimations = animationRequests.toArray(curAnimations); // Iterate over the animation requests. Duration duration = new Duration(); for (AnimationHandleImpl requestId : curAnimations) { // Remove the current request. animationRequests.remove(requestId); // Execute the callback. requestId.getCallback().execute(duration.getStartMillis()); } // Reschedule the timer if there are more animation requests. if (animationRequests.size() > 0) { /* * In order to achieve as close to 60fps as possible, we calculate the new * delay based on the execution time of this method. The delay will be * less than 16ms, assuming this method takes more than 1ms to complete. */ timer.schedule(Math.max(MIN_FRAME_DELAY, DEFAULT_FRAME_DELAY - duration.elapsedMillis())); } } }
timer.schedule(timeout); getHeadElement().appendChild(script);
/** * Sends a ping request to the server. If the ping response is not received * within a reasonable time limit, notifyDisconnected() will be called. */ private void verifyConnected() { // in case we were in the middle of something already pingTimeout.cancel(); transmit(Collections.singletonList(MessageBuilder.createMessage() .toSubject("ServerEchoService") .signalling().done().repliesToSubject(SSE_AGENT_SERVICE).getMessage())); pingTimeout.schedule(2500); }
@Override public void onResize(ResizeEvent event) { timer.schedule(250); } };
@Override public void onResize(ResizeEvent event) { timer.schedule(250); } };
@Override public void schedule(final int delayMillis) { if (mode != null) { throw new IllegalStateException("This timer has already been scheduled."); } mode = SchedulingMode.ONE_TIME; super.schedule(delayMillis); }
cancellationTimer.schedule(DEFAULT_CANCELLATION_TIMEOUT_MILLIS);
showTimer.schedule(1); } else { run(ANIMATION_DURATION);
initialConnectTimer.schedule(50);
@Override public void requestSuggestions(final Request request, final Callback callback) { m_keyTimer.cancel(); m_keyTimer = new Timer() { @Override public void run() { m_connector.query(request, callback, m_indexFrom, m_indexTo); } }; m_keyTimer.schedule(500); } }
private boolean throttleMessages(final List<Message> txMessages) { final int window = throttleOutgoing(); if (window <= 0) { heldMessages.addAll(txMessages); throttleTimer.schedule(-window); return true; } else { return false; } }
/** * Override VCKEditorTextField's default behavior, defer update in case field is immediate. */ @Override public void onChange() { if (editor != null && !editor.isReadOnly()) { clientToServer.updateVariable(paintableId, VAR_TEXT, editor.getData(), false); if (immediate) { valueUpdateTimer.schedule(200); } } }
@Override public void onDocumentChanged(final DocumentChangedEvent event) { if (documentHandle == null || !documentHandle.isSameAs(event.getDocument())) { return; } createDirtyRegion(event); autoSaveTimer.cancel(); autoSaveTimer.schedule(DELAY); }