Format all Java files with google-java-format
Change-Id: Id46240f027c75888265c1f878df52817cd50ec8a
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/AssigneeValidator.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/AssigneeValidator.java
index b7b66f5..3bec9da 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/AssigneeValidator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/AssigneeValidator.java
@@ -23,31 +23,28 @@
import com.google.gerrit.server.validators.ValidationException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AssigneeValidator implements AssigneeValidationListener {
- private static final Logger log =
- LoggerFactory.getLogger(AssigneeValidationListener.class);
+ private static final Logger log = LoggerFactory.getLogger(AssigneeValidationListener.class);
private static int MAX_ASSIGNED_CHANGES = 5;
- @Inject
- ChangeQueryBuilder queryBuilder;
+ @Inject ChangeQueryBuilder queryBuilder;
- @Inject
- ChangeQueryProcessor queryProcessor;
+ @Inject ChangeQueryProcessor queryProcessor;
@Override
- public void validateAssignee(Change change, Account assignee)
- throws ValidationException {
+ public void validateAssignee(Change change, Account assignee) throws ValidationException {
try {
if (queryProcessor
- .query(queryBuilder.assignee(assignee.getPreferredEmail())).entities()
- .size() > MAX_ASSIGNED_CHANGES) {
- throw new ValidationException("Cannot assign user to more than "
- + MAX_ASSIGNED_CHANGES + " changes");
+ .query(queryBuilder.assignee(assignee.getPreferredEmail()))
+ .entities()
+ .size()
+ > MAX_ASSIGNED_CHANGES) {
+ throw new ValidationException(
+ "Cannot assign user to more than " + MAX_ASSIGNED_CHANGES + " changes");
}
} catch (OrmException | QueryParseException e) {
log.error("Failed to validate assignee for change " + change.getId(), e);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/CommitValidator.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/CommitValidator.java
index 9bc6f5d..6703abf 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/CommitValidator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/CommitValidator.java
@@ -19,19 +19,17 @@
import com.google.gerrit.server.git.validators.CommitValidationException;
import com.google.gerrit.server.git.validators.CommitValidationListener;
import com.google.gerrit.server.git.validators.CommitValidationMessage;
-
import java.util.List;
public class CommitValidator implements CommitValidationListener {
@Override
- public List<CommitValidationMessage> onCommitReceived(
- CommitReceivedEvent receiveEvent) throws CommitValidationException {
- if ("plugins/cookbook".equals(receiveEvent.project.getName()) &&
- !receiveEvent.commit.getShortMessage().startsWith("Cookbook: ")) {
- CommitValidationMessage m = new CommitValidationMessage(
- "Subject should begin with 'Cookbook: '", true);
- throw new CommitValidationException(
- "Invalid commit message", ImmutableList.of(m));
+ public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent)
+ throws CommitValidationException {
+ if ("plugins/cookbook".equals(receiveEvent.project.getName())
+ && !receiveEvent.commit.getShortMessage().startsWith("Cookbook: ")) {
+ CommitValidationMessage m =
+ new CommitValidationMessage("Subject should begin with 'Cookbook: '", true);
+ throw new CommitValidationException("Invalid commit message", ImmutableList.of(m));
}
return ImmutableList.of();
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/ConsoleMetricReporter.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/ConsoleMetricReporter.java
index f2a3eb6..e3f88fd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/ConsoleMetricReporter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/ConsoleMetricReporter.java
@@ -13,36 +13,30 @@
// limitations under the License.
package com.googlesource.gerrit.plugins.cookbook;
+import com.codahale.metrics.ConsoleReporter;
+import com.codahale.metrics.MetricRegistry;
import com.google.gerrit.extensions.annotations.Listen;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-
-import com.codahale.metrics.ConsoleReporter;
-import com.codahale.metrics.MetricRegistry;
-
+import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.lib.Config;
-import java.util.concurrent.TimeUnit;
-
/**
- * Demonstration of how to add a new Dropwizard Metrics Reporter using
- * Gerrit's plug-in API.
+ * Demonstration of how to add a new Dropwizard Metrics Reporter using Gerrit's plug-in API.
*
- * @see <a href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#reporting-via-jmx">here</a>
- * @see <a href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#reporting-via-http">here</a>
- * @see <a href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#other-reporting">here</a>
- *
- * Also shows how to fetch plug-in specific configuration values.
- * <@see com.google.gerrit.server.config.PluginConfigFactory>
- *
- * Enable by adding the file etc/cookbook.config:
- *
- * [console-metrics]
- * enabled = true
- *
+ * @see <a
+ * href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#reporting-via-jmx">here</a>
+ * @see <a
+ * href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#reporting-via-http">here</a>
+ * @see <a
+ * href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#other-reporting">here</a>
+ * <p>Also shows how to fetch plug-in specific configuration values. <@see
+ * com.google.gerrit.server.config.PluginConfigFactory>
+ * <p>Enable by adding the file etc/cookbook.config:
+ * <p>[console-metrics] enabled = true
*/
@Listen
@Singleton
@@ -51,17 +45,18 @@
private boolean enabled;
@Inject
- public ConsoleMetricReporter(MetricRegistry registry,
- PluginConfigFactory configFactory,
- @PluginName String pluginName) {
+ public ConsoleMetricReporter(
+ MetricRegistry registry, PluginConfigFactory configFactory, @PluginName String pluginName) {
Config config = configFactory.getGlobalPluginConfig(pluginName);
enabled = config.getBoolean("console-metrics", "enabled", false);
if (!enabled) {
return;
}
this.consoleReporter =
- ConsoleReporter.forRegistry(registry).convertRatesTo(TimeUnit.SECONDS)
- .convertDurationsTo(TimeUnit.MILLISECONDS).build();
+ ConsoleReporter.forRegistry(registry)
+ .convertRatesTo(TimeUnit.SECONDS)
+ .convertDurationsTo(TimeUnit.MILLISECONDS)
+ .build();
}
@Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/DenyUploadExample.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/DenyUploadExample.java
index a19fab6..962cf37 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/DenyUploadExample.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/DenyUploadExample.java
@@ -19,21 +19,23 @@
import com.google.gerrit.server.git.validators.UploadValidationListener;
import com.google.gerrit.server.validators.ValidationException;
import com.google.inject.Inject;
-
+import java.util.Collection;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.UploadPack;
-import java.util.Collection;
-
public class DenyUploadExample implements UploadValidationListener {
- @Inject
- private CurrentUser user;
+ @Inject private CurrentUser user;
@Override
- public void onPreUpload(Repository repository, Project project,
- String remoteHost, UploadPack up, Collection<? extends ObjectId> wants,
- Collection<? extends ObjectId> haves) throws ValidationException {
+ public void onPreUpload(
+ Repository repository,
+ Project project,
+ String remoteHost,
+ UploadPack up,
+ Collection<? extends ObjectId> wants,
+ Collection<? extends ObjectId> haves)
+ throws ValidationException {
up.sendMessage("Validating project name for " + user.getUserName() + "\n");
up.sendMessage(" from host: " + remoteHost + "\n");
if (project.getName().equals("deny-upload-project")) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/DeployedOnIncludedInExtension.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/DeployedOnIncludedInExtension.java
index 14ec0da..c43930a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/DeployedOnIncludedInExtension.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/DeployedOnIncludedInExtension.java
@@ -17,7 +17,6 @@
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
import com.google.gerrit.extensions.config.ExternalIncludedIn;
-
import java.util.Collection;
public class DeployedOnIncludedInExtension implements ExternalIncludedIn {
@@ -25,10 +24,9 @@
private static final String STAGING = "Staging";
@Override
- public ListMultimap<String, String> getIncludedIn(String project,
- String commit, Collection<String> tags, Collection<String> branches) {
- ListMultimap<String, String> m =
- MultimapBuilder.hashKeys().arrayListValues().build();
+ public ListMultimap<String, String> getIncludedIn(
+ String project, String commit, Collection<String> tags, Collection<String> branches) {
+ ListMultimap<String, String> m = MultimapBuilder.hashKeys().arrayListValues().build();
m.put(PROD, "A");
m.put(PROD, "B");
m.put(PROD, "C");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/Greetings.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/Greetings.java
index f53b066..b577ff8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/Greetings.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/Greetings.java
@@ -17,7 +17,6 @@
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.change.RevisionResource;
-
import java.util.ArrayList;
import java.util.Collection;
@@ -26,12 +25,9 @@
@Override
public Response<Collection<GreetInfo>> apply(RevisionResource rev) {
Collection<GreetInfo> l = new ArrayList<>(3);
- l.add(new GreetInfo("Bonjour", "France",
- "http://en.wikipedia.org/wiki/France"));
- l.add(new GreetInfo("Hallo", "Germany",
- "http://en.wikipedia.org/wiki/Germany"));
- l.add(new GreetInfo("Hello", "USA",
- "http://en.wikipedia.org/wiki/USA"));
+ l.add(new GreetInfo("Bonjour", "France", "http://en.wikipedia.org/wiki/France"));
+ l.add(new GreetInfo("Hallo", "Germany", "http://en.wikipedia.org/wiki/Germany"));
+ l.add(new GreetInfo("Hello", "USA", "http://en.wikipedia.org/wiki/USA"));
return Response.ok(l);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HashtagValidator.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HashtagValidator.java
index 52f8680..58516c8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HashtagValidator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HashtagValidator.java
@@ -17,7 +17,6 @@
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.validators.HashtagValidationListener;
import com.google.gerrit.server.validators.ValidationException;
-
import java.util.Set;
public class HashtagValidator implements HashtagValidationListener {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloProjectAction.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloProjectAction.java
index 0e5f6f0..ab0032f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloProjectAction.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloProjectAction.java
@@ -22,8 +22,9 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
-class HelloProjectAction implements UiAction<ProjectResource>,
- RestModifyView<ProjectResource, HelloProjectAction.Input> {
+class HelloProjectAction
+ implements UiAction<ProjectResource>,
+ RestModifyView<ProjectResource, HelloProjectAction.Input> {
private Provider<CurrentUser> user;
@@ -53,10 +54,9 @@
@Override
public String apply(ProjectResource rsrc, Input input) {
- final String greeting = input.french
- ? "Bonjour"
- : "Hello";
- return String.format("%s %s from project %s!",
+ final String greeting = input.french ? "Bonjour" : "Hello";
+ return String.format(
+ "%s %s from project %s!",
greeting,
isNullOrEmpty(input.message)
? firstNonNull(user.get().getUserName(), "world")
@@ -65,8 +65,7 @@
}
@Override
- public Description getDescription(
- ProjectResource resource) {
+ public Description getDescription(ProjectResource resource) {
return new Description()
.setLabel("Say hello")
.setTitle("Say hello in different languages")
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloRevisionAction.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloRevisionAction.java
index 0cfbc10..68dc4b7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloRevisionAction.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloRevisionAction.java
@@ -24,8 +24,9 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
-class HelloRevisionAction implements UiAction<RevisionResource>,
- RestModifyView<RevisionResource, HelloRevisionAction.Input> {
+class HelloRevisionAction
+ implements UiAction<RevisionResource>,
+ RestModifyView<RevisionResource, HelloRevisionAction.Input> {
private Provider<CurrentUser> user;
@@ -41,10 +42,9 @@
@Override
public String apply(RevisionResource rev, Input input) {
- final String greeting = input.french
- ? "Bonjour"
- : "Hello";
- return String.format("%s %s from change %s, patch set %d!",
+ final String greeting = input.french ? "Bonjour" : "Hello";
+ return String.format(
+ "%s %s from change %s, patch set %d!",
greeting,
Strings.isNullOrEmpty(input.message)
? MoreObjects.firstNonNull(user.get().getUserName(), "world")
@@ -54,8 +54,7 @@
}
@Override
- public Description getDescription(
- RevisionResource resource) {
+ public Description getDescription(RevisionResource resource) {
return new Description()
.setLabel("Say hello")
.setTitle("Say hello in different languages")
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloTopMenu.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloTopMenu.java
index 8734b7c..d53d671 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloTopMenu.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloTopMenu.java
@@ -19,7 +19,6 @@
import com.google.gerrit.extensions.client.MenuItem;
import com.google.gerrit.extensions.webui.TopMenu;
import com.google.inject.Inject;
-
import java.util.List;
public class HelloTopMenu implements TopMenu {
@@ -33,12 +32,15 @@
menuItems.add(new MenuItem("Documentation", baseUrl));
menuEntries = Lists.newArrayListWithCapacity(2);
menuEntries.add(new MenuEntry("Cookbook", menuItems));
- menuEntries.add(new MenuEntry("Projects", Lists.newArrayList(
- new MenuItem("Browse Repositories", "https://gerrit.googlesource.com/"))));
+ menuEntries.add(
+ new MenuEntry(
+ "Projects",
+ Lists.newArrayList(
+ new MenuItem("Browse Repositories", "https://gerrit.googlesource.com/"))));
}
@Override
public List<MenuEntry> getEntries() {
- return menuEntries;
+ return menuEntries;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWeblink.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWeblink.java
index 14200d9..1e3b47d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWeblink.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWeblink.java
@@ -20,23 +20,20 @@
import com.google.gerrit.extensions.webui.PatchSetWebLink;
import com.google.gerrit.extensions.webui.ProjectWebLink;
-public class HelloWeblink implements PatchSetWebLink, ProjectWebLink,
- BranchWebLink, FileHistoryWebLink {
+public class HelloWeblink
+ implements PatchSetWebLink, ProjectWebLink, BranchWebLink, FileHistoryWebLink {
private String name = "HelloLink";
- private String placeHolderUrlProject =
- "http://my.hellolink.com/project=%s";
- private String placeHolderUrlProjectBranch =
- "http://my.hellolink.com/project=%s-branch=%s";
- private String placeHolderUrlProjectCommit =
- placeHolderUrlProject + "/commit=%s";
+ private String placeHolderUrlProject = "http://my.hellolink.com/project=%s";
+ private String placeHolderUrlProjectBranch = "http://my.hellolink.com/project=%s-branch=%s";
+ private String placeHolderUrlProjectCommit = placeHolderUrlProject + "/commit=%s";
private String placeHolderUrlProjectRevisionFileName =
placeHolderUrlProject + "-revision=%s-file=%s";
- private String myImageUrl =
- "http://dummyimage.com/16x16/000000/ffffff.png&text=CB";
+ private String myImageUrl = "http://dummyimage.com/16x16/000000/ffffff.png&text=CB";
@Override
public WebLinkInfo getBranchWebLink(String projectName, String branchName) {
- return new WebLinkInfo(name,
+ return new WebLinkInfo(
+ name,
myImageUrl,
String.format(placeHolderUrlProjectBranch, projectName, branchName),
Target.BLANK);
@@ -44,27 +41,25 @@
@Override
public WebLinkInfo getProjectWeblink(String projectName) {
- return new WebLinkInfo(name,
- myImageUrl,
- String.format(placeHolderUrlProject, projectName),
- Target.BLANK);
+ return new WebLinkInfo(
+ name, myImageUrl, String.format(placeHolderUrlProject, projectName), Target.BLANK);
}
@Override
public WebLinkInfo getPatchSetWebLink(String projectName, String commit) {
- return new WebLinkInfo(name,
+ return new WebLinkInfo(
+ name,
myImageUrl,
String.format(placeHolderUrlProjectCommit, projectName, commit),
Target.BLANK);
}
@Override
- public WebLinkInfo getFileHistoryWebLink(String projectName, String revision,
- String fileName) {
- return new WebLinkInfo(name,
+ public WebLinkInfo getFileHistoryWebLink(String projectName, String revision, String fileName) {
+ return new WebLinkInfo(
+ name,
myImageUrl,
- String.format(placeHolderUrlProjectRevisionFileName, projectName,
- revision, fileName),
+ String.format(placeHolderUrlProjectRevisionFileName, projectName, revision, fileName),
Target.BLANK);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWorldServlet.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWorldServlet.java
index e1f31a2..13d6246 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWorldServlet.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWorldServlet.java
@@ -18,17 +18,14 @@
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.io.Writer;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Singleton
class HelloWorldServlet extends HttpServlet {
@@ -36,14 +33,13 @@
private static final Logger log = LoggerFactory.getLogger(HelloWorldServlet.class);
@Inject
- HelloWorldServlet(@PluginName String pluginName,
- @PluginCanonicalWebUrl String url) {
+ HelloWorldServlet(@PluginName String pluginName, @PluginCanonicalWebUrl String url) {
log.info(String.format("Cookbook Plugin '%s' at url %s", pluginName, url));
}
@Override
- protected void doGet(final HttpServletRequest req,
- final HttpServletResponse rsp) throws IOException, ServletException {
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse rsp)
+ throws IOException, ServletException {
rsp.setContentType("text/html");
rsp.setCharacterEncoding("UTF-8");
try (Writer out = rsp.getWriter()) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/MergeUserValidator.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/MergeUserValidator.java
index ca48312..0459f0f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/MergeUserValidator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/MergeUserValidator.java
@@ -22,7 +22,6 @@
import com.google.gerrit.server.git.validators.MergeValidationListener;
import com.google.gerrit.server.project.ProjectState;
import com.google.inject.Singleton;
-
import org.eclipse.jgit.lib.Repository;
// Because we have a dedicated Module, we need to bind to the set
@@ -33,17 +32,19 @@
@Singleton
public class MergeUserValidator implements MergeValidationListener {
- /**
- * Reject all merges if the submitter is not an administrator
- */
+ /** Reject all merges if the submitter is not an administrator */
@Override
- public void onPreMerge(Repository repo, CodeReviewCommit commit,
- ProjectState destProject, Branch.NameKey destBranch,
- PatchSet.Id patchSetId, IdentifiedUser caller)
- throws MergeValidationException {
+ public void onPreMerge(
+ Repository repo,
+ CodeReviewCommit commit,
+ ProjectState destProject,
+ Branch.NameKey destBranch,
+ PatchSet.Id patchSetId,
+ IdentifiedUser caller)
+ throws MergeValidationException {
if (!caller.getCapabilities().canAdministrateServer()) {
- throw new MergeValidationException("Submitter " + caller.getNameEmail()
- + " is not a site administrator");
+ throw new MergeValidationException(
+ "Submitter " + caller.getNameEmail() + " is not a site administrator");
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java
index 7ac8eb3..de0b2c3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/Module.java
@@ -45,63 +45,52 @@
import com.google.gerrit.server.validators.AssigneeValidationListener;
import com.google.gerrit.server.validators.HashtagValidationListener;
import com.google.inject.AbstractModule;
-
import com.googlesource.gerrit.plugins.cookbook.pluginprovider.HelloSshPluginProvider;
public class Module extends AbstractModule {
@Override
protected void configure() {
- DynamicSet.bind(binder(), TopMenu.class)
- .to(HelloTopMenu.class);
+ DynamicSet.bind(binder(), TopMenu.class).to(HelloTopMenu.class);
DynamicSet.bind(binder(), PatchSetWebLink.class).to(HelloWeblink.class);
DynamicSet.bind(binder(), ProjectWebLink.class).to(HelloWeblink.class);
DynamicSet.bind(binder(), BranchWebLink.class).to(HelloWeblink.class);
DynamicSet.bind(binder(), FileHistoryWebLink.class).to(HelloWeblink.class);
- DynamicSet.bind(binder(), ServerPluginProvider.class).to(
- HelloSshPluginProvider.class);
+ DynamicSet.bind(binder(), ServerPluginProvider.class).to(HelloSshPluginProvider.class);
DynamicSet.bind(binder(), UsageDataPublishedListener.class).to(UsageDataLogger.class);
DynamicSet.bind(binder(), LifecycleListener.class).to(ConsoleMetricReporter.class);
- install(new RestApiModule() {
- @Override
- protected void configure() {
- post(REVISION_KIND, "hello-revision").to(HelloRevisionAction.class);
- post(PROJECT_KIND, "hello-project").to(HelloProjectAction.class);
- get(REVISION_KIND, "greetings").to(Greetings.class);
- }
- });
- DynamicSet.bind(binder(), UploadValidationListener.class)
- .to(DenyUploadExample.class);
- DynamicSet.bind(binder(), MergeValidationListener.class)
- .to(MergeUserValidator.class);
- DynamicSet.bind(binder(), HashtagValidationListener.class)
- .to(HashtagValidator.class);
- DynamicSet.bind(binder(), AssigneeValidationListener.class)
- .to(AssigneeValidator.class);
- DynamicSet.bind(binder(), CommitValidationListener.class)
- .to(CommitValidator.class);
- DynamicSet.bind(binder(), NewProjectCreatedListener.class)
- .to(ProjectCreatedListener.class);
+ install(
+ new RestApiModule() {
+ @Override
+ protected void configure() {
+ post(REVISION_KIND, "hello-revision").to(HelloRevisionAction.class);
+ post(PROJECT_KIND, "hello-project").to(HelloProjectAction.class);
+ get(REVISION_KIND, "greetings").to(Greetings.class);
+ }
+ });
+ DynamicSet.bind(binder(), UploadValidationListener.class).to(DenyUploadExample.class);
+ DynamicSet.bind(binder(), MergeValidationListener.class).to(MergeUserValidator.class);
+ DynamicSet.bind(binder(), HashtagValidationListener.class).to(HashtagValidator.class);
+ DynamicSet.bind(binder(), AssigneeValidationListener.class).to(AssigneeValidator.class);
+ DynamicSet.bind(binder(), CommitValidationListener.class).to(CommitValidator.class);
+ DynamicSet.bind(binder(), NewProjectCreatedListener.class).to(ProjectCreatedListener.class);
DynamicSet.bind(binder(), RefOperationValidationListener.class)
.to(RefOperationValidationExample.class);
configurePluginParameters();
- DynamicSet.bind(binder(), ExternalIncludedIn.class)
- .to(DeployedOnIncludedInExtension.class);
+ DynamicSet.bind(binder(), ExternalIncludedIn.class).to(DeployedOnIncludedInExtension.class);
bind(ChangeOperatorFactory.class)
.annotatedWith(Exports.named("sample"))
.to(SampleOperator.class);
- DynamicSet.bind(binder(), WebUiPlugin.class)
- .toInstance(new JavaScriptPlugin("greetings.js"));
+ DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new JavaScriptPlugin("greetings.js"));
DynamicSet.bind(binder(), WebUiPlugin.class)
.toInstance(new JavaScriptPlugin("hello-change.js"));
DynamicSet.bind(binder(), WebUiPlugin.class)
.toInstance(new JavaScriptPlugin("hello-project.js"));
DynamicSet.bind(binder(), WebUiPlugin.class)
.toInstance(new JavaScriptPlugin("hello-revision.js"));
- DynamicSet.bind(binder(), WebUiPlugin.class)
- .toInstance(new GwtPlugin("cookbook"));
+ DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new GwtPlugin("cookbook"));
}
private void configurePluginParameters() {
@@ -109,29 +98,33 @@
.annotatedWith(Exports.named("enable-hello"))
.toInstance(new ProjectConfigEntry("Enable Greeting", true));
bind(ProjectConfigEntry.class)
- .annotatedWith(Exports.named("enable-goodbye"))
- .toInstance(new ProjectConfigEntry("Enable Say Goodbye",
- InheritableBoolean.TRUE,
- InheritableBoolean.class, true));
+ .annotatedWith(Exports.named("enable-goodbye"))
+ .toInstance(
+ new ProjectConfigEntry(
+ "Enable Say Goodbye", InheritableBoolean.TRUE, InheritableBoolean.class, true));
bind(ProjectConfigEntry.class)
- .annotatedWith(Exports.named("default-greeting"))
- .toInstance(new ProjectConfigEntry("Default Greeting",
- "Hey dude, how are you?", true));
+ .annotatedWith(Exports.named("default-greeting"))
+ .toInstance(new ProjectConfigEntry("Default Greeting", "Hey dude, how are you?", true));
bind(ProjectConfigEntry.class)
.annotatedWith(Exports.named("language"))
- .toInstance(new ProjectConfigEntry("Preferred Language", "en",
- ImmutableList.of("en", "de", "fr"), true));
+ .toInstance(
+ new ProjectConfigEntry(
+ "Preferred Language", "en", ImmutableList.of("en", "de", "fr"), true));
bind(ProjectConfigEntry.class)
.annotatedWith(Exports.named("greet-number-per-week"))
.toInstance(new ProjectConfigEntry("Greets Per Week", 42, true));
bind(ProjectConfigEntry.class)
- .annotatedWith(Exports.named("greet-number-per-year"))
- .toInstance(new ProjectConfigEntry("Greets Per Year", 4711L, true));
+ .annotatedWith(Exports.named("greet-number-per-year"))
+ .toInstance(new ProjectConfigEntry("Greets Per Year", 4711L, true));
bind(ProjectConfigEntry.class)
- .annotatedWith(Exports.named("reviewers"))
+ .annotatedWith(Exports.named("reviewers"))
.toInstance(
- new ProjectConfigEntry("Reviewers", null,
- ProjectConfigEntryType.ARRAY, null, false,
+ new ProjectConfigEntry(
+ "Reviewers",
+ null,
+ ProjectConfigEntryType.ARRAY,
+ null,
+ false,
"Users or groups can be provided as reviewers"));
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/PrintHelloWorldCommand.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/PrintHelloWorldCommand.java
index 7f1f6e8..8042ff9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/PrintHelloWorldCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/PrintHelloWorldCommand.java
@@ -16,7 +16,6 @@
import com.google.gerrit.sshd.CommandMetaData;
import com.google.gerrit.sshd.SshCommand;
-
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/ProjectCreatedListener.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/ProjectCreatedListener.java
index deb9f49..162504d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/ProjectCreatedListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/ProjectCreatedListener.java
@@ -19,27 +19,22 @@
import com.google.gerrit.extensions.events.NewProjectCreatedListener;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.inject.Inject;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ProjectCreatedListener implements NewProjectCreatedListener {
- private static final Logger log =
- LoggerFactory.getLogger(ProjectCreatedListener.class);
+ private static final Logger log = LoggerFactory.getLogger(ProjectCreatedListener.class);
- @Inject
- protected GerritApi gApi;
+ @Inject protected GerritApi gApi;
@Override
public void onNewProjectCreated(Event event) {
String name = event.getProjectName();
try {
ProjectApi api = gApi.projects().name(name);
- log.info(String.format(
- "New project: '%s', Parent: '%s'", name, api.get().parent));
+ log.info(String.format("New project: '%s', Parent: '%s'", name, api.get().parent));
} catch (RestApiException e) {
- log.error(String.format(
- "Failed to get info for new project %s", name), e);
+ log.error(String.format("Failed to get info for new project %s", name), e);
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/RefOperationValidationExample.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/RefOperationValidationExample.java
index 2755902..200628e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/RefOperationValidationExample.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/RefOperationValidationExample.java
@@ -20,25 +20,20 @@
import com.google.gerrit.server.git.validators.RefOperationValidationListener;
import com.google.gerrit.server.git.validators.ValidationMessage;
import com.google.gerrit.server.validators.ValidationException;
-
import java.util.ArrayList;
import java.util.List;
-public class RefOperationValidationExample implements
- RefOperationValidationListener {
+public class RefOperationValidationExample implements RefOperationValidationListener {
@Override
- public List<ValidationMessage> onRefOperation(RefReceivedEvent event)
- throws ValidationException {
+ public List<ValidationMessage> onRefOperation(RefReceivedEvent event) throws ValidationException {
ArrayList<ValidationMessage> messages = Lists.newArrayList();
- if (event.command.getRefName()
- .startsWith(RefNames.REFS_HEADS + "protected-")
+ if (event.command.getRefName().startsWith(RefNames.REFS_HEADS + "protected-")
&& !event.user.getCapabilities().canAdministrateServer()) {
- throw new ValidationException(String.format(
- "Operation %s on %s branch in project %s is not valid!",
- event.command.getType(),
- event.command.getRefName(),
- event.project.getName()));
+ throw new ValidationException(
+ String.format(
+ "Operation %s on %s branch in project %s is not valid!",
+ event.command.getType(), event.command.getRefName(), event.project.getName()));
}
return messages;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/SampleOperator.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/SampleOperator.java
index adba674..df1964c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/SampleOperator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/SampleOperator.java
@@ -23,8 +23,7 @@
import com.google.inject.Singleton;
@Singleton
-public class SampleOperator
- implements ChangeQueryBuilder.ChangeOperatorFactory {
+public class SampleOperator implements ChangeQueryBuilder.ChangeOperatorFactory {
public static class MyPredicate extends ChangeOperatorPredicate {
private final Change.Id id;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/UsageDataLogger.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/UsageDataLogger.java
index 995e68c..8691d9d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/UsageDataLogger.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/UsageDataLogger.java
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.cookbook;
import com.google.gerrit.extensions.events.UsageDataPublishedListener;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -26,13 +25,14 @@
@Override
public void onUsageDataPublished(Event event) {
if (log.isInfoEnabled()) {
- log.info(String.format("Usage data for "
- + "%s at %s", event.getMetaData().getDescription(), event.getInstant()));
+ log.info(
+ String.format(
+ "Usage data for " + "%s at %s",
+ event.getMetaData().getDescription(), event.getInstant()));
log.info(String.format("project name - %s", event.getMetaData().getName()));
String unitSymbol = event.getMetaData().getUnitSymbol();
for (Data data : event.getData()) {
- log.info(String.format("%s - %d %s", data.getProjectName(), data.getValue(),
- unitSymbol));
+ log.info(String.format("%s - %d %s", data.getProjectName(), data.getValue(), unitSymbol));
}
log.info("");
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/BuildsDropDownPanel.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/BuildsDropDownPanel.java
index 86b7034..c314c83 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/BuildsDropDownPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/BuildsDropDownPanel.java
@@ -23,9 +23,7 @@
import com.google.gwt.user.client.ui.InlineHyperlink;
import com.google.gwt.user.client.ui.InlineLabel;
-/**
- * Extension for change screen that displays a status in the header bar.
- */
+/** Extension for change screen that displays a status in the header bar. */
public class BuildsDropDownPanel extends FlowPanel {
static class Factory implements Panel.EntryPoint {
@Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenPreferencePanel.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenPreferencePanel.java
index 47d05a9..96f777a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenPreferencePanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenPreferencePanel.java
@@ -27,7 +27,6 @@
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.VerticalPanel;
-
import java.util.Map;
public class ChangeScreenPreferencePanel extends VerticalPanel {
@@ -35,8 +34,7 @@
private static final String COOKBOOK = "COOKBOOK";
private static final String OTHER = "OTHER";
private static final String DEFAULT_URL_MATCH = "/c/(.*)";
- private static final String COOKBOOK_URL_TOKEN =
- "/x/" + Plugin.get().getName() + "/c/$1";
+ private static final String COOKBOOK_URL_TOKEN = "/x/" + Plugin.get().getName() + "/c/$1";
static class Factory implements Panel.EntryPoint {
@Override
@@ -49,18 +47,21 @@
private Timer hideTimer;
ChangeScreenPreferencePanel() {
- new RestApi("accounts").id("self").view("preferences")
- .get(new AsyncCallback<GeneralPreferences>() {
- @Override
- public void onSuccess(GeneralPreferences result) {
- display(result);
- }
+ new RestApi("accounts")
+ .id("self")
+ .view("preferences")
+ .get(
+ new AsyncCallback<GeneralPreferences>() {
+ @Override
+ public void onSuccess(GeneralPreferences result) {
+ display(result);
+ }
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
}
private void display(final GeneralPreferences info) {
@@ -103,37 +104,42 @@
}
}
- box.addChangeHandler(new ChangeHandler() {
- @Override
- public void onChange(ChangeEvent event) {
- savedLabel.setVisible(false);
- if (box.getSelectedValue().equals(OTHER)) {
- return;
- }
+ box.addChangeHandler(
+ new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent event) {
+ savedLabel.setVisible(false);
+ if (box.getSelectedValue().equals(OTHER)) {
+ return;
+ }
- Map<String, String> urlAliases = info.urlAliases();
- if (box.getSelectedValue().equals(COOKBOOK)) {
- urlAliases.put(DEFAULT_URL_MATCH, COOKBOOK_URL_TOKEN);
- } else {
- urlAliases.remove(DEFAULT_URL_MATCH);
- }
- info.setUrlAliases(urlAliases);
+ Map<String, String> urlAliases = info.urlAliases();
+ if (box.getSelectedValue().equals(COOKBOOK)) {
+ urlAliases.put(DEFAULT_URL_MATCH, COOKBOOK_URL_TOKEN);
+ } else {
+ urlAliases.remove(DEFAULT_URL_MATCH);
+ }
+ info.setUrlAliases(urlAliases);
- new RestApi("accounts").id("self").view("preferences")
- .put(info, new AsyncCallback<GeneralPreferences>() {
- @Override
- public void onSuccess(GeneralPreferences result) {
- Plugin.get().refreshUserPreferences();
- showSavedStatus();
- }
+ new RestApi("accounts")
+ .id("self")
+ .view("preferences")
+ .put(
+ info,
+ new AsyncCallback<GeneralPreferences>() {
+ @Override
+ public void onSuccess(GeneralPreferences result) {
+ Plugin.get().refreshUserPreferences();
+ showSavedStatus();
+ }
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
+ }
+ });
}
private void showSavedStatus() {
@@ -142,13 +148,14 @@
hideTimer = null;
}
savedLabel.setVisible(true);
- hideTimer = new Timer() {
- @Override
- public void run() {
- savedLabel.setVisible(false);
- hideTimer = null;
- }
- };
+ hideTimer =
+ new Timer() {
+ @Override
+ public void run() {
+ savedLabel.setVisible(false);
+ hideTimer = null;
+ }
+ };
hideTimer.schedule(1000);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenStatusExtension.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenStatusExtension.java
index e0ceeed..47b4cc3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenStatusExtension.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenStatusExtension.java
@@ -20,9 +20,7 @@
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.InlineLabel;
-/**
- * Extension for change screen that displays a status in the header bar.
- */
+/** Extension for change screen that displays a status in the header bar. */
public class ChangeScreenStatusExtension extends FlowPanel {
static class Factory implements Panel.EntryPoint {
@Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookChangeScreenExtension.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookChangeScreenExtension.java
index d2a2151..ec5ee79 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookChangeScreenExtension.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookChangeScreenExtension.java
@@ -23,10 +23,7 @@
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwtexpui.clippy.client.CopyableLabel;
-/**
- * Extension for change screen that displays the numeric change ID with
- * copy-to-clipboard icon.
- */
+/** Extension for change screen that displays the numeric change ID with copy-to-clipboard icon. */
public class CookBookChangeScreenExtension extends VerticalPanel {
static class Factory implements Panel.EntryPoint {
@Override
@@ -36,10 +33,8 @@
}
CookBookChangeScreenExtension(Panel panel) {
- ChangeInfo change =
- panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
- RevisionInfo rev =
- panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
+ ChangeInfo change = panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
+ RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
Grid g = new Grid(2, 2);
g.addStyleName("infoBlock");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookPlugin.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookPlugin.java
index c51ec3c..287bc0d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookPlugin.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookPlugin.java
@@ -32,35 +32,42 @@
public void onPluginLoad() {
Plugin.get().screen("", new IndexScreen.Factory());
Plugin.get().screenRegex("c/(.*)", new CookBookChangeScreen.Factory());
- Plugin.get().settingsScreen("preferences", "Food Preferences",
- new FoodPreferencesScreen.Factory());
- Plugin.get().panel(
- GerritUiExtensionPoint.PREFERENCES_SCREEN_BOTTOM,
- new ChangeScreenPreferencePanel.Factory());
- Plugin.get().panel(GerritUiExtensionPoint.PROFILE_SCREEN_BOTTOM,
- new CookBookProfileExtension.Factory());
- Plugin.get().panel(
- GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
- new CookBookChangeScreenExtension.Factory());
- Plugin.get().panel(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER,
- new ChangeScreenStatusExtension.Factory());
- Plugin.get().panel(
- GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS,
- new BuildsDropDownPanel.Factory());
- Plugin.get().panel(
- GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_BUTTONS,
- new Panel.EntryPoint() {
- @Override
- public void onLoad(Panel panel) {
- Button b = new HighlightButton("Library-Compliance+1");
- b.addClickHandler(new ClickHandler() {
+ Plugin.get()
+ .settingsScreen("preferences", "Food Preferences", new FoodPreferencesScreen.Factory());
+ Plugin.get()
+ .panel(
+ GerritUiExtensionPoint.PREFERENCES_SCREEN_BOTTOM,
+ new ChangeScreenPreferencePanel.Factory());
+ Plugin.get()
+ .panel(
+ GerritUiExtensionPoint.PROFILE_SCREEN_BOTTOM, new CookBookProfileExtension.Factory());
+ Plugin.get()
+ .panel(
+ GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
+ new CookBookChangeScreenExtension.Factory());
+ Plugin.get()
+ .panel(
+ GerritUiExtensionPoint.CHANGE_SCREEN_HEADER, new ChangeScreenStatusExtension.Factory());
+ Plugin.get()
+ .panel(
+ GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS,
+ new BuildsDropDownPanel.Factory());
+ Plugin.get()
+ .panel(
+ GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_BUTTONS,
+ new Panel.EntryPoint() {
@Override
- public void onClick(ClickEvent event) {
- Window.alert("TODO");
+ public void onLoad(Panel panel) {
+ Button b = new HighlightButton("Library-Compliance+1");
+ b.addClickHandler(
+ new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ Window.alert("TODO");
+ }
+ });
+ panel.setWidget(b);
}
});
- panel.setWidget(b);
- }
- });
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookProfileExtension.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookProfileExtension.java
index e50427a..a0ae088 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookProfileExtension.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookProfileExtension.java
@@ -21,15 +21,12 @@
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
import com.google.gwt.user.client.ui.VerticalPanel;
-/**
- * Extension for the user profile screen.
- */
+/** Extension for the user profile screen. */
public class CookBookProfileExtension extends VerticalPanel {
static class Factory implements Panel.EntryPoint {
@Override
public void onLoad(Panel panel) {
- AccountInfo accountInfo =
- panel.getObject(GerritUiExtensionPoint.Key.ACCOUNT_INFO).cast();
+ AccountInfo accountInfo = panel.getObject(GerritUiExtensionPoint.Key.ACCOUNT_INFO).cast();
panel.setWidget(new CookBookProfileExtension(accountInfo));
}
}
@@ -53,9 +50,8 @@
g.setText(2, 0, "CookBook Email");
fmt.addStyleName(2, 0, "header");
- g.setText(2, 1, accountInfo.username() != null
- ? accountInfo.username() + "@cookbook.com"
- : "N/A");
+ g.setText(
+ 2, 1, accountInfo.username() != null ? accountInfo.username() + "@cookbook.com" : "N/A");
add(g);
fmt.addStyleName(0, 0, "topmost");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/FoodPreferencesScreen.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/FoodPreferencesScreen.java
index 6ba46fd..9689ba7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/FoodPreferencesScreen.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/FoodPreferencesScreen.java
@@ -41,12 +41,13 @@
Panel messagePanel = new VerticalPanel();
messagePanel.add(new Label("Food Allergies or Dietary Concerns:"));
TextArea txt = new TextArea();
- txt.addKeyPressHandler(new KeyPressHandler() {
- @Override
- public void onKeyPress(final KeyPressEvent event) {
- event.stopPropagation();
- }
- });
+ txt.addKeyPressHandler(
+ new KeyPressHandler() {
+ @Override
+ public void onKeyPress(final KeyPressEvent event) {
+ event.stopPropagation();
+ }
+ });
txt.setVisibleLines(12);
txt.setCharacterWidth(80);
txt.getElement().setPropertyBoolean("spellcheck", false);
@@ -55,12 +56,13 @@
Button helloButton = new Button("Save");
helloButton.addStyleName("cookbook-helloButton");
- helloButton.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(final ClickEvent event) {
- Window.alert("TODO: implement save");
- }
- });
+ helloButton.addClickHandler(
+ new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ Window.alert("TODO: implement save");
+ }
+ });
add(helloButton);
helloButton.setEnabled(true);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/HighlightButton.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/HighlightButton.java
index 0af633f..5bb9379 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/HighlightButton.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/HighlightButton.java
@@ -20,16 +20,20 @@
/**
* Highlight button for header line in change screen.
*
- * This class can *only* be used within a panel that extends the header line of
- * the change screen, but will not work standalone.
+ * <p>This class can *only* be used within a panel that extends the header line of the change
+ * screen, but will not work standalone.
*/
public class HighlightButton extends Button {
public HighlightButton(String text) {
// Create Button with inner div. This is required to get proper styling
// in the context of the change screen.
- super((new SafeHtmlBuilder()).openDiv()
- .appendAttribute("style", "color: #fff;").append(text).closeDiv());
+ super(
+ (new SafeHtmlBuilder())
+ .openDiv()
+ .appendAttribute("style", "color: #fff;")
+ .append(text)
+ .closeDiv());
getElement().removeClassName("gwt-Button");
getElement().getStyle().setBackgroundColor("#4d90fe");
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/IndexScreen.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/IndexScreen.java
index 774ec3d..b0353a1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/IndexScreen.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/IndexScreen.java
@@ -55,28 +55,32 @@
labelImagePanel.add(img);
labelImagePanel.add(new Label(":"));
usernamePanel.add(labelImagePanel);
- usernameTxt = new TextBox() {
- @Override
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- if (event.getTypeInt() == Event.ONPASTE) {
- Scheduler.get().scheduleDeferred(new ScheduledCommand() {
- @Override
- public void execute() {
- if (getValue().trim().length() != 0) {
- setEnabled(true);
- }
+ usernameTxt =
+ new TextBox() {
+ @Override
+ public void onBrowserEvent(Event event) {
+ super.onBrowserEvent(event);
+ if (event.getTypeInt() == Event.ONPASTE) {
+ Scheduler.get()
+ .scheduleDeferred(
+ new ScheduledCommand() {
+ @Override
+ public void execute() {
+ if (getValue().trim().length() != 0) {
+ setEnabled(true);
+ }
+ }
+ });
}
- });
- }
- }
- };
- usernameTxt.addKeyPressHandler(new KeyPressHandler() {
- @Override
- public void onKeyPress(final KeyPressEvent event) {
- event.stopPropagation();
- }
- });
+ }
+ };
+ usernameTxt.addKeyPressHandler(
+ new KeyPressHandler() {
+ @Override
+ public void onKeyPress(final KeyPressEvent event) {
+ event.stopPropagation();
+ }
+ });
usernameTxt.sinkEvents(Event.ONPASTE);
usernameTxt.setVisibleLength(40);
usernamePanel.add(usernameTxt);
@@ -85,12 +89,13 @@
Panel messagePanel = new VerticalPanel();
messagePanel.add(new Label("Message:"));
greetingTxt = new TextArea();
- greetingTxt.addKeyPressHandler(new KeyPressHandler() {
- @Override
- public void onKeyPress(final KeyPressEvent event) {
- event.stopPropagation();
- }
- });
+ greetingTxt.addKeyPressHandler(
+ new KeyPressHandler() {
+ @Override
+ public void onKeyPress(final KeyPressEvent event) {
+ event.stopPropagation();
+ }
+ });
greetingTxt.setVisibleLines(12);
greetingTxt.setCharacterWidth(80);
greetingTxt.getElement().setPropertyBoolean("spellcheck", false);
@@ -99,12 +104,13 @@
Button helloButton = new Button("Say Hello");
helloButton.addStyleName("cookbook-helloButton");
- helloButton.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(final ClickEvent event) {
- sayHello();
- }
- });
+ helloButton.addClickHandler(
+ new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ sayHello();
+ }
+ });
add(helloButton);
helloButton.setEnabled(true);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/PopDownButton.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/PopDownButton.java
index 3cbe5d6..0ef0f4c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/PopDownButton.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/PopDownButton.java
@@ -32,12 +32,11 @@
/**
* Pop down button for header line in change screen.
*
- * This class implements a button that on click opens a pop down panel with the
- * provided widget, similar to the "Patch Sets", "Download" or "Included In" pop
- * down panels on the change screen.
+ * <p>This class implements a button that on click opens a pop down panel with the provided widget,
+ * similar to the "Patch Sets", "Download" or "Included In" pop down panels on the change screen.
*
- * This class can *only* be used within a panel that extends the header line of
- * the change screen, but will not work standalone.
+ * <p>This class can *only* be used within a panel that extends the header line of the change
+ * screen, but will not work standalone.
*/
public class PopDownButton extends Button {
private final Widget widget;
@@ -48,12 +47,13 @@
// in the context of the change screen.
super((new SafeHtmlBuilder()).openDiv().append(text).closeDiv());
getElement().removeClassName("gwt-Button");
- addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- show();
- }
- });
+ addClickHandler(
+ new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ show();
+ }
+ });
this.widget = widget;
}
@@ -65,33 +65,35 @@
}
final Widget relativeTo = getParent();
- final PopupPanel p = new PopupPanel(true) {
- @Override
- public void setPopupPosition(int left, int top) {
- top -= Document.get().getBodyOffsetTop();
+ final PopupPanel p =
+ new PopupPanel(true) {
+ @Override
+ public void setPopupPosition(int left, int top) {
+ top -= Document.get().getBodyOffsetTop();
- int w = Window.getScrollLeft() + Window.getClientWidth();
- int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth();
- int right = w - r;
- Style style = getElement().getStyle();
- style.clearProperty("left");
- style.setPropertyPx("right", right);
- style.setPropertyPx("top", top);
- }
- };
+ int w = Window.getScrollLeft() + Window.getClientWidth();
+ int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth();
+ int right = w - r;
+ Style style = getElement().getStyle();
+ style.clearProperty("left");
+ style.setPropertyPx("right", right);
+ style.setPropertyPx("top", top);
+ }
+ };
Style popupStyle = p.getElement().getStyle();
popupStyle.setBorderWidth(0, Unit.PX);
popupStyle.setBackgroundColor("#EEEEEE");
p.addAutoHidePartner(getElement());
- p.addCloseHandler(new CloseHandler<PopupPanel>() {
- @Override
- public void onClose(CloseEvent<PopupPanel> event) {
- if (popup == p) {
- getElement().getStyle().clearFontWeight();
- popup = null;
- }
- }
- });
+ p.addCloseHandler(
+ new CloseHandler<PopupPanel>() {
+ @Override
+ public void onClose(CloseEvent<PopupPanel> event) {
+ if (popup == p) {
+ getElement().getStyle().clearFontWeight();
+ popup = null;
+ }
+ }
+ });
p.add(widget);
p.showRelativeTo(relativeTo);
GlobalKey.dialog(p);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshCommand.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshCommand.java
index 853d04d..4e7a014 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshCommand.java
@@ -20,15 +20,13 @@
import com.google.gerrit.sshd.CommandMetaData;
import com.google.gerrit.sshd.SshCommand;
import com.google.inject.Inject;
-
-import org.kohsuke.args4j.Argument;
-
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
+import org.kohsuke.args4j.Argument;
/** SSH command defined by dynamically registered plugins. */
@CommandMetaData(name = "cat", description = "Print content of plugin file")
@@ -41,9 +39,8 @@
private List<String> files = new ArrayList<>();
@Inject
- public HelloSshCommand(@PluginName String pluginName,
- SitePaths sitePaths,
- @PluginData Path dataDir) {
+ public HelloSshCommand(
+ @PluginName String pluginName, SitePaths sitePaths, @PluginData Path dataDir) {
this.pluginName = pluginName;
this.pluginDir = sitePaths.plugins_dir.normalize();
this.dataDir = dataDir.normalize();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshModule.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshModule.java
index 8a9def0..5021b01 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshModule.java
@@ -16,9 +16,7 @@
import com.google.gerrit.sshd.PluginCommandModule;
-/**
- * SSH Module exported by provided plugins.
- */
+/** SSH Module exported by provided plugins. */
public class HelloSshModule extends PluginCommandModule {
@Override
protected void configureCommands() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshPluginContentScanner.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshPluginContentScanner.java
index 198e02a..4b0b056 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshPluginContentScanner.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshPluginContentScanner.java
@@ -17,7 +17,6 @@
import com.google.gerrit.server.plugins.InvalidPluginException;
import com.google.gerrit.server.plugins.PluginContentScanner;
import com.google.gerrit.server.plugins.PluginEntry;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -28,9 +27,7 @@
import java.util.Optional;
import java.util.jar.Manifest;
-/**
- * Plugin scanner is responsible for returning plugin contents.
- */
+/** Plugin scanner is responsible for returning plugin contents. */
public class HelloSshPluginContentScanner implements PluginContentScanner {
private final String pluginName;
@@ -38,9 +35,7 @@
this.pluginName = pluginName;
}
- /**
- * Scanner for self-registration: not used in this sample.
- */
+ /** Scanner for self-registration: not used in this sample. */
@Override
public Map<Class<? extends Annotation>, Iterable<ExtensionMetaData>> scan(
String pluginName, Iterable<Class<? extends Annotation>> annotations)
@@ -48,39 +43,35 @@
return null;
}
- /**
- * Returns the Plugin Manfiest content as it was packaged in a JAR file.
- */
+ /** Returns the Plugin Manfiest content as it was packaged in a JAR file. */
@Override
public Manifest getManifest() throws IOException {
String manifestString =
- "PluginName: " + pluginName + "\n" +
- "Implementation-Version: 1.0\n" +
- "Gerrit-ReloadMode: restart\n" +
- "Gerrit-ApiType: Plugin\n" +
- "Gerrit-SshModule: " + HelloSshModule.class.getName() + "\n";
+ "PluginName: "
+ + pluginName
+ + "\n"
+ + "Implementation-Version: 1.0\n"
+ + "Gerrit-ReloadMode: restart\n"
+ + "Gerrit-ApiType: Plugin\n"
+ + "Gerrit-SshModule: "
+ + HelloSshModule.class.getName()
+ + "\n";
return new Manifest(new ByteArrayInputStream(manifestString.getBytes()));
}
- /**
- * Read static plugin resources: not used in this sample.
- */
+ /** Read static plugin resources: not used in this sample. */
@Override
public InputStream getInputStream(PluginEntry entry) throws IOException {
return null;
}
- /**
- * Return plugin resource entry: not used in this sample.
- */
+ /** Return plugin resource entry: not used in this sample. */
@Override
public Optional<PluginEntry> getEntry(String resourcePath) {
return Optional.empty();
}
- /**
- * Return full list of plugin resources: not used in this sample.
- */
+ /** Return full list of plugin resources: not used in this sample. */
@Override
public Enumeration<PluginEntry> entries() {
return Collections.emptyEnumeration();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshPluginProvider.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshPluginProvider.java
index 8ffd8c2..a3af286 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshPluginProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/pluginprovider/HelloSshPluginProvider.java
@@ -19,28 +19,24 @@
import com.google.gerrit.server.plugins.ServerPlugin;
import com.google.gerrit.server.plugins.ServerPluginProvider;
import com.google.inject.Inject;
-
+import java.nio.file.Path;
import org.eclipse.jgit.internal.storage.file.FileSnapshot;
-import java.nio.file.Path;
-
/**
- * Dynamic provider of Gerrit plugins derived by *.ssh files under
- * $GERRIT_SITE/plugins.
- * <p>
- * Example of how to define a dynamic Gerrit plugin provider to register
- * a new plugin based on the content of *.ssh files.
- * <p>
- * This provider allows to define a Gerrit plugin by simply dropping a .ssh file
- * (e.g. hello.ssh) under $GERRIT_SITE/plugins.
- * <p>
- * Once the file is created a new plugin is automatically loaded with the name
- * without extension of the .ssh file (e.g. hello) and a new 'cat' SSH command
- * is automatically available from the registered plugin.
- * <p>
- * The 'cat' command will print the contents of the .ssh file, along with the
- * contents of any arguments, resolved against the plugin's data directory
- * $GERRIT_SITE/data/name.
+ * Dynamic provider of Gerrit plugins derived by *.ssh files under $GERRIT_SITE/plugins.
+ *
+ * <p>Example of how to define a dynamic Gerrit plugin provider to register a new plugin based on
+ * the content of *.ssh files.
+ *
+ * <p>This provider allows to define a Gerrit plugin by simply dropping a .ssh file (e.g. hello.ssh)
+ * under $GERRIT_SITE/plugins.
+ *
+ * <p>Once the file is created a new plugin is automatically loaded with the name without extension
+ * of the .ssh file (e.g. hello) and a new 'cat' SSH command is automatically available from the
+ * registered plugin.
+ *
+ * <p>The 'cat' command will print the contents of the .ssh file, along with the contents of any
+ * arguments, resolved against the plugin's data directory $GERRIT_SITE/data/name.
*/
public class HelloSshPluginProvider implements ServerPluginProvider {
private static final String SSH_EXT = ".ssh";
@@ -63,12 +59,17 @@
}
@Override
- public ServerPlugin get(Path srcPath, FileSnapshot snapshot,
- PluginDescription pluginDescriptor) throws InvalidPluginException {
+ public ServerPlugin get(Path srcPath, FileSnapshot snapshot, PluginDescription pluginDescriptor)
+ throws InvalidPluginException {
String name = getPluginName(srcPath);
- return new ServerPlugin(name, pluginDescriptor.canonicalUrl,
- pluginDescriptor.user, srcPath, snapshot,
- new HelloSshPluginContentScanner(name), pluginDescriptor.dataDir,
+ return new ServerPlugin(
+ name,
+ pluginDescriptor.canonicalUrl,
+ pluginDescriptor.user,
+ srcPath,
+ snapshot,
+ new HelloSshPluginContentScanner(name),
+ pluginDescriptor.dataDir,
getClass().getClassLoader());
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/cookbook/CookbookIT.java b/src/test/java/com/googlesource/gerrit/plugins/cookbook/CookbookIT.java
index 8247e64..636d213 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/cookbook/CookbookIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/cookbook/CookbookIT.java
@@ -20,30 +20,26 @@
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.TestPlugin;
import com.google.gerrit.acceptance.UseSsh;
-
import org.junit.Test;
@TestPlugin(
- name = "cookbook",
- sysModule = "com.googlesource.gerrit.plugins.cookbook.Module",
- httpModule = "com.googlesource.gerrit.plugins.cookbook.HttpModule",
- sshModule = "com.googlesource.gerrit.plugins.cookbook.SshModule"
+ name = "cookbook",
+ sysModule = "com.googlesource.gerrit.plugins.cookbook.Module",
+ httpModule = "com.googlesource.gerrit.plugins.cookbook.HttpModule",
+ sshModule = "com.googlesource.gerrit.plugins.cookbook.SshModule"
)
@UseSsh
public class CookbookIT extends LightweightPluginDaemonTest {
@Test
public void printTest() throws Exception {
- assertThat(adminSshSession.exec("cookbook print"))
- .isEqualTo("Hello world!\n");
+ assertThat(adminSshSession.exec("cookbook print")).isEqualTo("Hello world!\n");
assertThat(adminSshSession.hasError()).isFalse();
}
@Test
public void revisionTest() throws Exception {
createChange();
- RestResponse response =
- adminRestSession.post("/changes/1/revisions/1/cookbook~hello-revision");
- assertThat(response.getEntityContent())
- .contains("Hello admin from change 1, patch set 1!");
+ RestResponse response = adminRestSession.post("/changes/1/revisions/1/cookbook~hello-revision");
+ assertThat(response.getEntityContent()).contains("Hello admin from change 1, patch set 1!");
}
}