use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class Console method activateConsole.
private void activateConsole(boolean focusWindow) {
// ensure we don't leave focus in the console
final FocusContext focusContext = new FocusContext();
if (!focusWindow)
focusContext.record();
if (focusWindow)
WindowEx.get().focus();
view_.bringToFront();
view_.focus();
view_.ensureCursorVisible();
// if that's what the caller requested.
if (!focusWindow) {
new Timer() {
@Override
public void run() {
focusContext.restore();
}
}.schedule(100);
}
}
use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class MathJax method onMathJaxTypesetCompleted.
private void onMathJaxTypesetCompleted(final Object mathjaxElObject, final String text, final boolean error, final Object commandObject, final int attempt) {
final Element mathjaxEl = (Element) mathjaxElObject;
if (attempt < MAX_RENDER_ATTEMPTS) {
// if mathjax displayed an error, try re-rendering once more
Element[] errorEls = DomUtils.getElementsByClassName(mathjaxEl, "MathJax_Error");
if (errorEls != null && errorEls.length > 0 && attempt < MAX_RENDER_ATTEMPTS) {
// hide the error and retry in 25ms (experimentally this seems to
// produce a better shot at rendering successfully than an immediate
// or deferred retry)
mathjaxEl.getStyle().setVisibility(Visibility.HIDDEN);
new Timer() {
@Override
public void run() {
mathjaxTypeset(mathjaxEl, text, commandObject, attempt + 1);
}
}.schedule(25);
return;
}
}
// show whatever we've got (could be an error if we ran out of retries)
mathjaxEl.getStyle().setVisibility(Visibility.VISIBLE);
// execute callback
if (commandObject != null && commandObject instanceof MathJaxTypesetCallback) {
MathJaxTypesetCallback callback = (MathJaxTypesetCallback) commandObject;
callback.onMathJaxTypesetComplete(error);
}
if (!error) {
lastRenderedText_ = text;
}
}
use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class LocatorPanel method showFeedbackAt.
private void showFeedbackAt(Point p) {
cancelFeedback();
setWidgetTopHeight(feedbackImage_, p.getY() - FB_OFFSET_Y, Unit.PX, FB_HEIGHT, Unit.PX);
setWidgetLeftWidth(feedbackImage_, p.getX() - FB_OFFSET_X, Unit.PX, FB_WIDTH, Unit.PX);
forceLayout();
feedbackImage_.setVisible(true);
feedbackImage_.getElement().getStyle().setOpacity(1.0);
feedbackTimer_ = new Timer() {
@Override
public void run() {
feedbackTimer_ = null;
ArrayList<Widget> widgets = new ArrayList<Widget>();
widgets.add(feedbackImage_);
feedbackAnimation_ = new FadeOutAnimation(widgets, new Command() {
public void execute() {
feedbackAnimation_ = null;
}
});
feedbackAnimation_.run(300);
}
};
feedbackTimer_.schedule(700);
}
use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class EnvironmentObjects method setDeferredObjectDisplay.
private void setDeferredObjectDisplay() {
if (deferredObjectDisplayType_ == null) {
return;
}
final int type = deferredObjectDisplayType_;
// if we already have an active display of this type, do nothing
if (type == objectDisplayType_ && objectDisplay_ != null) {
return;
}
// clean up previous object display, if we had one
if (objectDisplay_ != null) {
objectDataProvider_.removeDataDisplay(objectDisplay_);
splitPanel.remove(objectDisplay_);
}
try {
// create the new object display and wire it to the data source
if (type == OBJECT_LIST_VIEW) {
objectDisplay_ = new EnvironmentObjectList(this, observer_, environmentName_);
objectSort_.setSortType(RObjectEntrySort.SORT_AUTO);
} else if (type == OBJECT_GRID_VIEW) {
objectDisplay_ = new EnvironmentObjectGrid(this, observer_, environmentName_);
objectSort_.setSortType(RObjectEntrySort.SORT_COLUMN);
}
} catch (Throwable e) {
if (SuperDevMode.isActive()) {
if (gridRenderRetryCount_ >= 5) {
Debug.log("WARNING: Failed to render environment pane data grid");
}
gridRenderRetryCount_++;
Debug.log("WARNING: Retrying environment data grid render (" + gridRenderRetryCount_ + ")");
Timer t = new Timer() {
@Override
public void run() {
setObjectDisplay(type);
}
};
t.schedule(5);
}
return;
}
objectDisplayType_ = type;
Collections.sort(objectDataProvider_.getList(), objectSort_);
updateCategoryLeaders(false);
objectDataProvider_.addDataDisplay(objectDisplay_);
objectDisplay_.getScrollPanel().addScrollHandler(new ScrollHandler() {
@Override
public void onScroll(ScrollEvent event) {
if (useStatePersistence()) {
deferredScrollPosition_ = getScrollPosition();
observer_.setPersistedScrollPosition(deferredScrollPosition_);
}
}
});
objectDisplay_.setEmptyTableWidget(buildEmptyGridMessage());
objectDisplay_.addStyleName(style.objectGrid());
objectDisplay_.addStyleName(style.environmentPanel());
splitPanel.add(objectDisplay_);
deferredObjectDisplayType_ = null;
}
use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class Application method reloadWindowWithDelay.
private void reloadWindowWithDelay(final boolean baseUrlOnly) {
new Timer() {
@Override
public void run() {
if (baseUrlOnly)
Window.Location.replace(GWT.getHostPageBaseURL());
else
Window.Location.reload();
}
}.schedule(100);
}
Aggregations