Add support for UiActions on Project Info Screen

Bug: issue 349
Change-Id: Ia29d08684aaf421fa0a16dd875af36667980fe2e
This commit is contained in:
David Ostrovsky
2013-08-30 08:09:53 +02:00
committed by David Pursehouse
parent 8ab4d6a845
commit 9e8b2fb8d1
17 changed files with 210 additions and 21 deletions

View File

@@ -16,25 +16,38 @@ package com.google.gerrit.client.actions;
import com.google.gerrit.client.api.ActionContext;
import com.google.gerrit.client.api.ChangeGlue;
import com.google.gerrit.client.api.ProjectGlue;
import com.google.gerrit.client.api.RevisionGlue;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.reviewdb.client.Project;
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.gwtexpui.safehtml.client.SafeHtmlBuilder;
public class ActionButton extends Button implements ClickHandler {
private final Project.NameKey project;
private final ChangeInfo change;
private final RevisionInfo revision;
private final ActionInfo action;
private ActionContext ctx;
public ActionButton(Project.NameKey project, ActionInfo action) {
this(project, null, null, action);
}
public ActionButton(ChangeInfo change, ActionInfo action) {
this(change, null, action);
}
public ActionButton(ChangeInfo change, RevisionInfo revision, ActionInfo action) {
public ActionButton(ChangeInfo change, RevisionInfo revision,
ActionInfo action) {
this(null, change, revision, action);
}
private ActionButton(Project.NameKey project, ChangeInfo change,
RevisionInfo revision, ActionInfo action) {
super(new SafeHtmlBuilder()
.openDiv()
.append(action.label())
@@ -44,6 +57,7 @@ public class ActionButton extends Button implements ClickHandler {
setEnabled(action.enabled());
addClickHandler(this);
this.project = project;
this.change = change;
this.revision = revision;
this.action = action;
@@ -59,8 +73,10 @@ public class ActionButton extends Button implements ClickHandler {
if (revision != null) {
RevisionGlue.onAction(change, revision, action, this);
} else {
} else if (change != null) {
ChangeGlue.onAction(change, action, this);
} else if (project != null) {
ProjectGlue.onAction(project, action, this);
}
}