use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class Application method go.
public void go(final RootLayoutPanel rootPanel, final Command dismissLoadingProgress) {
Widget w = view_.getWidget();
rootPanel.add(w);
rootPanel.setWidgetTopBottom(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
rootPanel.setWidgetLeftRight(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
// attempt init
pClientInit_.get().execute(new ServerRequestCallback<SessionInfo>() {
public void onResponseReceived(final SessionInfo sessionInfo) {
// initialize workbench after verifying agreement
verifyAgreement(sessionInfo, new Operation() {
public void execute() {
// directly to the user
if (ApplicationAction.isSwitchProject()) {
new Timer() {
@Override
public void run() {
dismissLoadingProgress.execute();
}
}.schedule(10000);
} else {
dismissLoadingProgress.execute();
}
session_.setSessionInfo(sessionInfo);
// initialize workbench
initializeWorkbench();
}
});
}
public void onError(ServerError error) {
Debug.logError(error);
dismissLoadingProgress.execute();
globalDisplay_.showErrorMessage("RStudio Initialization Error", error.getUserMessage());
}
});
}
use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class Application method initializeWorkbench.
private void initializeWorkbench() {
pAceThemes_.get();
// subscribe to ClientDisconnected event (wait to do this until here
// because there were spurious ClientDisconnected events occuring
// after a session interrupt sequence. we couldn't figure out why,
// and since this is a temporary hack why not add another temporary
// hack to go with it here :-)
// TOOD: move this back tot he constructor after we revise the
// interrupt hack(s)
events_.addHandler(ClientDisconnectedEvent.TYPE, this);
// create workbench
Workbench wb = workbench_.get();
eventBusProvider_.get().fireEvent(new SessionInitEvent());
// disable commands
SessionInfo sessionInfo = session_.getSessionInfo();
if (!sessionInfo.getAllowShell()) {
commands_.showShellDialog().remove();
removeTerminalCommands();
}
if (!sessionInfo.getAllowPackageInstallation()) {
commands_.installPackage().remove();
commands_.updatePackages().remove();
}
if (!sessionInfo.getAllowVcs()) {
commands_.versionControlProjectSetup().remove();
}
if (!sessionInfo.getAllowFileDownloads()) {
commands_.exportFiles().remove();
}
if (!sessionInfo.getAllowFileUploads()) {
commands_.uploadFile().remove();
}
// disable external publishing if requested
if (!SessionUtils.showExternalPublishUi(session_, uiPrefs_.get())) {
commands_.publishHTML().remove();
}
// hide the agreement menu item if we don't have one
if (!session_.getSessionInfo().hasAgreement())
commands_.rstudioAgreement().setVisible(false);
// remove knit params if they aren't supported
if (!sessionInfo.getKnitParamsAvailable())
commands_.knitWithParameters().remove();
// show the correct set of data import commands
if (uiPrefs_.get().useDataImport().getValue()) {
commands_.importDatasetFromFile().remove();
commands_.importDatasetFromURL().remove();
commands_.importDatasetFromCsvUsingReadr().setVisible(false);
commands_.importDatasetFromSAV().setVisible(false);
commands_.importDatasetFromSAS().setVisible(false);
commands_.importDatasetFromStata().setVisible(false);
commands_.importDatasetFromXML().setVisible(false);
commands_.importDatasetFromODBC().setVisible(false);
commands_.importDatasetFromJDBC().setVisible(false);
try {
String rVersion = sessionInfo.getRVersionsInfo().getRVersion();
if (ApplicationUtils.compareVersions(rVersion, "3.0.2") >= 0) {
commands_.importDatasetFromCsvUsingReadr().setVisible(true);
}
if (ApplicationUtils.compareVersions(rVersion, "3.1.0") >= 0) {
commands_.importDatasetFromSAV().setVisible(true);
commands_.importDatasetFromSAS().setVisible(true);
commands_.importDatasetFromStata().setVisible(true);
commands_.importDatasetFromXML().setVisible(true);
}
if (ApplicationUtils.compareVersions(rVersion, "3.0.0") >= 0) {
commands_.importDatasetFromODBC().setVisible(true);
}
if (ApplicationUtils.compareVersions(rVersion, "2.4.0") >= 0) {
commands_.importDatasetFromJDBC().setVisible(true);
}
} catch (Exception e) {
}
// Removing data import dialogs that are NYI
commands_.importDatasetFromXML().remove();
commands_.importDatasetFromJSON().remove();
commands_.importDatasetFromJDBC().remove();
commands_.importDatasetFromODBC().remove();
commands_.importDatasetFromMongo().remove();
} else {
commands_.importDatasetFromCsv().remove();
commands_.importDatasetFromCsvUsingBase().remove();
commands_.importDatasetFromCsvUsingReadr().remove();
commands_.importDatasetFromSAV().remove();
commands_.importDatasetFromSAS().remove();
commands_.importDatasetFromStata().remove();
commands_.importDatasetFromXLS().remove();
commands_.importDatasetFromXML().remove();
commands_.importDatasetFromJSON().remove();
commands_.importDatasetFromJDBC().remove();
commands_.importDatasetFromODBC().remove();
commands_.importDatasetFromMongo().remove();
}
// show workbench
view_.showWorkbenchView(wb.getMainView().asWidget());
// hide zoom actual size everywhere but cocoa desktop
if (!BrowseCap.isCocoaDesktop()) {
commands_.zoomActualSize().remove();
}
// hide zoom in and zoom out in web mode
if (!Desktop.isDesktop()) {
commands_.zoomIn().remove();
commands_.zoomOut().remove();
}
// show new session when appropriate
if (!Desktop.isDesktop()) {
if (sessionInfo.getMultiSession())
commands_.newSession().setMenuLabel("New Session...");
else
commands_.newSession().remove();
}
// toolbar (must be after call to showWorkbenchView because
// showing the toolbar repositions the workbench view widget)
showToolbar(uiPrefs_.get().toolbarVisible().getValue());
// sync to changes in the toolbar visibility state
uiPrefs_.get().toolbarVisible().addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
showToolbar(event.getValue());
}
});
clientStateUpdaterInstance_ = clientStateUpdater_.get();
// before we interrogate it for unsaved documents
if (ApplicationAction.hasAction()) {
new Timer() {
@Override
public void run() {
if (ApplicationAction.isQuit()) {
commands_.quitSession().execute();
} else if (ApplicationAction.isNewProject()) {
ApplicationAction.removeActionFromUrl();
events_.fireEvent(new NewProjectEvent(true, false));
} else if (ApplicationAction.isOpenProject()) {
ApplicationAction.removeActionFromUrl();
events_.fireEvent(new OpenProjectEvent(true, false));
} else if (ApplicationAction.isSwitchProject()) {
handleSwitchProjectAction();
}
}
}.schedule(500);
}
}
use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class ApplicationClientInit method execute.
public void execute(final ServerRequestCallback<SessionInfo> requestCallback, final boolean retryOnTransmissionError) {
// reset internal state
timedOut_ = false;
timeoutTimer_ = null;
// send the request
final ServerRequestCallback<SessionInfo> rpcRequestCallback = new ServerRequestCallback<SessionInfo>() {
@Override
public void onResponseReceived(SessionInfo sessionInfo) {
if (!timedOut_) {
cancelTimeoutTimer();
requestCallback.onResponseReceived(sessionInfo);
}
}
@Override
public void onError(ServerError error) {
if (!timedOut_) {
cancelTimeoutTimer();
if ((error.getCode() == ServerError.TRANSMISSION) && retryOnTransmissionError) {
// transmission error can occur due to a race
// condition when switching projects or versions, for
// this case wait 1000ms then retry
new Timer() {
@Override
public void run() {
// retry (specify flag to ensure we only retry once)
execute(requestCallback, false);
}
}.schedule(1000);
} else {
requestCallback.onError(error);
}
}
}
};
server_.clientInit(rpcRequestCallback);
// wait for 60 seconds then ask the user if they want to issue an
// interrupt to the server
int timeoutMs = 60000;
timeoutTimer_ = new Timer() {
public void run() {
// set timed out flag
timedOut_ = true;
// cancel our request
rpcRequestCallback.cancel();
// ask the user if they want to attempt to interrupt the server
globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, // caption
"Initializing RStudio", // message
"The RStudio server is taking a long time to respond. It is " + "possible that your R session has become unresponsive. " + "Do you want to terminate the currently running R session?", // don't include cancel
false, // Yes operation
new Operation() {
public void execute() {
// call interrupt then call this method back on success
server_.abort(null, new ServerRequestCallback<Void>() {
@Override
public void onResponseReceived(Void response) {
// reload the application
reloadWithDelay(1000);
}
@Override
public void onError(ServerError error) {
// if we get an error during interrupt then just
// forward the error on to the original handler
requestCallback.onError(error);
}
});
}
}, // No operation
new Operation() {
public void execute() {
// keep trying (reload to clear out any crufty app
// or networking state)
reloadWithDelay(1);
}
}, // Cancel operation (none)
null, "Terminate R", "Keep Waiting", // default to No
false);
}
};
// activate the timer
timeoutTimer_.schedule(timeoutMs);
}
use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class ApplicationClientInit method reloadWithDelay.
private void reloadWithDelay(int delayMs) {
// need a delay so the server has time to fully process the
// interrupt and go offline
Timer delayTimer = new Timer() {
public void run() {
Window.Location.reload();
}
};
delayTimer.schedule(delayMs);
}
use of com.google.gwt.user.client.Timer in project rstudio by rstudio.
the class ProgressIndicatorDelay method onProgress.
@Override
public void onProgress(final String status, final Operation onCancel) {
showing_ = true;
if (firstUpdate_) {
firstUpdate_ = false;
new Timer() {
@Override
public void run() {
if (showing_) {
progressIndicator_.onProgress(status, onCancel);
}
}
}.schedule(startDelay_);
} else {
progressIndicator_.onProgress(status, onCancel);
}
}
Aggregations