Merge "Remove GWT UI"
9
BUILD
@ -44,16 +44,10 @@ pkg_war(
|
||||
ui = None,
|
||||
)
|
||||
|
||||
pkg_war(
|
||||
name = "polygerrit",
|
||||
ui = "polygerrit",
|
||||
)
|
||||
|
||||
pkg_war(
|
||||
name = "release",
|
||||
context = ["//plugins:core"],
|
||||
doc = True,
|
||||
ui = "ui_optdbg_r",
|
||||
)
|
||||
|
||||
pkg_war(
|
||||
@ -71,9 +65,6 @@ API_DEPS = [
|
||||
"//plugins:plugin-api_deploy.jar",
|
||||
"//plugins:plugin-api-sources_deploy.jar",
|
||||
"//plugins:plugin-api-javadoc",
|
||||
"//gerrit-plugin-gwtui:gwtui-api_deploy.jar",
|
||||
"//gerrit-plugin-gwtui:gwtui-api-source_deploy.jar",
|
||||
"//gerrit-plugin-gwtui:gwtui-api-javadoc",
|
||||
]
|
||||
|
||||
genrule2(
|
||||
|
@ -47,7 +47,6 @@ license_map(
|
||||
name = "licenses",
|
||||
opts = ["--asciidoctor"],
|
||||
targets = [
|
||||
"//gerrit-gwtui:ui_module",
|
||||
"//polygerrit-ui/app:polygerrit_ui",
|
||||
"//java/com/google/gerrit/pgm",
|
||||
],
|
||||
@ -57,7 +56,6 @@ license_map(
|
||||
license_map(
|
||||
name = "js_licenses",
|
||||
targets = [
|
||||
"//gerrit-gwtui:ui_module",
|
||||
"//polygerrit-ui/app:polygerrit_ui",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
|
@ -273,10 +273,7 @@ When this is the configured authentication method a hyperlink titled
|
||||
`Become` appears in the top right corner of the page, taking the
|
||||
user to a form where they can enter the username of any existing
|
||||
user account, and immediately login as that account, without any
|
||||
authentication taking place. This form of authentication is only
|
||||
useful for the GWT hosted mode shell, where OpenID authentication
|
||||
redirects might be risky to the developer's host computer, and HTTP
|
||||
authentication is not possible.
|
||||
authentication taking place.
|
||||
|
||||
+
|
||||
By default, OpenID.
|
||||
@ -485,13 +482,12 @@ the "Switch Account" link is displayed next to "Sign Out".
|
||||
+
|
||||
When `auth.type` does not normally enable this URL administrators may
|
||||
set this to `login/`, allowing users to begin a new web session. This value
|
||||
is used as an href in PolyGerrit and the GWT UI, so absolute URLs like
|
||||
is used as an href in PolyGerrit, so absolute URLs like
|
||||
`https://someotherhost/login` work as well.
|
||||
+
|
||||
If a ${path} parameter is included, then PolyGerrit will substitute the
|
||||
currently viewed path in the link. Be aware that this path will include
|
||||
a leading slash, so a value like this might be appropriate: `/login${path}`.
|
||||
Note: in the GWT UI this substitution for ${path} is *always* `/`.
|
||||
|
||||
[[auth.cookiePath]]auth.cookiePath::
|
||||
+
|
||||
@ -1175,8 +1171,7 @@ Default is 5 minutes.
|
||||
|
||||
[[change.allowBlame]]change.allowBlame::
|
||||
+
|
||||
Allow blame on side by side diff in the GWT UI. If set to false, blame cannot be
|
||||
used.
|
||||
Allow blame on side by side diff. If set to false, blame cannot be used.
|
||||
+
|
||||
Default is true.
|
||||
|
||||
@ -1433,13 +1428,10 @@ upper and lower case character for each position must be used. For
|
||||
example, to match the string `bug` in a case insensitive way the match
|
||||
pattern `[bB][uU][gG]` needs to be used.
|
||||
+
|
||||
Between the GWT UI and PolyGerrit, the commentlink.name.match regular
|
||||
expressions are applied differently. Whereas in the GWT UI the
|
||||
expressions are applied to the formatted and escaped HTML result, the
|
||||
PolyGerrit UI applies them only to the raw, unformatted and unescaped
|
||||
text form. PolyGerrit does not support regex matching against HTML.
|
||||
Comment link patterns that are written in this style should be updated
|
||||
to match text formats.
|
||||
The commentlink.name.match regular expressions are applied to the raw,
|
||||
unformatted and unescaped text form. Regex matching against HTML is not
|
||||
supported. Comment link patterns that are written in this style should
|
||||
be updated to match text formats.
|
||||
+
|
||||
A common pattern to match is `bug\\s+(\\d+)`.
|
||||
|
||||
@ -5100,10 +5092,6 @@ The contents of the `system_config` table are cached at startup
|
||||
by Gerrit. If you modify any columns in this table, Gerrit needs
|
||||
to be restarted before it will use the new values.
|
||||
|
||||
== Configuring the Polygerrit UI
|
||||
|
||||
Please see link:dev-polygerrit.html[UI] on configuring the Polygerrit UI.
|
||||
|
||||
=== Configurable Parameters
|
||||
|
||||
site_path::
|
||||
|
@ -199,8 +199,7 @@ Project]
|
||||
|
||||
This plugin allows the rendering of Git repository branch network in a
|
||||
graphical HTML5 Canvas. It is mainly intended to be used as a
|
||||
"project link" in a gitweb configuration or by other Gerrit GWT UI
|
||||
plugins to be plugged elsewhere in Gerrit.
|
||||
"project link" in a gitweb configuration.
|
||||
|
||||
link:https://gerrit-review.googlesource.com/admin/repos/plugins/branch-network[
|
||||
Project] |
|
||||
|
@ -129,9 +129,7 @@ instead of '#' because Analytics won't track anchors.
|
||||
|
||||
The `window.onload` callback is necessary to ensure that the
|
||||
`Gerrit.on()` function has actually been defined by the
|
||||
page. Because GWT loads the module asynchronously any `<script>`
|
||||
block in the header or footer will execute before Gerrit has defined
|
||||
the function and is ready to register the hook callback.
|
||||
page.
|
||||
|
||||
GERRIT
|
||||
------
|
||||
|
@ -92,7 +92,7 @@ in `$gerrit_site/etc/gerrit.config` to run Gerrit with Java 9:
|
||||
|
||||
=== Gerrit Development WAR File
|
||||
|
||||
To build the Gerrit web application that includes the PolyGerrit UI:
|
||||
To build the Gerrit web application:
|
||||
|
||||
----
|
||||
bazel build gerrit
|
||||
@ -111,8 +111,8 @@ The output executable WAR will be placed in:
|
||||
[[release]]
|
||||
=== Gerrit Release WAR File
|
||||
|
||||
To build the Gerrit web application that includes the GWT UI, the
|
||||
PolyGerrit UI, core plugins and documentation:
|
||||
To build the Gerrit web application that includes the PolyGerrit UI,
|
||||
core plugins and documentation:
|
||||
|
||||
----
|
||||
bazel build release
|
||||
@ -126,7 +126,7 @@ The output executable WAR will be placed in:
|
||||
|
||||
=== Headless Mode
|
||||
|
||||
To build Gerrit in headless mode, i.e. without the PolyGerrit and GWT
|
||||
To build Gerrit in headless mode, i.e. without the PolyGerrit UI:
|
||||
Web UI:
|
||||
|
||||
----
|
||||
@ -141,7 +141,7 @@ The output executable WAR will be placed in:
|
||||
|
||||
=== Extension and Plugin API JAR Files
|
||||
|
||||
To build the extension, plugin and GWT API JAR files:
|
||||
To build the extension, plugin and acceptance-framework JAR files:
|
||||
|
||||
----
|
||||
bazel build api
|
||||
@ -154,7 +154,8 @@ Java docs will be placed in:
|
||||
bazel-genfiles/api.zip
|
||||
----
|
||||
|
||||
Install {extension,plugin,gwt}-api to the local maven repository:
|
||||
Install {extension,plugin,acceptance-framework}-api to the local
|
||||
maven repository:
|
||||
|
||||
----
|
||||
tools/maven/api.sh install
|
||||
|
@ -273,7 +273,6 @@ when coding:
|
||||
people from submitting actions more than once when operating
|
||||
on slow links. If the action buttons are disabled, they cannot
|
||||
be resubmitted and the user can see that Gerrit is still busy.
|
||||
* GWT EventBus is the new way forward.
|
||||
* ...and so is Guava (previously known as Google Collections).
|
||||
|
||||
|
||||
@ -333,21 +332,6 @@ Fixes that are known to be needed for a particular release should be pushed
|
||||
for review on that release's stable branch. It will then be included in
|
||||
the master branch when the stable branch is merged back.
|
||||
|
||||
=== Updating to new version of GWT
|
||||
|
||||
When updating to a new version of GWT, there are several things that also need
|
||||
to be updated or at least checked.
|
||||
|
||||
* Update common and plugin dependencies in `tools/gwt-constants.defs`.
|
||||
* Update to the same GWT version in the cookbook plugin and optionally in other
|
||||
plugins that have a dependency on GWT.
|
||||
* Update the GWT version in the archetype metadata in the
|
||||
`gerrit-plugin-gwt-archetype`.
|
||||
* Update the version of `gwt-maven-plugin` in the example pom.xml file in
|
||||
link:dev-plugins.html[dev-plugins].
|
||||
* Update to the same GWT version in the `gwtjsonrpc` project, and release a
|
||||
new version.
|
||||
|
||||
=== Finding starter projects to work on
|
||||
|
||||
We have created a
|
||||
|
@ -121,9 +121,9 @@ to be the author of the change.
|
||||
|
||||
End-user web browsers make HTTP requests directly to Gerrit's
|
||||
HTTP server. As nearly all of the user interface is implemented
|
||||
through Google Web Toolkit (GWT), the majority of these requests
|
||||
are transmitting compressed JSON payloads, with all HTML being
|
||||
generated within the browser. Most responses are under 1 KB.
|
||||
through PolyGerrit, the majority of these requests are transmitting
|
||||
compressed JSON payloads, with all HTML being generated within the
|
||||
browser. Most responses are under 1 KB.
|
||||
|
||||
Gerrit's HTTP server side component is implemented as a standard
|
||||
Java servlet, and thus runs within any J2EE servlet container.
|
||||
@ -166,7 +166,6 @@ User authentication is handled by OpenID, and therefore Gerrit
|
||||
requires that the OpenID provider selected by a user must be
|
||||
online and operating in order to authenticate that user.
|
||||
|
||||
* link:http://www.gwtproject.org/[Google Web Toolkit (GWT)]
|
||||
* link:http://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html[Git Repository Format]
|
||||
* link:http://www.postgresql.org/about/[About PostgreSQL]
|
||||
* link:http://openid.net/developers/specs/[OpenID Specifications]
|
||||
@ -200,11 +199,6 @@ The majority of Gerrit's users will be writing change descriptions
|
||||
and comments in English, and therefore an English user interface
|
||||
is usable by the target user base.
|
||||
|
||||
Gerrit uses GWT's i18n support to externalize all constant strings
|
||||
and messages shown to the user, so that in the future someone who
|
||||
really needed a translated version of the UI could contribute new
|
||||
string files for their locale(s).
|
||||
|
||||
Right-to-left (RTL) support is only barely considered within the
|
||||
Gerrit code base. Some portions of the code have tried to take
|
||||
RTL into consideration, while others probably need to be modified
|
||||
@ -235,20 +229,11 @@ provide hints to screen readers.
|
||||
|
||||
Supporting non-JavaScript enabled browsers is a non-goal for Gerrit.
|
||||
|
||||
As Gerrit is a pure-GWT application with no server side rendering
|
||||
fallbacks, the browser must support modern JavaScript semantics in
|
||||
order to access the Gerrit web application. Dumb clients such as
|
||||
`lynx`, `wget`, `curl`, or even many search engine spiders are not
|
||||
able to access Gerrit content.
|
||||
|
||||
As Google Web Toolkit (GWT) is used to generate the browser
|
||||
specific versions of the client-side JavaScript code, Gerrit works
|
||||
on any JavaScript enabled browser which GWT can produce code for.
|
||||
This covers the majority of the popular browsers.
|
||||
|
||||
The Gerrit project does not have the development resources necessary
|
||||
to support two parallel UI implementations (GWT based JavaScript
|
||||
and server-side rendering). Consequently only one is implemented.
|
||||
As Gerrit is a pure JavaScript application on the client side, with
|
||||
no server side rendering fallbacks, the browser must support modern
|
||||
JavaScript semantics in order to access the Gerrit web application.
|
||||
Dumb clients such as `lynx`, `wget`, `curl`, or even many search engine
|
||||
spiders are not able to access Gerrit content.
|
||||
|
||||
There are number of web browsers available with full JavaScript
|
||||
support, and nearly every operating system (including any PDA-like
|
||||
@ -323,7 +308,7 @@ services other than those listed above.
|
||||
Gerrit uses an XSRF protected variant of JSON-RPC 1.1 to communicate
|
||||
between the browser client and the server.
|
||||
|
||||
As the protocol is not the GWT-RPC protocol, but is instead a
|
||||
As the protocol is not the proprietry protocol, but is instead a
|
||||
self-describing standard JSON format it is easily implemented by
|
||||
any 3rd party client application, provided the client has a JSON
|
||||
parser and HTTP client library available.
|
||||
|
@ -1,11 +1,9 @@
|
||||
= Gerrit Code Review - Eclipse Setup
|
||||
|
||||
This document is about configuring Gerrit Code Review into an
|
||||
Eclipse workspace for development and debugging with GWT.
|
||||
|
||||
Java 8 or later SDK is also required to run GWT's compiler and
|
||||
runtime debugging environment.
|
||||
Eclipse workspace for development.
|
||||
|
||||
Java 8 or later SDK is require
|
||||
|
||||
[[setup]]
|
||||
== Project Setup
|
||||
@ -104,61 +102,6 @@ Duplicate the existing launch configuration:
|
||||
* Change Save as to be Local file.
|
||||
* Close the Debug Configurations dialog and save the changes when prompted.
|
||||
|
||||
|
||||
=== Running GWT Debug Mode
|
||||
|
||||
The `gerrit_gwt_debug` launch configuration uses GWT's
|
||||
link:http://www.gwtproject.org/articles/superdevmode.html[Super Dev Mode].
|
||||
|
||||
* Make a local copy of the `gerrit_gwt_debug` configuration, using the
|
||||
process described for `gerrit_daemon` above.
|
||||
* Launch the local copy of `gerrit_gwt_debug` from the Eclipse debug menu.
|
||||
* If debugging GWT for the first time:
|
||||
|
||||
** Open the link:http://localhost:9876/[codeserver URL] and add the `Dev Mode On`
|
||||
and `Dev Mode Off` bookmarklet to your bookmark bar.
|
||||
|
||||
** Activate the source maps feature in your browser. Refer to the
|
||||
link:https://developer.chrome.com/devtools/docs/javascript-debugging#source-maps[
|
||||
Chrome] and
|
||||
link:https://developer.mozilla.org/en-US/docs/Tools/Debugger#Use_a_source_map[
|
||||
Firefox] developer documentation.
|
||||
|
||||
* Load the link:http://localhost:8080[Gerrit page].
|
||||
* Open the source tab in developer tools.
|
||||
* Click the `Dev Mode On` bookmark to incrementally recompile changed files.
|
||||
* Select the `gerrit_ui` module to compile (the `Compile` button can also be used
|
||||
as a bookmarklet).
|
||||
* In the developer tools source tab, open a file and set a breakpoint.
|
||||
* Navigate to the UI and confirm that the breakpoint is hit.
|
||||
* To end the debugging session, click the `Dev Mode Off` bookmark.
|
||||
|
||||
.After changing the client side code:
|
||||
|
||||
* Hitting `F5` in the browser only reloads the last compile output, without
|
||||
recompiling.
|
||||
* To reflect your changes in the debug session, click `Dev Mode On` then `Compile`.
|
||||
|
||||
|
||||
=== Running GWT Debug Mode for Gerrit plugins
|
||||
|
||||
A Gerrit plugin can expose GWT module and its implementation can be inspected
|
||||
in the SDM debug session.
|
||||
|
||||
`codeserver` needs two additional inputs to expose the plugin module in the SDM
|
||||
debug session: the module name and the source folder location. For example the
|
||||
module name and source folder of `cookbook-plugin` should be added in the local
|
||||
copy of the `gerrit_gwt_debug` configuration:
|
||||
|
||||
----
|
||||
com.googlesource.gerrit.plugins.cookbook.HelloForm \
|
||||
-src ${resource_loc:/gerrit}/plugins/cookbook-plugin/src/main/java \
|
||||
-- --console-log [...]
|
||||
----
|
||||
|
||||
After doing that, both the Gerrit core and plugin GWT modules can be activated
|
||||
during SDM (debug session)[http://imgur.com/HFXZ5No].
|
||||
|
||||
GERRIT
|
||||
------
|
||||
Part of link:index.html[Gerrit Code Review]
|
||||
|
@ -1302,7 +1302,7 @@ this can be specified by setting `scope = CapabilityScope.CORE`:
|
||||
[[panels]]
|
||||
=== Panels
|
||||
|
||||
GWT plugins can contribute panels to Gerrit screens.
|
||||
UI plugins can contribute panels to Gerrit screens.
|
||||
|
||||
Gerrit screens define extension points where plugins can add GWT
|
||||
panels with custom controls:
|
||||
@ -1878,317 +1878,6 @@ public class MyTopMenuExtension implements TopMenu {
|
||||
----
|
||||
|
||||
|
||||
[[gwt_ui_extension]]
|
||||
== GWT UI Extension
|
||||
Plugins can extend the Gerrit UI with own GWT code.
|
||||
|
||||
A GWT plugin must contain a GWT module file, e.g. `HelloPlugin.gwt.xml`,
|
||||
that bundles together all the configuration settings of the GWT plugin:
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to="hello_gwt_plugin">
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name="com.google.gwt.user.User"/>
|
||||
<!-- Other module inherits -->
|
||||
<inherits name="com.google.gerrit.Plugin"/>
|
||||
<inherits name="com.google.gwt.http.HTTP"/>
|
||||
<!-- Using GWT built-in themes adds a number of static -->
|
||||
<!-- resources to the plugin. No theme inherits lines were -->
|
||||
<!-- added in order to make this plugin as simple as possible -->
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point class="${package}.client.HelloPlugin"/>
|
||||
<stylesheet src="hello.css"/>
|
||||
</module>
|
||||
----
|
||||
|
||||
The GWT module must inherit `com.google.gerrit.Plugin` and
|
||||
`com.google.gwt.http.HTTP`.
|
||||
|
||||
To register the GWT module a `GwtPlugin` needs to be bound.
|
||||
|
||||
If no Guice modules are declared in the manifest, the GWT plugin may
|
||||
use auto-registration by using the `@Listen` annotation:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@Listen
|
||||
public class MyExtension extends GwtPlugin {
|
||||
public MyExtension() {
|
||||
super("hello_gwt_plugin");
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
Otherwise the binding must be done in an `HttpModule`:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
public class HttpModule extends HttpPluginModule {
|
||||
|
||||
@Override
|
||||
protected void configureServlets() {
|
||||
DynamicSet.bind(binder(), WebUiPlugin.class)
|
||||
.toInstance(new GwtPlugin("hello_gwt_plugin"));
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
The HTTP module above must be declared in the `pom.xml` for Maven
|
||||
driven plugins:
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<manifestEntries>
|
||||
<Gerrit-HttpModule>com.googlesource.gerrit.plugins.myplugin.HttpModule</Gerrit-HttpModule>
|
||||
</manifestEntries>
|
||||
----
|
||||
|
||||
The name that is provided to the `GwtPlugin` must match the GWT
|
||||
module name compiled into the plugin. The name of the GWT module
|
||||
can be explicitly set in the GWT module XML file by specifying
|
||||
the `rename-to` attribute on the module. It is important that the
|
||||
module name be unique across all plugins installed on the server,
|
||||
as the module name determines the JavaScript namespace used by the
|
||||
compiled plugin code.
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<module rename-to="hello_gwt_plugin">
|
||||
----
|
||||
|
||||
The actual GWT code must be implemented in a class that extends
|
||||
`com.google.gerrit.plugin.client.PluginEntryPoint`:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
public class HelloPlugin extends PluginEntryPoint {
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
// Create the dialog box
|
||||
final DialogBox dialogBox = new DialogBox();
|
||||
|
||||
// The content of the dialog comes from a User specified Preference
|
||||
dialogBox.setText("Hello from GWT Gerrit UI plugin");
|
||||
dialogBox.setAnimationEnabled(true);
|
||||
Button closeButton = new Button("Close");
|
||||
VerticalPanel dialogVPanel = new VerticalPanel();
|
||||
dialogVPanel.setWidth("100%");
|
||||
dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
|
||||
dialogVPanel.add(closeButton);
|
||||
|
||||
closeButton.addClickHandler(new ClickHandler() {
|
||||
public void onClick(ClickEvent event) {
|
||||
dialogBox.hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Set the contents of the Widget
|
||||
dialogBox.setWidget(dialogVPanel);
|
||||
|
||||
RootPanel rootPanel = RootPanel.get(HelloMenu.MENU_ID);
|
||||
rootPanel.getElement().removeAttribute("href");
|
||||
rootPanel.addDomHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
dialogBox.center();
|
||||
dialogBox.show();
|
||||
}
|
||||
}, ClickEvent.getType());
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
This class must be set as entry point in the GWT module:
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<entry-point class="${package}.client.HelloPlugin"/>
|
||||
----
|
||||
|
||||
In addition this class must be defined as module in the `pom.xml` for the
|
||||
`gwt-maven-plugin` and the `webappDirectory` option of `gwt-maven-plugin`
|
||||
must be set to `${project.build.directory}/classes/static`:
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>gwt-maven-plugin</artifactId>
|
||||
<version>2.7.0</version>
|
||||
<configuration>
|
||||
<module>com.googlesource.gerrit.plugins.myplugin.HelloPlugin</module>
|
||||
<disableClassMetadata>true</disableClassMetadata>
|
||||
<disableCastChecking>true</disableCastChecking>
|
||||
<webappDirectory>${project.build.directory}/classes/static</webappDirectory>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
----
|
||||
|
||||
To attach a GWT widget defined by the plugin to the Gerrit core UI
|
||||
`com.google.gwt.user.client.ui.RootPanel` can be used to manipulate the
|
||||
Gerrit core widgets:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
RootPanel rootPanel = RootPanel.get(HelloMenu.MENU_ID);
|
||||
rootPanel.getElement().removeAttribute("href");
|
||||
rootPanel.addDomHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
dialogBox.center();
|
||||
dialogBox.show();
|
||||
}
|
||||
}, ClickEvent.getType());
|
||||
----
|
||||
|
||||
GWT plugins can come with their own css file. This css file must have a
|
||||
unique name and must be registered in the GWT module:
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<stylesheet src="hello.css"/>
|
||||
----
|
||||
|
||||
If a GWT plugin wants to invoke the Gerrit REST API it can use
|
||||
`com.google.gerrit.plugin.client.rpc.RestApi` to construct the URL
|
||||
path and to trigger the REST calls.
|
||||
|
||||
Example for invoking a Gerrit core REST endpoint:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
new RestApi("projects").id(projectName).view("description")
|
||||
.put("new description", new AsyncCallback<JavaScriptObject>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(JavaScriptObject result) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// never invoked
|
||||
}
|
||||
});
|
||||
----
|
||||
|
||||
Example for invoking a REST endpoint defined by a plugin:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
new RestApi("projects").id(projectName).view("myplugin", "myview")
|
||||
.get(new AsyncCallback<JavaScriptObject>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(JavaScriptObject result) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// never invoked
|
||||
}
|
||||
});
|
||||
----
|
||||
|
||||
The `onFailure(Throwable)` of the provided callback is never invoked.
|
||||
If an error occurs, it is shown in an error dialog.
|
||||
|
||||
In order to be able to do REST calls the GWT module must inherit
|
||||
`com.google.gwt.json.JSON`:
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<inherits name="com.google.gwt.json.JSON"/>
|
||||
----
|
||||
|
||||
[[screen]]
|
||||
== Add Screen
|
||||
A link:#gwt_ui_extension[GWT plugin] can link:#top-menu-extensions[add
|
||||
a menu item] that opens a screen that is implemented by the plugin.
|
||||
This way plugin screens can be fully integrated into the Gerrit UI.
|
||||
|
||||
Example menu item:
|
||||
[source,java]
|
||||
----
|
||||
public class MyMenu implements TopMenu {
|
||||
private final List<MenuEntry> menuEntries;
|
||||
|
||||
@Inject
|
||||
public MyMenu(@PluginName String name) {
|
||||
menuEntries = new ArrayList<>();
|
||||
menuEntries.add(new MenuEntry("My Menu", Collections.singletonList(
|
||||
new MenuItem("My Screen", "#/x/" + name + "/my-screen", ""))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuEntry> getEntries() {
|
||||
return menuEntries;
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
Example screen:
|
||||
[source,java]
|
||||
----
|
||||
public class MyPlugin extends PluginEntryPoint {
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
Plugin.get().screen("my-screen", new Screen.EntryPoint() {
|
||||
@Override
|
||||
public void onLoad(Screen screen) {
|
||||
screen.add(new InlineLabel("My Screen");
|
||||
screen.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
[[user-settings-screen]]
|
||||
== Add User Settings Screen
|
||||
|
||||
A link:#gwt_ui_extension[GWT plugin] can implement a user settings
|
||||
screen that is integrated into the Gerrit user settings menu.
|
||||
|
||||
Example settings screen:
|
||||
[source,java]
|
||||
----
|
||||
public class MyPlugin extends PluginEntryPoint {
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
Plugin.get().settingsScreen("my-preferences", "My Preferences",
|
||||
new Screen.EntryPoint() {
|
||||
@Override
|
||||
public void onLoad(Screen screen) {
|
||||
screen.setPageTitle("Settings");
|
||||
screen.add(new InlineLabel("My Preferences"));
|
||||
screen.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
By defining an link:config-gerrit.html#urlAlias[urlAlias] Gerrit
|
||||
administrators can map plugin screens into the Gerrit URL namespace or
|
||||
even replace Gerrit screens by plugin screens.
|
||||
|
||||
Plugins may also programatically add URL aliases in the preferences of
|
||||
of a user. This way certain screens can be replaced for certain users.
|
||||
E.g. the plugin may offer a user preferences setting for choosing a
|
||||
screen that then sets/unsets a URL alias for the user.
|
||||
|
||||
[[settings-screen]]
|
||||
== Plugin Settings Screen
|
||||
|
||||
|
@ -126,10 +126,7 @@ As result a link:#server-info[ServerInfo] entity is returned.
|
||||
"gerrit": {
|
||||
"all_projects": "All-Projects",
|
||||
"all_users": "All-Users"
|
||||
"doc_search": true,
|
||||
"web_uis": [
|
||||
"gwt"
|
||||
]
|
||||
"doc_search": true
|
||||
},
|
||||
"sshd": {},
|
||||
"suggest": {
|
||||
@ -1805,9 +1802,6 @@ link:config-gerrit.html#gerrit.reportBugUrl[URL to report bugs].
|
||||
|`report_bug_text` |optional, not set if default|
|
||||
link:config-gerrit.html#gerrit.reportBugText[Display text for report
|
||||
bugs link].
|
||||
|`web_uis` ||
|
||||
List of web UIs supported by the HTTP server. Possible values are `GWT`
|
||||
and `POLYGERRIT`.
|
||||
|=================================
|
||||
|
||||
[[hit-ration-info]]
|
||||
|
75
WORKSPACE
@ -3,7 +3,6 @@ workspace(name = "gerrit")
|
||||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
|
||||
load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_LOCAL", "maven_jar")
|
||||
load("//lib/codemirror:cm.bzl", "CM_VERSION", "DIFF_MATCH_PATCH_VERSION")
|
||||
load("//plugins:external_plugin_deps.bzl", "external_plugin_deps")
|
||||
|
||||
http_archive(
|
||||
@ -146,61 +145,6 @@ maven_jar(
|
||||
sha1 = "021a212688ec94fe77aff74ab34cc74f6f940e60",
|
||||
)
|
||||
|
||||
GWT_VERS = "2.8.2"
|
||||
|
||||
maven_jar(
|
||||
name = "user",
|
||||
artifact = "com.google.gwt:gwt-user:" + GWT_VERS,
|
||||
sha1 = "a2b9be2c996a658c4e009ba652a9c6a81c88a797",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "dev",
|
||||
artifact = "com.google.gwt:gwt-dev:" + GWT_VERS,
|
||||
sha1 = "7a87e060bbf129386b7ae772459fb9f87297c332",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "javax-validation",
|
||||
artifact = "javax.validation:validation-api:1.0.0.GA",
|
||||
sha1 = "b6bd7f9d78f6fdaa3c37dae18a4bd298915f328e",
|
||||
src_sha1 = "7a561191db2203550fbfa40d534d4997624cd369",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "jsinterop-annotations",
|
||||
artifact = "com.google.jsinterop:jsinterop-annotations:1.0.2",
|
||||
sha1 = "abd7319f53d018e11108a88f599bd16492448dd2",
|
||||
src_sha1 = "33716f8aef043f2f02b78ab4a1acda6cd90a7602",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "ant",
|
||||
artifact = "ant:ant:1.6.5",
|
||||
attach_source = False,
|
||||
sha1 = "7d18faf23df1a5c3a43613952e0e8a182664564b",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "colt",
|
||||
artifact = "colt:colt:1.2.0",
|
||||
attach_source = False,
|
||||
sha1 = "0abc984f3adc760684d49e0f11ddf167ba516d4f",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "tapestry",
|
||||
artifact = "tapestry:tapestry:4.0.2",
|
||||
attach_source = False,
|
||||
sha1 = "e855a807425d522e958cbce8697f21e9d679b1f7",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "w3c-css-sac",
|
||||
artifact = "org.w3c.css:sac:1.3",
|
||||
sha1 = "cdb2dcb4e22b83d6b32b93095f644c3462739e82",
|
||||
)
|
||||
|
||||
load("//lib/jgit:jgit.bzl", "jgit_repos")
|
||||
|
||||
jgit_repos()
|
||||
@ -1050,25 +994,6 @@ maven_jar(
|
||||
sha1 = "951b7eda125f3137538a94e2cbdcf744088ad4c2",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "codemirror-minified-gwt",
|
||||
artifact = "org.webjars.npm:codemirror-minified:" + CM_VERSION,
|
||||
sha1 = "36558ea3b8e30782e1e09c0e7bd781e09614f139",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "codemirror-original-gwt",
|
||||
artifact = "org.webjars.npm:codemirror:" + CM_VERSION,
|
||||
sha1 = "f1f8fbbc3e2d224fdccc43d2f4180658a92320f9",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "diff-match-patch",
|
||||
artifact = "org.webjars:google-diff-match-patch:" + DIFF_MATCH_PATCH_VERSION,
|
||||
attach_source = False,
|
||||
sha1 = "0cf1782dbcb8359d95070da9176059a5a9d37709",
|
||||
)
|
||||
|
||||
maven_jar(
|
||||
name = "commons-io",
|
||||
artifact = "commons-io:commons-io:2.2",
|
||||
|
@ -1,16 +0,0 @@
|
||||
java_library(
|
||||
name = "gwtdebug",
|
||||
srcs = glob(["src/main/java/**/*.java"]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//java/com/google/gerrit/pgm",
|
||||
"//java/com/google/gerrit/pgm/util",
|
||||
"//java/com/google/gerrit/util/cli",
|
||||
"//lib/flogger:api",
|
||||
"//lib/gwt:dev",
|
||||
"//lib/jetty:server",
|
||||
"//lib/jetty:servlet",
|
||||
"//lib/jetty:servlets",
|
||||
"//lib/log:log4j",
|
||||
],
|
||||
)
|
@ -1,77 +0,0 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.gwtdebug;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.pgm.Daemon;
|
||||
import com.google.gwt.dev.codeserver.CodeServer;
|
||||
import com.google.gwt.dev.codeserver.Options;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class GerritGwtDebugLauncher {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
GerritGwtDebugLauncher launcher = new GerritGwtDebugLauncher();
|
||||
launcher.mainImpl(argv);
|
||||
}
|
||||
|
||||
private int mainImpl(String[] argv) {
|
||||
List<String> sdmLauncherOptions = new ArrayList<>();
|
||||
List<String> daemonLauncherOptions = new ArrayList<>();
|
||||
|
||||
// Separator between Daemon and Codeserver parameters is "--"
|
||||
boolean daemonArgumentSeparator = false;
|
||||
int i = 0;
|
||||
for (; i < argv.length; i++) {
|
||||
if (!argv[i].equals("--")) {
|
||||
sdmLauncherOptions.add(argv[i]);
|
||||
} else {
|
||||
daemonArgumentSeparator = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (daemonArgumentSeparator) {
|
||||
++i;
|
||||
for (; i < argv.length; i++) {
|
||||
daemonLauncherOptions.add(argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Options options = new Options();
|
||||
if (!options.parseArgs(sdmLauncherOptions.toArray(new String[sdmLauncherOptions.size()]))) {
|
||||
logger.atSevere().log("Failed to parse codeserver arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
CodeServer.main(options);
|
||||
|
||||
try {
|
||||
int r =
|
||||
new Daemon()
|
||||
.main(daemonLauncherOptions.toArray(new String[daemonLauncherOptions.size()]));
|
||||
if (r != 0) {
|
||||
logger.atSevere().log("Daemon exited with return code: %d", r);
|
||||
return 1;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.atSevere().withCause(e).log("Cannot start daemon");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
load("//tools/bzl:java.bzl", "java_library2")
|
||||
load("//tools/bzl:junit.bzl", "junit_tests")
|
||||
load("//tools/bzl:gwt.bzl", "gwt_module")
|
||||
|
||||
EXPORTED_DEPS = [
|
||||
"//java/com/google/gerrit/common:client",
|
||||
"//java/com/google/gwtexpui/clippy",
|
||||
"//java/com/google/gwtexpui/globalkey",
|
||||
"//java/com/google/gwtexpui/progress",
|
||||
"//java/com/google/gwtexpui/safehtml",
|
||||
"//java/com/google/gwtexpui/user:agent",
|
||||
]
|
||||
|
||||
DEPS = ["//lib/gwt:user-neverlink"]
|
||||
|
||||
SRC = "src/main/java/com/google/gerrit/"
|
||||
|
||||
gwt_module(
|
||||
name = "client",
|
||||
srcs = glob(["src/main/**/*.java"]),
|
||||
exported_deps = EXPORTED_DEPS,
|
||||
gwt_xml = SRC + "GerritGwtUICommon.gwt.xml",
|
||||
resources = glob(
|
||||
["src/main/**/*"],
|
||||
exclude = [SRC + "client/**/*.java"] + [
|
||||
SRC + "GerritGwtUICommon.gwt.xml",
|
||||
],
|
||||
),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = DEPS,
|
||||
)
|
||||
|
||||
java_library2(
|
||||
name = "client-lib",
|
||||
srcs = glob(["src/main/**/*.java"]),
|
||||
exported_deps = EXPORTED_DEPS,
|
||||
resources = glob(["src/main/**/*"]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = DEPS,
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "diffy_logo",
|
||||
data = [
|
||||
"//lib:LICENSE-CC-BY3.0-unported",
|
||||
"//lib:LICENSE-diffy",
|
||||
],
|
||||
resources = glob(["src/main/resources/com/google/gerrit/client/diffy*.png"]),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
junit_tests(
|
||||
name = "client_tests",
|
||||
srcs = glob(["src/test/java/**/*.java"]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":client",
|
||||
"//lib:junit",
|
||||
"//lib/gwt:dev",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
],
|
||||
)
|
@ -1,43 +0,0 @@
|
||||
<!--
|
||||
Copyright (C) 2014 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<module>
|
||||
<inherits name='org.eclipse.jgit.JGit'/>
|
||||
<inherits name='com.google.gerrit.common.Common'/>
|
||||
<inherits name='com.google.gerrit.extensions.Extensions'/>
|
||||
<inherits name='com.google.gerrit.prettify.PrettyFormatter'/>
|
||||
<inherits name='com.google.gwtexpui.clippy.Clippy'/>
|
||||
<inherits name='com.google.gwtexpui.globalkey.GlobalKey'/>
|
||||
<inherits name='com.google.gwtexpui.progress.Progress'/>
|
||||
<inherits name='com.google.gwtexpui.safehtml.SafeHtml'/>
|
||||
<source path='client'>
|
||||
<include name='AccountFormatter.java'/>
|
||||
<include name='CommonConstants.java'/>
|
||||
<include name='CommonMessages.java'/>
|
||||
<include name='DateFormatter.java'/>
|
||||
<include name='GerritUiExtensionPoint.java'/>
|
||||
<include name='RelativeDateFormatter.java'/>
|
||||
<include name='Resources.java'/>
|
||||
<include name='CommonConstants.properties'/>
|
||||
<include name='CommonMessages.properties'/>
|
||||
<include name='info/*.java'/>
|
||||
<include name='rpc/NativeMap.java'/>
|
||||
<include name='rpc/Natives.java'/>
|
||||
<include name='rpc/NativeString.java'/>
|
||||
<include name='rpc/TransformCallback.java'/>
|
||||
<include name='ui/HighlightSuggestion.java'/>
|
||||
<include name='ui/RemoteSuggestOracle.java'/>
|
||||
</source>
|
||||
</module>
|
@ -1,70 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gerrit.client.info.AccountInfo;
|
||||
|
||||
public class AccountFormatter {
|
||||
private final String anonymousCowardName;
|
||||
|
||||
public AccountFormatter(String anonymousCowardName) {
|
||||
this.anonymousCowardName = anonymousCowardName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an account as a name and an email address.
|
||||
*
|
||||
* <p>Example output:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code A U. Thor <author@example.com>}: full populated
|
||||
* <li>{@code A U. Thor (12)}: missing email address
|
||||
* <li>{@code Anonymous Coward <author@example.com>}: missing name
|
||||
* <li>{@code Anonymous Coward (12)}: missing name and email address
|
||||
* </ul>
|
||||
*/
|
||||
public String nameEmail(AccountInfo info) {
|
||||
String name = info.name();
|
||||
if (name == null || name.trim().isEmpty()) {
|
||||
name = anonymousCowardName;
|
||||
}
|
||||
|
||||
StringBuilder b = new StringBuilder().append(name);
|
||||
if (info.email() != null) {
|
||||
b.append(" <").append(info.email()).append(">");
|
||||
} else if (info._accountId() > 0) {
|
||||
b.append(" (").append(info._accountId()).append(")");
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an account name.
|
||||
*
|
||||
* <p>If the account has a full name, it returns only the full name. Otherwise it returns a longer
|
||||
* form that includes the email address.
|
||||
*/
|
||||
public String name(AccountInfo ai) {
|
||||
if (ai.name() != null && !ai.name().trim().isEmpty()) {
|
||||
return ai.name();
|
||||
}
|
||||
String email = ai.email();
|
||||
if (email != null) {
|
||||
int at = email.indexOf('@');
|
||||
return 0 < at ? email.substring(0, at) : email;
|
||||
}
|
||||
return nameEmail(ai);
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.i18n.client.Constants;
|
||||
|
||||
public interface CommonConstants extends Constants {
|
||||
CommonConstants C = GWT.create(CommonConstants.class);
|
||||
|
||||
String inTheFuture();
|
||||
|
||||
String month();
|
||||
|
||||
String months();
|
||||
|
||||
String year();
|
||||
|
||||
String years();
|
||||
|
||||
String oneSecondAgo();
|
||||
|
||||
String oneMinuteAgo();
|
||||
|
||||
String oneHourAgo();
|
||||
|
||||
String oneDayAgo();
|
||||
|
||||
String oneWeekAgo();
|
||||
|
||||
String oneMonthAgo();
|
||||
|
||||
String oneYearAgo();
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
inTheFuture = in the future
|
||||
month = month
|
||||
months = months
|
||||
years = years
|
||||
year = year
|
||||
|
||||
oneSecondAgo = 1 second ago
|
||||
oneMinuteAgo = 1 minute ago
|
||||
oneHourAgo = 1 hour ago
|
||||
oneDayAgo = 1 day ago
|
||||
oneWeekAgo = 1 week ago
|
||||
oneMonthAgo = 1 month ago
|
||||
oneYearAgo = 1 year ago
|
@ -1,40 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.i18n.client.Messages;
|
||||
|
||||
public interface CommonMessages extends Messages {
|
||||
CommonMessages M = GWT.create(CommonMessages.class);
|
||||
|
||||
String secondsAgo(long seconds);
|
||||
|
||||
String minutesAgo(long minutes);
|
||||
|
||||
String hoursAgo(long hours);
|
||||
|
||||
String daysAgo(long days);
|
||||
|
||||
String weeksAgo(long weeks);
|
||||
|
||||
String monthsAgo(long months);
|
||||
|
||||
String yearsAgo(long years);
|
||||
|
||||
String years0MonthsAgo(long years, String yearLabel);
|
||||
|
||||
String yearsMonthsAgo(long years, String yearLabel, long months, String monthLabel);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
secondsAgo = {0} seconds ago
|
||||
minutesAgo = {0} minutes ago
|
||||
hoursAgo = {0} hours ago
|
||||
daysAgo = {0} days ago
|
||||
weeksAgo = {0} weeks ago
|
||||
monthsAgo = {0} months ago
|
||||
years0MonthsAgo = {0} {1} ago
|
||||
yearsMonthsAgo = {0} {1}, {2} {3} ago
|
||||
yearsAgo = {0} years ago
|
@ -1,99 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gerrit.client.info.GeneralPreferences;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateFormatter {
|
||||
private static final long ONE_YEAR = 182L * 24 * 60 * 60 * 1000;
|
||||
|
||||
private final DateTimeFormat sTime;
|
||||
private final DateTimeFormat sDate;
|
||||
private final DateTimeFormat sdtFmt;
|
||||
private final DateTimeFormat mDate;
|
||||
private final DateTimeFormat dtfmt;
|
||||
|
||||
public DateFormatter(GeneralPreferences prefs) {
|
||||
String fmt_sTime = prefs.timeFormat().getFormat();
|
||||
String fmt_sDate = prefs.dateFormat().getShortFormat();
|
||||
String fmt_mDate = prefs.dateFormat().getLongFormat();
|
||||
|
||||
sTime = DateTimeFormat.getFormat(fmt_sTime);
|
||||
sDate = DateTimeFormat.getFormat(fmt_sDate);
|
||||
sdtFmt = DateTimeFormat.getFormat(fmt_sDate + " " + fmt_sTime);
|
||||
mDate = DateTimeFormat.getFormat(fmt_mDate);
|
||||
dtfmt = DateTimeFormat.getFormat(fmt_mDate + " " + fmt_sTime);
|
||||
}
|
||||
|
||||
/** Format a date using a really short format. */
|
||||
public String shortFormat(Date dt) {
|
||||
if (dt == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
dt = new Date(dt.getTime());
|
||||
if (mDate.format(now).equals(mDate.format(dt))) {
|
||||
// Same day as today, report only the time.
|
||||
//
|
||||
return sTime.format(dt);
|
||||
|
||||
} else if (Math.abs(now.getTime() - dt.getTime()) < ONE_YEAR) {
|
||||
// Within the last year, show a shorter date.
|
||||
//
|
||||
return sDate.format(dt);
|
||||
|
||||
} else {
|
||||
// Report only date and year, its far away from now.
|
||||
//
|
||||
return mDate.format(dt);
|
||||
}
|
||||
}
|
||||
|
||||
/** Format a date using a really short format. */
|
||||
public String shortFormatDayTime(Date dt) {
|
||||
if (dt == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
dt = new Date(dt.getTime());
|
||||
if (mDate.format(now).equals(mDate.format(dt))) {
|
||||
// Same day as today, report only the time.
|
||||
//
|
||||
return sTime.format(dt);
|
||||
|
||||
} else if (Math.abs(now.getTime() - dt.getTime()) < ONE_YEAR) {
|
||||
// Within the last year, show a shorter date.
|
||||
//
|
||||
return sdtFmt.format(dt);
|
||||
|
||||
} else {
|
||||
// Report only date and year, its far away from now.
|
||||
//
|
||||
return mDate.format(dt);
|
||||
}
|
||||
}
|
||||
|
||||
/** Format a date using the locale's medium length format. */
|
||||
public String mediumFormat(Date dt) {
|
||||
if (dt == null) {
|
||||
return "";
|
||||
}
|
||||
return dtfmt.format(new Date(dt.getTime()));
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
public enum GerritUiExtensionPoint {
|
||||
/* ChangeScreen */
|
||||
CHANGE_SCREEN_HEADER,
|
||||
CHANGE_SCREEN_HEADER_RIGHT_OF_BUTTONS,
|
||||
CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS,
|
||||
CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
|
||||
CHANGE_SCREEN_BELOW_RELATED_INFO_BLOCK,
|
||||
CHANGE_SCREEN_BELOW_COMMIT_INFO_BLOCK,
|
||||
CHANGE_SCREEN_HISTORY_RIGHT_OF_BUTTONS,
|
||||
|
||||
/* MyPasswordScreen */
|
||||
PASSWORD_SCREEN_BOTTOM,
|
||||
|
||||
/* MyPreferencesScreen */
|
||||
PREFERENCES_SCREEN_BOTTOM,
|
||||
|
||||
/* MyProfileScreen */
|
||||
PROFILE_SCREEN_BOTTOM,
|
||||
|
||||
/* ProjectInfoScreen */
|
||||
PROJECT_INFO_SCREEN_TOP,
|
||||
PROJECT_INFO_SCREEN_BOTTOM;
|
||||
|
||||
public enum Key {
|
||||
ACCOUNT_INFO,
|
||||
CHANGE_INFO,
|
||||
PROJECT_NAME,
|
||||
REVISION_INFO
|
||||
}
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Formatter to format timestamps relative to the current time using time units in the format
|
||||
* defined by {@code git log --relative-date}.
|
||||
*/
|
||||
public class RelativeDateFormatter {
|
||||
private static CommonConstants constants;
|
||||
private static CommonMessages messages;
|
||||
|
||||
static final long SECOND_IN_MILLIS = 1000;
|
||||
static final long MINUTE_IN_MILLIS = 60 * SECOND_IN_MILLIS;
|
||||
static final long HOUR_IN_MILLIS = 60 * MINUTE_IN_MILLIS;
|
||||
static final long DAY_IN_MILLIS = 24 * HOUR_IN_MILLIS;
|
||||
static final long WEEK_IN_MILLIS = 7 * DAY_IN_MILLIS;
|
||||
static final long MONTH_IN_MILLIS = 30 * DAY_IN_MILLIS;
|
||||
static final long YEAR_IN_MILLIS = 365 * DAY_IN_MILLIS;
|
||||
|
||||
static void setConstants(CommonConstants c, CommonMessages m) {
|
||||
constants = c;
|
||||
messages = m;
|
||||
}
|
||||
|
||||
private static CommonConstants c() {
|
||||
return constants != null ? constants : CommonConstants.C;
|
||||
}
|
||||
|
||||
private static CommonMessages m() {
|
||||
return messages != null ? messages : CommonMessages.M;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param when {@link Date} to format
|
||||
* @return age of given {@link Date} compared to now formatted in the same relative format as
|
||||
* returned by {@code git log --relative-date}
|
||||
*/
|
||||
public static String format(Date when) {
|
||||
long ageMillis = (new Date()).getTime() - when.getTime();
|
||||
|
||||
// shouldn't happen in a perfect world
|
||||
if (ageMillis < 0) {
|
||||
return c().inTheFuture();
|
||||
}
|
||||
|
||||
// seconds
|
||||
if (ageMillis < upperLimit(MINUTE_IN_MILLIS)) {
|
||||
long seconds = round(ageMillis, SECOND_IN_MILLIS);
|
||||
if (seconds == 1) {
|
||||
return c().oneSecondAgo();
|
||||
}
|
||||
return m().secondsAgo(seconds);
|
||||
}
|
||||
|
||||
// minutes
|
||||
if (ageMillis < upperLimit(HOUR_IN_MILLIS)) {
|
||||
long minutes = round(ageMillis, MINUTE_IN_MILLIS);
|
||||
if (minutes == 1) {
|
||||
return c().oneMinuteAgo();
|
||||
}
|
||||
return m().minutesAgo(minutes);
|
||||
}
|
||||
|
||||
// hours
|
||||
if (ageMillis < upperLimit(DAY_IN_MILLIS)) {
|
||||
long hours = round(ageMillis, HOUR_IN_MILLIS);
|
||||
if (hours == 1) {
|
||||
return c().oneHourAgo();
|
||||
}
|
||||
return m().hoursAgo(hours);
|
||||
}
|
||||
|
||||
// up to 14 days use days
|
||||
if (ageMillis < 14 * DAY_IN_MILLIS) {
|
||||
long days = round(ageMillis, DAY_IN_MILLIS);
|
||||
if (days == 1) {
|
||||
return c().oneDayAgo();
|
||||
}
|
||||
return m().daysAgo(days);
|
||||
}
|
||||
|
||||
// up to 10 weeks use weeks
|
||||
if (ageMillis < 10 * WEEK_IN_MILLIS) {
|
||||
long weeks = round(ageMillis, WEEK_IN_MILLIS);
|
||||
if (weeks == 1) {
|
||||
return c().oneWeekAgo();
|
||||
}
|
||||
return m().weeksAgo(weeks);
|
||||
}
|
||||
|
||||
// months
|
||||
if (ageMillis < YEAR_IN_MILLIS) {
|
||||
long months = round(ageMillis, MONTH_IN_MILLIS);
|
||||
if (months == 1) {
|
||||
return c().oneMonthAgo();
|
||||
}
|
||||
return m().monthsAgo(months);
|
||||
}
|
||||
|
||||
// up to 5 years use "year, months" rounded to months
|
||||
if (ageMillis < 5 * YEAR_IN_MILLIS) {
|
||||
long years = round(ageMillis, MONTH_IN_MILLIS) / 12;
|
||||
String yearLabel = (years > 1) ? c().years() : c().year();
|
||||
long months = round(ageMillis - years * YEAR_IN_MILLIS, MONTH_IN_MILLIS);
|
||||
String monthLabel = (months > 1) ? c().months() : (months == 1 ? c().month() : "");
|
||||
if (months == 0) {
|
||||
return m().years0MonthsAgo(years, yearLabel);
|
||||
}
|
||||
return m().yearsMonthsAgo(years, yearLabel, months, monthLabel);
|
||||
}
|
||||
|
||||
// years
|
||||
long years = round(ageMillis, YEAR_IN_MILLIS);
|
||||
if (years == 1) {
|
||||
return c().oneYearAgo();
|
||||
}
|
||||
return m().yearsAgo(years);
|
||||
}
|
||||
|
||||
private static long upperLimit(long unit) {
|
||||
return unit + unit / 2;
|
||||
}
|
||||
|
||||
private static long round(long n, long unit) {
|
||||
return (n + unit / 2) / unit;
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
|
||||
public interface Resources extends ClientBundle {
|
||||
/** silk icons (CC-BY3.0): http://famfamfam.com/lab/icons/silk/ */
|
||||
@Source("note_add.png")
|
||||
ImageResource addFileComment();
|
||||
|
||||
@Source("tag_blue_add.png")
|
||||
ImageResource addHashtag();
|
||||
|
||||
@Source("user_add.png")
|
||||
ImageResource addUser();
|
||||
|
||||
@Source("user_edit.png")
|
||||
ImageResource editUser();
|
||||
|
||||
// derived from resultset_next.png
|
||||
@Source("resultset_down_gray.png")
|
||||
ImageResource arrowDown();
|
||||
|
||||
// derived from resultset_next.png
|
||||
@Source("resultset_next_gray.png")
|
||||
ImageResource arrowRight();
|
||||
|
||||
// derived from resultset_next.png
|
||||
@Source("resultset_up_gray.png")
|
||||
ImageResource arrowUp();
|
||||
|
||||
@Source("lightbulb.png")
|
||||
ImageResource blame();
|
||||
|
||||
@Source("page_white_put.png")
|
||||
ImageResource downloadIcon();
|
||||
|
||||
// derived from comment.png
|
||||
@Source("comment_draft.png")
|
||||
ImageResource draftComments();
|
||||
|
||||
@Source("page_edit.png")
|
||||
ImageResource edit();
|
||||
|
||||
@Source("arrow_undo.png")
|
||||
ImageResource editUndo();
|
||||
|
||||
@Source("cog.png")
|
||||
ImageResource gear();
|
||||
|
||||
@Source("tick.png")
|
||||
ImageResource greenCheck();
|
||||
|
||||
@Source("tag_blue.png")
|
||||
ImageResource hashtag();
|
||||
|
||||
@Source("lightbulb.png")
|
||||
ImageResource info();
|
||||
|
||||
@Source("find.png")
|
||||
ImageResource queryIcon();
|
||||
|
||||
@Source("lock.png")
|
||||
ImageResource readOnly();
|
||||
|
||||
@Source("cross.png")
|
||||
ImageResource redNot();
|
||||
|
||||
@Source("disk.png")
|
||||
ImageResource save();
|
||||
|
||||
@Source("star.png")
|
||||
ImageResource starFilled();
|
||||
|
||||
// derived from star.png
|
||||
@Source("star-open.png")
|
||||
ImageResource starOpen();
|
||||
|
||||
@Source("exclamation.png")
|
||||
ImageResource warning();
|
||||
|
||||
@Source("help.png")
|
||||
ImageResource question();
|
||||
|
||||
/** tango icon library (public domain): http://tango.freedesktop.org/Tango_Icon_Library */
|
||||
@Source("goNext.png")
|
||||
ImageResource goNext();
|
||||
|
||||
@Source("goPrev.png")
|
||||
ImageResource goPrev();
|
||||
|
||||
@Source("goUp.png")
|
||||
ImageResource goUp();
|
||||
|
||||
@Source("listAdd.png")
|
||||
ImageResource listAdd();
|
||||
|
||||
// derived from important.png
|
||||
@Source("merge.png")
|
||||
ImageResource merge();
|
||||
|
||||
/** contributed by the artist under Apache2.0 */
|
||||
@Source("sideBySideDiff.png")
|
||||
ImageResource sideBySideDiff();
|
||||
|
||||
@Source("unifiedDiff.png")
|
||||
ImageResource unifiedDiff();
|
||||
|
||||
/** contributed by the artist under CC-BY3.0 */
|
||||
@Source("diffy26.png")
|
||||
ImageResource gerritAvatar26();
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class AccountInfo extends JavaScriptObject {
|
||||
public final native int _accountId() /*-{ return this._account_id || 0; }-*/;
|
||||
|
||||
public final native String name() /*-{ return this.name; }-*/;
|
||||
|
||||
public final native String email() /*-{ return this.email; }-*/;
|
||||
|
||||
public final native JsArrayString secondaryEmails() /*-{ return this.secondary_emails; }-*/;
|
||||
|
||||
public final native String username() /*-{ return this.username; }-*/;
|
||||
|
||||
public final Timestamp registeredOn() {
|
||||
Timestamp ts = _getRegisteredOn();
|
||||
if (ts == null) {
|
||||
ts = JavaSqlTimestamp_JsonSerializer.parseTimestamp(registeredOnRaw());
|
||||
_setRegisteredOn(ts);
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
private native String registeredOnRaw() /*-{ return this.registered_on; }-*/;
|
||||
|
||||
private native Timestamp _getRegisteredOn() /*-{ return this._cts; }-*/;
|
||||
|
||||
private native void _setRegisteredOn(Timestamp ts) /*-{ this._cts = ts; }-*/;
|
||||
|
||||
/**
|
||||
* @return true if the server supplied avatar information about this account. The information may
|
||||
* be an empty list, indicating no avatars are available, such as when no plugin is installed.
|
||||
* This method returns false if the server did not check on avatars for the account.
|
||||
*/
|
||||
public final native boolean hasAvatarInfo() /*-{ return this.hasOwnProperty('avatars') }-*/;
|
||||
|
||||
public final AvatarInfo avatar(int sz) {
|
||||
JsArray<AvatarInfo> a = avatars();
|
||||
for (int i = 0; a != null && i < a.length(); i++) {
|
||||
AvatarInfo r = a.get(i);
|
||||
if (r.height() == sz) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private native JsArray<AvatarInfo> avatars() /*-{ return this.avatars }-*/;
|
||||
|
||||
public final native void name(String n) /*-{ this.name = n }-*/;
|
||||
|
||||
public final native void email(String e) /*-{ this.email = e }-*/;
|
||||
|
||||
public final native void username(String n) /*-{ this.username = n }-*/;
|
||||
|
||||
public static native AccountInfo create(int id, String name, String email, String username) /*-{
|
||||
return {'_account_id': id, 'name': name, 'email': email,
|
||||
'username': username};
|
||||
}-*/;
|
||||
|
||||
protected AccountInfo() {}
|
||||
|
||||
public static class AvatarInfo extends JavaScriptObject {
|
||||
public static final int DEFAULT_SIZE = 26;
|
||||
|
||||
public final native String url() /*-{ return this.url }-*/;
|
||||
|
||||
public final native int height() /*-{ return this.height || 0 }-*/;
|
||||
|
||||
public final native int width() /*-{ return this.width || 0 }-*/;
|
||||
|
||||
protected AvatarInfo() {}
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
public class ActionInfo extends JavaScriptObject {
|
||||
|
||||
public final native String id() /*-{ return this.id; }-*/;
|
||||
|
||||
public final native String method() /*-{ return this.method; }-*/;
|
||||
|
||||
public final native String label() /*-{ return this.label; }-*/;
|
||||
|
||||
public final native String title() /*-{ return this.title; }-*/;
|
||||
|
||||
public final native boolean enabled() /*-{ return this.enabled || false; }-*/;
|
||||
|
||||
protected ActionInfo() {}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
public class AgreementInfo extends JavaScriptObject {
|
||||
public final native String name() /*-{ return this.name; }-*/;
|
||||
|
||||
public final native String description() /*-{ return this.description; }-*/;
|
||||
|
||||
public final native String url() /*-{ return this.url; }-*/;
|
||||
|
||||
public final native GroupInfo autoVerifyGroup() /*-{ return this.auto_verify_group; }-*/;
|
||||
|
||||
protected AgreementInfo() {}
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.extensions.client.AccountFieldName;
|
||||
import com.google.gerrit.extensions.client.AuthType;
|
||||
import com.google.gerrit.extensions.client.GitBasicAuthPolicy;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AuthInfo extends JavaScriptObject {
|
||||
public final AuthType authType() {
|
||||
return AuthType.valueOf(authTypeRaw());
|
||||
}
|
||||
|
||||
public final boolean isLdap() {
|
||||
return authType() == AuthType.LDAP || authType() == AuthType.LDAP_BIND;
|
||||
}
|
||||
|
||||
public final boolean isOpenId() {
|
||||
return authType() == AuthType.OPENID;
|
||||
}
|
||||
|
||||
public final boolean isOAuth() {
|
||||
return authType() == AuthType.OAUTH;
|
||||
}
|
||||
|
||||
public final boolean isDev() {
|
||||
return authType() == AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT;
|
||||
}
|
||||
|
||||
public final boolean isClientSslCertLdap() {
|
||||
return authType() == AuthType.CLIENT_SSL_CERT_LDAP;
|
||||
}
|
||||
|
||||
public final boolean isCustomExtension() {
|
||||
return authType() == AuthType.CUSTOM_EXTENSION;
|
||||
}
|
||||
|
||||
public final boolean canEdit(AccountFieldName f) {
|
||||
return editableAccountFields().contains(f);
|
||||
}
|
||||
|
||||
public final List<AccountFieldName> editableAccountFields() {
|
||||
List<AccountFieldName> fields = new ArrayList<>();
|
||||
for (String f : Natives.asList(_editableAccountFields())) {
|
||||
fields.add(AccountFieldName.valueOf(f));
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
public final List<AgreementInfo> contributorAgreements() {
|
||||
List<AgreementInfo> agreements = new ArrayList<>();
|
||||
JsArray<AgreementInfo> contributorAgreements = _contributorAgreements();
|
||||
if (contributorAgreements != null) {
|
||||
agreements.addAll(Natives.asList(contributorAgreements));
|
||||
}
|
||||
return agreements;
|
||||
}
|
||||
|
||||
public final boolean siteHasUsernames() {
|
||||
if (isCustomExtension() && httpPasswordUrl() != null && !canEdit(AccountFieldName.USER_NAME)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public final boolean isHttpPasswordSettingsEnabled() {
|
||||
return gitBasicAuthPolicy() == GitBasicAuthPolicy.HTTP
|
||||
|| gitBasicAuthPolicy() == GitBasicAuthPolicy.HTTP_LDAP;
|
||||
}
|
||||
|
||||
public final GitBasicAuthPolicy gitBasicAuthPolicy() {
|
||||
return GitBasicAuthPolicy.valueOf(gitBasicAuthPolicyRaw());
|
||||
}
|
||||
|
||||
public final native boolean useContributorAgreements()
|
||||
/*-{ return this.use_contributor_agreements || false; }-*/ ;
|
||||
|
||||
public final native String loginUrl() /*-{ return this.login_url; }-*/;
|
||||
|
||||
public final native String loginText() /*-{ return this.login_text; }-*/;
|
||||
|
||||
public final native String switchAccountUrl() /*-{ return this.switch_account_url; }-*/;
|
||||
|
||||
public final native String registerUrl() /*-{ return this.register_url; }-*/;
|
||||
|
||||
public final native String registerText() /*-{ return this.register_text; }-*/;
|
||||
|
||||
public final native String editFullNameUrl() /*-{ return this.edit_full_name_url; }-*/;
|
||||
|
||||
public final native String httpPasswordUrl() /*-{ return this.http_password_url; }-*/;
|
||||
|
||||
private native String gitBasicAuthPolicyRaw() /*-{ return this.git_basic_auth_policy; }-*/;
|
||||
|
||||
private native String authTypeRaw() /*-{ return this.auth_type; }-*/;
|
||||
|
||||
private native JsArrayString _editableAccountFields()
|
||||
/*-{ return this.editable_account_fields; }-*/ ;
|
||||
|
||||
private native JsArray<AgreementInfo> _contributorAgreements()
|
||||
/*-{ return this.contributor_agreements; }-*/ ;
|
||||
|
||||
protected AuthInfo() {}
|
||||
}
|
@ -1,575 +0,0 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import static java.util.Comparator.comparing;
|
||||
|
||||
import com.google.gerrit.client.rpc.NativeMap;
|
||||
import com.google.gerrit.client.rpc.NativeString;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class ChangeInfo extends JavaScriptObject {
|
||||
public final void init() {
|
||||
if (allLabels() != null) {
|
||||
allLabels().copyKeysIntoChildren("_name");
|
||||
}
|
||||
}
|
||||
|
||||
public final Project.NameKey projectNameKey() {
|
||||
return new Project.NameKey(project());
|
||||
}
|
||||
|
||||
public final Change.Id legacyId() {
|
||||
return new Change.Id(_number());
|
||||
}
|
||||
|
||||
public final Timestamp created() {
|
||||
Timestamp ts = _getCts();
|
||||
if (ts == null) {
|
||||
ts = JavaSqlTimestamp_JsonSerializer.parseTimestamp(createdRaw());
|
||||
_setCts(ts);
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
||||
public final boolean hasEditBasedOnCurrentPatchSet() {
|
||||
JsArray<RevisionInfo> revList = revisions().values();
|
||||
RevisionInfo.sortRevisionInfoByNumber(revList);
|
||||
return revList.get(revList.length() - 1).isEdit();
|
||||
}
|
||||
|
||||
private native Timestamp _getCts() /*-{ return this._cts; }-*/;
|
||||
|
||||
private native void _setCts(Timestamp ts) /*-{ this._cts = ts; }-*/;
|
||||
|
||||
public final Timestamp updated() {
|
||||
return JavaSqlTimestamp_JsonSerializer.parseTimestamp(updatedRaw());
|
||||
}
|
||||
|
||||
public final Timestamp submitted() {
|
||||
return JavaSqlTimestamp_JsonSerializer.parseTimestamp(submittedRaw());
|
||||
}
|
||||
|
||||
public final String idAbbreviated() {
|
||||
return new Change.Key(changeId()).abbreviate();
|
||||
}
|
||||
|
||||
public final Change.Status status() {
|
||||
return Change.Status.valueOf(statusRaw());
|
||||
}
|
||||
|
||||
public final Set<String> labels() {
|
||||
return allLabels().keySet();
|
||||
}
|
||||
|
||||
public final Set<Integer> removableReviewerIds() {
|
||||
Set<Integer> removable = new HashSet<>();
|
||||
if (removableReviewers() != null) {
|
||||
for (AccountInfo a : Natives.asList(removableReviewers())) {
|
||||
removable.add(a._accountId());
|
||||
}
|
||||
}
|
||||
return removable;
|
||||
}
|
||||
|
||||
public final native String id() /*-{ return this.id; }-*/;
|
||||
|
||||
public final native String project() /*-{ return this.project; }-*/;
|
||||
|
||||
public final native String branch() /*-{ return this.branch; }-*/;
|
||||
|
||||
public final native String topic() /*-{ return this.topic; }-*/;
|
||||
|
||||
public final native String changeId() /*-{ return this.change_id; }-*/;
|
||||
|
||||
public final native boolean mergeable() /*-{ return this.mergeable ? true : false; }-*/;
|
||||
|
||||
public final native int insertions() /*-{ return this.insertions; }-*/;
|
||||
|
||||
public final native int deletions() /*-{ return this.deletions; }-*/;
|
||||
|
||||
private native String statusRaw() /*-{ return this.status; }-*/;
|
||||
|
||||
public final native String subject() /*-{ return this.subject; }-*/;
|
||||
|
||||
public final native AccountInfo owner() /*-{ return this.owner; }-*/;
|
||||
|
||||
public final native AccountInfo assignee() /*-{ return this.assignee; }-*/;
|
||||
|
||||
private native String createdRaw() /*-{ return this.created; }-*/;
|
||||
|
||||
private native String updatedRaw() /*-{ return this.updated; }-*/;
|
||||
|
||||
private native String submittedRaw() /*-{ return this.submitted; }-*/;
|
||||
|
||||
public final native AccountInfo submitter() /*-{ return this.submitter; }-*/;
|
||||
|
||||
public final native boolean starred() /*-{ return this.starred ? true : false; }-*/;
|
||||
|
||||
public final native boolean reviewed() /*-{ return this.reviewed ? true : false; }-*/;
|
||||
|
||||
public final native boolean isPrivate() /*-{ return this.is_private ? true : false; }-*/;
|
||||
|
||||
public final native boolean
|
||||
isWorkInProgress() /*-{ return this.work_in_progress ? true : false; }-*/;
|
||||
|
||||
public final native NativeMap<LabelInfo> allLabels() /*-{ return this.labels; }-*/;
|
||||
|
||||
public final native LabelInfo label(String n) /*-{ return this.labels[n]; }-*/;
|
||||
|
||||
public final native String currentRevision() /*-{ return this.current_revision; }-*/;
|
||||
|
||||
public final native void setCurrentRevision(String r) /*-{ this.current_revision = r; }-*/;
|
||||
|
||||
public final native NativeMap<RevisionInfo> revisions() /*-{ return this.revisions; }-*/;
|
||||
|
||||
public final native RevisionInfo revision(String n) /*-{ return this.revisions[n]; }-*/;
|
||||
|
||||
public final native JsArray<MessageInfo> messages() /*-{ return this.messages; }-*/;
|
||||
|
||||
public final native void setEdit(EditInfo edit) /*-{ this.edit = edit; }-*/;
|
||||
|
||||
public final native EditInfo edit() /*-{ return this.edit; }-*/;
|
||||
|
||||
public final native boolean hasEdit() /*-{ return this.hasOwnProperty('edit') }-*/;
|
||||
|
||||
public final native JsArrayString hashtags() /*-{ return this.hashtags; }-*/;
|
||||
|
||||
public final native boolean hasPermittedLabels()
|
||||
/*-{ return this.hasOwnProperty('permitted_labels') }-*/ ;
|
||||
|
||||
public final native NativeMap<JsArrayString> permittedLabels()
|
||||
/*-{ return this.permitted_labels; }-*/ ;
|
||||
|
||||
public final native JsArrayString permittedValues(String n)
|
||||
/*-{ return this.permitted_labels[n]; }-*/ ;
|
||||
|
||||
public final native JsArray<AccountInfo> removableReviewers()
|
||||
/*-{ return this.removable_reviewers; }-*/ ;
|
||||
|
||||
private native NativeMap<JsArray<AccountInfo>> _reviewers() /*-{ return this.reviewers; }-*/;
|
||||
|
||||
public final Map<ReviewerState, List<AccountInfo>> reviewers() {
|
||||
NativeMap<JsArray<AccountInfo>> reviewers = _reviewers();
|
||||
Map<ReviewerState, List<AccountInfo>> result = new HashMap<>();
|
||||
for (String k : reviewers.keySet()) {
|
||||
ReviewerState state = ReviewerState.valueOf(k.toUpperCase());
|
||||
List<AccountInfo> accounts = result.get(state);
|
||||
if (accounts == null) {
|
||||
accounts = new ArrayList<>();
|
||||
result.put(state, accounts);
|
||||
}
|
||||
accounts.addAll(Natives.asList(reviewers.get(k)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public final native boolean hasActions() /*-{ return this.hasOwnProperty('actions') }-*/;
|
||||
|
||||
public final native NativeMap<ActionInfo> actions() /*-{ return this.actions; }-*/;
|
||||
|
||||
public final native int _number() /*-{ return this._number; }-*/;
|
||||
|
||||
public final native boolean _more_changes() /*-{ return this._more_changes ? true : false; }-*/;
|
||||
|
||||
public final SubmitType submitType() {
|
||||
String submitType = _submitType();
|
||||
if (submitType == null) {
|
||||
return null;
|
||||
}
|
||||
return SubmitType.valueOf(submitType);
|
||||
}
|
||||
|
||||
private native String _submitType() /*-{ return this.submit_type; }-*/;
|
||||
|
||||
public final boolean submittable() {
|
||||
init();
|
||||
return _submittable();
|
||||
}
|
||||
|
||||
private native boolean _submittable() /*-{ return this.submittable ? true : false; }-*/;
|
||||
|
||||
/**
|
||||
* @return the index of the missing label or -1 if no label is missing, or if more than one label
|
||||
* is missing.
|
||||
*/
|
||||
public final int getMissingLabelIndex() {
|
||||
int i = -1;
|
||||
int ret = -1;
|
||||
List<LabelInfo> labels = Natives.asList(allLabels().values());
|
||||
for (LabelInfo label : labels) {
|
||||
i++;
|
||||
if (!permittedLabels().containsKey(label.name())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JsArrayString values = permittedValues(label.name());
|
||||
if (values.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (label.status()) {
|
||||
case NEED: // Label is required for submit.
|
||||
if (ret != -1) {
|
||||
// more than one label is missing, so it's unclear which to quick
|
||||
// approve, return -1
|
||||
return -1;
|
||||
}
|
||||
ret = i;
|
||||
continue;
|
||||
|
||||
case OK: // Label already applied.
|
||||
case MAY: // Label is not required.
|
||||
continue;
|
||||
|
||||
case REJECT: // Submit cannot happen, do not quick approve.
|
||||
case IMPOSSIBLE:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected ChangeInfo() {}
|
||||
|
||||
public static class LabelInfo extends JavaScriptObject {
|
||||
public final SubmitRecord.Label.Status status() {
|
||||
if (approved() != null) {
|
||||
return SubmitRecord.Label.Status.OK;
|
||||
} else if (rejected() != null) {
|
||||
return SubmitRecord.Label.Status.REJECT;
|
||||
} else if (optional()) {
|
||||
return SubmitRecord.Label.Status.MAY;
|
||||
} else {
|
||||
return SubmitRecord.Label.Status.NEED;
|
||||
}
|
||||
}
|
||||
|
||||
public final native String name() /*-{ return this._name; }-*/;
|
||||
|
||||
public final native AccountInfo approved() /*-{ return this.approved; }-*/;
|
||||
|
||||
public final native AccountInfo rejected() /*-{ return this.rejected; }-*/;
|
||||
|
||||
public final native AccountInfo recommended() /*-{ return this.recommended; }-*/;
|
||||
|
||||
public final native AccountInfo disliked() /*-{ return this.disliked; }-*/;
|
||||
|
||||
public final native JsArray<ApprovalInfo> all() /*-{ return this.all; }-*/;
|
||||
|
||||
public final ApprovalInfo forUser(int user) {
|
||||
JsArray<ApprovalInfo> all = all();
|
||||
for (int i = 0; all != null && i < all.length(); i++) {
|
||||
if (all.get(i)._accountId() == user) {
|
||||
return all.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private native NativeMap<NativeString> _values() /*-{ return this.values; }-*/;
|
||||
|
||||
public final Set<String> values() {
|
||||
return Natives.keys(_values());
|
||||
}
|
||||
|
||||
public final native String valueText(String n) /*-{ return this.values[n]; }-*/;
|
||||
|
||||
public final native boolean optional() /*-{ return this.optional ? true : false; }-*/;
|
||||
|
||||
public final native boolean blocking() /*-{ return this.blocking ? true : false; }-*/;
|
||||
|
||||
public final native short defaultValue() /*-{ return this.default_value; }-*/;
|
||||
|
||||
public final native short _value() /*-{
|
||||
if (this.value) return this.value;
|
||||
if (this.disliked) return -1;
|
||||
if (this.recommended) return 1;
|
||||
return 0;
|
||||
}-*/;
|
||||
|
||||
public final String maxValue() {
|
||||
return LabelValue.formatValue(valueSet().last());
|
||||
}
|
||||
|
||||
public final SortedSet<Short> valueSet() {
|
||||
SortedSet<Short> values = new TreeSet<>();
|
||||
for (String v : values()) {
|
||||
values.add(parseValue(v));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
public static final short parseValue(String formatted) {
|
||||
if (formatted.startsWith("+")) {
|
||||
formatted = formatted.substring(1);
|
||||
} else if (formatted.startsWith(" ")) {
|
||||
formatted = formatted.trim();
|
||||
}
|
||||
return Short.parseShort(formatted);
|
||||
}
|
||||
|
||||
protected LabelInfo() {}
|
||||
}
|
||||
|
||||
public static class ApprovalInfo extends AccountInfo {
|
||||
public final native boolean hasValue() /*-{ return this.hasOwnProperty('value'); }-*/;
|
||||
|
||||
public final native short value() /*-{ return this.value || 0; }-*/;
|
||||
|
||||
public final native VotingRangeInfo
|
||||
permittedVotingRange() /*-{ return this.permitted_voting_range; }-*/;
|
||||
|
||||
protected ApprovalInfo() {}
|
||||
}
|
||||
|
||||
public static class VotingRangeInfo extends AccountInfo {
|
||||
public final native short min() /*-{ return this.min || 0; }-*/;
|
||||
|
||||
public final native short max() /*-{ return this.max || 0; }-*/;
|
||||
|
||||
protected VotingRangeInfo() {}
|
||||
}
|
||||
|
||||
public static class EditInfo extends JavaScriptObject {
|
||||
public final native String name() /*-{ return this.name; }-*/;
|
||||
|
||||
public final native String setName(String n) /*-{ this.name = n; }-*/;
|
||||
|
||||
public final native String baseRevision() /*-{ return this.base_revision; }-*/;
|
||||
|
||||
public final native CommitInfo commit() /*-{ return this.commit; }-*/;
|
||||
|
||||
public final native boolean hasActions() /*-{ return this.hasOwnProperty('actions') }-*/;
|
||||
|
||||
public final native NativeMap<ActionInfo> actions() /*-{ return this.actions; }-*/;
|
||||
|
||||
public final native boolean hasFetch() /*-{ return this.hasOwnProperty('fetch') }-*/;
|
||||
|
||||
public final native NativeMap<FetchInfo> fetch() /*-{ return this.fetch; }-*/;
|
||||
|
||||
public final native boolean hasFiles() /*-{ return this.hasOwnProperty('files') }-*/;
|
||||
|
||||
public final native NativeMap<FileInfo> files() /*-{ return this.files; }-*/;
|
||||
|
||||
protected EditInfo() {}
|
||||
}
|
||||
|
||||
public static class RevisionInfo extends JavaScriptObject {
|
||||
public static RevisionInfo fromEdit(EditInfo edit) {
|
||||
RevisionInfo revisionInfo = createObject().cast();
|
||||
revisionInfo.takeFromEdit(edit);
|
||||
return revisionInfo;
|
||||
}
|
||||
|
||||
public static RevisionInfo forParent(int number, CommitInfo commit) {
|
||||
RevisionInfo revisionInfo = createObject().cast();
|
||||
revisionInfo.takeFromParent(number, commit);
|
||||
return revisionInfo;
|
||||
}
|
||||
|
||||
private native void takeFromEdit(EditInfo edit) /*-{
|
||||
this._number = 0;
|
||||
this.name = edit.name;
|
||||
this.commit = edit.commit;
|
||||
this.edit_base = edit.base_revision;
|
||||
}-*/;
|
||||
|
||||
private native void takeFromParent(int number, CommitInfo commit) /*-{
|
||||
this._number = number;
|
||||
this.commit = commit;
|
||||
this.name = this._number;
|
||||
}-*/;
|
||||
|
||||
public final native int _number() /*-{ return this._number; }-*/;
|
||||
|
||||
public final native String name() /*-{ return this.name; }-*/;
|
||||
|
||||
public final native AccountInfo uploader() /*-{ return this.uploader; }-*/;
|
||||
|
||||
public final native boolean isEdit() /*-{ return this._number == 0; }-*/;
|
||||
|
||||
public final native CommitInfo commit() /*-{ return this.commit; }-*/;
|
||||
|
||||
public final native void setCommit(CommitInfo c) /*-{ this.commit = c; }-*/;
|
||||
|
||||
public final native String editBase() /*-{ return this.edit_base; }-*/;
|
||||
|
||||
public final native boolean hasFiles() /*-{ return this.hasOwnProperty('files') }-*/;
|
||||
|
||||
public final native NativeMap<FileInfo> files() /*-{ return this.files; }-*/;
|
||||
|
||||
public final native boolean hasActions() /*-{ return this.hasOwnProperty('actions') }-*/;
|
||||
|
||||
public final native NativeMap<ActionInfo> actions() /*-{ return this.actions; }-*/;
|
||||
|
||||
public final native boolean hasFetch() /*-{ return this.hasOwnProperty('fetch') }-*/;
|
||||
|
||||
public final native NativeMap<FetchInfo> fetch() /*-{ return this.fetch; }-*/;
|
||||
|
||||
public final native boolean
|
||||
hasPushCertificate() /*-{ return this.hasOwnProperty('push_certificate'); }-*/;
|
||||
|
||||
public final native PushCertificateInfo
|
||||
pushCertificate() /*-{ return this.push_certificate; }-*/;
|
||||
|
||||
public static void sortRevisionInfoByNumber(JsArray<RevisionInfo> list) {
|
||||
final int editParent = findEditParent(list);
|
||||
Natives.asList(list)
|
||||
.sort(comparing(r -> !r.isEdit() ? 2 * (r._number() - 1) + 1 : 2 * editParent));
|
||||
}
|
||||
|
||||
public static int findEditParent(JsArray<RevisionInfo> list) {
|
||||
RevisionInfo r = findEditParentRevision(list);
|
||||
return r == null ? -1 : r._number();
|
||||
}
|
||||
|
||||
public static RevisionInfo findEditParentRevision(JsArray<RevisionInfo> list) {
|
||||
for (int i = 0; i < list.length(); i++) {
|
||||
// edit under revisions?
|
||||
RevisionInfo editInfo = list.get(i);
|
||||
if (editInfo.isEdit()) {
|
||||
String parentRevision = editInfo.editBase();
|
||||
// find parent
|
||||
for (int j = 0; j < list.length(); j++) {
|
||||
RevisionInfo parentInfo = list.get(j);
|
||||
String name = parentInfo.name();
|
||||
if (name.equals(parentRevision)) {
|
||||
// found parent pacth set number
|
||||
return parentInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final String id() {
|
||||
return PatchSet.Id.toId(_number());
|
||||
}
|
||||
|
||||
public final boolean isMerge() {
|
||||
return commit().parents().length() > 1;
|
||||
}
|
||||
|
||||
protected RevisionInfo() {}
|
||||
}
|
||||
|
||||
public static class FetchInfo extends JavaScriptObject {
|
||||
public final native String url() /*-{ return this.url }-*/;
|
||||
|
||||
public final native String ref() /*-{ return this.ref }-*/;
|
||||
|
||||
public final native NativeMap<NativeString> commands() /*-{ return this.commands }-*/;
|
||||
|
||||
public final native String command(String n) /*-{ return this.commands[n]; }-*/;
|
||||
|
||||
protected FetchInfo() {}
|
||||
}
|
||||
|
||||
public static class CommitInfo extends JavaScriptObject {
|
||||
public final native String commit() /*-{ return this.commit; }-*/;
|
||||
|
||||
public final native JsArray<CommitInfo> parents() /*-{ return this.parents; }-*/;
|
||||
|
||||
public final native GitPerson author() /*-{ return this.author; }-*/;
|
||||
|
||||
public final native GitPerson committer() /*-{ return this.committer; }-*/;
|
||||
|
||||
public final native String subject() /*-{ return this.subject; }-*/;
|
||||
|
||||
public final native String message() /*-{ return this.message; }-*/;
|
||||
|
||||
public final native JsArray<WebLinkInfo> webLinks() /*-{ return this.web_links; }-*/;
|
||||
|
||||
protected CommitInfo() {}
|
||||
}
|
||||
|
||||
public static class GitPerson extends JavaScriptObject {
|
||||
public final native String name() /*-{ return this.name; }-*/;
|
||||
|
||||
public final native String email() /*-{ return this.email; }-*/;
|
||||
|
||||
private native String dateRaw() /*-{ return this.date; }-*/;
|
||||
|
||||
public final Timestamp date() {
|
||||
return JavaSqlTimestamp_JsonSerializer.parseTimestamp(dateRaw());
|
||||
}
|
||||
|
||||
protected GitPerson() {}
|
||||
}
|
||||
|
||||
public static class MessageInfo extends JavaScriptObject {
|
||||
public final native AccountInfo author() /*-{ return this.author; }-*/;
|
||||
|
||||
public final native String message() /*-{ return this.message; }-*/;
|
||||
|
||||
public final native int _revisionNumber() /*-{ return this._revision_number || 0; }-*/;
|
||||
|
||||
public final native String tag() /*-{ return this.tag; }-*/;
|
||||
|
||||
private native String dateRaw() /*-{ return this.date; }-*/;
|
||||
|
||||
public final Timestamp date() {
|
||||
return JavaSqlTimestamp_JsonSerializer.parseTimestamp(dateRaw());
|
||||
}
|
||||
|
||||
protected MessageInfo() {}
|
||||
}
|
||||
|
||||
public static class MergeableInfo extends JavaScriptObject {
|
||||
public final native String submitType() /*-{ return this.submit_type }-*/;
|
||||
|
||||
public final native boolean mergeable() /*-{ return this.mergeable }-*/;
|
||||
|
||||
protected MergeableInfo() {}
|
||||
}
|
||||
|
||||
public static class IncludedInInfo extends JavaScriptObject {
|
||||
public final Set<String> externalNames() {
|
||||
return Natives.keys(external());
|
||||
}
|
||||
|
||||
public final native JsArrayString branches() /*-{ return this.branches; }-*/;
|
||||
|
||||
public final native JsArrayString tags() /*-{ return this.tags; }-*/;
|
||||
|
||||
public final native JsArrayString external(String n) /*-{ return this.external[n]; }-*/;
|
||||
|
||||
private native NativeMap<JsArrayString> external() /*-{ return this.external; }-*/;
|
||||
|
||||
protected IncludedInInfo() {}
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gerrit.client.rpc.NativeMap;
|
||||
import com.google.gerrit.client.rpc.NativeString;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class DownloadInfo extends JavaScriptObject {
|
||||
public final List<String> schemes() {
|
||||
return _schemes().sortedKeys();
|
||||
}
|
||||
|
||||
public final List<String> archives() {
|
||||
List<String> archives = new ArrayList<>();
|
||||
archives.addAll(Natives.asList(_archives()));
|
||||
return archives;
|
||||
}
|
||||
|
||||
public final native DownloadSchemeInfo scheme(String n) /*-{ return this.schemes[n]; }-*/;
|
||||
|
||||
private native NativeMap<DownloadSchemeInfo> _schemes() /*-{ return this.schemes; }-*/;
|
||||
|
||||
private native JsArrayString _archives() /*-{ return this.archives; }-*/;
|
||||
|
||||
protected DownloadInfo() {}
|
||||
|
||||
public static class DownloadSchemeInfo extends JavaScriptObject {
|
||||
public final List<String> commandNames() {
|
||||
return _commands().sortedKeys();
|
||||
}
|
||||
|
||||
public final Set<DownloadCommandInfo> commands(String project) {
|
||||
Set<DownloadCommandInfo> commands = new HashSet<>();
|
||||
for (String commandName : commandNames()) {
|
||||
commands.add(new DownloadCommandInfo(commandName, command(commandName, project)));
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
|
||||
public final String command(String commandName, String project) {
|
||||
return command(commandName).replaceAll("\\$\\{project\\}", project);
|
||||
}
|
||||
|
||||
private static String projectBaseName(String project) {
|
||||
return project.substring(project.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
public final List<String> cloneCommandNames() {
|
||||
return _cloneCommands().sortedKeys();
|
||||
}
|
||||
|
||||
public final List<DownloadCommandInfo> cloneCommands(String project) {
|
||||
List<String> commandNames = cloneCommandNames();
|
||||
List<DownloadCommandInfo> commands = new ArrayList<>(commandNames.size());
|
||||
for (String commandName : commandNames) {
|
||||
commands.add(new DownloadCommandInfo(commandName, cloneCommand(commandName, project)));
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
|
||||
public final String cloneCommand(String commandName, String project) {
|
||||
return cloneCommand(commandName)
|
||||
.replaceAll("\\$\\{project\\}", project)
|
||||
.replaceAll("\\$\\{project-base-name\\}", projectBaseName(project));
|
||||
}
|
||||
|
||||
public final String getUrl(String project) {
|
||||
return url().replaceAll("\\$\\{project\\}", project);
|
||||
}
|
||||
|
||||
public final native String name() /*-{ return this.name; }-*/;
|
||||
|
||||
public final native String url() /*-{ return this.url; }-*/;
|
||||
|
||||
public final native boolean isAuthRequired() /*-{ return this.is_auth_required || false; }-*/;
|
||||
|
||||
public final native boolean isAuthSupported() /*-{ return this.is_auth_supported || false; }-*/;
|
||||
|
||||
public final native String command(String n) /*-{ return this.commands[n]; }-*/;
|
||||
|
||||
public final native String cloneCommand(String n) /*-{ return this.clone_commands[n]; }-*/;
|
||||
|
||||
private native NativeMap<NativeString> _commands() /*-{ return this.commands; }-*/;
|
||||
|
||||
private native NativeMap<NativeString> _cloneCommands() /*-{ return this.clone_commands; }-*/;
|
||||
|
||||
protected DownloadSchemeInfo() {}
|
||||
}
|
||||
|
||||
public static class DownloadCommandInfo {
|
||||
private final String name;
|
||||
private final String command;
|
||||
|
||||
DownloadCommandInfo(String name, String command) {
|
||||
this.name = name;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String command() {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.common.data.FilenameComparator;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class FileInfo extends JavaScriptObject {
|
||||
public final native String path() /*-{ return this.path; }-*/;
|
||||
|
||||
public final native String oldPath() /*-{ return this.old_path; }-*/;
|
||||
|
||||
public final native int linesInserted() /*-{ return this.lines_inserted || 0; }-*/;
|
||||
|
||||
public final native int linesDeleted() /*-{ return this.lines_deleted || 0; }-*/;
|
||||
|
||||
public final native boolean binary() /*-{ return this.binary || false; }-*/;
|
||||
|
||||
public final native String status() /*-{ return this.status; }-*/;
|
||||
|
||||
// JSNI methods cannot have 'long' as a parameter type or a return type and
|
||||
// it's suggested to use double in this case:
|
||||
// http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html#important
|
||||
public final long size() {
|
||||
return (long) _size();
|
||||
}
|
||||
|
||||
private native double _size() /*-{ return this.size || 0; }-*/;
|
||||
|
||||
public final long sizeDelta() {
|
||||
return (long) _sizeDelta();
|
||||
}
|
||||
|
||||
private native double _sizeDelta() /*-{ return this.size_delta || 0; }-*/;
|
||||
|
||||
public final native int _row() /*-{ return this._row }-*/;
|
||||
|
||||
public final native void _row(int r) /*-{ this._row = r }-*/;
|
||||
|
||||
public static void sortFileInfoByPath(JsArray<FileInfo> list) {
|
||||
Natives.asList(list).sort(Comparator.comparing(FileInfo::path, FilenameComparator.INSTANCE));
|
||||
}
|
||||
|
||||
public static String getFileName(String path) {
|
||||
String fileName;
|
||||
if (Patch.COMMIT_MSG.equals(path)) {
|
||||
fileName = "Commit Message";
|
||||
} else if (Patch.MERGE_LIST.equals(path)) {
|
||||
fileName = "Merge List";
|
||||
} else {
|
||||
fileName = path;
|
||||
}
|
||||
|
||||
int s = fileName.lastIndexOf('/');
|
||||
return s >= 0 ? fileName.substring(s + 1) : fileName;
|
||||
}
|
||||
|
||||
protected FileInfo() {}
|
||||
}
|
@ -1,274 +0,0 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gerrit.client.rpc.NativeMap;
|
||||
import com.google.gerrit.client.rpc.NativeString;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DateFormat;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DefaultBase;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DiffView;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DownloadCommand;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailFormat;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.ReviewCategoryStrategy;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.TimeFormat;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GeneralPreferences extends JavaScriptObject {
|
||||
public static GeneralPreferences create() {
|
||||
return createObject().cast();
|
||||
}
|
||||
|
||||
public static GeneralPreferences createDefault() {
|
||||
GeneralPreferencesInfo d = GeneralPreferencesInfo.defaults();
|
||||
GeneralPreferences p = createObject().cast();
|
||||
p.changesPerPage(d.changesPerPage);
|
||||
p.showSiteHeader(d.showSiteHeader);
|
||||
p.useFlashClipboard(d.useFlashClipboard);
|
||||
p.downloadScheme(d.downloadScheme);
|
||||
p.downloadCommand(d.downloadCommand);
|
||||
p.dateFormat(d.getDateFormat());
|
||||
p.timeFormat(d.getTimeFormat());
|
||||
p.highlightAssigneeInChangeTable(d.highlightAssigneeInChangeTable);
|
||||
p.relativeDateInChangeTable(d.relativeDateInChangeTable);
|
||||
p.sizeBarInChangeTable(d.sizeBarInChangeTable);
|
||||
p.legacycidInChangeTable(d.legacycidInChangeTable);
|
||||
p.muteCommonPathPrefixes(d.muteCommonPathPrefixes);
|
||||
p.signedOffBy(d.signedOffBy);
|
||||
p.emailFormat(d.emailFormat);
|
||||
p.reviewCategoryStrategy(d.getReviewCategoryStrategy());
|
||||
p.diffView(d.getDiffView());
|
||||
p.emailStrategy(d.emailStrategy);
|
||||
p.defaultBaseForMerges(d.defaultBaseForMerges);
|
||||
return p;
|
||||
}
|
||||
|
||||
public final int changesPerPage() {
|
||||
int changesPerPage = get("changes_per_page", GeneralPreferencesInfo.DEFAULT_PAGESIZE);
|
||||
return 0 < changesPerPage ? changesPerPage : GeneralPreferencesInfo.DEFAULT_PAGESIZE;
|
||||
}
|
||||
|
||||
private native short get(String n, int d) /*-{ return this.hasOwnProperty(n) ? this[n] : d }-*/;
|
||||
|
||||
public final native boolean showSiteHeader() /*-{ return this.show_site_header || false }-*/;
|
||||
|
||||
public final native boolean useFlashClipboard()
|
||||
/*-{ return this.use_flash_clipboard || false }-*/ ;
|
||||
|
||||
public final native String downloadScheme() /*-{ return this.download_scheme }-*/;
|
||||
|
||||
public final DownloadCommand downloadCommand() {
|
||||
String s = downloadCommandRaw();
|
||||
return s != null ? DownloadCommand.valueOf(s) : null;
|
||||
}
|
||||
|
||||
private native String downloadCommandRaw() /*-{ return this.download_command }-*/;
|
||||
|
||||
public final DateFormat dateFormat() {
|
||||
String s = dateFormatRaw();
|
||||
return s != null ? DateFormat.valueOf(s) : null;
|
||||
}
|
||||
|
||||
private native String dateFormatRaw() /*-{ return this.date_format }-*/;
|
||||
|
||||
public final TimeFormat timeFormat() {
|
||||
String s = timeFormatRaw();
|
||||
return s != null ? TimeFormat.valueOf(s) : null;
|
||||
}
|
||||
|
||||
private native String timeFormatRaw() /*-{ return this.time_format }-*/;
|
||||
|
||||
public final native boolean highlightAssigneeInChangeTable()
|
||||
/*-{ return this.highlight_assignee_in_change_table || false }-*/ ;
|
||||
|
||||
public final native boolean relativeDateInChangeTable()
|
||||
/*-{ return this.relative_date_in_change_table || false }-*/ ;
|
||||
|
||||
public final native boolean sizeBarInChangeTable()
|
||||
/*-{ return this.size_bar_in_change_table || false }-*/ ;
|
||||
|
||||
public final native boolean legacycidInChangeTable()
|
||||
/*-{ return this.legacycid_in_change_table || false }-*/ ;
|
||||
|
||||
public final native boolean muteCommonPathPrefixes()
|
||||
/*-{ return this.mute_common_path_prefixes || false }-*/ ;
|
||||
|
||||
public final native boolean signedOffBy() /*-{ return this.signed_off_by || false }-*/;
|
||||
|
||||
public final ReviewCategoryStrategy reviewCategoryStrategy() {
|
||||
String s = reviewCategeoryStrategyRaw();
|
||||
return s != null ? ReviewCategoryStrategy.valueOf(s) : ReviewCategoryStrategy.NONE;
|
||||
}
|
||||
|
||||
private native String reviewCategeoryStrategyRaw() /*-{ return this.review_category_strategy }-*/;
|
||||
|
||||
public final DiffView diffView() {
|
||||
String s = diffViewRaw();
|
||||
return s != null ? DiffView.valueOf(s) : null;
|
||||
}
|
||||
|
||||
private native String diffViewRaw() /*-{ return this.diff_view }-*/;
|
||||
|
||||
public final EmailStrategy emailStrategy() {
|
||||
String s = emailStrategyRaw();
|
||||
return s != null ? EmailStrategy.valueOf(s) : null;
|
||||
}
|
||||
|
||||
private native String emailStrategyRaw() /*-{ return this.email_strategy }-*/;
|
||||
|
||||
public final EmailFormat emailFormat() {
|
||||
String s = emailFormatRaw();
|
||||
return s != null ? EmailFormat.valueOf(s) : null;
|
||||
}
|
||||
|
||||
private native String emailFormatRaw() /*-{ return this.email_format }-*/;
|
||||
|
||||
public final DefaultBase defaultBaseForMerges() {
|
||||
String s = defaultBaseForMergesRaw();
|
||||
return s != null ? DefaultBase.valueOf(s) : null;
|
||||
}
|
||||
|
||||
private native String defaultBaseForMergesRaw() /*-{ return this.default_base_for_merges }-*/;
|
||||
|
||||
public final native boolean
|
||||
publishCommentsOnPush() /*-{ return this.publish_comments_on_push || false }-*/;
|
||||
|
||||
public final native boolean
|
||||
workInProgressByDefault() /*-{ return this.work_in_progress_by_default || false }-*/;
|
||||
|
||||
public final native JsArray<TopMenuItem> my() /*-{ return this.my; }-*/;
|
||||
|
||||
public final native void changesPerPage(int n) /*-{ this.changes_per_page = n }-*/;
|
||||
|
||||
public final native void showSiteHeader(boolean s) /*-{ this.show_site_header = s }-*/;
|
||||
|
||||
public final native void useFlashClipboard(boolean u) /*-{ this.use_flash_clipboard = u }-*/;
|
||||
|
||||
public final native void downloadScheme(String d) /*-{ this.download_scheme = d }-*/;
|
||||
|
||||
public final void downloadCommand(DownloadCommand d) {
|
||||
downloadCommandRaw(d != null ? d.toString() : null);
|
||||
}
|
||||
|
||||
public final native void downloadCommandRaw(String d) /*-{ this.download_command = d }-*/;
|
||||
|
||||
public final void dateFormat(DateFormat f) {
|
||||
dateFormatRaw(f != null ? f.toString() : null);
|
||||
}
|
||||
|
||||
private native void dateFormatRaw(String f) /*-{ this.date_format = f }-*/;
|
||||
|
||||
public final void timeFormat(TimeFormat f) {
|
||||
timeFormatRaw(f != null ? f.toString() : null);
|
||||
}
|
||||
|
||||
private native void timeFormatRaw(String f) /*-{ this.time_format = f }-*/;
|
||||
|
||||
public final native void highlightAssigneeInChangeTable(boolean d)
|
||||
/*-{ this.highlight_assignee_in_change_table = d }-*/ ;
|
||||
|
||||
public final native void relativeDateInChangeTable(boolean d)
|
||||
/*-{ this.relative_date_in_change_table = d }-*/ ;
|
||||
|
||||
public final native void sizeBarInChangeTable(boolean s)
|
||||
/*-{ this.size_bar_in_change_table = s }-*/ ;
|
||||
|
||||
public final native void legacycidInChangeTable(boolean s)
|
||||
/*-{ this.legacycid_in_change_table = s }-*/ ;
|
||||
|
||||
public final native void muteCommonPathPrefixes(boolean s)
|
||||
/*-{ this.mute_common_path_prefixes = s }-*/ ;
|
||||
|
||||
public final native void signedOffBy(boolean s) /*-{ this.signed_off_by = s }-*/;
|
||||
|
||||
public final void reviewCategoryStrategy(ReviewCategoryStrategy s) {
|
||||
reviewCategoryStrategyRaw(s != null ? s.toString() : null);
|
||||
}
|
||||
|
||||
private native void reviewCategoryStrategyRaw(String s)
|
||||
/*-{ this.review_category_strategy = s }-*/ ;
|
||||
|
||||
public final void diffView(DiffView d) {
|
||||
diffViewRaw(d != null ? d.toString() : null);
|
||||
}
|
||||
|
||||
private native void diffViewRaw(String d) /*-{ this.diff_view = d }-*/;
|
||||
|
||||
public final void emailStrategy(EmailStrategy s) {
|
||||
emailStrategyRaw(s != null ? s.toString() : null);
|
||||
}
|
||||
|
||||
private native void emailStrategyRaw(String s) /*-{ this.email_strategy = s }-*/;
|
||||
|
||||
public final void emailFormat(EmailFormat f) {
|
||||
emailFormatRaw(f != null ? f.toString() : null);
|
||||
}
|
||||
|
||||
private native void emailFormatRaw(String s) /*-{ this.email_format = s }-*/;
|
||||
|
||||
public final void defaultBaseForMerges(DefaultBase b) {
|
||||
defaultBaseForMergesRaw(b != null ? b.toString() : null);
|
||||
}
|
||||
|
||||
private native void defaultBaseForMergesRaw(String b) /*-{ this.default_base_for_merges = b }-*/;
|
||||
|
||||
public final native void publishCommentsOnPush(
|
||||
boolean p) /*-{ this.publish_comments_on_push = p }-*/;
|
||||
|
||||
public final native void workInProgressByDefault(
|
||||
boolean p) /*-{ this.work_in_progress_by_default = p }-*/;
|
||||
|
||||
public final void setMyMenus(List<TopMenuItem> myMenus) {
|
||||
initMy();
|
||||
for (TopMenuItem n : myMenus) {
|
||||
addMy(n);
|
||||
}
|
||||
}
|
||||
|
||||
final native void initMy() /*-{ this.my = []; }-*/;
|
||||
|
||||
final native void addMy(TopMenuItem m) /*-{ this.my.push(m); }-*/;
|
||||
|
||||
public final Map<String, String> urlAliases() {
|
||||
Map<String, String> urlAliases = new HashMap<>();
|
||||
for (String k : Natives.keys(_urlAliases())) {
|
||||
urlAliases.put(k, urlAliasToken(k));
|
||||
}
|
||||
return urlAliases;
|
||||
}
|
||||
|
||||
private native String urlAliasToken(String m) /*-{ return this.url_aliases[m]; }-*/;
|
||||
|
||||
private native NativeMap<NativeString> _urlAliases() /*-{ return this.url_aliases; }-*/;
|
||||
|
||||
public final void setUrlAliases(Map<String, String> urlAliases) {
|
||||
initUrlAliases();
|
||||
for (Map.Entry<String, String> e : urlAliases.entrySet()) {
|
||||
putUrlAlias(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private native void putUrlAlias(String m, String t) /*-{ this.url_aliases[m] = t; }-*/;
|
||||
|
||||
private native void initUrlAliases() /*-{ this.url_aliases = {}; }-*/;
|
||||
|
||||
protected GeneralPreferences() {}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gerrit.extensions.client.UiType;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GerritInfo extends JavaScriptObject {
|
||||
public final Project.NameKey allProjectsNameKey() {
|
||||
return new Project.NameKey(allProjects());
|
||||
}
|
||||
|
||||
public final boolean isAllProjects(Project.NameKey p) {
|
||||
return allProjectsNameKey().equals(p);
|
||||
}
|
||||
|
||||
public final Project.NameKey allUsersNameKey() {
|
||||
return new Project.NameKey(allUsers());
|
||||
}
|
||||
|
||||
public final boolean isAllUsers(Project.NameKey p) {
|
||||
return allUsersNameKey().equals(p);
|
||||
}
|
||||
|
||||
public final native String allProjects() /*-{ return this.all_projects; }-*/;
|
||||
|
||||
public final native String allUsers() /*-{ return this.all_users; }-*/;
|
||||
|
||||
public final native boolean docSearch() /*-{ return this.doc_search; }-*/;
|
||||
|
||||
public final native String docUrl() /*-{ return this.doc_url; }-*/;
|
||||
|
||||
public final native boolean editGpgKeys() /*-{ return this.edit_gpg_keys || false; }-*/;
|
||||
|
||||
public final native String reportBugUrl() /*-{ return this.report_bug_url; }-*/;
|
||||
|
||||
public final native String reportBugText() /*-{ return this.report_bug_text; }-*/;
|
||||
|
||||
private native JsArrayString _webUis() /*-{ return this.web_uis; }-*/;
|
||||
|
||||
public final List<UiType> webUis() {
|
||||
JsArrayString webUis = _webUis();
|
||||
List<UiType> result = new ArrayList<>(webUis.length());
|
||||
for (int i = 0; i < webUis.length(); i++) {
|
||||
UiType t = UiType.parse(webUis.get(i));
|
||||
if (t != null) {
|
||||
result.add(t);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected GerritInfo() {}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
|
||||
public class GpgKeyInfo extends JavaScriptObject {
|
||||
public enum Status {
|
||||
BAD,
|
||||
OK,
|
||||
TRUSTED;
|
||||
}
|
||||
|
||||
public final native String id() /*-{ return this.id; }-*/;
|
||||
|
||||
public final native String fingerprint() /*-{ return this.fingerprint; }-*/;
|
||||
|
||||
public final native JsArrayString userIds() /*-{ return this.user_ids; }-*/;
|
||||
|
||||
public final native String key() /*-{ return this.key; }-*/;
|
||||
|
||||
private native String statusRaw() /*-{ return this.status; }-*/;
|
||||
|
||||
public final Status status() {
|
||||
String s = statusRaw();
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
return Status.valueOf(s);
|
||||
}
|
||||
|
||||
public final native boolean hasProblems() /*-{ return this.hasOwnProperty('problems'); }-*/;
|
||||
|
||||
public final native JsArrayString problems() /*-{ return this.problems; }-*/;
|
||||
|
||||
protected GpgKeyInfo() {}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.http.client.URL;
|
||||
|
||||
public class GroupBaseInfo extends JavaScriptObject {
|
||||
public final AccountGroup.UUID getGroupUUID() {
|
||||
return new AccountGroup.UUID(URL.decodeQueryString(id()));
|
||||
}
|
||||
|
||||
public final native String id() /*-{ return this.id; }-*/;
|
||||
|
||||
public final native String name() /*-{ return this.name; }-*/;
|
||||
|
||||
protected GroupBaseInfo() {}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import com.google.gwt.http.client.URL;
|
||||
|
||||
public class GroupInfo extends GroupBaseInfo {
|
||||
public final AccountGroup.Id getGroupId() {
|
||||
return new AccountGroup.Id(group_id());
|
||||
}
|
||||
|
||||
public final native GroupOptionsInfo options() /*-{ return this.options; }-*/;
|
||||
|
||||
public final native String description() /*-{ return this.description; }-*/;
|
||||
|
||||
public final native String url() /*-{ return this.url; }-*/;
|
||||
|
||||
public final native String owner() /*-{ return this.owner; }-*/;
|
||||
|
||||
public final native void owner(String o) /*-{ if(o)this.owner=o; }-*/;
|
||||
|
||||
public final native JsArray<AccountInfo> members() /*-{ return this.members; }-*/;
|
||||
|
||||
public final native JsArray<GroupInfo> includes() /*-{ return this.includes; }-*/;
|
||||
|
||||
private native int group_id() /*-{ return this.group_id; }-*/;
|
||||
|
||||
private native String owner_id() /*-{ return this.owner_id; }-*/;
|
||||
|
||||
private native void owner_id(String o) /*-{ if(o)this.owner_id=o; }-*/;
|
||||
|
||||
public final AccountGroup.UUID getOwnerUUID() {
|
||||
String owner = owner_id();
|
||||
if (owner != null) {
|
||||
return new AccountGroup.UUID(URL.decodeQueryString(owner));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void setOwnerUUID(AccountGroup.UUID uuid) {
|
||||
owner_id(URL.encodeQueryString(uuid.get()));
|
||||
}
|
||||
|
||||
protected GroupInfo() {}
|
||||
|
||||
public static class GroupOptionsInfo extends JavaScriptObject {
|
||||
public final native boolean
|
||||
isVisibleToAll() /*-{ return this['visible_to_all'] ? true : false; }-*/;
|
||||
|
||||
protected GroupOptionsInfo() {}
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
public class OAuthTokenInfo extends JavaScriptObject {
|
||||
|
||||
protected OAuthTokenInfo() {}
|
||||
|
||||
public final native String username() /*-{ return this.username; }-*/;
|
||||
|
||||
public final native String resourceHost() /*-{ return this.resource_host; }-*/;
|
||||
|
||||
public final native String accessToken() /*-{ return this.access_token; }-*/;
|
||||
|
||||
public final native String providerId() /*-{ return this.provider_id; }-*/;
|
||||
|
||||
public final native String expiresAt() /*-{ return this.expires_at; }-*/;
|
||||
|
||||
public final native String type() /*-{ return this.type; }-*/;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
public class PushCertificateInfo extends JavaScriptObject {
|
||||
public final native String certificate() /*-{ return this.certificate; }-*/;
|
||||
|
||||
public final native GpgKeyInfo key() /*-{ return this.key; }-*/;
|
||||
|
||||
protected PushCertificateInfo() {}
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gerrit.client.rpc.NativeMap;
|
||||
import com.google.gerrit.client.rpc.NativeString;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ServerInfo extends JavaScriptObject {
|
||||
public final native AuthInfo auth() /*-{ return this.auth; }-*/;
|
||||
|
||||
public final native ChangeConfigInfo change() /*-{ return this.change; }-*/;
|
||||
|
||||
public final native DownloadInfo download() /*-{ return this.download; }-*/;
|
||||
|
||||
public final native GerritInfo gerrit() /*-{ return this.gerrit; }-*/;
|
||||
|
||||
public final native PluginConfigInfo plugin() /*-{ return this.plugin; }-*/;
|
||||
|
||||
public final native SshdInfo sshd() /*-{ return this.sshd; }-*/;
|
||||
|
||||
public final native SuggestInfo suggest() /*-{ return this.suggest; }-*/;
|
||||
|
||||
public final native UserConfigInfo user() /*-{ return this.user; }-*/;
|
||||
|
||||
public final native ReceiveInfo receive() /*-{ return this.receive; }-*/;
|
||||
|
||||
public final Map<String, String> urlAliases() {
|
||||
Map<String, String> urlAliases = new HashMap<>();
|
||||
for (String k : Natives.keys(_urlAliases())) {
|
||||
urlAliases.put(k, urlAliasToken(k));
|
||||
}
|
||||
return urlAliases;
|
||||
}
|
||||
|
||||
public final native String urlAliasToken(String n) /*-{ return this.url_aliases[n]; }-*/;
|
||||
|
||||
private native NativeMap<NativeString> _urlAliases() /*-{ return this.url_aliases; }-*/;
|
||||
|
||||
public final boolean hasSshd() {
|
||||
return sshd() != null;
|
||||
}
|
||||
|
||||
protected ServerInfo() {}
|
||||
|
||||
public static class ChangeConfigInfo extends JavaScriptObject {
|
||||
public final native boolean allowBlame() /*-{ return this.allow_blame || false; }-*/;
|
||||
|
||||
public final native int largeChange() /*-{ return this.large_change || 0; }-*/;
|
||||
|
||||
public final native String replyLabel() /*-{ return this.reply_label; }-*/;
|
||||
|
||||
public final native String replyTooltip() /*-{ return this.reply_tooltip; }-*/;
|
||||
|
||||
public final native boolean
|
||||
showAssigneeInChangesTable() /*-{ return this.show_assignee_in_changes_table || false; }-*/;
|
||||
|
||||
public final native int updateDelay() /*-{ return this.update_delay || 0; }-*/;
|
||||
|
||||
public final native boolean isSubmitWholeTopicEnabled() /*-{
|
||||
return this.submit_whole_topic; }-*/;
|
||||
|
||||
protected ChangeConfigInfo() {}
|
||||
}
|
||||
|
||||
public static class PluginConfigInfo extends JavaScriptObject {
|
||||
public final native boolean hasAvatars() /*-{ return this.has_avatars || false; }-*/;
|
||||
|
||||
public final native JsArrayString jsResourcePaths() /*-{
|
||||
return this.js_resource_paths || []; }-*/;
|
||||
|
||||
protected PluginConfigInfo() {}
|
||||
}
|
||||
|
||||
public static class SshdInfo extends JavaScriptObject {
|
||||
protected SshdInfo() {}
|
||||
}
|
||||
|
||||
public static class SuggestInfo extends JavaScriptObject {
|
||||
public final native int from() /*-{ return this.from || 0; }-*/;
|
||||
|
||||
protected SuggestInfo() {}
|
||||
}
|
||||
|
||||
public static class UserConfigInfo extends JavaScriptObject {
|
||||
public final native String anonymousCowardName() /*-{ return this.anonymous_coward_name; }-*/;
|
||||
|
||||
protected UserConfigInfo() {}
|
||||
}
|
||||
|
||||
public static class ReceiveInfo extends JavaScriptObject {
|
||||
public final native boolean enableSignedPush()
|
||||
/*-{ return this.enable_signed_push || false; }-*/ ;
|
||||
|
||||
protected ReceiveInfo() {}
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
|
||||
public class TopMenu extends JavaScriptObject {
|
||||
|
||||
protected TopMenu() {}
|
||||
|
||||
public final native String getName() /*-{ return this.name; }-*/;
|
||||
|
||||
public final native JsArray<TopMenuItem> getItems() /*-{ return this.items; }-*/;
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
public class TopMenuItem extends JavaScriptObject {
|
||||
public static TopMenuItem create(String name, String url) {
|
||||
TopMenuItem i = createObject().cast();
|
||||
i.name(name);
|
||||
i.url(url);
|
||||
return i;
|
||||
}
|
||||
|
||||
public final native String getName() /*-{ return this.name; }-*/;
|
||||
|
||||
public final native String getUrl() /*-{ return this.url; }-*/;
|
||||
|
||||
public final native String getTarget() /*-{ return this.target; }-*/;
|
||||
|
||||
public final native String getId() /*-{ return this.id; }-*/;
|
||||
|
||||
public final native void name(String n) /*-{ this.name = n }-*/;
|
||||
|
||||
public final native void url(String u) /*-{ this.url = u }-*/;
|
||||
|
||||
protected TopMenuItem() {}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
|
||||
public class TopMenuList extends JsArray<TopMenu> {
|
||||
|
||||
protected TopMenuList() {}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.info;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
|
||||
public class WebLinkInfo extends JavaScriptObject {
|
||||
|
||||
public final native String name() /*-{ return this.name; }-*/;
|
||||
|
||||
public final native String imageUrl() /*-{ return this.image_url; }-*/;
|
||||
|
||||
public final native String url() /*-{ return this.url; }-*/;
|
||||
|
||||
public final native String target() /*-{ return this.target; }-*/;
|
||||
|
||||
protected WebLinkInfo() {}
|
||||
|
||||
public final Anchor toAnchor() {
|
||||
Anchor a = new Anchor();
|
||||
a.setHref(url());
|
||||
if (target() != null && !target().isEmpty()) {
|
||||
a.setTarget(target());
|
||||
}
|
||||
if (imageUrl() != null && !imageUrl().isEmpty()) {
|
||||
Image img = new Image();
|
||||
img.setAltText(name());
|
||||
img.setUrl(imageUrl());
|
||||
img.setTitle(name());
|
||||
a.getElement().appendChild(img.getElement());
|
||||
} else {
|
||||
a.setText("(" + name() + ")");
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.rpc;
|
||||
|
||||
import static java.util.stream.Collectors.toCollection;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/** A map of native JSON objects, keyed by a string. */
|
||||
public class NativeMap<T extends JavaScriptObject> extends JavaScriptObject {
|
||||
public static <T extends JavaScriptObject> NativeMap<T> create() {
|
||||
return createObject().cast();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loop through the result map's entries and copy the key strings into the "name" property of the
|
||||
* corresponding child object. This only runs on the top level map of the result, and requires the
|
||||
* children to be JSON objects and not a JSON primitive (e.g. boolean or string).
|
||||
*/
|
||||
public static <T extends JavaScriptObject, M extends NativeMap<T>>
|
||||
AsyncCallback<M> copyKeysIntoChildren(AsyncCallback<M> callback) {
|
||||
return copyKeysIntoChildren("name", callback);
|
||||
}
|
||||
|
||||
/** Loop through the result map and set asProperty on the children. */
|
||||
public static <T extends JavaScriptObject, M extends NativeMap<T>>
|
||||
AsyncCallback<M> copyKeysIntoChildren(String asProperty, AsyncCallback<M> callback) {
|
||||
return new TransformCallback<M, M>(callback) {
|
||||
@Override
|
||||
protected M transform(M result) {
|
||||
result.copyKeysIntoChildren(asProperty);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected NativeMap() {}
|
||||
|
||||
public final Set<String> keySet() {
|
||||
return Natives.keys(this);
|
||||
}
|
||||
|
||||
public final List<String> sortedKeys() {
|
||||
return keySet().stream().sorted().collect(toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
public final native JsArray<T> values() /*-{
|
||||
var s = this;
|
||||
var v = [];
|
||||
var i = 0;
|
||||
for (var k in s) {
|
||||
if (s.hasOwnProperty(k)) {
|
||||
v[i++] = s[k];
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}-*/;
|
||||
|
||||
public final int size() {
|
||||
return keySet().size();
|
||||
}
|
||||
|
||||
public final boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
public final boolean containsKey(String n) {
|
||||
return get(n) != null;
|
||||
}
|
||||
|
||||
public final native T get(String n) /*-{ return this[n]; }-*/;
|
||||
|
||||
public final native void put(String n, T v) /*-{ this[n] = v; }-*/;
|
||||
|
||||
public final native void copyKeysIntoChildren(String p) /*-{
|
||||
var s = this;
|
||||
for (var k in s) {
|
||||
if (s.hasOwnProperty(k)) {
|
||||
var c = s[k];
|
||||
c[p] = k;
|
||||
}
|
||||
}
|
||||
}-*/;
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.rpc;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/** Wraps a String that was returned from a JSON API. */
|
||||
public final class NativeString extends JavaScriptObject {
|
||||
public static final JavaScriptObject TYPE = init();
|
||||
|
||||
// Used from core and plugins
|
||||
private static native JavaScriptObject init() /*-{
|
||||
if ($wnd.Gerrit === undefined || $wnd.Gerrit.JsonString === undefined) {
|
||||
return function(s){this.s=s};
|
||||
} else {
|
||||
return $wnd.Gerrit.JsonString;
|
||||
}
|
||||
}-*/;
|
||||
|
||||
static NativeString wrap(String s) {
|
||||
return wrap0(TYPE, s);
|
||||
}
|
||||
|
||||
private static native NativeString wrap0(JavaScriptObject T, String s) /*-{ return new T(s) }-*/;
|
||||
|
||||
public native String asString() /*-{ return this.s; }-*/;
|
||||
|
||||
public static AsyncCallback<NativeString> unwrap(AsyncCallback<String> cb) {
|
||||
return new AsyncCallback<NativeString>() {
|
||||
@Override
|
||||
public void onSuccess(NativeString result) {
|
||||
cb.onSuccess(result != null ? result.asString() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
cb.onFailure(caught);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean is(JavaScriptObject o) {
|
||||
return is(TYPE, o);
|
||||
}
|
||||
|
||||
private static native boolean is(JavaScriptObject T, JavaScriptObject o)
|
||||
/*-{ return o instanceof T }-*/ ;
|
||||
|
||||
protected NativeString() {}
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.rpc;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import com.google.gwt.json.client.JSONObject;
|
||||
import java.util.AbstractList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Natives {
|
||||
/**
|
||||
* Get the names of defined properties on the object. The returned set iterates in the native
|
||||
* iteration order, which may match the source order.
|
||||
*/
|
||||
public static Set<String> keys(JavaScriptObject obj) {
|
||||
if (obj != null) {
|
||||
return new JSONObject(obj).keySet();
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
public static List<String> asList(JsArrayString arr) {
|
||||
if (arr == null) {
|
||||
return null;
|
||||
}
|
||||
return new AbstractList<String>() {
|
||||
@Override
|
||||
public String set(int index, String element) {
|
||||
String old = arr.get(index);
|
||||
arr.set(index, element);
|
||||
return old;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(int index) {
|
||||
return arr.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return arr.length();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <T extends JavaScriptObject> List<T> asList(JsArray<T> arr) {
|
||||
if (arr == null) {
|
||||
return null;
|
||||
}
|
||||
return new AbstractList<T>() {
|
||||
@Override
|
||||
public T set(int index, T element) {
|
||||
T old = arr.get(index);
|
||||
arr.set(index, element);
|
||||
return old;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return arr.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return arr.length();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static <T extends JavaScriptObject> JsArray<T> arrayOf(T element) {
|
||||
JsArray<T> arr = JavaScriptObject.createArray().cast();
|
||||
arr.push(element);
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static JsArrayString arrayOf(Iterable<String> elements) {
|
||||
JsArrayString arr = JavaScriptObject.createArray().cast();
|
||||
for (String elem : elements) {
|
||||
arr.push(elem);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static JsArrayString arrayOf(String element) {
|
||||
JsArrayString arr = JavaScriptObject.createArray().cast();
|
||||
arr.push(element);
|
||||
return arr;
|
||||
}
|
||||
|
||||
private Natives() {}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
// Copyright (C) 2012 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.rpc;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
/** Transforms a value and passes it on to another callback. */
|
||||
public abstract class TransformCallback<I, O> implements AsyncCallback<I> {
|
||||
private final AsyncCallback<O> callback;
|
||||
|
||||
protected TransformCallback(AsyncCallback<O> callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(I result) {
|
||||
callback.onSuccess(transform(result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
protected abstract O transform(I result);
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.ui;
|
||||
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
||||
|
||||
/** A {@code Suggestion} with highlights. */
|
||||
public class HighlightSuggestion implements Suggestion {
|
||||
|
||||
private final String keyword;
|
||||
private final String value;
|
||||
|
||||
public HighlightSuggestion(String keyword, String value) {
|
||||
this.keyword = keyword;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayString() {
|
||||
int start = 0;
|
||||
int keyLen = keyword.length();
|
||||
SafeHtmlBuilder builder = new SafeHtmlBuilder();
|
||||
for (; ; ) {
|
||||
int index = value.indexOf(keyword, start);
|
||||
if (index == -1) {
|
||||
builder.appendEscaped(value.substring(start));
|
||||
break;
|
||||
}
|
||||
builder.appendEscaped(value.substring(start, index));
|
||||
builder.appendHtmlConstant("<strong>");
|
||||
start = index + keyLen;
|
||||
builder.appendEscaped(value.substring(index, start));
|
||||
builder.appendHtmlConstant("</strong>");
|
||||
}
|
||||
return builder.toSafeHtml().asString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReplacementString() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
// Copyright (C) 2010 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.ui;
|
||||
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle;
|
||||
|
||||
/**
|
||||
* Delegates to a slow SuggestOracle, such as a remote server API.
|
||||
*
|
||||
* <p>A response is only supplied to the UI if no requests were made after the oracle begin that
|
||||
* request.
|
||||
*
|
||||
* <p>When a request is made while the delegate is still processing a prior request all intermediate
|
||||
* requests are discarded and the most recent request is queued. The pending request's response is
|
||||
* discarded and the most recent request is started.
|
||||
*/
|
||||
public class RemoteSuggestOracle extends SuggestOracle {
|
||||
private final SuggestOracle oracle;
|
||||
private Query query;
|
||||
private String last;
|
||||
private Timer requestRetentionTimer;
|
||||
private boolean cancelOutstandingRequest;
|
||||
|
||||
private boolean serveSuggestions;
|
||||
|
||||
public RemoteSuggestOracle(SuggestOracle src) {
|
||||
oracle = src;
|
||||
}
|
||||
|
||||
public String getLast() {
|
||||
return last;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestSuggestions(Request req, Callback cb) {
|
||||
if (!serveSuggestions) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Use a timer for key stroke retention, such that we don't query the
|
||||
// backend for each and every keystroke we receive.
|
||||
if (requestRetentionTimer != null) {
|
||||
requestRetentionTimer.cancel();
|
||||
}
|
||||
requestRetentionTimer =
|
||||
new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
Query q = new Query(req, cb);
|
||||
if (query == null) {
|
||||
query = q;
|
||||
q.start();
|
||||
} else {
|
||||
query = q;
|
||||
}
|
||||
}
|
||||
};
|
||||
requestRetentionTimer.schedule(200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDefaultSuggestions(Request req, Callback cb) {
|
||||
requestSuggestions(req, cb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplayStringHTML() {
|
||||
return oracle.isDisplayStringHTML();
|
||||
}
|
||||
|
||||
public void cancelOutstandingRequest() {
|
||||
if (requestRetentionTimer != null) {
|
||||
requestRetentionTimer.cancel();
|
||||
}
|
||||
if (query != null) {
|
||||
cancelOutstandingRequest = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setServeSuggestions(boolean serveSuggestions) {
|
||||
this.serveSuggestions = serveSuggestions;
|
||||
}
|
||||
|
||||
private class Query implements Callback {
|
||||
final Request request;
|
||||
final Callback callback;
|
||||
|
||||
Query(Request req, Callback cb) {
|
||||
request = req;
|
||||
callback = cb;
|
||||
}
|
||||
|
||||
void start() {
|
||||
oracle.requestSuggestions(request, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuggestionsReady(Request req, Response res) {
|
||||
if (cancelOutstandingRequest || !serveSuggestions) {
|
||||
// If cancelOutstandingRequest() was called, we ignore this response
|
||||
cancelOutstandingRequest = false;
|
||||
query = null;
|
||||
} else if (query == this) {
|
||||
// No new request was started while this query was running.
|
||||
// Propose this request's response as the suggestions.
|
||||
query = null;
|
||||
last = request.getQuery();
|
||||
callback.onSuggestionsReady(req, res);
|
||||
} else {
|
||||
// Another query came in while this one was running. Skip
|
||||
// this response and start the most recent query.
|
||||
query.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 631 B |
Before Width: | Height: | Size: 512 B |
Before Width: | Height: | Size: 382 B |
Before Width: | Height: | Size: 655 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 620 B |
Before Width: | Height: | Size: 701 B |
Before Width: | Height: | Size: 659 B |
Before Width: | Height: | Size: 653 B |
Before Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 609 B |
Before Width: | Height: | Size: 637 B |
Before Width: | Height: | Size: 786 B |
Before Width: | Height: | Size: 782 B |
Before Width: | Height: | Size: 323 B |
Before Width: | Height: | Size: 749 B |
Before Width: | Height: | Size: 710 B |
Before Width: | Height: | Size: 641 B |
Before Width: | Height: | Size: 807 B |
Before Width: | Height: | Size: 523 B |
Before Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 398 B |
Before Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 488 B |
Before Width: | Height: | Size: 670 B |
Before Width: | Height: | Size: 586 B |
Before Width: | Height: | Size: 671 B |
Before Width: | Height: | Size: 537 B |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 746 B |
Before Width: | Height: | Size: 833 B |
@ -1,216 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import static com.google.gerrit.client.RelativeDateFormatter.DAY_IN_MILLIS;
|
||||
import static com.google.gerrit.client.RelativeDateFormatter.HOUR_IN_MILLIS;
|
||||
import static com.google.gerrit.client.RelativeDateFormatter.MINUTE_IN_MILLIS;
|
||||
import static com.google.gerrit.client.RelativeDateFormatter.SECOND_IN_MILLIS;
|
||||
import static com.google.gerrit.client.RelativeDateFormatter.YEAR_IN_MILLIS;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Date;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RelativeDateFormatterTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setConstants() {
|
||||
Constants c = new Constants();
|
||||
RelativeDateFormatter.setConstants(c, c);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void unsetConstants() {
|
||||
RelativeDateFormatter.setConstants(null, null);
|
||||
}
|
||||
|
||||
private static void assertFormat(long ageFromNow, long timeUnit, String expectedFormat) {
|
||||
Date d = new Date(System.currentTimeMillis() - ageFromNow * timeUnit);
|
||||
String s = RelativeDateFormatter.format(d);
|
||||
assertEquals(expectedFormat, s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void future() {
|
||||
assertFormat(-100, YEAR_IN_MILLIS, "in the future");
|
||||
assertFormat(-1, SECOND_IN_MILLIS, "in the future");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatSeconds() {
|
||||
assertFormat(1, SECOND_IN_MILLIS, "1 second ago");
|
||||
assertFormat(89, SECOND_IN_MILLIS, "89 seconds ago");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatMinutes() {
|
||||
assertFormat(90, SECOND_IN_MILLIS, "2 minutes ago");
|
||||
assertFormat(3, MINUTE_IN_MILLIS, "3 minutes ago");
|
||||
assertFormat(60, MINUTE_IN_MILLIS, "60 minutes ago");
|
||||
assertFormat(89, MINUTE_IN_MILLIS, "89 minutes ago");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatHours() {
|
||||
assertFormat(90, MINUTE_IN_MILLIS, "2 hours ago");
|
||||
assertFormat(149, MINUTE_IN_MILLIS, "2 hours ago");
|
||||
assertFormat(35, HOUR_IN_MILLIS, "35 hours ago");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatDays() {
|
||||
assertFormat(36, HOUR_IN_MILLIS, "2 days ago");
|
||||
assertFormat(13, DAY_IN_MILLIS, "13 days ago");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatWeeks() {
|
||||
assertFormat(14, DAY_IN_MILLIS, "2 weeks ago");
|
||||
assertFormat(69, DAY_IN_MILLIS, "10 weeks ago");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatMonths() {
|
||||
assertFormat(70, DAY_IN_MILLIS, "2 months ago");
|
||||
assertFormat(75, DAY_IN_MILLIS, "3 months ago");
|
||||
assertFormat(364, DAY_IN_MILLIS, "12 months ago");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatYearsMonths() {
|
||||
assertFormat(366, DAY_IN_MILLIS, "1 year ago");
|
||||
assertFormat(380, DAY_IN_MILLIS, "1 year, 1 month ago");
|
||||
assertFormat(410, DAY_IN_MILLIS, "1 year, 2 months ago");
|
||||
assertFormat(2, YEAR_IN_MILLIS, "2 years ago");
|
||||
assertFormat(1824, DAY_IN_MILLIS, "5 years ago");
|
||||
assertFormat(2 * 365 - 10, DAY_IN_MILLIS, "2 years ago");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatYears() {
|
||||
assertFormat(5, YEAR_IN_MILLIS, "5 years ago");
|
||||
assertFormat(60, YEAR_IN_MILLIS, "60 years ago");
|
||||
}
|
||||
|
||||
private static class Constants implements CommonConstants, CommonMessages {
|
||||
@Override
|
||||
public String inTheFuture() {
|
||||
return "in the future";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String month() {
|
||||
return "month";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String months() {
|
||||
return "months";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String year() {
|
||||
return "year";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String years() {
|
||||
return "years";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String oneSecondAgo() {
|
||||
return "1 second ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String oneMinuteAgo() {
|
||||
return "1 minute ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String oneHourAgo() {
|
||||
return "1 hour ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String oneDayAgo() {
|
||||
return "1 day ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String oneWeekAgo() {
|
||||
return "1 week ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String oneMonthAgo() {
|
||||
return "1 month ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String oneYearAgo() {
|
||||
return "1 year ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String secondsAgo(long seconds) {
|
||||
return seconds + " seconds ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String minutesAgo(long minutes) {
|
||||
return minutes + " minutes ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String hoursAgo(long hours) {
|
||||
return hours + " hours ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String daysAgo(long days) {
|
||||
return days + " days ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String weeksAgo(long weeks) {
|
||||
return weeks + " weeks ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String monthsAgo(long months) {
|
||||
return months + " months ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String yearsAgo(long years) {
|
||||
return years + " years ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String years0MonthsAgo(long years, String yearLabel) {
|
||||
return years + " " + yearLabel + " ago";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String yearsMonthsAgo(long years, String yearLabel, long months, String monthLabel) {
|
||||
return years + " " + yearLabel + ", " + months + " " + monthLabel + " ago";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.ui;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class HighlightSuggestionTest {
|
||||
|
||||
@Test
|
||||
public void singleHighlight() throws Exception {
|
||||
String keyword = "key";
|
||||
String value = "somethingkeysomething";
|
||||
HighlightSuggestion suggestion = new HighlightSuggestion(keyword, value);
|
||||
assertEquals("something<strong>key</strong>something", suggestion.getDisplayString());
|
||||
assertEquals(value, suggestion.getReplacementString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noHighlight() throws Exception {
|
||||
String keyword = "key";
|
||||
String value = "something";
|
||||
HighlightSuggestion suggestion = new HighlightSuggestion(keyword, value);
|
||||
assertEquals(value, suggestion.getDisplayString());
|
||||
assertEquals(value, suggestion.getReplacementString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doubleHighlight() throws Exception {
|
||||
String keyword = "key";
|
||||
String value = "somethingkeysomethingkeysomething";
|
||||
HighlightSuggestion suggestion = new HighlightSuggestion(keyword, value);
|
||||
assertEquals(
|
||||
"something<strong>key</strong>something<strong>key</strong>something",
|
||||
suggestion.getDisplayString());
|
||||
assertEquals(value, suggestion.getReplacementString());
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
load(
|
||||
"//tools/bzl:gwt.bzl",
|
||||
"gen_ui_module",
|
||||
"gwt_genrule",
|
||||
"gwt_user_agent_permutations",
|
||||
)
|
||||
load("//tools/bzl:license.bzl", "license_test")
|
||||
load("//tools/bzl:junit.bzl", "junit_tests")
|
||||
|
||||
gwt_genrule()
|
||||
|
||||
gwt_genrule("_r")
|
||||
|
||||
gen_ui_module(name = "ui_module")
|
||||
|
||||
gen_ui_module(
|
||||
name = "ui_module",
|
||||
suffix = "_r",
|
||||
)
|
||||
|
||||
gwt_user_agent_permutations()
|
||||
|
||||
license_test(
|
||||
name = "ui_module_license_test",
|
||||
target = ":ui_module",
|
||||
)
|
||||
|
||||
junit_tests(
|
||||
name = "ui_tests",
|
||||
srcs = glob(["src/test/java/**/*.java"]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":ui_module",
|
||||
"//java/com/google/gerrit/common:client",
|
||||
"//java/com/google/gerrit/extensions:client",
|
||||
"//lib:junit",
|
||||
"//lib/gwt:dev",
|
||||
"//lib/gwt:user",
|
||||
"//lib/truth",
|
||||
],
|
||||
)
|
@ -1,39 +0,0 @@
|
||||
<!--
|
||||
Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<module rename-to="gerrit_ui">
|
||||
<inherits name='com.google.gwt.editor.Editor'/>
|
||||
<inherits name='com.google.gwt.user.User'/>
|
||||
<inherits name='com.google.gwt.resources.Resources'/>
|
||||
<inherits name='com.google.gwt.user.theme.chrome.Chrome'/>
|
||||
<inherits name='com.google.gwtexpui.css.CSS'/>
|
||||
<inherits name='com.google.gerrit.GerritGwtUICommon'/>
|
||||
<inherits name='com.google.gerrit.UserAgent'/>
|
||||
<inherits name='net.codemirror.CodeMirror'/>
|
||||
|
||||
<extend-property name='locale' values='en'/>
|
||||
<set-property-fallback name='locale' value='en'/>
|
||||
<set-property name='locale' value='en'/>
|
||||
<set-configuration-property name='UiBinder.useSafeHtmlTemplates' value='true'/>
|
||||
<set-configuration-property name='CssResource.style' value='stable'/>
|
||||
<add-linker name='xsiframe'/>
|
||||
|
||||
<set-property name='gwt.logging.logLevel' value='SEVERE'/>
|
||||
|
||||
<!-- Disable GSS -->
|
||||
<set-configuration-property name='CssResource.enableGss' value='false'/>
|
||||
|
||||
<entry-point class='com.google.gerrit.client.Gerrit'/>
|
||||
</module>
|
@ -1,41 +0,0 @@
|
||||
<!--
|
||||
Copyright (C) 2009 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<module>
|
||||
<replace-with class="com.google.gerrit.client.api.PluginName.PluginNameMoz">
|
||||
<when-type-is class="com.google.gerrit.client.api.PluginName" />
|
||||
<when-property-is name="compiler.stackMode" value="native" />
|
||||
<when-property-is name="user.agent" value="safari" />
|
||||
<when-property-is name="user.agent" value="gecko1_8" />
|
||||
</replace-with>
|
||||
|
||||
<replace-with class="com.google.gerrit.client.ui.FancyFlexTableImplIE8">
|
||||
<when-type-is class="com.google.gerrit.client.ui.FancyFlexTableImpl" />
|
||||
<any>
|
||||
<when-property-is name="user.agent" value="ie8"/>
|
||||
</any>
|
||||
</replace-with>
|
||||
|
||||
<replace-with class="com.google.gerrit.client.Themer.ThemerIE">
|
||||
<when-type-is class="com.google.gerrit.client.Themer" />
|
||||
<any>
|
||||
<when-property-is name="user.agent" value="ie8"/>
|
||||
<when-property-is name="user.agent" value="ie9"/>
|
||||
<when-property-is name="user.agent" value="ie10"/>
|
||||
<when-property-is name="user.agent" value="ie11"/>
|
||||
<when-property-is name="user.agent" value="edge"/>
|
||||
</any>
|
||||
</replace-with>
|
||||
</module>
|
@ -1,202 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gerrit.client.changes.Util;
|
||||
import com.google.gerrit.client.info.AccountInfo;
|
||||
import com.google.gerrit.client.info.AccountInfo.AvatarInfo;
|
||||
import com.google.gerrit.client.rpc.RestApi;
|
||||
import com.google.gwt.event.dom.client.LoadEvent;
|
||||
import com.google.gwt.event.dom.client.LoadHandler;
|
||||
import com.google.gwt.event.dom.client.MouseOutEvent;
|
||||
import com.google.gwt.event.dom.client.MouseOutHandler;
|
||||
import com.google.gwt.event.dom.client.MouseOverEvent;
|
||||
import com.google.gwt.event.dom.client.MouseOverHandler;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.UIObject;
|
||||
|
||||
public class AvatarImage extends Image implements LoadHandler {
|
||||
public AvatarImage() {
|
||||
setVisible(false);
|
||||
addLoadHandler(this);
|
||||
}
|
||||
|
||||
/** A default sized avatar image. */
|
||||
public AvatarImage(AccountInfo account) {
|
||||
this(account, AccountInfo.AvatarInfo.DEFAULT_SIZE, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* An avatar image for the given account using the requested size.
|
||||
*
|
||||
* @param account The account in which we are interested
|
||||
* @param size A requested size. Note that the size can be ignored depending on the avatar
|
||||
* provider. A size <= 0 indicates to let the provider decide a default size.
|
||||
* @param addPopup show avatar popup with user info on hovering over the avatar image
|
||||
*/
|
||||
public AvatarImage(AccountInfo account, int size, boolean addPopup) {
|
||||
addLoadHandler(this);
|
||||
setAccount(account, size, addPopup);
|
||||
}
|
||||
|
||||
public void setAccount(AccountInfo account, int size, boolean addPopup) {
|
||||
if (account == null) {
|
||||
setVisible(false);
|
||||
} else if (isGerritServer(account)) {
|
||||
setVisible(true);
|
||||
setResource(Gerrit.RESOURCES.gerritAvatar26());
|
||||
} else if (account.hasAvatarInfo()) {
|
||||
setVisible(false);
|
||||
AvatarInfo info = account.avatar(size);
|
||||
if (info != null) {
|
||||
setWidth(info.width() > 0 ? info.width() + "px" : "");
|
||||
setHeight(info.height() > 0 ? info.height() + "px" : "");
|
||||
setUrl(info.url());
|
||||
popup(account, addPopup);
|
||||
} else if (account.email() != null) {
|
||||
loadAvatar(account, size, addPopup);
|
||||
}
|
||||
} else if (account.email() != null) {
|
||||
loadAvatar(account, size, addPopup);
|
||||
} else {
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAvatar(AccountInfo account, int size, boolean addPopup) {
|
||||
if (!Gerrit.info().plugin().hasAvatars()) {
|
||||
setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO Kill /accounts/*/avatar URL.
|
||||
String u = account.email();
|
||||
if (Gerrit.isSignedIn() && u.equals(Gerrit.getUserAccount().email())) {
|
||||
u = "self";
|
||||
}
|
||||
RestApi api = new RestApi("/accounts/").id(u).view("avatar");
|
||||
if (size > 0) {
|
||||
api.addParameter("s", size);
|
||||
setSize("", size + "px");
|
||||
}
|
||||
setVisible(false);
|
||||
setUrl(api.url());
|
||||
popup(account, addPopup);
|
||||
}
|
||||
|
||||
private void popup(AccountInfo account, boolean addPopup) {
|
||||
if (addPopup) {
|
||||
PopupHandler popupHandler = new PopupHandler(account, this);
|
||||
addMouseOverHandler(popupHandler);
|
||||
addMouseOutHandler(popupHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad(LoadEvent event) {
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private static boolean isGerritServer(AccountInfo account) {
|
||||
return account._accountId() == 0 && Util.C.messageNoAuthor().equals(account.name());
|
||||
}
|
||||
|
||||
private static class PopupHandler implements MouseOverHandler, MouseOutHandler {
|
||||
private final AccountInfo account;
|
||||
private final UIObject target;
|
||||
|
||||
private UserPopupPanel popup;
|
||||
private Timer showTimer;
|
||||
private Timer hideTimer;
|
||||
|
||||
PopupHandler(AccountInfo account, UIObject target) {
|
||||
this.account = account;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
private UserPopupPanel createPopupPanel(AccountInfo account) {
|
||||
UserPopupPanel popup = new UserPopupPanel(account, false, false);
|
||||
popup.addDomHandler(
|
||||
new MouseOverHandler() {
|
||||
@Override
|
||||
public void onMouseOver(MouseOverEvent event) {
|
||||
scheduleShow();
|
||||
}
|
||||
},
|
||||
MouseOverEvent.getType());
|
||||
popup.addDomHandler(
|
||||
new MouseOutHandler() {
|
||||
@Override
|
||||
public void onMouseOut(MouseOutEvent event) {
|
||||
scheduleHide();
|
||||
}
|
||||
},
|
||||
MouseOutEvent.getType());
|
||||
return popup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseOver(MouseOverEvent event) {
|
||||
scheduleShow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseOut(MouseOutEvent event) {
|
||||
scheduleHide();
|
||||
}
|
||||
|
||||
private void scheduleShow() {
|
||||
if (hideTimer != null) {
|
||||
hideTimer.cancel();
|
||||
hideTimer = null;
|
||||
}
|
||||
if ((popup != null && popup.isShowing() && popup.isVisible()) || showTimer != null) {
|
||||
return;
|
||||
}
|
||||
showTimer =
|
||||
new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (popup == null) {
|
||||
popup = createPopupPanel(account);
|
||||
}
|
||||
if (!popup.isShowing() || !popup.isVisible()) {
|
||||
popup.showRelativeTo(target);
|
||||
}
|
||||
}
|
||||
};
|
||||
showTimer.schedule(600);
|
||||
}
|
||||
|
||||
private void scheduleHide() {
|
||||
if (showTimer != null) {
|
||||
showTimer.cancel();
|
||||
showTimer = null;
|
||||
}
|
||||
if (popup == null || !popup.isShowing() || !popup.isVisible() || hideTimer != null) {
|
||||
return;
|
||||
}
|
||||
hideTimer =
|
||||
new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
popup.hide();
|
||||
}
|
||||
};
|
||||
hideTimer.schedule(50);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
// Copyright (C) 2010 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
/**
|
||||
* Interface that a caller must implement to react on the result of a {@link ConfirmationDialog}.
|
||||
*/
|
||||
public abstract class ConfirmationCallback {
|
||||
|
||||
/**
|
||||
* Called when the {@link ConfirmationDialog} is finished with OK. To be overwritten by
|
||||
* subclasses.
|
||||
*/
|
||||
public abstract void onOk();
|
||||
|
||||
/**
|
||||
* Called when the {@link ConfirmationDialog} is finished with Cancel. To be overwritten by
|
||||
* subclasses.
|
||||
*/
|
||||
public void onCancel() {}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
// Copyright (C) 2010 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
||||
import com.google.gwtexpui.user.client.AutoCenterDialogBox;
|
||||
|
||||
public class ConfirmationDialog extends AutoCenterDialogBox {
|
||||
|
||||
private Button cancelButton;
|
||||
private Button okButton;
|
||||
|
||||
public ConfirmationDialog(
|
||||
final String dialogTitle, SafeHtml message, ConfirmationCallback callback) {
|
||||
super(/* auto hide */ false, /* modal */ true);
|
||||
setGlassEnabled(true);
|
||||
setText(dialogTitle);
|
||||
|
||||
final FlowPanel buttons = new FlowPanel();
|
||||
|
||||
okButton = new Button();
|
||||
okButton.setText(Gerrit.C.confirmationDialogOk());
|
||||
okButton.addClickHandler(
|
||||
new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
hide();
|
||||
callback.onOk();
|
||||
}
|
||||
});
|
||||
buttons.add(okButton);
|
||||
|
||||
cancelButton = new Button();
|
||||
cancelButton.getElement().getStyle().setProperty("marginLeft", "300px");
|
||||
cancelButton.setText(Gerrit.C.confirmationDialogCancel());
|
||||
cancelButton.addClickHandler(
|
||||
new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
hide();
|
||||
callback.onCancel();
|
||||
}
|
||||
});
|
||||
buttons.add(cancelButton);
|
||||
|
||||
final FlowPanel center = new FlowPanel();
|
||||
final Widget msgWidget = message.toBlockWidget();
|
||||
center.add(msgWidget);
|
||||
center.add(buttons);
|
||||
add(center);
|
||||
|
||||
msgWidget.setWidth("400px");
|
||||
|
||||
setWidget(center);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void center() {
|
||||
super.center();
|
||||
GlobalKey.dialog(this);
|
||||
cancelButton.setFocus(true);
|
||||
}
|
||||
|
||||
public void setCancelVisible(boolean visible) {
|
||||
cancelButton.setVisible(visible);
|
||||
if (!visible) {
|
||||
okButton.setFocus(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,183 +0,0 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DefaultBase;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
|
||||
/**
|
||||
* Represent an object that can be diffed. This can be either a regular patch set, the base of a
|
||||
* patch set, the parent of a merge, the auto-merge of a merge or an edit patch set.
|
||||
*/
|
||||
public class DiffObject {
|
||||
public static final String AUTO_MERGE = "AutoMerge";
|
||||
|
||||
/**
|
||||
* Parses a string that represents a diff object.
|
||||
*
|
||||
* <p>The following string representations are supported:
|
||||
*
|
||||
* <ul>
|
||||
* <li>a positive integer: represents a patch set
|
||||
* <li>a negative integer: represents a parent of a merge patch set
|
||||
* <li>'0': represents the edit patch set
|
||||
* <li>empty string or null: represents the parent of a 1-parent patch set, also called base
|
||||
* <li>'AutoMerge': represents the auto-merge of a merge patch set
|
||||
* </ul>
|
||||
*
|
||||
* @param changeId the ID of the change to which the diff object belongs
|
||||
* @param str the string representation of the diff object
|
||||
* @return the parsed diff object, {@code null} if str cannot be parsed as diff object
|
||||
*/
|
||||
public static DiffObject parse(Change.Id changeId, String str) {
|
||||
if (str == null || str.isEmpty()) {
|
||||
return new DiffObject(false);
|
||||
}
|
||||
|
||||
if (AUTO_MERGE.equals(str)) {
|
||||
return new DiffObject(true);
|
||||
}
|
||||
|
||||
return new DiffObject(Dispatcher.toPsId(changeId, str));
|
||||
}
|
||||
|
||||
/** Create a DiffObject that represents the parent of a 1-parent patch set. */
|
||||
public static DiffObject base() {
|
||||
return new DiffObject(false);
|
||||
}
|
||||
|
||||
/** Create a DiffObject that represents the auto-merge for a merge patch set. */
|
||||
public static DiffObject autoMerge() {
|
||||
return new DiffObject(true);
|
||||
}
|
||||
|
||||
/** Create a DiffObject that represents a patch set. */
|
||||
public static DiffObject patchSet(PatchSet.Id psId) {
|
||||
return new DiffObject(psId);
|
||||
}
|
||||
|
||||
private final PatchSet.Id psId;
|
||||
private final boolean autoMerge;
|
||||
|
||||
private DiffObject(PatchSet.Id psId) {
|
||||
this.psId = psId;
|
||||
this.autoMerge = false;
|
||||
}
|
||||
|
||||
private DiffObject(boolean autoMerge) {
|
||||
this.psId = null;
|
||||
this.autoMerge = autoMerge;
|
||||
}
|
||||
|
||||
public boolean isBase() {
|
||||
return psId == null && !autoMerge;
|
||||
}
|
||||
|
||||
public boolean isAutoMerge() {
|
||||
return psId == null && autoMerge;
|
||||
}
|
||||
|
||||
public boolean isBaseOrAutoMerge() {
|
||||
return psId == null;
|
||||
}
|
||||
|
||||
public boolean isPatchSet() {
|
||||
return psId != null && psId.get() > 0;
|
||||
}
|
||||
|
||||
public boolean isParent() {
|
||||
return psId != null && psId.get() < 0;
|
||||
}
|
||||
|
||||
public boolean isEdit() {
|
||||
return psId != null && psId.get() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DiffObject as PatchSet.Id.
|
||||
*
|
||||
* @return PatchSet.Id with an id > 0 for a regular patch set; PatchSet.Id with an id < 0 for a
|
||||
* parent of a merge; PatchSet.Id with id == 0 for an edit patch set; {@code null} for the
|
||||
* base of a 1-parent patch set and for the auto-merge of a merge patch set
|
||||
*/
|
||||
public PatchSet.Id asPatchSetId() {
|
||||
return psId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent number for a parent of a merge.
|
||||
*
|
||||
* @return 1-based parent number, 0 if this DiffObject is not a parent of a merge
|
||||
*/
|
||||
public int getParentNum() {
|
||||
if (!isParent()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -psId.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this DiffObject that can be used in URLs.
|
||||
*
|
||||
* <p>The following string representations are returned:
|
||||
*
|
||||
* <ul>
|
||||
* <li>a positive integer for a patch set
|
||||
* <li>a negative integer for a parent of a merge patch set
|
||||
* <li>'0' for the edit patch set
|
||||
* <li>{@code null} for the parent of a 1-parent patch set, also called base
|
||||
* <li>'AutoMerge' for the auto-merge of a merge patch set
|
||||
* </ul>
|
||||
*
|
||||
* @return string representation of this DiffObject
|
||||
*/
|
||||
public String asString() {
|
||||
if (autoMerge) {
|
||||
if (Gerrit.getUserPreferences().defaultBaseForMerges() != DefaultBase.AUTO_MERGE) {
|
||||
return AUTO_MERGE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (psId != null) {
|
||||
return psId.getId();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isPatchSet()) {
|
||||
return "Patch Set " + psId.getId();
|
||||
}
|
||||
|
||||
if (isParent()) {
|
||||
return "Parent " + psId.getId();
|
||||
}
|
||||
|
||||
if (isEdit()) {
|
||||
return "Edit Patch Set";
|
||||
}
|
||||
|
||||
if (isAutoMerge()) {
|
||||
return "Auto Merge";
|
||||
}
|
||||
|
||||
return "Base";
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gerrit.client.info.WebLinkInfo;
|
||||
|
||||
public class DiffWebLinkInfo extends WebLinkInfo {
|
||||
public final native boolean showOnSideBySideDiffView()
|
||||
/*-{ return this.show_on_side_by_side_diff_view || false; }-*/ ;
|
||||
|
||||
public final native boolean showOnUnifiedDiffView()
|
||||
/*-{ return this.show_on_unified_diff_view || false; }-*/ ;
|
||||
|
||||
protected DiffWebLinkInfo() {}
|
||||
}
|
@ -1,879 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_CREATE_GROUP;
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_CREATE_PROJECT;
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_GROUPS;
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_PLUGINS;
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_PROJECTS;
|
||||
import static com.google.gerrit.common.PageLinks.DASHBOARDS;
|
||||
import static com.google.gerrit.common.PageLinks.MINE;
|
||||
import static com.google.gerrit.common.PageLinks.MY_GROUPS;
|
||||
import static com.google.gerrit.common.PageLinks.PROJECTS;
|
||||
import static com.google.gerrit.common.PageLinks.QUERY;
|
||||
import static com.google.gerrit.common.PageLinks.REGISTER;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_AGREEMENTS;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_CONTACT;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_DIFF_PREFERENCES;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_EDIT_PREFERENCES;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_EXTENSION;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_GPGKEYS;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_HTTP_PASSWORD;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_MYGROUPS;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_NEW_AGREEMENT;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_OAUTH_TOKEN;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_PREFERENCES;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_PROJECTS;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_SSHKEYS;
|
||||
import static com.google.gerrit.common.PageLinks.SETTINGS_WEBIDENT;
|
||||
|
||||
import com.google.gerrit.client.account.MyAgreementsScreen;
|
||||
import com.google.gerrit.client.account.MyContactInformationScreen;
|
||||
import com.google.gerrit.client.account.MyDiffPreferencesScreen;
|
||||
import com.google.gerrit.client.account.MyEditPreferencesScreen;
|
||||
import com.google.gerrit.client.account.MyGpgKeysScreen;
|
||||
import com.google.gerrit.client.account.MyGroupsScreen;
|
||||
import com.google.gerrit.client.account.MyIdentitiesScreen;
|
||||
import com.google.gerrit.client.account.MyOAuthTokenScreen;
|
||||
import com.google.gerrit.client.account.MyPasswordScreen;
|
||||
import com.google.gerrit.client.account.MyPreferencesScreen;
|
||||
import com.google.gerrit.client.account.MyProfileScreen;
|
||||
import com.google.gerrit.client.account.MySshKeysScreen;
|
||||
import com.google.gerrit.client.account.MyWatchedProjectsScreen;
|
||||
import com.google.gerrit.client.account.NewAgreementScreen;
|
||||
import com.google.gerrit.client.account.RegisterScreen;
|
||||
import com.google.gerrit.client.account.ValidateEmailScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupAuditLogScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupInfoScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupMembersScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupScreen;
|
||||
import com.google.gerrit.client.admin.CreateGroupScreen;
|
||||
import com.google.gerrit.client.admin.CreateProjectScreen;
|
||||
import com.google.gerrit.client.admin.GroupListScreen;
|
||||
import com.google.gerrit.client.admin.PluginListScreen;
|
||||
import com.google.gerrit.client.admin.ProjectAccessScreen;
|
||||
import com.google.gerrit.client.admin.ProjectBranchesScreen;
|
||||
import com.google.gerrit.client.admin.ProjectDashboardsScreen;
|
||||
import com.google.gerrit.client.admin.ProjectInfoScreen;
|
||||
import com.google.gerrit.client.admin.ProjectListScreen;
|
||||
import com.google.gerrit.client.admin.ProjectScreen;
|
||||
import com.google.gerrit.client.admin.ProjectTagsScreen;
|
||||
import com.google.gerrit.client.api.ExtensionScreen;
|
||||
import com.google.gerrit.client.api.ExtensionSettingsScreen;
|
||||
import com.google.gerrit.client.change.ChangeScreen;
|
||||
import com.google.gerrit.client.change.FileTable;
|
||||
import com.google.gerrit.client.change.ProjectChangeId;
|
||||
import com.google.gerrit.client.changes.AccountDashboardScreen;
|
||||
import com.google.gerrit.client.changes.CustomDashboardScreen;
|
||||
import com.google.gerrit.client.changes.ProjectDashboardScreen;
|
||||
import com.google.gerrit.client.changes.QueryScreen;
|
||||
import com.google.gerrit.client.dashboards.DashboardInfo;
|
||||
import com.google.gerrit.client.dashboards.DashboardList;
|
||||
import com.google.gerrit.client.diff.DisplaySide;
|
||||
import com.google.gerrit.client.diff.SideBySide;
|
||||
import com.google.gerrit.client.diff.Unified;
|
||||
import com.google.gerrit.client.documentation.DocScreen;
|
||||
import com.google.gerrit.client.editor.EditScreen;
|
||||
import com.google.gerrit.client.groups.GroupApi;
|
||||
import com.google.gerrit.client.info.GroupInfo;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.rpc.RestApi;
|
||||
import com.google.gerrit.client.ui.Screen;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DiffView;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.RunAsyncCallback;
|
||||
import com.google.gwt.http.client.URL;
|
||||
import com.google.gwtexpui.user.client.UserAgent;
|
||||
import com.google.gwtorm.client.KeyUtil;
|
||||
|
||||
public class Dispatcher {
|
||||
public static String toPatch(
|
||||
@Nullable Project.NameKey project,
|
||||
DiffObject diffBase,
|
||||
PatchSet.Id revision,
|
||||
String fileName) {
|
||||
return toPatch("", project, diffBase, revision, fileName, null, 0);
|
||||
}
|
||||
|
||||
public static String toPatch(
|
||||
@Nullable Project.NameKey project,
|
||||
DiffObject diffBase,
|
||||
PatchSet.Id revision,
|
||||
String fileName,
|
||||
DisplaySide side,
|
||||
int line) {
|
||||
return toPatch("", project, diffBase, revision, fileName, side, line);
|
||||
}
|
||||
|
||||
public static String toSideBySide(
|
||||
@Nullable Project.NameKey project,
|
||||
DiffObject diffBase,
|
||||
PatchSet.Id revision,
|
||||
String fileName) {
|
||||
return toPatch("sidebyside", project, diffBase, revision, fileName, null, 0);
|
||||
}
|
||||
|
||||
public static String toUnified(
|
||||
@Nullable Project.NameKey project,
|
||||
DiffObject diffBase,
|
||||
PatchSet.Id revision,
|
||||
String fileName) {
|
||||
return toPatch("unified", project, diffBase, revision, fileName, null, 0);
|
||||
}
|
||||
|
||||
public static String toPatch(
|
||||
@Nullable Project.NameKey project, String type, DiffObject diffBase, Patch.Key id) {
|
||||
return toPatch(type, project, diffBase, id.getParentKey(), id.get(), null, 0);
|
||||
}
|
||||
|
||||
public static String toEditScreen(
|
||||
@Nullable Project.NameKey project, PatchSet.Id revision, String fileName) {
|
||||
return toEditScreen(project, revision, fileName, 0);
|
||||
}
|
||||
|
||||
public static String toEditScreen(
|
||||
@Nullable Project.NameKey project, PatchSet.Id revision, String fileName, int line) {
|
||||
return toPatch("edit", project, DiffObject.base(), revision, fileName, null, line);
|
||||
}
|
||||
|
||||
private static String toPatch(
|
||||
String type,
|
||||
@Nullable Project.NameKey project,
|
||||
DiffObject diffBase,
|
||||
PatchSet.Id revision,
|
||||
String fileName,
|
||||
DisplaySide side,
|
||||
int line) {
|
||||
Change.Id c = revision.getParentKey();
|
||||
StringBuilder p = new StringBuilder(PageLinks.toChange(project, c));
|
||||
if (diffBase != null && diffBase.asString() != null) {
|
||||
p.append(diffBase.asString()).append("..");
|
||||
}
|
||||
p.append(revision.getId()).append("/").append(KeyUtil.encode(fileName));
|
||||
if (type != null && !type.isEmpty() && (!"sidebyside".equals(type) || preferUnified())) {
|
||||
p.append(",").append(type);
|
||||
}
|
||||
if (side == DisplaySide.A && line > 0) {
|
||||
p.append("@a").append(line);
|
||||
} else if (line > 0) {
|
||||
p.append("@").append(line);
|
||||
}
|
||||
return p.toString();
|
||||
}
|
||||
|
||||
public static String toGroup(AccountGroup.Id id) {
|
||||
return ADMIN_GROUPS + id.toString();
|
||||
}
|
||||
|
||||
public static String toGroup(AccountGroup.Id id, String panel) {
|
||||
return ADMIN_GROUPS + id.toString() + "," + panel;
|
||||
}
|
||||
|
||||
public static String toGroup(AccountGroup.UUID uuid) {
|
||||
return PageLinks.toGroup(uuid);
|
||||
}
|
||||
|
||||
public static String toGroup(AccountGroup.UUID uuid, String panel) {
|
||||
return toGroup(uuid) + "," + panel;
|
||||
}
|
||||
|
||||
public static String toProject(Project.NameKey n) {
|
||||
return toProjectAdmin(n, ProjectScreen.getSavedPanel());
|
||||
}
|
||||
|
||||
public static String toProjectAdmin(Project.NameKey n, String panel) {
|
||||
if (panel == null || ProjectScreen.INFO.equals(panel)) {
|
||||
return ADMIN_PROJECTS + n.toString();
|
||||
}
|
||||
return ADMIN_PROJECTS + n.toString() + "," + panel;
|
||||
}
|
||||
|
||||
static final String RELOAD_UI = "/reload-ui/";
|
||||
private static boolean wasStartedByReloadUI;
|
||||
|
||||
void display(String token) {
|
||||
assert token != null;
|
||||
try {
|
||||
try {
|
||||
if (matchPrefix(RELOAD_UI, token)) {
|
||||
wasStartedByReloadUI = true;
|
||||
token = skip(token);
|
||||
}
|
||||
select(token);
|
||||
} finally {
|
||||
wasStartedByReloadUI = false;
|
||||
}
|
||||
} catch (RuntimeException err) {
|
||||
GWT.log("Error parsing history token: " + token, err);
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
}
|
||||
|
||||
private static void select(String token) {
|
||||
token = Gerrit.getUrlAliasMatcher().replace(token);
|
||||
|
||||
if (matchPrefix(QUERY, token)) {
|
||||
query(token);
|
||||
|
||||
} else if (matchPrefix("/Documentation/q/", token)) {
|
||||
docSearch(token);
|
||||
|
||||
} else if (matchPrefix("/c/", token)) {
|
||||
change(token);
|
||||
|
||||
} else if (matchPrefix("/x/", token)) {
|
||||
extension(token);
|
||||
|
||||
} else if (matchExact(MINE, token)) {
|
||||
String defaultScreenToken = Gerrit.getDefaultScreenToken();
|
||||
if (defaultScreenToken != null && !MINE.equals(defaultScreenToken)) {
|
||||
select(defaultScreenToken);
|
||||
} else {
|
||||
Gerrit.display(token, mine());
|
||||
}
|
||||
|
||||
} else if (matchPrefix("/dashboard/", token)) {
|
||||
dashboard(token);
|
||||
|
||||
} else if (matchPrefix(PROJECTS, token)) {
|
||||
projects(token);
|
||||
|
||||
} else if (matchExact(SETTINGS, token)
|
||||
|| matchPrefix("/settings/", token)
|
||||
|| matchExact(MY_GROUPS, token)
|
||||
|| matchExact("register", token)
|
||||
|| matchExact(REGISTER, token)
|
||||
|| matchPrefix("/register/", token)
|
||||
|| matchPrefix("/VE/", token)
|
||||
|| matchPrefix("VE,", token)
|
||||
|| matchPrefix("/SignInFailure,", token)) {
|
||||
settings(token);
|
||||
|
||||
} else if (matchPrefix("/admin/", token)) {
|
||||
admin(token);
|
||||
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
}
|
||||
|
||||
private static void query(String token) {
|
||||
String s = skip(token);
|
||||
int c = s.indexOf(',');
|
||||
Screen screen;
|
||||
if (c >= 0) {
|
||||
String prefix = s.substring(0, c);
|
||||
if (s.substring(c).equals(",n,z")) {
|
||||
// Respect legacy token with max sortkey.
|
||||
screen = new QueryScreen(prefix, 0);
|
||||
} else {
|
||||
screen = new QueryScreen(prefix, Integer.parseInt(s.substring(c + 1)));
|
||||
}
|
||||
} else {
|
||||
screen = new QueryScreen(s, 0);
|
||||
}
|
||||
Gerrit.display(token, screen);
|
||||
}
|
||||
|
||||
private static Screen mine() {
|
||||
if (Gerrit.isSignedIn()) {
|
||||
return new AccountDashboardScreen(Gerrit.getUserAccount()._accountId());
|
||||
}
|
||||
Screen r = new AccountDashboardScreen(null);
|
||||
r.setRequiresSignIn(true);
|
||||
return r;
|
||||
}
|
||||
|
||||
private static void dashboard(String token) {
|
||||
String rest = skip(token);
|
||||
if (rest.matches("[0-9]+")) {
|
||||
int accountId = Integer.parseInt(rest);
|
||||
Gerrit.display(token, new AccountDashboardScreen(accountId));
|
||||
return;
|
||||
}
|
||||
|
||||
if (rest.equals("self")) {
|
||||
if (Gerrit.isSignedIn()) {
|
||||
Gerrit.display(token, new AccountDashboardScreen(Gerrit.getUserAccount()._accountId()));
|
||||
} else {
|
||||
Screen s = new AccountDashboardScreen(null);
|
||||
s.setRequiresSignIn(true);
|
||||
Gerrit.display(token, s);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (rest.startsWith("?")) {
|
||||
Gerrit.display(token, new CustomDashboardScreen(rest.substring(1)));
|
||||
return;
|
||||
}
|
||||
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
|
||||
private static void projects(String token) {
|
||||
String rest = skip(token);
|
||||
int c = rest.indexOf(DASHBOARDS);
|
||||
if (0 <= c) {
|
||||
final String project = URL.decodePathSegment(rest.substring(0, c));
|
||||
rest = rest.substring(c);
|
||||
if (matchPrefix(DASHBOARDS, rest)) {
|
||||
final String dashboardId = skip(rest);
|
||||
GerritCallback<DashboardInfo> cb =
|
||||
new GerritCallback<DashboardInfo>() {
|
||||
@Override
|
||||
public void onSuccess(DashboardInfo result) {
|
||||
if (matchPrefix("/dashboard/", result.url())) {
|
||||
String params = skip(result.url()).substring(1);
|
||||
ProjectDashboardScreen dash =
|
||||
new ProjectDashboardScreen(new Project.NameKey(project), params);
|
||||
Gerrit.display(token, dash);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if ("default".equals(dashboardId) && RestApi.isNotFound(caught)) {
|
||||
Gerrit.display(
|
||||
PageLinks.toChangeQuery(
|
||||
PageLinks.projectQuery(new Project.NameKey(project))));
|
||||
} else {
|
||||
super.onFailure(caught);
|
||||
}
|
||||
}
|
||||
};
|
||||
if ("default".equals(dashboardId)) {
|
||||
DashboardList.getDefault(new Project.NameKey(project), cb);
|
||||
return;
|
||||
}
|
||||
c = dashboardId.indexOf(":");
|
||||
if (0 <= c) {
|
||||
final String ref = URL.decodeQueryString(dashboardId.substring(0, c));
|
||||
final String path = URL.decodeQueryString(dashboardId.substring(c + 1));
|
||||
DashboardList.get(new Project.NameKey(project), ref + ":" + path, cb);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
|
||||
private static void change(String token) {
|
||||
String rest = skip(token);
|
||||
int c = rest.lastIndexOf(',');
|
||||
String panel = null;
|
||||
if (0 <= c) {
|
||||
panel = rest.substring(c + 1);
|
||||
rest = rest.substring(0, c);
|
||||
int at = panel.lastIndexOf('@');
|
||||
if (at > 0) {
|
||||
rest += panel.substring(at);
|
||||
panel = panel.substring(0, at);
|
||||
}
|
||||
}
|
||||
|
||||
ProjectChangeId id = ProjectChangeId.create(rest);
|
||||
rest = rest.length() > id.identifierLength() ? rest.substring(id.identifierLength() + 1) : "";
|
||||
|
||||
if (rest.isEmpty()) {
|
||||
FileTable.Mode mode = FileTable.Mode.REVIEW;
|
||||
if (panel != null && (panel.equals("edit") || panel.startsWith("edit/"))) {
|
||||
mode = FileTable.Mode.EDIT;
|
||||
panel = null;
|
||||
}
|
||||
Gerrit.display(
|
||||
token,
|
||||
panel == null
|
||||
? new ChangeScreen(
|
||||
id.getProject(), id.getChangeId(), DiffObject.base(), null, false, mode)
|
||||
: new NotFoundScreen());
|
||||
return;
|
||||
}
|
||||
|
||||
String psIdStr;
|
||||
int s = rest.indexOf('/');
|
||||
if (0 <= s) {
|
||||
psIdStr = rest.substring(0, s);
|
||||
rest = rest.substring(s + 1);
|
||||
} else {
|
||||
psIdStr = rest;
|
||||
rest = "";
|
||||
}
|
||||
|
||||
DiffObject base = DiffObject.base();
|
||||
PatchSet.Id ps;
|
||||
int dotdot = psIdStr.indexOf("..");
|
||||
if (1 <= dotdot) {
|
||||
base = DiffObject.parse(id.getChangeId(), psIdStr.substring(0, dotdot));
|
||||
if (base == null) {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
psIdStr = psIdStr.substring(dotdot + 2);
|
||||
}
|
||||
ps = toPsId(id.getChangeId(), psIdStr);
|
||||
|
||||
if (!rest.isEmpty()) {
|
||||
DisplaySide side = DisplaySide.B;
|
||||
int line = 0;
|
||||
int at = rest.lastIndexOf('@');
|
||||
if (at > 0) {
|
||||
String l = rest.substring(at + 1);
|
||||
if (l.startsWith("a")) {
|
||||
side = DisplaySide.A;
|
||||
l = l.substring(1);
|
||||
}
|
||||
line = Integer.parseInt(l);
|
||||
rest = rest.substring(0, at);
|
||||
}
|
||||
Patch.Key p = new Patch.Key(ps, KeyUtil.decode(rest));
|
||||
patch(token, id.getProject(), base, p, side, line, panel);
|
||||
} else {
|
||||
if (panel == null) {
|
||||
Gerrit.display(
|
||||
token,
|
||||
new ChangeScreen(
|
||||
id.getProject(),
|
||||
id.getChangeId(),
|
||||
base,
|
||||
String.valueOf(ps.get()),
|
||||
false,
|
||||
FileTable.Mode.REVIEW));
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static PatchSet.Id toPsId(Change.Id id, String psIdStr) {
|
||||
return new PatchSet.Id(id, psIdStr.equals("edit") ? 0 : Integer.parseInt(psIdStr));
|
||||
}
|
||||
|
||||
private static void extension(String token) {
|
||||
ExtensionScreen view = new ExtensionScreen(skip(token));
|
||||
if (view.isFound()) {
|
||||
Gerrit.display(token, view);
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
}
|
||||
|
||||
private static void patch(
|
||||
String token,
|
||||
@Nullable Project.NameKey project,
|
||||
DiffObject base,
|
||||
Patch.Key id,
|
||||
DisplaySide side,
|
||||
int line,
|
||||
String panelType) {
|
||||
String panel = panelType;
|
||||
if (panel == null) {
|
||||
int c = token.lastIndexOf(',');
|
||||
panel = 0 <= c ? token.substring(c + 1) : "";
|
||||
}
|
||||
|
||||
if ("".equals(panel) || /* DEPRECATED URL */ "cm".equals(panel)) {
|
||||
if (preferUnified()) {
|
||||
unified(token, project, base, id, side, line);
|
||||
} else {
|
||||
codemirror(token, base, project, id, side, line);
|
||||
}
|
||||
} else if ("sidebyside".equals(panel)) {
|
||||
codemirror(token, base, project, id, side, line);
|
||||
} else if ("unified".equals(panel)) {
|
||||
unified(token, project, base, id, side, line);
|
||||
} else if ("edit".equals(panel)) {
|
||||
if (!Patch.isMagic(id.get()) || Patch.COMMIT_MSG.equals(id.get())) {
|
||||
codemirrorForEdit(token, project, id, line);
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean preferUnified() {
|
||||
return DiffView.UNIFIED_DIFF.equals(Gerrit.getUserPreferences().diffView())
|
||||
|| (UserAgent.isPortrait() && UserAgent.isMobile());
|
||||
}
|
||||
|
||||
private static void unified(
|
||||
final String token,
|
||||
final Project.NameKey project,
|
||||
final DiffObject base,
|
||||
final Patch.Key id,
|
||||
final DisplaySide side,
|
||||
final int line) {
|
||||
GWT.runAsync(
|
||||
new AsyncSplit(token) {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Gerrit.display(
|
||||
token,
|
||||
new Unified(
|
||||
project, base, DiffObject.patchSet(id.getParentKey()), id.get(), side, line));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void codemirror(
|
||||
final String token,
|
||||
final DiffObject base,
|
||||
@Nullable final Project.NameKey project,
|
||||
final Patch.Key id,
|
||||
final DisplaySide side,
|
||||
final int line) {
|
||||
GWT.runAsync(
|
||||
new AsyncSplit(token) {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Gerrit.display(
|
||||
token,
|
||||
new SideBySide(
|
||||
project, base, DiffObject.patchSet(id.getParentKey()), id.get(), side, line));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void codemirrorForEdit(
|
||||
final String token,
|
||||
@Nullable final Project.NameKey project,
|
||||
final Patch.Key id,
|
||||
final int line) {
|
||||
GWT.runAsync(
|
||||
new AsyncSplit(token) {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Gerrit.display(token, new EditScreen(project, id, line));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void settings(String token) {
|
||||
GWT.runAsync(
|
||||
new AsyncSplit(token) {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Gerrit.display(token, select());
|
||||
}
|
||||
|
||||
private Screen select() {
|
||||
if (matchExact(SETTINGS, token)) {
|
||||
return new MyProfileScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_PREFERENCES, token)) {
|
||||
return new MyPreferencesScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_DIFF_PREFERENCES, token)) {
|
||||
return new MyDiffPreferencesScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_EDIT_PREFERENCES, token)) {
|
||||
return new MyEditPreferencesScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_PROJECTS, token)) {
|
||||
return new MyWatchedProjectsScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_CONTACT, token)) {
|
||||
return new MyContactInformationScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_SSHKEYS, token)) {
|
||||
return new MySshKeysScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_GPGKEYS, token) && Gerrit.info().gerrit().editGpgKeys()) {
|
||||
return new MyGpgKeysScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_WEBIDENT, token)) {
|
||||
return new MyIdentitiesScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_HTTP_PASSWORD, token)) {
|
||||
return new MyPasswordScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_OAUTH_TOKEN, token) && Gerrit.info().auth().isOAuth()) {
|
||||
return new MyOAuthTokenScreen();
|
||||
}
|
||||
|
||||
if (matchExact(MY_GROUPS, token) || matchExact(SETTINGS_MYGROUPS, token)) {
|
||||
return new MyGroupsScreen();
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_AGREEMENTS, token)
|
||||
&& Gerrit.info().auth().useContributorAgreements()) {
|
||||
return new MyAgreementsScreen();
|
||||
}
|
||||
|
||||
if (matchExact(REGISTER, token)
|
||||
|| matchExact("/register/", token)
|
||||
|| matchExact("register", token)) {
|
||||
return new RegisterScreen(MINE);
|
||||
} else if (matchPrefix("/register/", token)) {
|
||||
return new RegisterScreen("/" + skip(token));
|
||||
}
|
||||
|
||||
if (matchPrefix("/VE/", token) || matchPrefix("VE,", token)) {
|
||||
return new ValidateEmailScreen(skip(token));
|
||||
}
|
||||
|
||||
if (matchExact(SETTINGS_NEW_AGREEMENT, token)) {
|
||||
return new NewAgreementScreen();
|
||||
}
|
||||
|
||||
if (matchPrefix(SETTINGS_NEW_AGREEMENT + "/", token)) {
|
||||
return new NewAgreementScreen(skip(token));
|
||||
}
|
||||
|
||||
if (matchPrefix(SETTINGS_EXTENSION, token)) {
|
||||
ExtensionSettingsScreen view = new ExtensionSettingsScreen(skip(token));
|
||||
if (view.isFound()) {
|
||||
return view;
|
||||
}
|
||||
return new NotFoundScreen();
|
||||
}
|
||||
|
||||
return new NotFoundScreen();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void admin(String token) {
|
||||
GWT.runAsync(
|
||||
new AsyncSplit(token) {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (matchExact(ADMIN_GROUPS, token) || matchExact("/admin/groups", token)) {
|
||||
Gerrit.display(token, new GroupListScreen());
|
||||
|
||||
} else if (matchPrefix(ADMIN_GROUPS, token)) {
|
||||
String rest = skip(token);
|
||||
if (rest.startsWith("?")) {
|
||||
Gerrit.display(token, new GroupListScreen(rest.substring(1)));
|
||||
} else {
|
||||
group();
|
||||
}
|
||||
|
||||
} else if (matchPrefix("/admin/groups", token)) {
|
||||
String rest = skip(token);
|
||||
if (rest.startsWith("?")) {
|
||||
Gerrit.display(token, new GroupListScreen(rest.substring(1)));
|
||||
}
|
||||
|
||||
} else if (matchExact(ADMIN_PROJECTS, token) || matchExact("/admin/projects", token)) {
|
||||
Gerrit.display(token, new ProjectListScreen());
|
||||
|
||||
} else if (matchPrefix(ADMIN_PROJECTS, token)) {
|
||||
String rest = skip(token);
|
||||
if (rest.startsWith("?")) {
|
||||
Gerrit.display(token, new ProjectListScreen(rest.substring(1)));
|
||||
} else {
|
||||
Gerrit.display(token, selectProject());
|
||||
}
|
||||
|
||||
} else if (matchPrefix("/admin/projects", token)) {
|
||||
String rest = skip(token);
|
||||
if (rest.startsWith("?")) {
|
||||
Gerrit.display(token, new ProjectListScreen(rest.substring(1)));
|
||||
}
|
||||
|
||||
} else if (matchPrefix(ADMIN_PLUGINS, token) || matchExact("/admin/plugins", token)) {
|
||||
Gerrit.display(token, new PluginListScreen());
|
||||
|
||||
} else if (matchExact(ADMIN_CREATE_PROJECT, token)
|
||||
|| matchExact("/admin/create-project", token)) {
|
||||
Gerrit.display(token, new CreateProjectScreen());
|
||||
|
||||
} else if (matchExact(ADMIN_CREATE_GROUP, token)
|
||||
|| matchExact("/admin/create-group", token)) {
|
||||
Gerrit.display(token, new CreateGroupScreen());
|
||||
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
}
|
||||
|
||||
private void group() {
|
||||
final String panel;
|
||||
final String group;
|
||||
|
||||
if (matchPrefix("/admin/groups/uuid-", token)) {
|
||||
String p = skip(token);
|
||||
int c = p.indexOf(',');
|
||||
if (c < 0) {
|
||||
group = p;
|
||||
panel = null;
|
||||
} else {
|
||||
group = p.substring(0, c);
|
||||
panel = p.substring(c + 1);
|
||||
}
|
||||
} else if (matchPrefix(ADMIN_GROUPS, token)) {
|
||||
String p = skip(token);
|
||||
int c = p.indexOf(',');
|
||||
if (c < 0) {
|
||||
group = p;
|
||||
panel = null;
|
||||
} else {
|
||||
group = p.substring(0, c);
|
||||
panel = p.substring(c + 1);
|
||||
}
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
return;
|
||||
}
|
||||
|
||||
GroupApi.getGroupDetail(
|
||||
group,
|
||||
new GerritCallback<GroupInfo>() {
|
||||
@Override
|
||||
public void onSuccess(GroupInfo group) {
|
||||
if (panel == null || panel.isEmpty()) {
|
||||
// The token does not say which group screen should be shown,
|
||||
// as default for internal groups show the members, as default
|
||||
// for external and system groups show the info screen (since
|
||||
// for external and system groups the members cannot be
|
||||
// shown in the web UI).
|
||||
//
|
||||
if (AccountGroup.isInternalGroup(group.getGroupUUID())) {
|
||||
String newToken = toGroup(group.getGroupId(), AccountGroupScreen.MEMBERS);
|
||||
Gerrit.display(newToken, new AccountGroupMembersScreen(group, newToken));
|
||||
} else {
|
||||
String newToken = toGroup(group.getGroupId(), AccountGroupScreen.INFO);
|
||||
Gerrit.display(newToken, new AccountGroupInfoScreen(group, newToken));
|
||||
}
|
||||
} else if (AccountGroupScreen.INFO.equals(panel)) {
|
||||
Gerrit.display(token, new AccountGroupInfoScreen(group, token));
|
||||
} else if (AccountGroupScreen.MEMBERS.equals(panel)) {
|
||||
Gerrit.display(token, new AccountGroupMembersScreen(group, token));
|
||||
} else if (AccountGroupScreen.AUDIT_LOG.equals(panel)) {
|
||||
Gerrit.display(token, new AccountGroupAuditLogScreen(group, token));
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Screen selectProject() {
|
||||
if (matchPrefix(ADMIN_PROJECTS, token)) {
|
||||
String rest = skip(token);
|
||||
int c = rest.lastIndexOf(',');
|
||||
if (c < 0) {
|
||||
return new ProjectInfoScreen(Project.NameKey.parse(rest));
|
||||
} else if (c == 0) {
|
||||
return new NotFoundScreen();
|
||||
}
|
||||
|
||||
int q = rest.lastIndexOf('?');
|
||||
if (q > 0 && rest.lastIndexOf(',', q) > 0) {
|
||||
c = rest.substring(0, q - 1).lastIndexOf(',');
|
||||
}
|
||||
|
||||
Project.NameKey k = Project.NameKey.parse(rest.substring(0, c));
|
||||
String panel = rest.substring(c + 1);
|
||||
|
||||
if (ProjectScreen.INFO.equals(panel)) {
|
||||
return new ProjectInfoScreen(k);
|
||||
}
|
||||
|
||||
if (ProjectScreen.BRANCHES.equals(panel)
|
||||
|| matchPrefix(ProjectScreen.BRANCHES, panel)) {
|
||||
return new ProjectBranchesScreen(k);
|
||||
}
|
||||
|
||||
if (ProjectScreen.TAGS.equals(panel) || matchPrefix(ProjectScreen.TAGS, panel)) {
|
||||
return new ProjectTagsScreen(k);
|
||||
}
|
||||
|
||||
if (ProjectScreen.ACCESS.equals(panel)) {
|
||||
return new ProjectAccessScreen(k);
|
||||
}
|
||||
|
||||
if (ProjectScreen.DASHBOARDS.equals(panel)) {
|
||||
return new ProjectDashboardsScreen(k);
|
||||
}
|
||||
}
|
||||
return new NotFoundScreen();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean matchExact(String want, String token) {
|
||||
return token.equals(want);
|
||||
}
|
||||
|
||||
private static int prefixlen;
|
||||
|
||||
private static boolean matchPrefix(String want, String token) {
|
||||
if (token.startsWith(want)) {
|
||||
prefixlen = want.length();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String skip(String token) {
|
||||
return token.substring(prefixlen);
|
||||
}
|
||||
|
||||
private abstract static class AsyncSplit implements RunAsyncCallback {
|
||||
private final boolean isReloadUi;
|
||||
protected final String token;
|
||||
|
||||
protected AsyncSplit(String token) {
|
||||
this.isReloadUi = wasStartedByReloadUI;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onFailure(Throwable reason) {
|
||||
if (!isReloadUi && "HTTP download failed with status 404".equals(reason.getMessage())) {
|
||||
// The server was upgraded since we last download the main script,
|
||||
// so the pointers to the splits aren't valid anymore. Force the
|
||||
// page to reload itself and pick up the new code.
|
||||
//
|
||||
Gerrit.upgradeUI(token);
|
||||
} else {
|
||||
new ErrorDialog(reason).center();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void docSearch(String token) {
|
||||
GWT.runAsync(
|
||||
new AsyncSplit(token) {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
Gerrit.display(token, new DocScreen(skip(token)));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gerrit.client.rpc.RestApi;
|
||||
import com.google.gerrit.client.rpc.RpcConstants;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.http.client.Response;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.StatusCodeException;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.PopupPanel;
|
||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
||||
import com.google.gwtjsonrpc.client.RemoteJsonException;
|
||||
|
||||
/** A dialog box showing an error message, when bad things happen. */
|
||||
public class ErrorDialog extends PopupPanel {
|
||||
private final Label text;
|
||||
private final FlowPanel body;
|
||||
private final Button closey;
|
||||
|
||||
protected ErrorDialog() {
|
||||
super(/* auto hide */ false, /* modal */ true);
|
||||
setGlassEnabled(true);
|
||||
getGlassElement().addClassName(Gerrit.RESOURCES.css().errorDialogGlass());
|
||||
|
||||
text = new Label();
|
||||
text.setStyleName(Gerrit.RESOURCES.css().errorDialogTitle());
|
||||
|
||||
body = new FlowPanel();
|
||||
|
||||
final FlowPanel buttons = new FlowPanel();
|
||||
buttons.setStyleName(Gerrit.RESOURCES.css().errorDialogButtons());
|
||||
|
||||
closey = new Button();
|
||||
closey.setText(Gerrit.C.errorDialogContinue());
|
||||
closey.addClickHandler(
|
||||
new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
closey.addKeyPressHandler(
|
||||
new KeyPressHandler() {
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
// if the close button is triggered by a key we need to consume the key
|
||||
// event, otherwise the key event would be propagated to the parent
|
||||
// screen and eventually trigger some unwanted action there after the
|
||||
// error dialog was closed
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
buttons.add(closey);
|
||||
|
||||
final FlowPanel center = new FlowPanel();
|
||||
center.add(text);
|
||||
center.add(body);
|
||||
center.add(buttons);
|
||||
|
||||
setText(Gerrit.C.errorTitle());
|
||||
addStyleName(Gerrit.RESOURCES.css().errorDialog());
|
||||
add(center);
|
||||
|
||||
int l = Window.getScrollLeft() + 20;
|
||||
int t = Window.getScrollTop() + 20;
|
||||
setPopupPosition(l, t);
|
||||
}
|
||||
|
||||
/** Create a dialog box to show a single message string. */
|
||||
public ErrorDialog(String message) {
|
||||
this();
|
||||
body.add(createErrorMsgLabel(message));
|
||||
}
|
||||
|
||||
/** Create a dialog box to show a single message string. */
|
||||
public ErrorDialog(SafeHtml message) {
|
||||
this();
|
||||
body.add(message.toBlockWidget());
|
||||
}
|
||||
|
||||
/** Create a dialog box to nicely format an exception. */
|
||||
public ErrorDialog(Throwable what) {
|
||||
this();
|
||||
|
||||
String hdr;
|
||||
String msg;
|
||||
|
||||
if (what instanceof StatusCodeException) {
|
||||
StatusCodeException sc = (StatusCodeException) what;
|
||||
if (RestApi.isExpected(sc.getStatusCode())) {
|
||||
hdr = null;
|
||||
msg = sc.getEncodedResponse();
|
||||
} else if (sc.getStatusCode() == Response.SC_INTERNAL_SERVER_ERROR) {
|
||||
hdr = null;
|
||||
msg = what.getMessage();
|
||||
} else {
|
||||
hdr = RpcConstants.C.errorServerUnavailable();
|
||||
msg = what.getMessage();
|
||||
}
|
||||
|
||||
} else if (what instanceof RemoteJsonException) {
|
||||
// TODO Remove RemoteJsonException from Gerrit sources.
|
||||
hdr = RpcConstants.C.errorRemoteJsonException();
|
||||
msg = what.getMessage();
|
||||
|
||||
} else {
|
||||
// TODO Fix callers of ErrorDialog to stop passing random types.
|
||||
hdr = what.getClass().getName();
|
||||
if (hdr.startsWith("java.lang.")) {
|
||||
hdr = hdr.substring("java.lang.".length());
|
||||
} else if (hdr.startsWith("com.google.gerrit.")) {
|
||||
hdr = hdr.substring(hdr.lastIndexOf('.') + 1);
|
||||
}
|
||||
if (hdr.endsWith("Exception")) {
|
||||
hdr = hdr.substring(0, hdr.length() - "Exception".length());
|
||||
} else if (hdr.endsWith("Error")) {
|
||||
hdr = hdr.substring(0, hdr.length() - "Error".length());
|
||||
}
|
||||
msg = what.getMessage();
|
||||
}
|
||||
|
||||
if (hdr != null) {
|
||||
final Label r = new Label(hdr);
|
||||
r.setStyleName(Gerrit.RESOURCES.css().errorDialogErrorType());
|
||||
body.add(r);
|
||||
}
|
||||
|
||||
if (msg != null) {
|
||||
body.add(createErrorMsgLabel(msg));
|
||||
}
|
||||
}
|
||||
|
||||
private Label createErrorMsgLabel(String message) {
|
||||
Label m = new Label(message);
|
||||
m.getElement().getStyle().setProperty("white-space", "pre");
|
||||
return m;
|
||||
}
|
||||
|
||||
public ErrorDialog setText(String t) {
|
||||
text.setText(t);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void center() {
|
||||
show();
|
||||
closey.setFocus(true);
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gerrit.client.change.Resources;
|
||||
import com.google.gerrit.client.info.AccountInfo;
|
||||
import com.google.gerrit.client.info.GeneralPreferences;
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/** Misc. formatting functions. */
|
||||
public class FormatUtil {
|
||||
private static DateFormatter dateFormatter;
|
||||
|
||||
public static void setPreferences(GeneralPreferences prefs) {
|
||||
dateFormatter = new DateFormatter(prefs);
|
||||
}
|
||||
|
||||
/** Format a date using a really short format. */
|
||||
public static String shortFormat(Date dt) {
|
||||
ensureInited();
|
||||
return dateFormatter.shortFormat(dt);
|
||||
}
|
||||
|
||||
/** Format a date using a really short format. */
|
||||
public static String shortFormatDayTime(Date dt) {
|
||||
ensureInited();
|
||||
return dateFormatter.shortFormatDayTime(dt);
|
||||
}
|
||||
|
||||
/** Format a date using the locale's medium length format. */
|
||||
public static String mediumFormat(Date dt) {
|
||||
ensureInited();
|
||||
return dateFormatter.mediumFormat(dt);
|
||||
}
|
||||
|
||||
private static void ensureInited() {
|
||||
if (dateFormatter == null) {
|
||||
setPreferences(Gerrit.getUserPreferences());
|
||||
}
|
||||
}
|
||||
|
||||
/** Format a date using git log's relative date format. */
|
||||
public static String relativeFormat(Date dt) {
|
||||
return RelativeDateFormatter.format(dt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an account as a name and an email address.
|
||||
*
|
||||
* <p>Example output:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code A U. Thor <author@example.com>}: full populated
|
||||
* <li>{@code A U. Thor (12)}: missing email address
|
||||
* <li>{@code Anonymous Coward <author@example.com>}: missing name
|
||||
* <li>{@code Anonymous Coward (12)}: missing name and email address
|
||||
* </ul>
|
||||
*/
|
||||
public static String nameEmail(AccountInfo info) {
|
||||
return createAccountFormatter().nameEmail(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an account name.
|
||||
*
|
||||
* <p>If the account has a full name, it returns only the full name. Otherwise it returns a longer
|
||||
* form that includes the email address.
|
||||
*/
|
||||
public static String name(AccountInfo info) {
|
||||
return createAccountFormatter().name(info);
|
||||
}
|
||||
|
||||
private static AccountFormatter createAccountFormatter() {
|
||||
return new AccountFormatter(Gerrit.info().user().anonymousCowardName());
|
||||
}
|
||||
|
||||
/** The returned format string doesn't contain any +/- sign. */
|
||||
public static String formatAbsBytes(long bytes) {
|
||||
return formatBytes(bytes, true);
|
||||
}
|
||||
|
||||
public static String formatBytes(long bytes) {
|
||||
return formatBytes(bytes, false);
|
||||
}
|
||||
|
||||
private static String formatBytes(long bytes, boolean abs) {
|
||||
bytes = abs ? Math.abs(bytes) : bytes;
|
||||
|
||||
if (bytes == 0) {
|
||||
return abs ? "0 B" : "+/- 0 B";
|
||||
}
|
||||
|
||||
if (Math.abs(bytes) < 1024) {
|
||||
return (bytes > 0 && !abs ? "+" : "") + bytes + " B";
|
||||
}
|
||||
|
||||
int exp = (int) (Math.log(Math.abs(bytes)) / Math.log(1024));
|
||||
return (bytes > 0 && !abs ? "+" : "")
|
||||
+ NumberFormat.getFormat("#.0").format(bytes / Math.pow(1024, exp))
|
||||
+ " "
|
||||
+ "KMGTPE".charAt(exp - 1)
|
||||
+ "iB";
|
||||
}
|
||||
|
||||
public static String formatPercentage(long size, long delta) {
|
||||
if (size == 0) {
|
||||
return Resources.C.notAvailable();
|
||||
}
|
||||
return (delta > 0 ? "+" : "-") + formatAbsPercentage(size, delta);
|
||||
}
|
||||
|
||||
public static String formatAbsPercentage(long size, long delta) {
|
||||
if (size == 0) {
|
||||
return Resources.C.notAvailable();
|
||||
}
|
||||
long percentage = Math.abs(Math.round(delta * 100.0 / size));
|
||||
return percentage + "%";
|
||||
}
|
||||
}
|
@ -1,199 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gwt.i18n.client.Constants;
|
||||
|
||||
public interface GerritConstants extends Constants {
|
||||
String menuSignIn();
|
||||
|
||||
String menuRegister();
|
||||
|
||||
String reportBug();
|
||||
|
||||
String loadingPlugins();
|
||||
|
||||
String signInDialogTitle();
|
||||
|
||||
String signInDialogGoAnonymous();
|
||||
|
||||
String linkIdentityDialogTitle();
|
||||
|
||||
String registerDialogTitle();
|
||||
|
||||
String loginTypeUnsupported();
|
||||
|
||||
String errorTitle();
|
||||
|
||||
String errorDialogContinue();
|
||||
|
||||
String warnTitle();
|
||||
|
||||
String confirmationDialogOk();
|
||||
|
||||
String confirmationDialogCancel();
|
||||
|
||||
String branchCreationDialogTitle();
|
||||
|
||||
String branchCreationConfirmationMessage();
|
||||
|
||||
String tagCreationDialogTitle();
|
||||
|
||||
String tagCreationConfirmationMessage();
|
||||
|
||||
String branchDeletionDialogTitle();
|
||||
|
||||
String branchDeletionConfirmationMessage();
|
||||
|
||||
String tagDeletionDialogTitle();
|
||||
|
||||
String tagDeletionConfirmationMessage();
|
||||
|
||||
String newUi();
|
||||
|
||||
String notSignedInTitle();
|
||||
|
||||
String notSignedInBody();
|
||||
|
||||
String notFoundTitle();
|
||||
|
||||
String notFoundBody();
|
||||
|
||||
String noSuchAccountTitle();
|
||||
|
||||
String noSuchGroupTitle();
|
||||
|
||||
String inactiveAccountBody();
|
||||
|
||||
String labelNotApplicable();
|
||||
|
||||
String menuAll();
|
||||
|
||||
String menuAllOpen();
|
||||
|
||||
String menuAllMerged();
|
||||
|
||||
String menuAllAbandoned();
|
||||
|
||||
String menuMine();
|
||||
|
||||
String menuMyChanges();
|
||||
|
||||
String menuMyWatchedChanges();
|
||||
|
||||
String menuMyStarredChanges();
|
||||
|
||||
String menuMyDraftComments();
|
||||
|
||||
String menuDiff();
|
||||
|
||||
String menuDiffCommit();
|
||||
|
||||
String menuDiffPreferences();
|
||||
|
||||
String menuDiffPatchSets();
|
||||
|
||||
String menuDiffFiles();
|
||||
|
||||
String menuProjects();
|
||||
|
||||
String menuProjectsList();
|
||||
|
||||
String menuProjectsInfo();
|
||||
|
||||
String menuProjectsBranches();
|
||||
|
||||
String menuProjectsTags();
|
||||
|
||||
String menuProjectsAccess();
|
||||
|
||||
String menuProjectsDashboards();
|
||||
|
||||
String menuProjectsCreate();
|
||||
|
||||
String menuPeople();
|
||||
|
||||
String menuPeopleGroupsList();
|
||||
|
||||
String menuPeopleGroupsCreate();
|
||||
|
||||
String menuPlugins();
|
||||
|
||||
String menuPluginsInstalled();
|
||||
|
||||
String menuDocumentation();
|
||||
|
||||
String menuDocumentationTOC();
|
||||
|
||||
String menuDocumentationSearch();
|
||||
|
||||
String menuDocumentationUpload();
|
||||
|
||||
String menuDocumentationAccess();
|
||||
|
||||
String menuDocumentationAPI();
|
||||
|
||||
String menuDocumentationProjectOwnerGuide();
|
||||
|
||||
String searchHint();
|
||||
|
||||
String searchButton();
|
||||
|
||||
String rpcStatusWorking();
|
||||
|
||||
String sectionNavigation();
|
||||
|
||||
String sectionActions();
|
||||
|
||||
String keySearch();
|
||||
|
||||
String keyEditor();
|
||||
|
||||
String keyHelp();
|
||||
|
||||
String sectionJumping();
|
||||
|
||||
String jumpAllOpen();
|
||||
|
||||
String jumpAllMerged();
|
||||
|
||||
String jumpAllAbandoned();
|
||||
|
||||
String jumpMine();
|
||||
|
||||
String jumpMineWatched();
|
||||
|
||||
String jumpMineStarred();
|
||||
|
||||
String jumpMineDraftComments();
|
||||
|
||||
String projectAccessError();
|
||||
|
||||
String projectAccessProposeForReviewHint();
|
||||
|
||||
String userCannotVoteToolTip();
|
||||
|
||||
String stringListPanelAdd();
|
||||
|
||||
String stringListPanelDelete();
|
||||
|
||||
String stringListPanelUp();
|
||||
|
||||
String stringListPanelDown();
|
||||
|
||||
String searchDropdownChanges();
|
||||
|
||||
String searchDropdownDoc();
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
menuSignIn = Sign In
|
||||
menuRegister = Register
|
||||
reportBug = Report Bug
|
||||
loadingPlugins = Loading plugins ...
|
||||
|
||||
signInDialogTitle = Code Review - Sign In
|
||||
signInDialogGoAnonymous = Go Anonymous
|
||||
|
||||
linkIdentityDialogTitle = Code Review - Link Identity
|
||||
registerDialogTitle = Code Review - Register New Account
|
||||
loginTypeUnsupported = Sign in is not available.
|
||||
|
||||
errorTitle = Code Review - Error
|
||||
errorDialogContinue = Continue
|
||||
warnTitle = Code Review - Warning
|
||||
|
||||
confirmationDialogOk = OK
|
||||
confirmationDialogCancel = Cancel
|
||||
|
||||
branchCreationDialogTitle = Branch Creation
|
||||
branchCreationConfirmationMessage = The following branch was successfully created:
|
||||
|
||||
tagCreationDialogTitle = Tag Creation
|
||||
tagCreationConfirmationMessage = The following tag was successfully created:
|
||||
|
||||
branchDeletionDialogTitle = Branch Deletion
|
||||
branchDeletionConfirmationMessage = Do you really want to delete the following branches?
|
||||
|
||||
tagDeletionDialogTitle = Tag Deletion
|
||||
tagDeletionConfirmationMessage = Do you really want to delete the following tags?
|
||||
|
||||
newUi = Switch to New UI
|
||||
|
||||
notSignedInTitle = Code Review - Session Expired
|
||||
notSignedInBody = <b>Session Expired</b>\
|
||||
<p>You are no longer signed in to Gerrit Code Review.</p>\
|
||||
<p>To continue, please sign-in again.</p>
|
||||
|
||||
notFoundTitle = Not Found
|
||||
notFoundBody = The page you requested was not found, or you do not have permission to view this page.
|
||||
noSuchAccountTitle = Code Review - Unknown User
|
||||
|
||||
noSuchGroupTitle = Code Review - Unknown Group
|
||||
|
||||
inactiveAccountBody = This user is currently inactive.
|
||||
|
||||
labelNotApplicable = Label not applicable
|
||||
|
||||
menuAll = All
|
||||
menuAllOpen = Open
|
||||
menuAllMerged = Merged
|
||||
menuAllAbandoned = Abandoned
|
||||
|
||||
menuMine = My
|
||||
menuMyChanges = Changes
|
||||
menuMyStarredChanges = Starred Changes
|
||||
menuMyWatchedChanges = Watched Changes
|
||||
menuMyDraftComments = Draft Comments
|
||||
|
||||
menuDiff = Differences
|
||||
menuDiffCommit = Commit Message
|
||||
menuDiffPreferences = Preferences
|
||||
menuDiffPatchSets = Patch Sets
|
||||
menuDiffFiles = Files
|
||||
|
||||
menuProjects = Projects
|
||||
menuProjectsList = List
|
||||
menuProjectsInfo = General
|
||||
menuProjectsBranches = Branches
|
||||
menuProjectsTags = Tags
|
||||
menuProjectsAccess = Access
|
||||
menuProjectsDashboards = Dashboards
|
||||
menuProjectsCreate = Create New Project
|
||||
|
||||
menuPeople = People
|
||||
menuPeopleGroupsList = List Groups
|
||||
menuPeopleGroupsCreate = Create New Group
|
||||
|
||||
menuPlugins = Plugins
|
||||
menuPluginsInstalled = Installed
|
||||
|
||||
menuDocumentation = Documentation
|
||||
menuDocumentationTOC = Table of Contents
|
||||
menuDocumentationSearch = Searching
|
||||
menuDocumentationUpload = Uploading
|
||||
menuDocumentationAccess = Access Controls
|
||||
menuDocumentationAPI = REST API
|
||||
menuDocumentationProjectOwnerGuide = Project Owner Guide
|
||||
|
||||
searchHint = Search term
|
||||
searchButton = Search
|
||||
|
||||
rpcStatusWorking = Working ...
|
||||
|
||||
sectionNavigation = Navigation
|
||||
sectionActions = Actions
|
||||
keySearch = Search
|
||||
keyEditor = Open Inline Editor
|
||||
keyHelp = Press '?' to view keyboard shortcuts
|
||||
|
||||
sectionJumping = Jumping
|
||||
jumpAllOpen = Go to all open changes
|
||||
jumpAllMerged = Go to all merged changes
|
||||
jumpAllAbandoned = Go to all abandoned changes
|
||||
jumpMine = Go to my dashboard
|
||||
jumpMineWatched = Go to watched changes
|
||||
jumpMineStarred = Go to starred changes
|
||||
jumpMineDraftComments = Go to draft comments
|
||||
|
||||
projectAccessError = You don't have permissions to modify the access rights for the following refs:
|
||||
projectAccessProposeForReviewHint = You may propose these modifications to the project owners by clicking on 'Save for Review'.
|
||||
|
||||
userCannotVoteToolTip = User cannot vote in this category
|
||||
|
||||
stringListPanelAdd = Add
|
||||
stringListPanelDelete = Delete
|
||||
stringListPanelUp = Up
|
||||
stringListPanelDown = Down
|
||||
|
||||
searchDropdownChanges = Changes
|
||||
searchDropdownDoc = Docs
|
@ -1,299 +0,0 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
|
||||
public interface GerritCss extends CssResource {
|
||||
String accountDashboard();
|
||||
|
||||
String accountInfoBlock();
|
||||
|
||||
String accountLinkPanel();
|
||||
|
||||
String accountPassword();
|
||||
|
||||
String accountUsername();
|
||||
|
||||
String activeRow();
|
||||
|
||||
String addBranch();
|
||||
|
||||
String addMemberTextBox();
|
||||
|
||||
String addSshKeyPanel();
|
||||
|
||||
String addWatchPanel();
|
||||
|
||||
String avatarInfoPanel();
|
||||
|
||||
String bottomheader();
|
||||
|
||||
String branchTableDeleteButton();
|
||||
|
||||
String branchTablePrevNextLinks();
|
||||
|
||||
String cAPPROVAL();
|
||||
|
||||
String cASSIGNEE();
|
||||
|
||||
String cASSIGNEDTOME();
|
||||
|
||||
String cLastUpdate();
|
||||
|
||||
String cOWNER();
|
||||
|
||||
String cSIZE();
|
||||
|
||||
String cSUBJECT();
|
||||
|
||||
String cSTATUS();
|
||||
|
||||
String changeSize();
|
||||
|
||||
String changeTable();
|
||||
|
||||
String changeTablePrevNextLinks();
|
||||
|
||||
String commentedActionDialog();
|
||||
|
||||
String commentedActionMessage();
|
||||
|
||||
String contributorAgreementAlreadySubmitted();
|
||||
|
||||
String contributorAgreementButton();
|
||||
|
||||
String contributorAgreementLegal();
|
||||
|
||||
String contributorAgreementShortDescription();
|
||||
|
||||
String createProjectPanel();
|
||||
|
||||
String dataCell();
|
||||
|
||||
String dataCellHidden();
|
||||
|
||||
String dataHeader();
|
||||
|
||||
String dataHeaderHidden();
|
||||
|
||||
String downloadBox();
|
||||
|
||||
String downloadBoxTable();
|
||||
|
||||
String downloadBoxTableCommandColumn();
|
||||
|
||||
String downloadBoxSpacer();
|
||||
|
||||
String downloadBoxScheme();
|
||||
|
||||
String downloadBoxCopyLabel();
|
||||
|
||||
String downloadLink();
|
||||
|
||||
String downloadLinkCopyLabel();
|
||||
|
||||
String downloadLinkHeader();
|
||||
|
||||
String downloadLinkHeaderGap();
|
||||
|
||||
String downloadLinkList();
|
||||
|
||||
String downloadLink_Active();
|
||||
|
||||
String editHeadButton();
|
||||
|
||||
String emptySection();
|
||||
|
||||
String errorDialog();
|
||||
|
||||
String errorDialogButtons();
|
||||
|
||||
String errorDialogErrorType();
|
||||
|
||||
String errorDialogGlass();
|
||||
|
||||
String errorDialogTitle();
|
||||
|
||||
String extensionPanel();
|
||||
|
||||
String loadingPluginsDialog();
|
||||
|
||||
String gerritBody();
|
||||
|
||||
String gerritTopMenu();
|
||||
|
||||
String greenCheckClass();
|
||||
|
||||
String groupDescriptionPanel();
|
||||
|
||||
String groupIncludesTable();
|
||||
|
||||
String groupMembersTable();
|
||||
|
||||
String groupName();
|
||||
|
||||
String groupNamePanel();
|
||||
|
||||
String groupNameTextBox();
|
||||
|
||||
String groupOptionsPanel();
|
||||
|
||||
String groupOwnerPanel();
|
||||
|
||||
String groupOwnerTextBox();
|
||||
|
||||
String groupUUIDPanel();
|
||||
|
||||
String header();
|
||||
|
||||
String iconCell();
|
||||
|
||||
String iconHeader();
|
||||
|
||||
String identityUntrustedExternalId();
|
||||
|
||||
String infoBlock();
|
||||
|
||||
String inputFieldTypeHint();
|
||||
|
||||
String labelNotApplicable();
|
||||
|
||||
String leftMostCell();
|
||||
|
||||
String link();
|
||||
|
||||
String linkMenuBar();
|
||||
|
||||
String linkMenuItemNotLast();
|
||||
|
||||
String maxObjectSizeLimitEffectiveLabel();
|
||||
|
||||
String menuBarUserName();
|
||||
|
||||
String menuBarUserNameAvatar();
|
||||
|
||||
String menuBarUserNameFocusPanel();
|
||||
|
||||
String menuBarUserNamePanel();
|
||||
|
||||
String menuItem();
|
||||
|
||||
String menuScreenMenuBar();
|
||||
|
||||
String needsReview();
|
||||
|
||||
String negscore();
|
||||
|
||||
String oauthExpires();
|
||||
|
||||
String oauthInfoBlock();
|
||||
|
||||
String oauthPanel();
|
||||
|
||||
String oauthPanelCookieEntry();
|
||||
|
||||
String oauthPanelCookieHeading();
|
||||
|
||||
String oauthPanelNetRCEntry();
|
||||
|
||||
String oauthPanelNetRCHeading();
|
||||
|
||||
String oauthToken();
|
||||
|
||||
String pagingLink();
|
||||
|
||||
String patchSetActions();
|
||||
|
||||
String pluginProjectConfigInheritedValue();
|
||||
|
||||
String pluginsTable();
|
||||
|
||||
String posscore();
|
||||
|
||||
String projectActions();
|
||||
|
||||
String projectFilterLabel();
|
||||
|
||||
String projectFilterPanel();
|
||||
|
||||
String projectNameColumn();
|
||||
|
||||
String queryIcon();
|
||||
|
||||
String rebaseContentPanel();
|
||||
|
||||
String rebaseSuggestBox();
|
||||
|
||||
String registerScreenExplain();
|
||||
|
||||
String registerScreenNextLinks();
|
||||
|
||||
String registerScreenSection();
|
||||
|
||||
String rpcStatus();
|
||||
|
||||
String screen();
|
||||
|
||||
String screenHeader();
|
||||
|
||||
String searchPanel();
|
||||
|
||||
String suggestBoxPopup();
|
||||
|
||||
String sectionHeader();
|
||||
|
||||
String singleLine();
|
||||
|
||||
String smallHeading();
|
||||
|
||||
String specialBranchDataCell();
|
||||
|
||||
String specialBranchIconCell();
|
||||
|
||||
String sshHostKeyPanel();
|
||||
|
||||
String sshHostKeyPanelFingerprintData();
|
||||
|
||||
String sshHostKeyPanelHeading();
|
||||
|
||||
String sshHostKeyPanelKnownHostEntry();
|
||||
|
||||
String sshKeyPanelEncodedKey();
|
||||
|
||||
String sshKeyPanelInvalid();
|
||||
|
||||
String sshKeyTable();
|
||||
|
||||
String stringListPanelButtons();
|
||||
|
||||
String topmenu();
|
||||
|
||||
String topmenuMenuLeft();
|
||||
|
||||
String topmenuMenuRight();
|
||||
|
||||
String topmenuTDglue();
|
||||
|
||||
String topmenuTDmenu();
|
||||
|
||||
String topmost();
|
||||
|
||||
String userInfoPopup();
|
||||
|
||||
String usernameField();
|
||||
|
||||
String watchedProjectFilter();
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import com.google.gwt.i18n.client.Messages;
|
||||
|
||||
public interface GerritMessages extends Messages {
|
||||
String windowTitle1(String hostname);
|
||||
|
||||
String windowTitle2(String section, String hostname);
|
||||
|
||||
String poweredBy(String version);
|
||||
|
||||
String noSuchAccountMessage(String who);
|
||||
|
||||
String noSuchGroupMessage(String who);
|
||||
|
||||
String nameAlreadyUsedBody(String alreadyUsedName);
|
||||
|
||||
String branchCreationFailed(String branchName, String error);
|
||||
|
||||
String invalidBranchName(String branchName);
|
||||
|
||||
String invalidRevision(String revision);
|
||||
|
||||
String branchCreationNotAllowedUnderRefnamePrefix(String refnamePrefix);
|
||||
|
||||
String branchAlreadyExists(String branchName);
|
||||
|
||||
String branchCreationConflict(String branchName, String existingBranchName);
|
||||
|
||||
String pluginFailed(String scriptPath);
|
||||
|
||||
String cannotDownloadPlugin(String scriptPath);
|
||||
|
||||
String parentUpdateFailed(String message);
|
||||
|
||||
String fileCount(int fileNumber, int fileCount);
|
||||
}
|