use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class RSConnectDeploy method initialize.
@Inject
public void initialize(RSConnectServerOperations server, RSAccountConnector connector, GlobalDisplay display, UIPrefs prefs) {
server_ = server;
connector_ = connector;
display_ = display;
prefs_ = prefs;
accountList_ = new RSConnectAccountList(server_, display_, false, !asStatic_);
appName_ = new AppNameTextbox(this);
// when the account list finishes populating, select the account from the
// previous deployment if we have one
accountList_.setOnRefreshCompleted(new Operation() {
@Override
public void execute() {
if (fromPrevious_ != null) {
// when re-deploying, select the account used the last time
// around
accountList_.selectAccount(fromPrevious_.getAccount());
} else {
// when doing a first-time publish, select the account the user
// prefers (currently this just tracks the last account used)
RSConnectAccount preferred = prefs_.preferredPublishAccount().getGlobalValue();
if (preferred != null) {
accountList_.selectAccount(preferred);
}
// validate the app name now that we have an account selected
appName_.validateAppName();
}
}
});
// when the user selects a different account, show the appropriate UI
addAccountChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent arg0) {
if (fromPrevious_ != null) {
boolean existing = accountList_.getSelectedAccount().equals(fromPrevious_.getAccount());
appInfoPanel_.setVisible(existing);
newAppPanel_.setVisible(!existing);
// validate name if necessary
if (existing && onDeployEnabled_ != null)
onDeployEnabled_.execute();
else if (!existing)
appName_.validateAppName();
} else {
// re-validate app name as different accounts have different
// name restrictions
appName_.validateAppName();
}
}
});
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class PublishingPreferencesPane method onDisconnect.
private void onDisconnect() {
final RSConnectAccount account = accountList_.getSelectedAccount();
if (account == null) {
display_.showErrorMessage("Error Disconnecting Account", "Please select an account to disconnect.");
return;
}
display_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Confirm Remove Account", "Are you sure you want to disconnect the '" + account.getName() + "' account on '" + account.getServer() + "'" + "? This won't delete the account on the server.", false, new Operation() {
@Override
public void execute() {
onConfirmDisconnect(account);
}
}, null, null, "Disconnect Account", "Cancel", false);
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class DataImport method onColumnMenuShow.
private Operation onColumnMenuShow(final DataImportPreviewResponse response) {
final Operation completeAndPreview = new Operation() {
@Override
public void execute() {
previewDataImport();
}
};
return new Operation() {
@Override
public void execute() {
final DataImportDataActiveColumn column = gridViewer_.getActiveColumn();
columnTypesMenu_.setOnChange(new OperationWithInput<String>() {
@Override
public void execute(final String input) {
columnTypesMenu_.hide();
if (input == "guess") {
importOptions_.setColumnType(column.getName(), null);
completeAndPreview.execute();
} else if (input == "date") {
if (dataImportMode_ == DataImportModes.Text) {
promptForParseString("Date Format", "%m/%d/%Y", completeAndPreview, column.getName(), input);
} else {
importOptions_.setColumnType(column.getName(), input);
completeAndPreview.execute();
}
} else if (input == "time") {
promptForParseString("Time Format", "%H:%M", completeAndPreview, column.getName(), input);
} else if (input == "dateTime") {
promptForParseString("Date and Time Format", "%m/%d/%Y %H:%M", completeAndPreview, column.getName(), input);
} else if (input == "factor") {
promptForFactorString("Factors", completeAndPreview, column.getName(), input);
} else {
importOptions_.setColumnType(column.getName(), input);
completeAndPreview.execute();
}
}
}, new OperationWithInput<String>() {
@Override
public void execute(String input) {
if (input == "include") {
importOptions_.setOnlyColumn(column.getName(), false);
if (importOptions_.getColumnType(column.getName()) == "skip") {
importOptions_.setColumnType(column.getName(), null);
}
}
if (input == "only") {
importOptions_.setOnlyColumn(column.getName(), true);
if (importOptions_.getColumnType(column.getName()) == "skip") {
importOptions_.setColumnType(column.getName(), null);
}
}
if (input == "skip") {
importOptions_.setOnlyColumn(column.getName(), false);
importOptions_.setColumnType(column.getName(), "skip");
}
columnTypesMenu_.hide();
previewDataImport();
}
});
columnTypesMenu_.setPopupPosition(gridViewer_.getAbsoluteLeft() + column.getLeft(), gridViewer_.getAbsoluteTop() + column.getTop());
columnTypesMenu_.setSize(column.getWidth() + "px", "");
if (zIndex_ != null) {
columnTypesMenu_.getElement().getStyle().setZIndex(zIndex_);
}
boolean columnOnly = importOptions_.getColumnOnly(column.getName());
String columnType = importOptions_.getColumnType(column.getName());
columnTypesMenu_.resetSelected();
columnTypesMenu_.setSelected(columnType != null ? columnType : "guess");
if (columnOnly) {
columnTypesMenu_.setSelected("only");
}
columnTypesMenu_.setVisibleColumns(response.getSupportedColumnTypes());
if (someColumnsHaveNoName(lastSuccessfulResponse_)) {
columnTypesMenu_.setError("All columns must have names in order to " + "perform column operations.");
columnTypesMenu_.setWidth("200px");
}
columnTypesMenu_.show();
}
};
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class DataImport method previewDataImport.
private void previewDataImport() {
Operation previewDataImportOperation = new Operation() {
@Override
public void execute() {
DataImportOptions previewImportOptions = getOptions();
if (dataImportFileChooser_.getText() == "") {
gridViewer_.setData(null);
return;
}
previewImportOptions.setMaxRows(maxRows_);
progressIndicator_.onProgress("Retrieving preview data...", new Operation() {
@Override
public void execute() {
progressIndicator_.clearProgress();
cleanPreviewResources();
server_.previewDataImportAsyncAbort(new ServerRequestCallback<Void>() {
@Override
public void onResponseReceived(Void empty) {
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
progressIndicator_.onError(error.getMessage());
}
});
}
});
server_.previewDataImportAsync(previewImportOptions, maxCols_, maxFactors_, new ServerRequestCallback<DataImportPreviewResponse>() {
@Override
public void onResponseReceived(DataImportPreviewResponse response) {
if (response == null || response.getErrorMessage() != null) {
if (response != null) {
setGridViewerData(response);
response.setColumnDefinitions(lastSuccessfulResponse_);
progressIndicator_.onError(enhancePreviewErrorMessage(response.getErrorMessage()));
}
return;
}
// Set the column definitions to allow subsequent calls to assemble
// generate preview code based on data.
importOptions_.setBaseColumnDefinitions(response);
lastSuccessfulResponse_ = response;
dataImportOptionsUi_.setPreviewResponse(response);
if (response.getLocalFiles() != null) {
localFiles_ = response.getLocalFiles();
}
gridViewer_.setOption("status", "Previewing first " + toLocaleString(maxRows_) + " entries. " + (response.getParsingErrors() > 0 ? Integer.toString(response.getParsingErrors()) + " parsing errors." : ""));
assignColumnDefinitions(response, importOptions_.getColumnDefinitions());
setGridViewerData(response);
progressIndicator_.onCompleted();
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
cleanPreviewResources();
gridViewer_.setData(null);
progressIndicator_.onError(error.getMessage());
}
});
}
};
assembleDataImport(previewDataImportOperation);
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class DataImport method setGridViewerData.
private void setGridViewerData(DataImportPreviewResponse response) {
gridViewer_.setOption("nullsAsNAs", "true");
gridViewer_.setOption("ordering", "false");
gridViewer_.setOption("rowNumbers", "false");
gridViewer_.setData(response);
if (response.getSupportedColumnTypes() != null && response.getSupportedColumnTypes().length > 0) {
gridViewer_.setColumnDefinitionsUIVisible(true, onColumnMenuShow(response), new Operation() {
@Override
public void execute() {
columnTypesMenu_.hide();
}
});
}
}
Aggregations