本文整理汇总了Java中com.google.gwt.core.client.Duration类的典型用法代码示例。如果您正苦于以下问题:Java Duration类的具体用法?Java Duration怎么用?Java Duration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Duration类属于com.google.gwt.core.client包,在下文中一共展示了Duration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UploadFormPopup
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
/**
* Creates an upload popup.
*/
public UploadFormPopup() {
form = BINDER.createAndBindUi(this);
PopupChrome chrome = PopupChromeFactory.createPopupChrome();
chrome.enableTitleBar();
popup = PopupFactory.createPopup(null, new CenterPopupPositioner(), chrome, false);
popup.getTitleBar().setTitleText("Upload attachment");
popup.add(form);
iframe = Document.get().createIFrameElement();
iframe.setName("_uploadform" + iframeId++);
// HACK(danilatos): Prevent browser from caching due to whatever reason
iframe.setSrc("/uploadform?nocache=" + Duration.currentTimeMillis());
form.getElement().setAttribute("target", iframe.getName());
onloadRegistration =
DomHelper.registerEventHandler(iframe, "load", new JavaScriptEventListener() {
@Override
public void onJavaScriptEvent(String name, Event event) {
onIframeLoad();
}
});
UIObject.setVisible(iframe, false);
}
示例2: processScreenChange
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
private void processScreenChange(ChangeSource changeSource) {
if (scrollPanel == null) {
return;
}
lastChangeTime = Duration.currentTimeMillis();
lastChangeSource = changeSource;
lastScrollPosition = scrollPanel.getScrollTop();
lastScrollDirection = calculateScrollDirection();
lastAbsoluteScrollSpeed = calculateAbsoluteScrollSpeed();
lastScrollSpeedChange = calculateScrollSpeedChange();
if (!ChangeSource.PROGRAM.equals(changeSource)) {
triggerOnScreenChanged();
needsSupplementUpdate = true;
}
previousChangeTime = lastChangeTime;
previousScrollPosition = lastScrollPosition;
previousAbsoluteScrollSpeed = lastAbsoluteScrollSpeed;
previousScrollDirection = lastScrollDirection;
}
示例3: execute
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
@Override
public boolean execute() {
if (!isActive()) {
log("Not active.");
return false;
} else if (gadgetLibraryLoaded()) {
controllerRegistration(crUrl, crWidth, crHeight);
return false;
} else {
if (Duration.currentTimeMillis() > loadWarningTime) {
showBrokenGadget("Gadget RPC script failed to load on time.");
return false;
}
}
return true;
}
示例4: run
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
@Override
public void run() {
if (isPaused) {
return;
}
try {
double start = Duration.currentTimeMillis();
boolean keepRunning = worker.run(currentWorkAmount);
updateWorkAmount(Duration.currentTimeMillis() - start);
if (keepRunning) {
schedule();
} else {
clearWorker();
}
} catch (Throwable t) {
Log.error(getClass(), "Could not run worker", t);
}
}
示例5: initialize
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
public void initialize(Integer width, Integer height, GwtGridStackOptions options) {
if(initialized) {
LOGGER.severe("gridstack already initialized");
return;
}
getElement().addClassName(INITIALIZING_CLASSNAME);
if(width != null) {
getElement().setAttribute("data-gs-width", width.toString());
}
if(height != null) {
getElement().setAttribute("data-gs-height", height.toString());
}
Duration duration = new Duration();
initializeGridStack(options);
LOGGER.info("Initialize grid stack took " + duration.elapsedMillis());
initialized = true;
getElement().removeClassName(INITIALIZING_CLASSNAME);
getElement().addClassName(READY_CLASSNAME);
for (GwtGridStackReadyListener readyListener : readyListeners) {
readyListener.onReady();
}
}
示例6: processReadyList
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
private void processReadyList() {
new Timer() {
@Override
public void run() {
for (int i = readyList.size() - 1; i >= 0; i--) {
ResponseHandler handler = readyList.get(i);
if (handler.sequenceNumber == currentSequenceNumber) {
if (handler.response != null) {
double t0 = Duration.currentTimeMillis();
handler.callback.onSuccess(sbb.stringToByteBuffer(handler.response));
Com.Printf("Processed #" + currentSequenceNumber + " in " + (Duration.currentTimeMillis() - t0) / 1000.0 + "s\r");
}
readyList.remove(i);
currentSequenceNumber++;
processReadyList();
return;
}
}
}
}.schedule(RECEIVED_WAIT_TIME);
}
示例7: onModuleLoad
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
/**
* Entry point to the program
*/
public void onModuleLoad() {
JavascriptLib.init();
// Feature detection
if (!featureHandler.detect()) return;
// Atlas to look up position of textures
xhr = Browser.getWindow().newXMLHttpRequest();
xhr.open("GET", "http://" + getConfigAdddress() + "/resources/blocks.json", true);
xhr.setOnload(this);
xhr.send();
Platform.runRepeated(new Runnable() {
@Override
public void run() {
if (connection == null) return;
if (Duration.currentTimeMillis() - lastKeepAlive > 1000) {
lastKeepAlive = Duration.currentTimeMillis();
connection.send(new KeepAlive());
}
}
}, 1000);
}
示例8: scheduleControllerRegistration
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
/**
* Registers the Gadget object as RPC event listener with the Gadget RPC
* Controller after waiting for the Gadget RPC library to load.
*/
private void scheduleControllerRegistration(
final String url, final long width, final long height) {
new ScheduleTimer() {
private double loadWarningTime =
Duration.currentTimeMillis() + GADGET_RPC_LOAD_WARNING_TIMEOUT_MS;
@Override
public void run() {
if (!isActive()) {
cancel();
log("Not active.");
return;
} else if (gadgetLibraryLoaded()) {
cancel();
controllerRegistration(url, width, height);
} else {
if (Duration.currentTimeMillis() > loadWarningTime) {
log("Gadget RPC script failed to load on time.");
loadWarningTime += GADGET_RPC_LOAD_WARNING_TIMEOUT_MS;
}
}
}
}.scheduleRepeating(GADGET_RPC_LOAD_TIMER_MS);
}
示例9: createHeartbeatTimer
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
private Timer createHeartbeatTimer() {
return new Timer() {
@Override
public void run() {
double currentTimeMillis = Duration.currentTimeMillis();
double difference = currentTimeMillis - lastReceivedTime;
if (difference >= heartbeatTimeout) {
doDisconnect();
doOnError(new CometException("Heartbeat failed"), false, CometClientTransportWrapper.this);
}
else {
// we have received a message since the timer was
// schedule so reschedule it.
schedule(heartbeatTimeout - (int) difference);
}
}
};
}
示例10: initTrackingInformation
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
/**
* Initializes the tracking information on each link in the chain
*
* @param actionName the name of action this chain of commands represents
* @param chainDuration duration to be used for the entire chain
*/
private void initTrackingInformation(String actionName, Duration chainDuration) {
this.actionName = actionName;
// Note that all links in the chain have a reference to the same chainDuration.
this.chainDuration = chainDuration;
if (nextCommand != null) {
nextCommand.initTrackingInformation(actionName, chainDuration);
}
}
示例11: startExecuteChain
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
/**
* Kick off the chain of commands.
*
* @param actionName the name of action this chain of commands represents
* @param node the project node to which the chain of commands is applied
* @param finallyCommand a command to execute after the chain is finished,
* regardless of whether it succeeds
*/
public final void startExecuteChain(String actionName, ProjectNode node,
Command finallyCommand) {
// The node must not be null.
// If you are calling startExecuteChain with null for the node parameter, maybe you should
// question why you are using a ChainableCommand at all. ChainableCommands were designed to
// perform an operation on a ProjectNode.
Preconditions.checkNotNull(node);
setFinallyCommand(finallyCommand);
initTrackingInformation(actionName, new Duration());
executeLink(node);
}
示例12: timeStamp
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
/**
* @return Timestamp for use in log
*/
private static String timeStamp() {
double ts = Duration.currentTimeMillis() / 1000.0;
// divide the startTime to second from millsecond and seconds is much easier to read
// for the user.
if (TIMESTAMP_FORMAT != null) {
return TIMESTAMP_FORMAT.format(ts);
} else {
return Double.toString(ts);
}
}
示例13: cleanupExpiredCache
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
private void cleanupExpiredCache() {
GadgetLog.log("GadgetDataStoreImpl.cleanupExpiredCache");
double currentTime = Duration.currentTimeMillis();
Iterator<CacheElement> it = metadataCache.values().iterator();
while (it.hasNext()) {
if (currentTime > it.next().getExpirationTime()) {
it.remove();
}
}
}
示例14: currentTimeMillis
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
@Override
public double currentTimeMillis() {
// Replace this with just Duration.currentTimeMillis() when it is itself
// implemented with a GWT.isClient() check.
return GWT.isClient()
? Duration.currentTimeMillis()
: System.currentTimeMillis();
}
示例15: moveTo
import com.google.gwt.core.client.Duration; //导入依赖的package包/类
@Override
public void moveTo(double location) {
startLocation = getViewport().getStart();
endLocation = location;
counter = new Duration();
execute();
scheduler.scheduleDelayed(this, 0);
}