Merge "Allow plugins to display errors in the Gerrit ErrorDialog"

This commit is contained in:
Shawn Pearce 2014-01-31 22:51:07 +00:00 committed by Gerrit Code Review
commit 0eca733594
5 changed files with 16 additions and 0 deletions

View File

@ -755,6 +755,10 @@ Gerrit.url('/123'); // "https://gerrit-review.googlesource.com/123"
For a plugin specific version see link:#self_url()[`self.url()`].
[[Gerrit_showError]]
=== Gerrit.showError(message)
Displays the given message in the Gerrit ErrorDialog.
GERRIT
------
Part of link:index.html[Gerrit Code Review]

View File

@ -37,6 +37,7 @@ public class ActionContext extends JavaScriptObject {
Gerrit.ActionContext.prototype = {
go: Gerrit.go,
refresh: Gerrit.refresh,
showError: Gerrit.showError,
br: function(){return doc.createElement('br')},
hr: function(){return doc.createElement('hr')},

View File

@ -14,6 +14,7 @@
package com.google.gerrit.client.api;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
@ -56,6 +57,7 @@ public class ApiGlue {
go: @com.google.gerrit.client.api.ApiGlue::go(Ljava/lang/String;),
refresh: @com.google.gerrit.client.api.ApiGlue::refresh(),
showError: @com.google.gerrit.client.api.ApiGlue::showError(Ljava/lang/String;),
on: function (e,f){(this.events[e] || (this.events[e]=[])).push(f)},
onAction: function (t,n,c){this._onAction(this.getPluginName(),t,n,c)},
@ -143,6 +145,10 @@ public class ApiGlue {
Gerrit.display(History.getToken());
}
private static final void showError(String message) {
new ErrorDialog(message).center();
}
static final native void invoke(JavaScriptObject f) /*-{ f(); }-*/;
static final native void invoke(JavaScriptObject f, JavaScriptObject a) /*-{ f(a); }-*/;
static final native void invoke(JavaScriptObject f, JavaScriptObject a, JavaScriptObject b) /*-{ f(a,b) }-*/;

View File

@ -52,6 +52,7 @@ final class Plugin extends JavaScriptObject {
getPluginName: function(){return this.name},
go: @com.google.gerrit.client.api.ApiGlue::go(Ljava/lang/String;),
refresh: @com.google.gerrit.client.api.ApiGlue::refresh(),
showError: @com.google.gerrit.client.api.ApiGlue::showError(Ljava/lang/String;),
on: function(e,f){G.on(e,f)},
onAction: function(t,n,c){G._onAction(this.name,t,n,c)},
screen: function(p,c){G._screen(this.name,p,c)},

View File

@ -50,6 +50,10 @@ public final class Plugin extends JavaScriptObject {
public final native void refresh()
/*-{ return this.refresh() }-*/;
/** Show message in Gerrit's ErrorDialog. */
public final native void showError(String message)
/*-{ return this.showError(message) }-*/;
/**
* Register a screen displayed at {@code /#/x/plugin/token}.
*