use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class DynamicIFrame method pollForLoad.
protected void pollForLoad() {
// wait for the window object to become available
final Scheduler.RepeatingCommand loadFrame = new Scheduler.RepeatingCommand() {
@Override
public boolean execute() {
if (getIFrame() == null || getWindow() == null || getDocument() == null)
return true;
// URL refers to is fully loaded
if (url_ != null && getDocument().getURL() == "about:blank" || getDocument().getBody() == null || getDocument().getReadyState() != DocumentEx.STATE_COMPLETE)
return true;
onFrameLoaded();
return false;
}
};
// defer an attempt to pull the window object; if it isn't successful, try
// every 50ms
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (loadFrame.execute()) {
Scheduler.get().scheduleFixedDelay(loadFrame, 50);
}
}
});
}
use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class FileSystemDialog method showModal.
@Override
public void showModal() {
super.showModal();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
center();
}
});
}
use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class BinarySplitLayoutPanel method onAttach.
@Override
protected void onAttach() {
super.onAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
offsetHeight_ = getOffsetHeight();
}
});
}
use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class SlideLabel method show.
public void show(final int autoHideMillis, final Command executeOnComplete) {
assert autoHideMillis >= 0 || executeOnComplete == null : "Possible error: executeOnComplete will never be called with " + "negative value for autoHideMillis";
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
stopCurrentAnimation();
currentAnimation_ = new Animation() {
@Override
protected void onStart() {
setVisible(true);
curtain_.setHeight("0px");
height = content_.getOffsetHeight() + 14 + 14;
super.onStart();
}
@Override
protected void onUpdate(double progress) {
setHeight(height * progress);
}
@Override
protected void onComplete() {
currentAnimation_ = null;
if (autoHideMillis >= 0) {
currentAutoHideTimer_ = new Timer() {
@Override
public void run() {
currentAutoHideTimer_ = null;
hide(executeOnComplete);
}
};
currentAutoHideTimer_.schedule(autoHideMillis);
}
}
private int height;
};
currentAnimation_.run(ANIM_MILLIS);
}
});
}
use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class ToolbarButton method addMenuHandlers.
private void addMenuHandlers(final ToolbarPopupMenu popupMenu, final boolean rightAlign) {
menu_ = popupMenu;
/*
* We want clicks on this button to toggle the visibility of the menu,
* as well as having the menu auto-hide itself as it normally does.
* It's necessary to manually track the visibility (menuShowing) because
* in the case where the menu is showing, clicking on this button first
* causes the menu to auto-hide and then our mouseDown handler is called
* (so we can't rely on menu.isShowing(), it'll always be false by the
* time you get into the mousedown handler).
*/
final boolean[] menuShowing = new boolean[1];
addMouseDownHandler(new MouseDownHandler() {
public void onMouseDown(MouseDownEvent event) {
event.preventDefault();
event.stopPropagation();
addStyleName(styles_.toolbarButtonPushed());
// Some menus are rebuilt on every invocation. Ask the menu for
// the most up-to-date version before proceeding.
popupMenu.getDynamicPopupMenu(new ToolbarPopupMenu.DynamicPopupMenuCallback() {
@Override
public void onPopupMenu(final ToolbarPopupMenu menu) {
if (menuShowing[0]) {
removeStyleName(styles_.toolbarButtonPushed());
menu.hide();
} else {
if (rightAlign) {
menu.setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
menu.setPopupPosition((rightImageWidget_ != null ? rightImageWidget_.getAbsoluteLeft() : leftImageWidget_.getAbsoluteLeft()) + 20 - offsetWidth, ToolbarButton.this.getAbsoluteTop() + ToolbarButton.this.getOffsetHeight());
}
});
} else {
menu.showRelativeTo(ToolbarButton.this);
}
menuShowing[0] = true;
}
}
});
}
});
popupMenu.addCloseHandler(new CloseHandler<PopupPanel>() {
public void onClose(CloseEvent<PopupPanel> popupPanelCloseEvent) {
removeStyleName(styles_.toolbarButtonPushed());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
menuShowing[0] = false;
}
});
}
});
}
Aggregations