Skip to content

Commit

Permalink
Revert "Revert "Revert "don't pass ServerError to RequestCallback.onF…
Browse files Browse the repository at this point in the history
…ailure"""

This reverts commit 48ce0bf.
  • Loading branch information
jjallaire committed Sep 26, 2011
1 parent c7e19a3 commit d98e015
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/gwt/src/org/rstudio/core/client/ResultCallback.java
Expand Up @@ -16,15 +16,15 @@
* Provides a generic interface for handling success and/or failure of an
* operation, especially an asynchronous one.
*/
public abstract class ResultCallback<TSuccess>
public abstract class ResultCallback<TSuccess, TFailure>
{
public void onSuccess(TSuccess result) {}
public void onFailure() {}
public void onFailure(TFailure info) {}

public static <TSuccess>
ResultCallback<TSuccess> create(final CommandWithArg<TSuccess> cmd)
public static <TSuccess, TFailure>
ResultCallback<TSuccess, TFailure> create(final CommandWithArg<TSuccess> cmd)
{
return new ResultCallback<TSuccess>()
return new ResultCallback<TSuccess, TFailure>()
{
@Override
public void onSuccess(TSuccess result)
Expand Down
Expand Up @@ -406,7 +406,7 @@ public void onNewSourceDoc()
}

private void newDoc(EditableFileType fileType,
final ResultCallback<EditingTarget> resultCallback)
final ResultCallback<EditingTarget, ServerError> resultCallback)
{
ensureVisible(true);
server_.newDocument(
Expand All @@ -430,7 +430,7 @@ public void onError(ServerError error)
super.onError(error);

if (resultCallback != null)
resultCallback.onFailure();
resultCallback.onFailure(error);
}
});
}
Expand Down Expand Up @@ -876,7 +876,7 @@ private void openFile(final FileSystemItem file,
final CommandWithArg<EditingTarget> executeOnSuccess)
{
openFile(file, fileType,
ResultCallback.<EditingTarget>create(executeOnSuccess));
ResultCallback.<EditingTarget, ServerError>create(executeOnSuccess));
}

// top-level wrapper for opening files. takes care of:
Expand All @@ -888,7 +888,7 @@ private void openFile(final FileSystemItem file,
// via the call to the lower level openFile method
private void openFile(final FileSystemItem file,
final TextFileType fileType,
final ResultCallback<EditingTarget> resultCallback)
final ResultCallback<EditingTarget, ServerError> resultCallback)
{
ensureVisible(true);

Expand Down Expand Up @@ -918,7 +918,7 @@ private void openFile(final FileSystemItem file,
if (file.getLength() > target.getFileSizeLimit())
{
if (resultCallback != null)
resultCallback.onFailure();
resultCallback.onFailure(null);
showFileTooLargeWarning(file, target.getFileSizeLimit());
}
else if (file.getLength() > target.getLargeFileSize())
Expand All @@ -933,7 +933,7 @@ public void execute()
{
// user (wisely) cancelled
if (resultCallback != null)
resultCallback.onFailure();
resultCallback.onFailure(null);
}
});
}
Expand All @@ -946,7 +946,7 @@ public void execute()
// variation of top-level file opening wrapper which automatically
// deduces the file type
private void openFile(FileSystemItem file,
ResultCallback<EditingTarget> callback)
ResultCallback<EditingTarget, ServerError> callback)
{
TextFileType fileType = fileTypeRegistry_.getTextTypeForFile(file);
openFile(file, fileType, callback);
Expand Down Expand Up @@ -986,7 +986,7 @@ private void confirmOpenLargeFile(FileSystemItem file,
private void openFileFromServer(
final FileSystemItem file,
final TextFileType fileType,
final ResultCallback<EditingTarget> resultCallback)
final ResultCallback<EditingTarget, ServerError> resultCallback)
{
final Command dismissProgress = globalDisplay_.showProgress(
"Opening file...");
Expand All @@ -1003,7 +1003,7 @@ public void onError(ServerError error)
dismissProgress.execute();
Debug.logError(error);
if (resultCallback != null)
resultCallback.onFailure();
resultCallback.onFailure(error);
globalDisplay_.showMessage(GlobalDisplay.MSG_ERROR,
"Error while opening file",
error.getUserMessage());
Expand Down Expand Up @@ -1115,7 +1115,7 @@ public void onInsertSource(final InsertSourceEvent event)
else
{
newDoc(FileTypeRegistry.R,
new ResultCallback<EditingTarget>()
new ResultCallback<EditingTarget, ServerError>()
{
public void onSuccess(EditingTarget arg)
{
Expand Down Expand Up @@ -1358,7 +1358,7 @@ else if (navigation.getPath() != null)
{
suspendSourceNavigationAdding_ = true;
openFile(FileSystemItem.createFile(navigation.getPath()),
new ResultCallback<EditingTarget>() {
new ResultCallback<EditingTarget, ServerError>() {
public void onSuccess(EditingTarget target)
{
try
Expand All @@ -1372,7 +1372,7 @@ public void onSuccess(EditingTarget target)
}

@Override
public void onFailure()
public void onFailure(ServerError info)
{
suspendSourceNavigationAdding_ = false;
}
Expand Down

0 comments on commit d98e015

Please sign in to comment.