Ejemplo n.º 1
0
  /**
   * Handling MouseOver event.
   *
   * @param tr - element to be processed.
   */
  protected void onRowHovered(Element tr) {
    if (tr == hoveredTR) {
      return;
    }

    setStyleNormal(hoveredTR);
    if (subPopupAnchor != null) {
      setStyleHovered(subPopupAnchor);
    }

    if (!isRowEnabled(tr)) {
      hoveredTR = null;
      return;
    }

    hoveredTR = tr;
    setStyleHovered(tr);

    int itemIndex = Integer.parseInt(tr.getAttribute("item-index"));
    Action menuItem = list.get(itemIndex);
    openSubPopupTimer.cancel();
    if (menuItem instanceof ActionGroup
        && !(((ActionGroup) menuItem).canBePerformed()
            && !Utils.hasVisibleChildren(
                (ActionGroup) menuItem,
                presentationFactory,
                actionManager,
                managerProvider.get()))) {
      openSubPopupTimer.schedule(300);
    } else {
      closeSubPopupTimer.cancel();
      closeSubPopupTimer.schedule(200);
    }
  }
 private void mainLoop() {
   mainController.timeStep();
   if (world.isGameLost()) {
     eventBus.fireEvent(new GameFinishedEvent());
     timer.cancel();
   }
 }
Ejemplo n.º 3
0
 @Override
 protected void onHide() {
   super.onHide();
   if (indexProgressTimer != null) {
     indexProgressTimer.cancel();
   }
 }
Ejemplo n.º 4
0
  /**
   * Called when the field value might have changed and/or the field was blurred. These are combined
   * so the blur event is sent in the same batch as a possible value change event (these are often
   * connected).
   *
   * @param blurred true if the field was blurred
   */
  public void valueChange(boolean blurred) {
    if (client != null && paintableId != null) {
      boolean sendBlurEvent = false;
      boolean sendValueChange = false;

      if (blurred && client.hasEventListeners(this, EventId.BLUR)) {
        sendBlurEvent = true;
        client.updateVariable(paintableId, EventId.BLUR, "", false);
      }

      String newText = getText();
      if (!prompting && newText != null && !newText.equals(valueBeforeEdit)) {
        sendValueChange = immediate;
        client.updateVariable(paintableId, "text", newText, false);
        valueBeforeEdit = newText;
        valueBeforeEditIsSynced = true;
      }

      /*
       * also send cursor position, no public api yet but for easier
       * extension
       */
      updateCursorPosition();

      if (sendBlurEvent || sendValueChange) {
        /*
         * Avoid sending text change event as we will simulate it on the
         * server side before value change events.
         */
        textChangeEventTrigger.cancel();
        scheduled = false;
        client.sendPendingVariableChanges();
      }
    }
  }
Ejemplo n.º 5
0
 private void refresh(Timer timer) {
   if (ach == goal) {
     timer.cancel();
     return;
   } else if (goal > ach) {
     ach++;
     if (ach > pot + 1) {
       ach = goal;
     }
     if (pot < ach) {
       bluRect.setFillColor(CANVASCOLORDARKGREEN);
       greenRect.setFillColor(CANVASCOLORDARKGREEN);
     }
   } else {
     ach--;
     if (ach > pot + 1) {
       ach = pot;
     }
     if (pot == ach) {
       greenRect.setFillColor(CANVASCOLORGREEN);
       bluRect.setFillColor(CANVASCOLORBLUE);
     }
   }
   String achStr = String.valueOf(ach);
   achText.setX(getTextPosition(achStr));
   achText.setText(achStr);
   if (pot != 0) {
     greenRect.setHeight(istogramHeight - (istogramHeight * ach / pot));
   } else greenRect.setHeight(0);
 }
Ejemplo n.º 6
0
 @Override
 public void uninstall() {
   autoSaveTimer.cancel();
   for (ReconcilingStrategy strategy : strategies.values()) {
     strategy.closeReconciler();
   }
 }
Ejemplo n.º 7
0
  public static void onDestroy(Timer refreshTimer) {

    if (refreshTimer != null) {

      refreshTimer.cancel();
    }
  }
Ejemplo n.º 8
0
 /** Stop monitoring for parent element resizes. */
 @Override
 protected void onUnload() {
   if (resizeTimer != null) {
     resizeTimer.cancel();
     resizeTimer = null;
   }
   super.onUnload();
 }
Ejemplo n.º 9
0
 @Override
 public void onStateChanged(StateChangeEvent event) {
   super.onStateChanged(event);
   timer.cancel();
   if (isEnabled()) {
     timer.scheduleRepeating(getState().interval);
   }
 }
Ejemplo n.º 10
0
 private void stopShake() {
   if (shaking) {
     shakeTimer.cancel();
     RootPanel.get().setWidgetPosition(panel, left, top);
     shaking = false;
   }
   runCommandQueue();
 }
Ejemplo n.º 11
0
 @Override
 public void onStop() {
   eventBus = null;
   // Kill the refresh timer.
   if (refreshTimer != null) {
     refreshTimer.cancel();
   }
 }
Ejemplo n.º 12
0
 private void deferTextChangeEvent() {
   if (textChangeEventMode.equals(TEXTCHANGE_MODE_TIMEOUT) && scheduled) {
     return;
   } else {
     textChangeEventTrigger.cancel();
   }
   textChangeEventTrigger.schedule(getTextChangeEventTimeout());
   scheduled = true;
 }
Ejemplo n.º 13
0
 /**
  * Updates the schedule of the heartbeat to match the set interval. A negative interval disables
  * the heartbeat.
  */
 public void schedule() {
   if (interval > 0) {
     getLogger().fine("Scheduling heartbeat in " + interval + " seconds");
     timer.schedule(interval * 1000);
   } else {
     getLogger().fine("Disabling heartbeat");
     timer.cancel();
   }
 }
Ejemplo n.º 14
0
  private void reconcilerDocumentChanged() {
    for (String key : strategies.keySet()) {
      ReconcilingStrategy reconcilingStrategy = strategies.get(key);
      reconcilingStrategy.setDocument(documentHandle.getDocument());
    }

    autoSaveTimer.cancel();
    autoSaveTimer.schedule(DELAY);
  }
Ejemplo n.º 15
0
 @Override
 public void onDocumentChange(final DocumentChangeEvent event) {
   if (documentHandle == null || !documentHandle.isSameAs(event.getDocument())) {
     return;
   }
   createDirtyRegion(event);
   autoSaveTimer.cancel();
   autoSaveTimer.schedule(DELAY);
 }
 protected void clearTimer(String timer) {
   if (timer.equals("hide")) {
     if (hideTimer != null) {
       hideTimer.cancel();
       hideTimer = null;
     }
   } else if (timer.equals("dismiss")) {
     if (dismissTimer != null) {
       dismissTimer.cancel();
       dismissTimer = null;
     }
   } else if (timer.equals("show")) {
     if (showTimer != null) {
       showTimer.cancel();
       showTimer = null;
     }
   }
 }
Ejemplo n.º 17
0
 public void hide() {
   if (!drawn) throw new IllegalStateException();
   if (timer != null) timer.cancel();
   if (hidden) return;
   this.hidden = true;
   stopShake();
   AbsolutePanel root = RootPanel.get();
   root.remove(a);
   root.remove(panel);
 }
Ejemplo n.º 18
0
 public void unhide() {
   if (!drawn) throw new IllegalStateException();
   if (timer != null) timer.cancel();
   if (hidden) {
     stopShake();
     this.hidden = false;
     AbsolutePanel root = RootPanel.get();
     root.add(panel, left, top);
     root.add(a, arrowLeft, arrowTop);
   }
 }
Ejemplo n.º 19
0
  public void timedHide(int millis) {
    if (timer != null) timer.cancel();
    else
      timer =
          new Timer() {
            public void run() {
              hide();
            }
          };

    timer.schedule(millis);
  }
Ejemplo n.º 20
0
  private void notifyConnected() {
    pingTimeout.cancel();
    retries = 0;

    if (!connected) {
      connected = true;
      connectedTime = System.currentTimeMillis();
      LogUtil.log(this + ": SSE channel is active.");
    }

    if (clientMessageBus.getState() == BusState.CONNECTION_INTERRUPTED) {
      clientMessageBus.setState(BusState.CONNECTED);
    }
  }
  private void receivedContactResponse() {
    int elapsedTime = (int) (System.currentTimeMillis() - contactRequestTime);

    contactRequestTime = 0;
    unresponsiveConnectionTimer.cancel();

    setConnectivityStatus(true);

    // Adjust the unresponsiveTimeLimit.
    unresponsiveTimeLimit = Math.max(MINIMUM_UNRESPONSIVE_TIME_LIMIT, elapsedTime);

    if (connectivityListeners.size() >= 1) {
      contactTimer.schedule(CONTACT_REQUEST_TIMER_DELAY);
    }
  }
Ejemplo n.º 22
0
 /**
  * Logs unresolved components.
  *
  * <p>This is optional, but if set any component with unresolved dependencies will be logged when
  * the timer expires, along with the details of what dependency failed.
  *
  * <p>Use the @see setTimeout(Timer) call to set a custom timeout for this.
  */
 public void setTimeout(int milliseconds) {
   if (timer != null) timer.cancel();
   timer =
       new Timer() {
         @Override
         public void run() {
           failed = true; // Timeout.
           invokeReadyCallbacks();
           componentAudit();
           timer = null; // Reset
           timeout = 0;
         }
       };
   timeout = milliseconds;
 }
Ejemplo n.º 23
0
  private void notifyDisconnected() {
    connected = false;

    pingTimeout.cancel();
    LogUtil.log(this + " channel disconnected.");
    connectedTime = -1;
    clientMessageBus.setState(BusState.CONNECTION_INTERRUPTED);

    disconnect(sseChannel);

    if (!stopped) {
      retries++;
      start();
    }
  }
Ejemplo n.º 24
0
  private void adjustUpdateSpeed(int newSpeed) {
    updateSpeed = newSpeed;
    updateCmd.execute();

    if (updater != null) updater.cancel();
    if (updateSpeed == 0) {
      return;
    }
    updater =
        new Timer() {
          public void run() {
            updateCmd.execute();
          }
        };
    updater.scheduleRepeating(updateSpeed);
  }
Ejemplo n.º 25
0
  /**
   * 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);
  }
 /**
  * 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();
   }
 }
Ejemplo n.º 27
0
 private void scheduleHide() {
   if (showTimer != null) {
     showTimer.cancel();
     showTimer = null;
   }
   if (popup == null || !popup.isShowing() || !popup.isVisible() || hideTimer != null) {
     return;
   }
   hideTimer =
       new Timer() {
         @Override
         public void run() {
           popup.hide();
         }
       };
   hideTimer.schedule(50);
 }
  @Override
  public void createScreen(final PageController pageController, Long modelId) {
    this.pageController = pageController;
    pageController.setBackground(Background.MENU);
    pageController.getSoundPlayer().playMenuScreenMusic();
    pageController.setScreenTitle("Select a Game to Observe");

    pageController.addScreen(screen.content);

    requestUpdateObservableGameList();

    refreshObservableGameListTimer.cancel();
    // TODO would scheduling each time we update work better?
    // updates take different amounts of time for different
    // computers/networks
    refreshObservableGameListTimer.scheduleRepeating(GAME_LIST_REFRESH_INTERVAL_MS);
  }
Ejemplo n.º 29
0
    protected void change(@Nullable DomEvent event) {
      String newText = textBox.getText();

      boolean newFocus;
      if (event instanceof BlurEvent || event instanceof FocusEvent) {
        newFocus = event instanceof FocusEvent;
      } else {
        newFocus = hasFocus;
      }

      if (newFocus == hasFocus
          && newText.equals(text)
          && caret == textBox.getCursorPos()
          && selectionLength == textBox.getSelectionLength()) {
        return;
      }

      timer.cancel();

      hasFocus = newFocus;
      text = newText;

      caret = this.textBox.getCursorPos();
      if (caret < 0) {
        caret = 0;
      }
      if (caret >= text.length()) {
        caret = text.length();
      }

      selectionLength = this.textBox.getSelectionLength();

      CharSequence charSequence =
          recreateView(text, caret, selectionLength, hasFocus, highlighters);

      html.setHTML(charSequence.toString());

      if (selectionLength == 0 && hasFocus) {
        html.removeStyleName("caretHidden");
        isCaretShown = true;
        timer.schedule(1000);
      }
    }
Ejemplo n.º 30
0
  /** Sends a heartbeat to the server */
  public void send() {
    timer.cancel();

    final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri);

    final RequestCallback callback =
        new RequestCallback() {

          @Override
          public void onResponseReceived(Request request, Response response) {
            int status = response.getStatusCode();

            if (status == Response.SC_OK) {
              connection.getConnectionStateHandler().heartbeatOk();
            } else {
              // Handler should stop the application if heartbeat should
              // no longer be sent
              connection.getConnectionStateHandler().heartbeatInvalidStatusCode(request, response);
            }

            schedule();
          }

          @Override
          public void onError(Request request, Throwable exception) {
            // Handler should stop the application if heartbeat should no
            // longer be sent
            connection.getConnectionStateHandler().heartbeatException(request, exception);
            schedule();
          }
        };

    rb.setCallback(callback);

    try {
      getLogger().fine("Sending heartbeat request...");
      rb.send();
    } catch (RequestException re) {
      callback.onError(null, re);
    }
  }