Java 类com.google.gwt.core.client.Scheduler.RepeatingCommand 实例源码

项目:Wiab.pro    文件:UndercurrentHarness.java   
/**
 * Populates the info box. Continuously reports which element has browser
 * focus, and reports timing information for the stage loading.
 *
 * @param timeline timeline to report
 */
private static void showInfo(Timeline timeline) {
  Element timeBox = Document.get().getElementById("timeline");
  timeline.dump(timeBox);

  Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
    private final Element activeBox = Document.get().getElementById("active");

    @Override
    public boolean execute() {
      Element e = getActiveElement();
      String text = (e != null ? e.getTagName() + " id:" + e.getId() : "none");
      activeBox.setInnerText(text);
      return true;
    }

    private native Element getActiveElement() /*-{
      return $doc.activeElement;
    }-*/;
  }, 1000);
}
项目:gerrit    文件:DiffScreen.java   
void setupSyntaxHighlighting() {
  if (prefs.syntaxHighlighting() && fileSize.compareTo(FileSize.SMALL) > 0) {
    Scheduler.get()
        .scheduleFixedDelay(
            new RepeatingCommand() {
              @Override
              public boolean execute() {
                if (prefs.syntaxHighlighting() && isAttached()) {
                  setSyntaxHighlighting(prefs.syntaxHighlighting());
                }
                return false;
              }
            },
            250);
  }
}
项目:putnami-web-toolkit    文件:TabPanel.java   
public void setActivePane(final TabPanelContent source) {
    for (TabPanelContent tabPane : this.tabPaneList) {
        if (!tabPane.equals(source)) {
            tabPane.setActive(false);
        }
    }
    source.getTabLink().setActive(true);
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            source.setActive(true);
            return false;
        }
    }, 150);
}
项目:putnami-web-toolkit    文件:TabPanelContent.java   
public void setActive(final boolean active) {
    this.active = active;
    if (this.tabLink != null) {
        this.tabLink.setActive(active);
    }
    StyleUtils.toggleStyle(this, TabPanelContent.STYLE_IN, active);
    if (active) {
        StyleUtils.addStyle(this, TabPanelContent.STYLE_ACTIVE);
    } else {
        Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

            @Override
            public boolean execute() {
                StyleUtils.removeStyle(TabPanelContent.this, TabPanelContent.STYLE_ACTIVE);
                return false;
            }
        }, 150);
    }
}
项目:putnami-web-toolkit    文件:Modal.java   
public void show() {
    this.ensureDismissButton();
    this.redraw();
    this.visible = true;

    Widget modal = getContainerWidget();

    if (modal.isAttached()) {
        modal.removeFromParent();
    }

    Modal.MODAL_BACKDROP.show();
    this.getElement().getStyle().setDisplay(Display.BLOCK);
    RootPanel rootPanel = RootPanel.get();
    rootPanel.add(modal);
    StyleUtils.addStyle(rootPanel, Modal.STYLE_MODAL_OPEN);

    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        @Override
        public boolean execute() {
            StyleUtils.addStyle(Modal.this, Modal.STYLE_VISIBLE);
            return false;
        }
    }, 150);
}
项目:putnami-web-toolkit    文件:Modal.java   
public void hide() {
    final RootPanel rootPanel = RootPanel.get();

    this.visible = false;
    StyleUtils.removeStyle(Modal.this, Modal.STYLE_VISIBLE);
    StyleUtils.removeStyle(rootPanel, Modal.STYLE_MODAL_OPEN);

    Modal.MODAL_BACKDROP.hide();

    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        @Override
        public boolean execute() {
            Modal.this.getElement().getStyle().clearDisplay();
            rootPanel.remove(getContainerWidget());
            return false;
        }
    }, 150);
}
项目:incubator-wave    文件:UndercurrentHarness.java   
/**
 * Populates the info box. Continuously reports which element has browser
 * focus, and reports timing information for the stage loading.
 *
 * @param timeline timeline to report
 */
private static void showInfo(Timeline timeline) {
  Element timeBox = Document.get().getElementById("timeline");
  timeline.dump(timeBox);

  Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
    private final Element activeBox = Document.get().getElementById("active");

    @Override
    public boolean execute() {
      Element e = getActiveElement();
      String text = (e != null ? e.getTagName() + " id:" + e.getId() : "none");
      activeBox.setInnerText(text);
      return true;
    }

    private native Element getActiveElement() /*-{
      return $doc.activeElement;
    }-*/;
  }, 1000);
}
项目:gwt-jackson    文件:Launcher.java   
public void launch() {
    if ( operations.isEmpty() ) {
        return;
    }

    final Operation operation = operations.remove( 0 );
    Scheduler.get().scheduleIncremental( new RepeatingCommand() {
        @Override
        public boolean execute() {
            boolean res = operation.execute();
            if ( !res ) {
                Scheduler.get().scheduleDeferred( new ScheduledCommand() {
                    @Override
                    public void execute() {
                        launch();
                    }
                } );
            }
            return res;
        }
    } );
}
项目:arondor-common-reflection    文件:AbstractTreeNodeView.java   
/**
 * Overriden setVisible to setup widget layout
 */
@Override
public void setVisible(boolean visible)
{
    Scheduler.get().scheduleFixedPeriod(new RepeatingCommand()
    {
        public boolean execute()
        {
            int nodeLabelWidth = nodeLabel.getElement().getClientWidth();
            int diff = NODE_LABEL_MARGIN_WIDTH - nodeLabelWidth;
            diff = Math.max(diff, NODE_LABEL_MINIMUM_MARGIN_WIDTH);
            nodeLabel.getElement().getStyle().setMarginRight(diff, Unit.PX);
            return false;
        }
    }, 50);
}
项目:arondor-common-reflection    文件:DefaultImplementingClassPresenter.java   
private void updateDisplay()
{
    if (updateDisplayScheduled)
    {
        return;
    }
    updateDisplayScheduled = true;

    if (GWT.isClient())
    {
        Scheduler.get().scheduleFixedDelay(new RepeatingCommand()
        {

            public boolean execute()
            {
                doUpdateDisplay();
                return false;
            }
        }, 2000);
    }
    else
    {
        doUpdateDisplay();
    }
}
项目:ifictionary    文件:QueuedImageDataGraphicsHandler.java   
public void executeQueuedCommands() {
    if (!backgroundTaskInProgress) {
        Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

            @Override
            public boolean execute() {
                if (hasNext()) {
                    GraphicsCommand cmd = peek();
                    boolean invokeAgain = cmd.execute();
                    if (!invokeAgain) {
                        removeFirst();
                    }
                }
                backgroundTaskInProgress = hasNext();
                return backgroundTaskInProgress;
            }
        }, 10);
    }
}
项目:realtime-channel    文件:HtmlScheduler.java   
@Override
public int scheduleDelay(int delayMs, final Handler<Void> handler) {
  final String key = "" + (++timerId);
  RepeatingCommand cmd = new RepeatingCommand() {
    @Override
    public boolean execute() {
      if (timers.has(key)) {
        timers.remove(key);
        handler.handle(null);
      }
      return false;
    }
  };
  timers.set(key, cmd);
  com.google.gwt.core.client.Scheduler.get().scheduleFixedDelay(cmd, delayMs);
  return timerId;
}
项目:realtime-channel    文件:HtmlScheduler.java   
@Override
public int schedulePeriodic(int delayMs, final Handler<Void> handler) {
  final String key = "" + (++timerId);
  RepeatingCommand cmd = new RepeatingCommand() {
    @Override
    public boolean execute() {
      if (timers.has(key)) {
        handler.handle(null);
        return true;
      }
      return false;
    }
  };
  timers.set(key, cmd);
  com.google.gwt.core.client.Scheduler.get().scheduleFixedPeriod(cmd, delayMs);
  return timerId;
}
项目:rxgwt-tips    文件:Tips.java   
private void schedulers() {
    // GWT Schedulers, various callbacks, not easy to combine or specify timing operations like a timeout!
    gwtScheduler().scheduleDeferred((ScheduledCommand) () -> L.log("one time command done!"));
    gwtScheduler().scheduleIncremental((RepeatingCommand) () -> {L.log("repeating command done!"); return false;});
    // to use RX first just wrap the task in a RX type, for example a log call into a Completable
    Completable rxTask = Completable.fromAction(() -> L.log("one time command done!")); // by default synchronous
    // with RX you can specify in which scheduler do you want to execute the task
    rxTask.subscribeOn(GwtSchedulers.deferredScheduler()); // async using a deferred scheduler
    rxTask.subscribeOn(GwtSchedulers.incrementalScheduler()); // async using a incremental scheduler
    rxTask.subscribeOn(Schedulers.io()); // GWT agnostic, but yep, this is mapped to deferred
    rxTask.subscribeOn(Schedulers.computation()); // and this one to is mapped to incremental
    // remember that this is a chained description, so you should save the instance, like this
    rxTask.subscribeOn(Schedulers.io()).subscribe(() -> L.log("task executed async!"));

    // for repeating tasks like a timer
    new Timer() { public void run() { L.log("whOOt? inheritance instead of composition?!");} }.schedule(100);
    // you should generate stream of ticks, called 'interval' (timer exists, but just emmit 1 tick)
    interval(100, MILLISECONDS).flatMapCompletable(n -> rxTask);

    // and a final example, if the web is online (and stop if not) do a task each 5min
    online().switchMap(online -> online ? interval(5, MINUTES) : Observable.never())
            // fetching a big list of data, so big that need to be reduced incrementally to no block the
            // main loop, as our API is RX friendly, just observe each result item in the computation scheduler
            .flatMapSingle(refresh -> requestData().observeOn(computation())
                    // and reduce each item here, until the whole response is processed
                    .<Set<String>>reduceWith(HashSet::new, (acc,n) -> { acc.add(n); return acc; }))
            // at this point the response has been processed incrementally!
            .doOnNext(result -> GWT.log("save the processed result: " + result))
            // if something goes wrong, wait 1 minute and try again, the try will reconnect the whole observable
            // so if the web is offline, it will not try to process again until it get online!
            .retryWhen(at -> at.flatMapSingle(ex -> { GWT.log("updater error", ex); return timer(1, MINUTES); }))
            .subscribe(); // eventually we'll see that subscribe responsibility can be delegated! (safer!)
}
项目:jaxmpp-android    文件:Jaxmpp.java   
@Override
protected void init() {
    // if (PresenceModule.getPresenceStore(sessionObject) == null)
    // PresenceModule.setPresenceStore(sessionObject, new
    // GWTPresenceStore());

    // if (RosterModule.getRosterStore(sessionObject) == null)
    // RosterModule.setRosterStore(sessionObject, new RosterStore());

    if (ResponseManager.getResponseManager(sessionObject) == null)
        ResponseManager.setResponseManager(sessionObject, new ResponseManager());

    super.init();

    connectionManager.setContext(context);

    this.timeoutChecker = new RepeatingCommand() {

        @Override
        public boolean execute() {
            try {
                checkTimeouts();
            } catch (Exception e) {
            }
            return true;
        }
    };
    Scheduler.get().scheduleFixedDelay(timeoutChecker, 1000 * 31);

    this.connector = this.connectorWrapper;

    this.processor = new Processor(this.modulesManager, context);

    sessionObject.setProperty(DiscoveryModule.IDENTITY_TYPE_KEY, "web");

    modulesInit();
}
项目:platypus-js    文件:JsUi.java   
public static void selectFile(final Callback<JavaScriptObject, String> aCallback, String aFileTypes) {
    final FileUpload fu = new FileUpload();
    fu.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    fu.setWidth("10px");
    fu.setHeight("10px");
    fu.getElement().getStyle().setLeft(-100, Style.Unit.PX);
    fu.getElement().getStyle().setTop(-100, Style.Unit.PX);
    fu.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            Utils.JsObject jsFu = fu.getElement().cast();
            JavaScriptObject oFiles = jsFu.getJs("files");
            if (oFiles != null) {
                JsArray<JavaScriptObject> jsFiles = oFiles.cast();
                for (int i = 0; i < jsFiles.length(); i++) {
                    try {
                        aCallback.onSuccess(jsFiles.get(i));
                    } catch (Exception ex) {
                        Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
            fu.removeFromParent();
        }
    });
    RootPanel.get().add(fu, -100, -100);
    fu.click();
    Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
        @Override
        public boolean execute() {
            fu.removeFromParent();
            return false;
        }
    }, 1000 * 60 * 1);// 1 min
}
项目:platypus-js    文件:JsUi.java   
public static void selectColor(String aOldValue, final Callback<String, String> aCallback) {
    final TextBox tb = new TextBox();
    tb.getElement().setAttribute("type", "color");
    tb.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    tb.setWidth("10px");
    tb.setHeight("10px");
    tb.setValue(aOldValue);
    tb.getElement().getStyle().setLeft(-100, Style.Unit.PX);
    tb.getElement().getStyle().setTop(-100, Style.Unit.PX);

    tb.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            try {
                aCallback.onSuccess(tb.getValue());
            } finally {
                tb.removeFromParent();
            }
        }

    });
    RootPanel.get().add(tb, -100, -100);
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            tb.setFocus(true);
            tb.getElement().<XElement>cast().click();
            Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
                @Override
                public boolean execute() {
                    tb.removeFromParent();
                    return false;
                }
            }, 1000 * 60 * 1);// 1 min
        }
    });
}
项目:platypus-js    文件:Utils.java   
public static void invokeScheduled(int aTimeout, final JavaScriptObject aTarget) {
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            invokeJsFunction(aTarget);
            return false;
        }
    }, aTimeout);
}
项目:putnami-web-toolkit    文件:InputDatePicker.java   
public void hide() {
    StyleUtils.removeStyle(this.getElement(), InputDatePicker.STYLE_SHOW);
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            InputDatePicker.this.setVisible(false);
            RootPanel.get().remove(InputDatePicker.this);
            return false;
        }
    }, 200);
}
项目:putnami-web-toolkit    文件:AbstractHover.java   
public void changeVisibility(Visibility visibilityChange) {
    Visibility order = visibilityChange;
    if (order == Visibility.TOGGLE) {
        order = this.visibilityChange == Visibility.HIDE ? Visibility.SHOW : Visibility.HIDE;
    }
    final Element toDisplayElement = this.getHoverWidget().getElement();
    final Element target = this.getWidget().getElement();
    final Element parent = target.getParentElement();
    if (parent == null) {
        return;
    }
    switch (order) {
        case SHOW:
            parent.insertAfter(toDisplayElement, target);
            toDisplayElement.getStyle().setDisplay(Display.BLOCK);
            this.resetPosition(toDisplayElement, this.getWidget(), this.placement);
            StyleUtils.addStyle(this.getHoverWidget(), this.placement);
            StyleUtils.addStyle(toDisplayElement, Visibility.SHOW);
            break;
        case HIDE:
            StyleUtils.removeStyle(toDisplayElement, Visibility.SHOW);
            Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

                @Override
                public boolean execute() {
                    toDisplayElement.getStyle().clearDisplay();
                    toDisplayElement.removeFromParent();
                    return false;
                }
            }, 200);
            break;
        default:
            break;
    }
    this.visibilityChange = order;
}
项目:putnami-web-toolkit    文件:AbstractHover.java   
private void schedule(int delay, final Visibility visibility) {
    if (delay > 0) {
        Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

            @Override
            public boolean execute() {
                AbstractHover.this.changeVisibility(visibility);
                return false;
            }
        }, delay);
    } else {
        this.changeVisibility(visibility);
    }
}
项目:putnami-web-toolkit    文件:CollapseHelper.java   
public void doCollapse(final boolean collapse) {
    if (collapse != this.collapsed) {
        EventBus.get().fireEventFromSource(new CollapseEvent(CollapseHelper.this, collapse), CollapseHelper.this);

        this.collapsableElement.getStyle().setHeight(this.collapsableElement.getOffsetHeight(), Unit.PX);

        StyleUtils.removeStyle(this.collapsableElement, CollapseHelper.STYLE_COLLAPSE);
        StyleUtils.removeStyle(this.collapsableElement, CollapseHelper.STYLE_VISIBLE);
        StyleUtils.addStyle(this.collapsableElement, CollapseHelper.STYLE_COLLAPSING);

        final int endHeight = collapse ? 0 : this.collapsableElement.getScrollHeight();

        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                CollapseHelper.this.collapsableElement.getStyle().setHeight(endHeight, Unit.PX);
            }
        });

        Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

            @Override
            public boolean execute() {
                CollapseHelper.this.collapsableElement.getStyle().clearHeight();
                StyleUtils.removeStyle(CollapseHelper.this.collapsableElement, CollapseHelper.STYLE_COLLAPSING);
                StyleUtils.addStyle(CollapseHelper.this.collapsableElement, CollapseHelper.STYLE_COLLAPSE);
                StyleUtils.toggleStyle(CollapseHelper.this.collapsableElement, CollapseHelper.STYLE_VISIBLE, !collapse);
                return false;
            }
        }, 350);
        this.collapsed = collapse;
    }
}
项目:putnami-web-toolkit    文件:InputFile.java   
private void handleCompleteJson(String reponseData) {
    if (Strings.isNullOrEmpty(reponseData)) {
        handleError("500", "Unable to post data");
    }

    JSONObject jsObject = JSONParser.parseLenient(reponseData).isObject();

    final FileDto file = new FileDto();
    file.setName(jsObject.get("name").isString().stringValue());
    file.setExtension(jsObject.get("extension").isString().stringValue());
    file.setMime(jsObject.get("mime").isString().stringValue());
    file.setToken(jsObject.get("token").isString().stringValue());
    file.setContentLength((long) jsObject.get("contentLength").isNumber().doubleValue());

    if (this.uploadForm != null) {
        this.uploadForm = this.uploadForm.destroy();
    }
    this.sendRequest = null;
    this.fileId = null;

    this.progressBar.edit(this.progressBar.getMax());

    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            InputFile.this.edit(file);
            return false;
        }
    }, this.params.inputFileProgressHideDelay());
}
项目:putnami-web-toolkit    文件:Modal.java   
public void hide() {
    StyleUtils.removeStyle(ModalBackdrop.this, Modal.STYLE_VISIBLE);
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            RootPanel.get().remove(ModalBackdrop.this);
            return false;
        }
    }, 100);
}
项目:putnami-web-toolkit    文件:Alert.java   
public void hide() {
    StyleUtils.removeStyle(this, Alert.STYLE_VISIBLE);
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            Alert.this.removeFromParent();
            Alert.this.fireEvent(new AlertDismissEvent(Alert.this));
            return false;
        }
    }, 150);
}
项目:MultiPage    文件:Page.java   
public void remove(int delay) {
  if (delay <= 0) {
    Page.this.removeFromParent();
    return;
  }
  Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
    @Override
    public boolean execute() {
      Page.this.removeFromParent();
      return false;
    }
  }, delay);
}
项目:QMAClone    文件:SceneMatching.java   
public void onFailure(Throwable caught) {
  Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
    @Override
    public boolean execute() {
      requestSkip();
      return false;
    }
  }, 1000);

  logger.log(Level.WARNING, "スキップリクエスト送信中にエラーが発生しました。パケットを再送します", caught);
}
项目:RedQueryBuilder    文件:ConditionAndOr.java   
@Override
public void onDirty() {
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        @Override
        public boolean execute() {
            Element opOuter = op.getElement().getParentElement();
            Element outerDiv = opOuter.getParentElement();
            Element topDiv = outerDiv.getFirstChildElement();

            int middleOffset = (hook() - getAbsoluteTop()) - opOuter.getOffsetHeight() / 2;

            opOuter.getStyle().setTop(middleOffset, Unit.PX);

            int leftHook = getLeft().hook();
            int rightHook = getRight().hook();

            int borderWidth = 10;

            int h = rightHook - leftHook - borderWidth;
            int top = leftHook - getAbsoluteTop() - borderWidth / 2;

            topDiv.getStyle().setHeight(h, Unit.PX);
            topDiv.getStyle().setTop(top, Unit.PX);

            return false;
    }

    }, 30);
}
项目:RedQueryBuilder    文件:GwtTestSuggestEditorWidget.java   
@Test
public void testDirtyKeepsValue() throws Exception {
    Session sess = getSession();

    Column col = sess.getDatabase().getMainSchema()
            .findTableOrView("PERSON").getColumn("county");

    final SuggestEditorWidget sew = new SuggestEditorWidget(sess, col);

    final List events = new ArrayList();
    sew.addValueChangeHandler(new ValueChangeHandler() {
        @Override
        public void onValueChange(ValueChangeEvent event) {
            events.add(event.getValue());
        }
    });

    RootPanel.get().add(sew);

    Element elmt = sew.getElement();

    elmt.setAttribute("value", "A");
    elmt.dispatchEvent(Document.get().createKeyUpEvent(false, false, false, false, 'C'));

    //System.out.println("X=" + box.getElement().getParentElement().getInnerHTML());
    List<Element> elmts = find(elmt.getParentElement(), "item");
    assertEquals(3, elmts.size());
    elmts.get(0).dispatchEvent(Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false));

    this.delayTestFinish(10000);
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        @Override
        public boolean execute() {
            assertEquals(1, events.size());
            finishTest();
            return false;
        }
    }, 100);
}
项目:SmartMonitoring    文件:AbstractMonitoringWidget.java   
/**
 * @param name - the name of the widget
 * @param refreshDelay - referesh rate in ms.
 */
public AbstractMonitoringWidget(final String name, final int refreshDelay, SR service) {
    this.name = name;
    this.service = service;
    header.setStyleName("header");
    Image img = new Image();
    img.setUrl("img/header-icon.png");
    img.addClickHandler(zoom);
    img.addMouseOverHandler(handCursor);

    header.add(img);
    lable.setText(name);
    lable.setStyleName("lable");
    header.add(lable);
    mainPanel.add(header);

    mainPanel.add(dataPanel);
    dataPanel.setStyleName("data");

    initWidget(mainPanel);
    setStyleName("monitoringWidget");

    if (refreshDelay > 0) {

        // first time do the request faster then the original one
        Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

            @Override
            public boolean execute() {
                forceRefresh();
                Scheduler.get().scheduleFixedDelay(refreshCommand, refreshDelay);
                return false;
            }
        }, 1);
    }

    setRefresh(true);

}
项目:gwteventbinder    文件:ServerProxy.java   
@EventHandler
void onContactsScreenOpened(ContactScreenOpenedEvent event) {
  // Pretend to make a server request
  Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
    @Override
    public boolean execute() {
      LinkedList<String> results = new LinkedList<String>();
      results.add("John Doe");
      results.add("Jane Doe");
      eventBus.fireEvent(new ContactsLoadedEvent(results));
      return false;
    }
  }, 1000);
}
项目:gwt-rf-queue    文件:QosManager.java   
public void start() {
    Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() {
        @Override
        public boolean execute() {
            tick();
            return true;
        }
    }, TIMER_PERIOD);
}
项目:tigase-jaxmpp2    文件:Jaxmpp.java   
public Jaxmpp(SessionObject sessionObject) {
    super(sessionObject);
    this.timeoutChecker = new RepeatingCommand() {

        @Override
        public boolean execute() {
            try {
                checkTimeouts();
            } catch (Exception e) {
            }
            return true;
        }
    };
    Scheduler.get().scheduleFixedDelay(timeoutChecker, 1000 * 31);

    this.connectorWrapper = new ConnectorWrapper(observable);
    this.connector = this.connectorWrapper;

    this.connector.addListener(Connector.StanzaReceived, this.stanzaReceivedListener);
    this.connector.addListener(Connector.StreamTerminated, this.streamTerminateListener);
    this.connector.addListener(Connector.Error, this.streamErrorListener);

    this.processor = new Processor(this.modulesManager, this.sessionObject, this.writer);

    sessionObject.setProperty(DiscoInfoModule.IDENTITY_TYPE_KEY, "web");

    modulesInit();

    ResourceBinderModule r = this.modulesManager.getModule(ResourceBinderModule.class);
    r.addListener(ResourceBinderModule.ResourceBindSuccess, resourceBindListener);
}
项目:touchkit    文件:OfflineModeEntrypoint.java   
private void waitForConnectionAvailable() {
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        int counter = 0;
        @Override
        public boolean execute() {
            if (!ApplicationConfiguration.getRunningApplications()
                    .isEmpty()) {
                configureHandlers(ApplicationConfiguration
                        .getRunningApplications().iterator().next());
            }
            return counter++ < 50 && applicationConnection == null;
        }
    }, 100);
}
项目:gwtc3    文件:Webapp.java   
/**
 * This is the entry point method.
 */
public void onModuleLoad() {
    Data data = Data.create();
    data.setX("x");
    data.setColumns(//
            array(//
                    numberArray("x", (ts += 1000), (ts += 1000), (ts += 1000), (ts += 1000), (ts += 1000), (ts += 1000)),//
                    integerArray("data1", (int)(Math.random() * 1000), (int)(Math.random() * 1000), (int)(Math.random() * 1000), (int)(Math.random() * 1000), (int)(Math.random() * 1000), (int)(Math.random() * 1000)),//
                    integerArray("data2", (int)(Math.random() * 1000), (int)(Math.random() * 1000), (int)(Math.random() * 1000), (int)(Math.random() * 1000), (int)(Math.random() * 1000), (int)(Math.random() * 1000))//
            )//
    );
    Map names = Map.create();
    names.put("data1", "data1 Name");
    names.put("data2", "data2 Name");

    data.setNames(names);

    Tick tick = Tick.create();
    tick.setFormat("%H:%M:%S");

    XorY x = XorY.create();
    x.setType(XorY.Type.TIMESERIES);
    x.setTick(tick);

    Axis axis = Axis.create();
    axis.setX(x);

    Subchart subchart = Subchart.create();
    subchart.setShow(true);

    Zoom zoom = Zoom.create();
    zoom.setEnabled(true);

    Format format = Format.create();
    format.setTitle(new ObjectHandler<JsDate>() {
        @Override
        public String handle(JsDate element) {
            Date date = cast(element);
            return dateTimeFormat.format(date);
        }
    });

    Map<Formatter> formatters = Map.create();
    formatters.put("data1", D3.format(","));
    formatters.put("data2", D3.format("$"));
    format.setValue(formatters);

    Tooltip tooltip = Tooltip.create();
    tooltip.setFormat(format);

    Generate generate = new Builder()//
            .withAxis(axis)//
            .withData(data)//
            .withSubchart(subchart)//
            .withZoom(zoom)//
            .withTooltip(tooltip)//
            .build();

    dir(generate);
    final Chart chart = C3.generate(//
            generate//
    );

    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
        @Override
        public boolean execute() {
            FlowData flowData = FlowData.create();
            flowData.setRows(array(//
                    stringArray("x", "data1", "data2"),//
                    integerArray((ts += 1000), (int)(Math.random() * 1000), (int)(Math.random() * 1000))//
            ));

            dir(flowData);
            chart.flow(flowData);

            return true;
        }
    }, 4000);
}
项目:gerrit    文件:ReplyBox.java   
@Override
protected void onLoad() {
  commentsPanel.setVisible(false);
  post.setEnabled(false);
  if (lc.hasReplyComment()) {
    message.setText(lc.getReplyComment());
    lc.removeReplyComment();
  }
  ChangeApi.drafts(project.get(), psId.getParentKey().get())
      .get(
          new AsyncCallback<NativeMap<JsArray<CommentInfo>>>() {
            @Override
            public void onSuccess(NativeMap<JsArray<CommentInfo>> result) {
              displayComments(result);
              post.setEnabled(true);
            }

            @Override
            public void onFailure(Throwable caught) {
              post.setEnabled(true);
            }
          });

  Scheduler.get()
      .scheduleDeferred(
          new ScheduledCommand() {
            @Override
            public void execute() {
              message.setFocus(true);
            }
          });
  Scheduler.get()
      .scheduleFixedDelay(
          new RepeatingCommand() {
            @Override
            public boolean execute() {
              String t = message.getText();
              if (t != null) {
                message.setCursorPos(t.length());
              }
              return false;
            }
          },
          0);
}
项目:dhcalc    文件:Service.java   
public void execute(boolean showDialog, final AsyncTask task) {

        boolean createDlg = false;

        if ((waitDialog == null) && showDialog) {
            waitDialog = ApplicationPanel.showWaitDialogBox(
                    "Please wait...", null);
            createDlg = true;
        }

        final boolean create = createDlg;

        Scheduler.get().scheduleFixedDelay(new RepeatingCommand(){

            @Override
            public boolean execute() {
                if (create && (waitDialog != null) && !waitDialog.getDialogBox().isShowing())
                    return true;

                final AsyncTaskHandler handler = create ? new AsyncTaskHandler(){

                    @Override
                    public void taskCompleted() {
                        waitDialog.taskCompleted();
                        waitDialog = null;

                    }} : AsyncTaskHandler.Default;

                checkVersion(new Handler<VersionCheck>() {

                    @Override
                    public void handleResult(VersionCheck result) {
                        if (result.success) {
                            task.run(handler);
                        } else {
                            handler.taskCompleted();
                        }
                    }
                });

                return false;

            }}, 500);

    }
项目:gwt-ol3    文件:AnimationExample.java   
@Override
public void show(String exampleId) {

    Coordinate centerCoordinate = new Coordinate(13.37, 52.52);
    Coordinate transformedMidPoint = Projection.transform(centerCoordinate, DemoConstants.EPSG_4326, DemoConstants.EPSG_3857);

    // create an OSM-layer
    XyzOptions osmSourceOptions = new XyzOptions();
    Osm osmSource = new Osm(osmSourceOptions);
    LayerOptions osmLayerOptions = new LayerOptions();
    osmLayerOptions.setSource(osmSource);
    Tile osmLayer = new Tile(osmLayerOptions);

    // create a view
    View view = new View();

    view.setCenter(transformedMidPoint);
    view.setZoom(16);

    // create the map
    MapOptions mapOptions = new MapOptions();
    mapOptions.setLoadTilesWhileAnimating(true);
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);

    Collection<Base> lstLayer = new Collection<Base>();
    lstLayer.push(osmLayer);
    mapOptions.setLayers(lstLayer);
    Map map = new Map(mapOptions);

    // add some controls
    map.addControl(new ScaleLine());

    MousePositionOptions mousePositionOptions = new MousePositionOptions();
    ProjectionOptions projectionOptions = new ProjectionOptions();
    projectionOptions.setCode(DemoConstants.EPSG_4326);
    mousePositionOptions.setProjection(new Projection(projectionOptions));

    MousePosition mousePosition = new MousePosition(mousePositionOptions);
    mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
    map.addControl(mousePosition);

    Coordinate tvTowerCoordinate = Projection.transform(new Coordinate(13.409, 52.52), DemoConstants.EPSG_4326, DemoConstants.EPSG_3857);
    Coordinate pplaceCoordinate = Projection.transform(new Coordinate(13.377, 52.509), DemoConstants.EPSG_4326, DemoConstants.EPSG_3857);
    Coordinate zooCoordinate = Projection.transform(new Coordinate(13.338, 52.508), DemoConstants.EPSG_4326, DemoConstants.EPSG_3857);

    final List<Coordinate> coordinates = Arrays.asList(transformedMidPoint, tvTowerCoordinate, pplaceCoordinate, zooCoordinate);

    Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() {

        @Override
        public boolean execute() {

            int index = getNextIndex(coordinates.size());

            AnimationOptions panAnimationOptions = new AnimationOptions();
            panAnimationOptions.setDuration(2000);
            // Switch this to rotate the animation while animating.
            // panAnimationOptions.setRotation(view.getRotation() + 2 * Math.PI);
            panAnimationOptions.setCenter(coordinates.get(index));

            view.animate(panAnimationOptions);

            AnimationOptions zoomOutAnimationOptions = new AnimationOptions();
            zoomOutAnimationOptions.setDuration(1000);
            zoomOutAnimationOptions.setResolution(view.getResolution() + 4);

            AnimationOptions zoomInAnimationOptions = new AnimationOptions();
            zoomInAnimationOptions.setDuration(1000);
            zoomInAnimationOptions.setResolution(view.getResolution());

            view.animate(zoomOutAnimationOptions, zoomInAnimationOptions);

            return true;

        }

    }, 6000);

}
项目:putnami-web-toolkit    文件:Carousel.java   
public void goTo(int itemIndex) {
    if (itemIndex == this.currentIndex || this.sliding) {
        return;
    }
    this.sliding = true;
    final int newItemIndex;
    if (itemIndex < 0) {
        newItemIndex = this.carouselItems.size() - 1;
    } else if (itemIndex >= this.carouselItems.size()) {
        newItemIndex = 0;
    } else {
        newItemIndex = itemIndex;
    }

    StyleUtils.addStyle(this.carouselItemsIndicators.get(this.currentIndex), ItemType.DEFAULT);

    boolean goLeft = newItemIndex > this.currentIndex;
    final CarouselItem curentItem = this.carouselItems.get(this.currentIndex);
    final CarouselItem newItem = this.carouselItems.get(newItemIndex);

    StyleUtils.addStyle(newItem, goLeft ? ItemType.NEXT : ItemType.PREVIOUS);
    // hook to force width evaluation (cf original bootstrap JS file)
    this.carouselItems.get(newItemIndex).getOffsetWidth();
    StyleUtils.addStyle(newItem, goLeft ? LeftRightType.LEFT : LeftRightType.RIGHT);
    StyleUtils.addStyle(curentItem, goLeft ? LeftRightType.LEFT : LeftRightType.RIGHT);

    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            StyleUtils.removeStyle(curentItem, ItemType.DEFAULT);
            StyleUtils.removeStyle(newItem, ItemType.ACTIVE);
            StyleUtils.addStyle(curentItem, ItemType.DEFAULT);
            StyleUtils.addStyle(newItem, ItemType.ACTIVE);
            StyleUtils.cleanEnumStyle(curentItem.getElement(), LeftRightType.class);
            StyleUtils.cleanEnumStyle(newItem.getElement(), LeftRightType.class);
            StyleUtils.addStyle(Carousel.this.carouselItemsIndicators.get(newItemIndex), ItemType.ACTIVE);
            Carousel.this.currentIndex = newItemIndex;
            Carousel.this.sliding = false;
            return false;
        }
    }, 600);
}
项目:dhcalc    文件:MainPanel.java   
protected void calculate() {

        final DialogBoxHandler dialog = super.showWaitDialogBox("Simulating",
                "Please wait...");

        Scheduler.get().scheduleFixedDelay(new RepeatingCommand(){

            @Override
            public boolean execute() {
                if (dialog.getDialogBox().isShowing()) {

                    doCalculate(dialog);

                    return false;

                } else {
                    return true;
                }

            }}, 500);


//      Scheduler.get().scheduleDeferred(new Command() {
//
//          @Override
//          public void execute() {
//              doCalculate(dialog);
//          }
//      });

    }