本文整理汇总了Java中com.google.gwt.core.client.Scheduler.RepeatingCommand类的典型用法代码示例。如果您正苦于以下问题:Java RepeatingCommand类的具体用法?Java RepeatingCommand怎么用?Java RepeatingCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RepeatingCommand类属于com.google.gwt.core.client.Scheduler包,在下文中一共展示了RepeatingCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showInfo
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
/**
* 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);
}
示例2: setupSyntaxHighlighting
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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);
}
}
示例3: selectFile
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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
}
示例4: setActivePane
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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);
}
示例5: setActive
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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);
}
}
示例6: show
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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);
}
示例7: hide
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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);
}
示例8: launch
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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;
}
} );
}
示例9: setVisible
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
/**
* 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);
}
示例10: updateDisplay
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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();
}
}
示例11: executeQueuedCommands
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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);
}
}
示例12: scheduleDelay
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
@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;
}
示例13: schedulePeriodic
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
@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;
}
示例14: schedulers
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
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!)
}
示例15: init
import com.google.gwt.core.client.Scheduler.RepeatingCommand; //导入依赖的package包/类
@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();
}