コード例 #1
0
ファイル: PopupMenu.java プロジェクト: raphsoft/che
  /**
   * 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);
    }
  }
コード例 #2
0
  @NotNull
  private Runner launchRunner(@NotNull Runner runner) {
    if (runActionPermit.isAllowed()) {

      CurrentProject currentProject = appContext.getCurrentProject();

      if (currentProject == null) {
        throw new IllegalStateException(
            "Can't launch runner for current project. Current project is absent...");
      }

      selectedEnvironment = null;

      panelState.setState(RUNNERS);
      view.showOtherButtons();

      history.addRunner(runner);

      runnerInQueueTimer.schedule(ONE_SEC.getValue());

      CheckRamAndRunAction checkRamAndRunAction = actionFactory.createCheckRamAndRun();
      checkRamAndRunAction.perform(runner);

      runnerActions.put(runner, checkRamAndRunAction);

      runner.resetCreationTime();
      runnerTimer.schedule(ONE_SEC.getValue());
    } else {
      runActionDenyAccessDialog.show();
    }
    return runner;
  }
コード例 #3
0
ファイル: createChat.java プロジェクト: nievesbq/webAppClient
  public void run(final RootPanel rp, final String nick) {

    if (Cookies.getCookie(nick) == null) Cookies.setCookie(nick, "" + 0);

    cl.setPageSize(500);

    final Button sendMessage =
        new Button(
            "sendMessage",
            new ClickHandler() {

              public void onClick(ClickEvent event) {

                if (!message.getText().equals("")) {
                  new Post().postJson(SERVERURL, nick.toString(), message.getText());
                  message.setText("");
                }
              }
            });

    rp.get("mainDiv2").setVisible(true);
    message.getElement().setAttribute("placeholder", "Introduce your message");
    message.getElement().setAttribute("id", "message");

    cl.getElement().setAttribute("id", "chatBox");

    sendMessage.getElement().setAttribute("id", "sendMessage");
    sendMessage.setText("Send");

    vp.getElement().setAttribute("id", "verticalPanel");
    hp.getElement().setAttribute("id", "horizontalPanel");

    panel.getElement().setAttribute("id", "scroller");

    hp.add(message);
    hp.add(sendMessage);
    panel.add(cl);
    vp.add(panel);

    vp.add(hp);
    rp.get("mainDiv2").add(vp);

    Timer t =
        new Timer() {
          @Override
          public void run() {
            getMessages();

            if (chatList != null && Integer.parseInt(Cookies.getCookie(nick)) < chatList.size()) {
              cl.setRowCount(chatList.size() + 1, true);
              cl.setRowData(
                  Integer.parseInt(Cookies.getCookie(nick)),
                  chatList.subList(Integer.parseInt(Cookies.getCookie(nick)), chatList.size()));
              panel.setVerticalScrollPosition(panel.getMaximumVerticalScrollPosition() - 1);
              Cookies.setCookie(nick, "" + chatList.size());
            }
          }
        };
    t.scheduleRepeating(1000);
  }
コード例 #4
0
  @Override
  public void initializePhoneGap(final int timeoutInMs) {

    final long end = System.currentTimeMillis() + timeoutInMs;
    if (isPhoneGapInitialized()) {

      firePhoneGapAvailable();

    } else {
      Timer timer =
          new Timer() {

            @Override
            public void run() {
              if (isPhoneGapInitialized()) {
                firePhoneGapAvailable();
                return;
              }

              if (System.currentTimeMillis() - end > 0) {
                handlerManager.fireEvent(new PhoneGapTimeoutEvent());
              } else {
                schedule(INIT_TICK);
              }
            }
          };

      timer.schedule(INIT_TICK);
    }
  }
コード例 #5
0
  void show(int delayMilliseconds) {

    ///// transtimer

    Timer t1 =
        new Timer() {
          @Override
          public void run() {
            panel.addStyleName("notificationShowed");
            // Notification.this.setVisible(false);
            // Notification.this.removeFromParent();

          }
        };

    // Schedule the timer to close the popup in 3 seconds.
    t1.schedule(119);

    ////////////////

    Timer t =
        new Timer() {
          @Override
          public void run() {

            Notification.this.setVisible(false);
            Notification.this.removeFromParent();
          }
        };

    // Schedule the timer to close the popup in 3 seconds.
    t.schedule(delayMilliseconds);
  }
コード例 #6
0
  public void onMessage(final Message message) {
    if (!message.isTransient()) {

      // update the visible message count
      reflectMessageCount();

      if (message.isSticky()) // sticky messages override each other like this
      {
        lastSticky = message;
        displayNotification(message);
      } else if (null == lastSticky
          || Message.Severity.Error == message.getSeverity()
          || Message.Severity.Fatal
              == message.getSeverity()) // regular message don't replace sticky ones
      {
        clearSticky();

        displayNotification(message);

        Timer hideTimer =
            new Timer() {
              @Override
              public void run() {
                // hide message
                messageDisplay.clear();
                if (displayPopup != null) displayPopup.hide();
              }
            };

        hideTimer.schedule(5000);
      }
    }
  }
コード例 #7
0
 protected void testUntil(final long duration, final Runnable runnable) {
   delayTestFinish((int) (2 * duration));
   final long startTime = System.currentTimeMillis();
   final int interval = 500;
   timer =
       new Timer() {
         @Override
         public void run() {
           final long buffer = 4 * interval;
           if (System.currentTimeMillis() + buffer < startTime + duration) {
             boolean passed = true;
             try {
               runnable.run();
             } catch (AssertionFailedError e) {
               passed = false;
             } finally {
               if (passed) {
                 cancel();
                 finishTest();
               }
             }
           } else {
             cancel();
             runnable.run();
             finishTest();
           }
         }
       };
   timer.scheduleRepeating(interval);
   timer.run();
 }
コード例 #8
0
ファイル: GeoStory.java プロジェクト: GeoStoryTeam/GeoStory
  public void geodecode(
      final Geocoder geo, final Triple<String, Interval, String> event, final int delay) {
    Timer t =
        new Timer() {
          public void run() {
            if (!event.get1().equals("")) {
              geo.getLatLng(
                  event.get1(),
                  new LatLngCallback() {
                    @Override
                    public void onFailure() {
                      System.out.println("Failed geocoder for   " + "---" + event + " ");
                      geodecode(geo, event, delay + 1000);
                    }

                    @Override
                    public void onSuccess(LatLng point) {
                      GeoStoryItem gsi =
                          new GeoStoryItem(event.get2(), event.get1(), point, event.get3());
                      Window.alert("Item is " + gsi);
                      types.itemAdded.shareEvent(gsi);
                      types.centerEvent.shareEvent(null);
                    }
                  });
            }
          }
        };
    t.schedule(delay);
  }
コード例 #9
0
ファイル: SearchSummaryPanel.java プロジェクト: ltly/firefly
  private void layout(final SearchSummaryItem ssi, final int depth) {

    final int row = table.getRowCount();
    final Image loading = new Image(GwtUtil.LOADING_ICON_URL);
    ssi.checkUpdate();

    table.setWidget(row, iconColIdx, loading);

    if (ssi.isLoaded()) {
      ssi.renderItem(table, row, curGroupByName);
      GwtUtil.setStyles(loading, "visibility", "hidden");
    } else {
      ssi.checkUpdate();
      table.setWidget(row, iconColIdx, loading);
      Timer timer =
          new Timer() {
            public void run() {
              ssi.checkUpdate();
              ssi.renderItem(table, row, curGroupByName);
              if (ssi.isLoaded()) {
                cancel();
                GwtUtil.setStyles(loading, "visibility", "hidden");
              }
            }
          };
      bgList.add(timer);
      timer.scheduleRepeating(1000);
    }

    if (ssi.getChildren() != null && ssi.getChildren().size() > 0) {
      for (SearchSummaryItem child : ssi.getChildren()) {
        layout(child, depth + 1);
      }
    }
  }
コード例 #10
0
ファイル: MainPanel.java プロジェクト: vega113/ReadOnlyGadget
  @Inject
  public MainPanel(
      final MessagesImpl messages,
      final ConstantsImpl constants,
      final GlobalResources resources,
      final NewPostGadgetService service,
      final VegaUtils utils) {
    initWidget(uiBinder.createAndBindUi(this));
    resources.globalCSS().ensureInjected();
    this.service = service;
    this.messages = messages;
    this.constants = constants;
    this.resources = resources;
    this.utils = utils;
    //		dsAboutPnl.setHeader()
    try {
      setForumInfoIntoGadget(messages, utils);
    } catch (Exception e) {
      Log.debug(e.getMessage());
    }
    Timer timer =
        new Timer() {

          @Override
          public void run() {
            try {
              setForumInfoIntoGadget(messages, utils);
            } catch (Exception e) {
              Log.debug(e.getMessage());
            }
          }
        };
    timer.schedule(1000);
    utils.reportPageview("/newpost/");
  }
コード例 #11
0
ファイル: ViewFilePanel.java プロジェクト: kiwiroy/rstudio
  public void showFile(FileSystemItem file, String commitId, String contents) {
    commitId_ = commitId;
    targetFile_ = file;

    docDisplay_.setCode(contents, false);

    adaptToFileType(fileTypeRegistry_.getTextTypeForFile(file));

    // header widget has icon + label
    HorizontalPanel panel = new HorizontalPanel();

    Image imgFile = new Image(fileTypeRegistry_.getIconForFile(file));
    imgFile.addStyleName(RES.styles().captionIcon());
    panel.add(imgFile);

    Label lblCaption = new Label(file.getPath() + " @ " + commitId);
    lblCaption.addStyleName(RES.styles().captionLabel());
    panel.add(lblCaption);

    popupPanel_ = new FullscreenPopupPanel(panel, asWidget(), false);
    popupPanel_.center();

    // set focus to the doc display after 100ms
    Timer timer =
        new Timer() {
          public void run() {
            docDisplay_.focus();
          }
        };
    timer.schedule(100);
  }
コード例 #12
0
  public StockPresenter(final StockView view) {

    this.view = view;

    stocks = new ListVariable<StockSymbol>();

    // set up event listeners for adding a new stock
    StreamMerge.<Object>mergeStreams(
            view.addButtonClick(), view.newSymbolTextEntry().keyDown().filter(new IsEnterKeyCode()))
        .loop(
            new Effect<Object>() {
              @Override
              public void e(Object o) {
                addStock();
              }
            });

    // set up timer to refresh list automatically
    final Timer refreshTimer =
        new Timer() {
          public void run() {
            refreshWatchList();
          }
        };
    refreshTimer.scheduleRepeating(REFRESH_INTERVAL);

    // move cursor focus to the text box
    view.newSymbolTextEntry().focus().put(true);
  }
コード例 #13
0
  @Override
  public void getElements(final AsyncCallback<List<SignalingElement>> callback) {
    final List<SignalingElement> result = new ArrayList<SignalingElement>(3);
    SignalingElement element = new SignalingElement();
    element.setEnabled(true);
    element.setAlarm(false);
    element.setId(1);
    element.setTitle("Window sensor 1");
    element.setLabelAddress(238925926L);
    element.setKeyAddress(3457383838L);
    result.add(element);

    element = new SignalingElement();
    element.setEnabled(true);
    element.setAlarm(false);
    element.setId(2);
    element.setTitle("Window sensor 2");
    element.setLabelAddress(2381325926L);
    element.setKeyAddress(34573483838L);
    result.add(element);

    final Timer timer =
        new Timer() {
          @Override
          public void run() {
            callback.onSuccess(result);
            //                callback.onFailure(new Throwable());
          }
        };
    timer.schedule(1000);
  }
コード例 #14
0
ファイル: LockManagerImpl.java プロジェクト: jomarko/uberfire
  private void handleLockFailure(final LockInfo lockInfo) {

    if (lockInfo != null) {
      updateLockInfo(lockInfo);
      lockNotification.fire(
          new NotificationEvent(
              WorkbenchConstants.INSTANCE.lockedMessage(lockInfo.lockedBy()),
              NotificationEvent.NotificationType.INFO,
              true,
              lockTarget.getPlace(),
              20));
    } else {
      lockNotification.fire(
          new NotificationEvent(
              WorkbenchConstants.INSTANCE.lockError(),
              NotificationEvent.NotificationType.ERROR,
              true,
              lockTarget.getPlace(),
              20));
    }
    // Delay reloading slightly in case we're dealing with a flood of events
    if (reloadTimer == null) {
      reloadTimer =
          new Timer() {

            public void run() {
              reload();
            }
          };
    }

    if (!reloadTimer.isRunning()) {
      reloadTimer.schedule(250);
    }
  }
コード例 #15
0
  /** Tests submitting an alternate frame. TODO: Investigate intermittent failures with HtmlUnit. */
  @DoNotRunWith(Platform.HtmlUnitUnknown)
  public void testSubmitFrame() {
    System.out.println("testSubmitFrame");
    final NamedFrame frame = new NamedFrame("myFrame");
    FormPanel form = new FormPanel(frame);
    form.setMethod(FormPanel.METHOD_POST);
    form.setAction(GWT.getModuleBaseURL() + "formHandler?sendHappyHtml");
    RootPanel.get().add(form);
    RootPanel.get().add(frame);

    delayTestFinish(TEST_DELAY);
    form.submit();
    Timer t =
        new Timer() {
          @Override
          public void run() {
            // Make sure the frame got the contents we expected.
            assertTrue(isHappyDivPresent(frame.getElement()));
            finishTest();
          }
        };

    // Wait 5 seconds before checking the results.
    t.schedule(TEST_DELAY - 2000);
  }
コード例 #16
0
  /**
   * Check GeoPlatformGridWidget Status
   *
   * @param widget
   * @param title
   * @param message
   */
  public static void checkGridWidgetStatus(
      final IGeoPlatformGrid<GeoPlatformBeanModel> widget,
      final String title,
      final String message) {

    Timer timer =
        new Timer() {

          @Override
          public void run() {
            if (widget.getGrid().getView().getBody().isMasked()) {
              MessageBox.confirm(
                  title,
                  message,
                  new Listener<MessageBoxEvent>() {

                    @Override
                    public void handleEvent(MessageBoxEvent be) {
                      if (Dialog.YES.equals(be.getButtonClicked().getItemId())) {
                        widget.getGrid().getView().getBody().unmask();
                        widget.getGrid().getView().refresh(false);
                      } else {
                        schedule(15000);
                      }
                    }
                  });
            }
          }
        };
    timer.schedule(15000);
  }
コード例 #17
0
  @Override
  protected void onReveal() {

    Map<AlertType, String> alMap = getView().checkPermission();

    if (!alMap.isEmpty()) {
      for (Entry<AlertType, String> entry : alMap.entrySet()) {
        fireEvent(new ShowAlertEvent(entry.getKey(), entry.getValue(), false));

        getView().hideAlert(3000);
      }
    }

    Timer timer =
        new Timer() {

          @Override
          public void run() {
            boolean mineOnly = getView().getChkMineOnly().getValue();

            if (mineOnly) {
              fireEvent(
                  new ShowAlertEvent(AlertType.INFO, "You are viewing filterd content", false));
              getView().hideAlert(3000);
            }
          }
        };

    timer.schedule(3500);

    super.onReveal();
  }
コード例 #18
0
  /** Test load simple association */
  protected void testLoadMessage(final Integer id) {
    // Setup an asynchronous event handler.
    Timer timer =
        new Timer() {
          public void run() {
            // Call remote loading service
            LoadingServiceAsync<Message> remoteService =
                (LoadingServiceAsync<Message>) GWT.create(LoadingService.class);
            remoteService.loadEntity(
                Message.class.getName(),
                new IntegerParameter(id),
                new AsyncCallback<Message>() {
                  public void onFailure(Throwable caught) {
                    fail(caught.toString());

                    // tell the test system the test is now done
                    finishTest();
                  }

                  public void onSuccess(Message result) {
                    assertNotNull(result);
                    assertEquals(id, Integer.valueOf(result.getId()));

                    // tell the test system the test is now done
                    finishTest();
                  }
                });
          }
        };

    // Schedule the event and return control to the test system.
    timer.schedule(100);
  }
コード例 #19
0
  /** Test loading of a list association */
  public void testLoadSetAssociation() {
    //	1. Load test user
    //
    // Setup an asynchronous event handler.
    Timer timer =
        new Timer() {
          public void run() {
            // Call remote init service
            StatelessInitServiceAsync remoteService =
                (StatelessInitServiceAsync) GWT.create(StatelessInitService.class);
            remoteService.loadTestUser(
                new AsyncCallback<User>() {
                  public void onFailure(Throwable caught) {
                    fail(caught.toString());
                    finishTest();
                  }

                  public void onSuccess(User result) {
                    testLoadSetAssociation(result);
                  }
                });
          }
        };

    // Set a delay period significantly longer than the
    // event is expected to take.
    delayTestFinish(60000);

    // Schedule the event and return control to the test system.
    timer.schedule(100);
  }
コード例 #20
0
  /** Test load simple association */
  protected void testLoadSimpleAssociation(final Message message) {
    // Setup an asynchronous event handler.
    Timer timer =
        new Timer() {
          public void run() {
            // Call remote loading service
            LoadingServiceAsync<Message> remoteService =
                (LoadingServiceAsync<Message>) GWT.create(LoadingService.class);
            remoteService.loadEntityAssociation(
                message,
                "author",
                new AsyncCallback<User>() {
                  public void onFailure(Throwable caught) {
                    fail(caught.toString());

                    // tell the test system the test is now done
                    finishTest();
                  }

                  public void onSuccess(User result) {
                    assertNotNull(result);

                    // tell the test system the test is now done
                    finishTest();
                  }
                });
          }
        };

    // Schedule the event and return control to the test system.
    timer.schedule(100);
  }
コード例 #21
0
  /** Test load list association */
  protected void testLoadSetAssociation(final User user) {
    // Setup an asynchronous event handler.
    Timer timer =
        new Timer() {
          public void run() {
            // Call remote loading service
            LoadingServiceAsync<User> remoteService =
                (LoadingServiceAsync<User>) GWT.create(LoadingService.class);
            remoteService.loadSetAssociation(
                user,
                "messageList",
                new AsyncCallback<Set<Message>>() {
                  public void onFailure(Throwable caught) {
                    fail(caught.toString());

                    // tell the test system the test is now done
                    finishTest();
                  }

                  public void onSuccess(Set<Message> result) {
                    assertNotNull(result);
                    assertFalse(result.isEmpty());

                    // tell the test system the test is now done
                    finishTest();
                  }
                });
          }
        };

    // Schedule the event and return control to the test system.
    timer.schedule(100);
  }
コード例 #22
0
ファイル: ModalDialogBase.java プロジェクト: vwendy/rstudio
  public void showModal() {
    if (mainWidget_ == null) {
      mainWidget_ = createMainWidget();

      // get the main widget to line up with the right edge of the buttons.
      mainWidget_.getElement().getStyle().setMarginRight(3, Unit.PX);

      mainPanel_.insert(mainWidget_, 0);
    }

    originallyActiveElement_ = DomUtils.getActiveElement();
    if (originallyActiveElement_ != null) originallyActiveElement_.blur();

    // position the dialog
    positionAndShowDialog();

    // defer shown notification to allow all elements to render
    // before attempting to interact w/ them programatically (e.g. setFocus)
    Timer timer =
        new Timer() {
          public void run() {
            onDialogShown();
          }
        };
    timer.schedule(100);
  }
コード例 #23
0
  public TeachersUI() {
    setScrollMode(Scroll.AUTO);
    setId("centerPanelBackground");
    addStyleName("uiContainer");
    setHeaderVisible(false);

    image = Resources.ICONS.image();
    add(image.createImage());

    String text = "<br><center><font color='orange' size='5px'>Teachers</font></center>";
    text += "<h2>Teachers directions here </h2> ";
    label = new Label();
    label.setText(text);
    add(label);

    videoPanel = new ContentPanel();
    videoPanel.setId("jwplayer");
    videoPanel.setHeaderVisible(false);
    videoPanel.setBodyBorder(false);
    add(videoPanel);

    Timer timer =
        new Timer() {

          @Override
          public void run() {
            loadVideoPlayer();
          }
        };

    timer.schedule(50);
  }
コード例 #24
0
ファイル: RefresherConnector.java プロジェクト: horun/vaadin
 @Override
 public void onStateChanged(StateChangeEvent event) {
   super.onStateChanged(event);
   timer.cancel();
   if (isEnabled()) {
     timer.scheduleRepeating(getState().interval);
   }
 }
コード例 #25
0
  private void reconcilerDocumentChanged() {
    for (String key : strategies.keySet()) {
      ReconcilingStrategy reconcilingStrategy = strategies.get(key);
      reconcilingStrategy.setDocument(documentHandle.getDocument());
    }

    autoSaveTimer.cancel();
    autoSaveTimer.schedule(DELAY);
  }
コード例 #26
0
 private void deferTextChangeEvent() {
   if (textChangeEventMode.equals(TEXTCHANGE_MODE_TIMEOUT) && scheduled) {
     return;
   } else {
     textChangeEventTrigger.cancel();
   }
   textChangeEventTrigger.schedule(getTextChangeEventTimeout());
   scheduled = true;
 }
コード例 #27
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();
   }
 }
コード例 #28
0
 @Override
 public void onDocumentChange(final DocumentChangeEvent event) {
   if (documentHandle == null || !documentHandle.isSameAs(event.getDocument())) {
     return;
   }
   createDirtyRegion(event);
   autoSaveTimer.cancel();
   autoSaveTimer.schedule(DELAY);
 }
コード例 #29
0
ファイル: StockWatcher.java プロジェクト: rumland/learnGWT
 private void setupTimerToRefreshListAutomatically() {
   Timer refreshTimer =
       new Timer() {
         public void run() {
           refreshWatchList();
         }
       };
   refreshTimer.scheduleRepeating(REFRESH_INTERVAL);
 }
コード例 #30
0
  private void drawUnifyingChartsAndTables(
      final String[] intervals,
      final HashMap<String, Integer[]> userValues,
      final boolean showCharts) {

    final String[] allNames = new String[userValues.size()];
    final Integer[] allValues = new Integer[userValues.size()];

    int index = 0;
    for (String user : userValues.keySet()) {

      allNames[index] = user;

      int sumCount = 0;
      for (int value : userValues.get(user)) {
        sumCount += value;
      }
      allValues[index++] = sumCount;
    }

    if (showCharts) {
      setHeight(userValues.size() * 30 + 280);
    } else {
      setHeight(userValues.size() * 25 + 30);
      redraw();
    }

    Timer timer =
        new Timer() {

          @Override
          public void run() {
            if (showCharts) {
              ChartUtils.drawPieChart(
                  JSOHelper.convertToJavaScriptArray(allNames),
                  JSOHelper.convertToJavaScriptArray(allValues),
                  allNames.length,
                  PIE_CHART_NESTED_DIV_ID + userId,
                  (int) (UserStatisticsLayout.this.getWidth() * PIE_SIZE_CONVERSION));

              ChartUtils.drawBarChart(
                  JSOHelper.convertToJavaScriptArray(allNames),
                  JSOHelper.convertToJavaScriptArray(allValues),
                  allNames.length,
                  LINE_CHART_NESTED_DIV_ID + userId,
                  (int) (UserStatisticsLayout.this.getWidth() * LINE_BAR_SIZE_CONVERSION));
            }
            if (table == null) {
              table = new TableListGrid(intervals, userValues);
              addMember(table);
            }
          }
        };
    timer.schedule(100);
  }