use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class DesktopApplicationHeader method initialize.
@Inject
public void initialize(final Commands commands, EventBus events, final Session session, ApplicationServerOperations server, Provider<DesktopHooks> pDesktopHooks, Provider<CodeSearch> pCodeSearch, Provider<UIPrefs> pUIPrefs, ErrorManager errorManager, GlobalDisplay globalDisplay, ApplicationQuit appQuit) {
session_ = session;
eventBus_ = events;
pUIPrefs_ = pUIPrefs;
globalDisplay_ = globalDisplay;
ignoredUpdates_ = IgnoredUpdates.create();
server_ = server;
appQuit_ = appQuit;
binder_.bind(commands, this);
commands.mainMenu(new DesktopMenuCallback());
pDesktopHooks.get();
commands.uploadFile().remove();
commands.exportFiles().remove();
commands.updateCredentials().remove();
commands.checkForUpdates().setVisible(true);
commands.showLogFiles().setVisible(true);
commands.diagnosticsReport().setVisible(true);
commands.showFolder().setVisible(true);
events.addHandler(SessionInitEvent.TYPE, new SessionInitHandler() {
public void onSessionInit(SessionInitEvent sie) {
final SessionInfo sessionInfo = session.getSessionInfo();
toolbar_.completeInitialization(sessionInfo);
new JSObjectStateValue("updates", "ignoredUpdates", ClientState.PERSISTENT, session_.getSessionInfo().getClientState(), false) {
@Override
protected void onInit(JsObject value) {
if (value != null)
ignoredUpdates_ = value.cast();
}
@Override
protected JsObject getValue() {
ignoredUpdatesDirty_ = false;
return ignoredUpdates_.cast();
}
@Override
protected boolean hasChanged() {
return ignoredUpdatesDirty_;
}
};
Scheduler.get().scheduleFinally(new ScheduledCommand() {
public void execute() {
Desktop.getFrame().onWorkbenchInitialized(sessionInfo.getScratchDir());
if (sessionInfo.getDisableCheckForUpdates())
commands.checkForUpdates().remove();
if (!sessionInfo.getDisableCheckForUpdates() && pUIPrefs_.get().checkForUpdates().getValue()) {
checkForUpdates(false);
}
}
});
}
});
events.addHandler(ShowFolderEvent.TYPE, new ShowFolderHandler() {
public void onShowFolder(ShowFolderEvent event) {
Desktop.getFrame().showFolder(event.getPath().getPath());
}
});
toolbar_ = new GlobalToolbar(commands, events, pCodeSearch);
ThemeStyles styles = ThemeResources.INSTANCE.themeStyles();
toolbar_.addStyleName(styles.desktopGlobalToolbar());
}
use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class ShellWidget method onLoad.
@Override
protected void onLoad() {
super.onLoad();
if (!initialized_) {
initialized_ = true;
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
doOnLoad();
scrollPanel_.scrollToBottom();
}
});
}
ElementIds.assignElementId(this.getElement(), ElementIds.SHELL_WIDGET);
}
use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class RmdOutput method displayHTMLRenderResult.
private void displayHTMLRenderResult(RmdRenderResult result) {
// find the last known position for this file
int scrollPosition = 0;
String anchor = "";
if (scrollPositions_.containsKey(keyFromResult(result))) {
scrollPosition = scrollPositions_.get(keyFromResult(result));
}
if (anchors_.containsKey(keyFromResult(result))) {
anchor = anchors_.get(keyFromResult(result));
}
final RmdPreviewParams params = RmdPreviewParams.create(result, scrollPosition, anchor);
// get the default viewer type from prefs
int viewerType = prefs_.rmdViewerType().getValue();
// apply override from result, if any
if (result.getViewerType() == RmdEditorOptions.PREVIEW_IN_VIEWER)
viewerType = RMD_VIEWER_TYPE_PANE;
else if (result.getViewerType() == RmdEditorOptions.PREVIEW_IN_WINDOW)
viewerType = RMD_VIEWER_TYPE_WINDOW;
else if (result.getViewerType() == RmdEditorOptions.PREVIEW_IN_NONE)
viewerType = RMD_VIEWER_TYPE_NONE;
// slides well without help
if (result.isHtmlPresentation() && viewerType == RMD_VIEWER_TYPE_PANE)
viewerType = RMD_VIEWER_TYPE_WINDOW;
final int newViewerType = viewerType;
// we don't disturb the publish flow with a window popping up
if (newViewerType == RMD_VIEWER_TYPE_WINDOW && RSConnectPublishButton.isAnyRmdRenderPending()) {
return;
}
// get the window object if available
WindowEx win = null;
boolean needsReopen = false;
if (outputFrame_ != null) {
win = outputFrame_.getWindowObject();
if (outputFrame_.getViewerType() != newViewerType)
needsReopen = true;
}
// close it so that we can create a new one better suited to this doc type
if (needsReopen || (win != null && result_ != null && !result_.getFormatName().equals(result.getFormatName()))) {
outputFrame_.closeOutputFrame(false);
outputFrame_ = null;
win = null;
// let window finish closing before continuing
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
displayRenderResult(null, newViewerType, params);
}
});
} else {
displayRenderResult(win, newViewerType, params);
}
}
use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class MainSplitPanel method initialize.
public void initialize(Widget left, Widget right) {
left_ = left;
right_ = right;
new JSObjectStateValue(GROUP_WORKBENCH, KEY_RIGHTPANESIZE, ClientState.PERSISTENT, session_.getSessionInfo().getClientState(), false) {
@Override
protected void onInit(JsObject value) {
State state = value == null ? null : (State) value.cast();
if (state != null && state.hasSplitterPos()) {
if (state.hasPanelWidth() && state.hasWindowWidth() && state.getWindowWidth() != Window.getClientWidth()) {
int delta = state.getWindowWidth() - state.getPanelWidth();
int offsetWidth = Window.getClientWidth() - delta;
double pct = (double) state.getSplitterPos() / state.getPanelWidth();
addEast(right_, pct * offsetWidth);
} else {
addEast(right_, state.getSplitterPos());
}
} else {
addEast(right_, Window.getClientWidth() * 0.45);
}
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
enforceBoundaries();
}
});
}
@Override
protected JsObject getValue() {
State state = JavaScriptObject.createObject().cast();
state.setPanelWidth(getOffsetWidth());
state.setWindowWidth(Window.getClientWidth());
state.setSplitterPos(right_.getOffsetWidth());
return state.cast();
}
@Override
protected boolean hasChanged() {
JsObject newValue = getValue();
if (!State.equals(lastKnownValue_, (State) newValue.cast())) {
lastKnownValue_ = newValue.cast();
return true;
}
return false;
}
private State lastKnownValue_;
};
add(left);
setWidgetMinSize(right_, 0);
}
use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project rstudio by rstudio.
the class Shell method onConsoleClear.
@Handler
void onConsoleClear() {
// clear output
view_.clearOutput();
// notify server
server_.resetConsoleActions(new VoidServerRequestCallback());
// if we don't bounce setFocus the menu retains focus
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
view_.getInputEditorDisplay().setFocus(true);
}
});
}
Aggregations