Merge "Use SafeHtml for confirmation dialog"
This commit is contained in:
@@ -19,8 +19,9 @@ import com.google.gwt.event.dom.client.ClickHandler;
|
|||||||
import com.google.gwt.user.client.DOM;
|
import com.google.gwt.user.client.DOM;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
||||||
|
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
||||||
import com.google.gwtexpui.user.client.AutoCenterDialogBox;
|
import com.google.gwtexpui.user.client.AutoCenterDialogBox;
|
||||||
|
|
||||||
public class ConfirmationDialog extends AutoCenterDialogBox {
|
public class ConfirmationDialog extends AutoCenterDialogBox {
|
||||||
@@ -28,7 +29,7 @@ public class ConfirmationDialog extends AutoCenterDialogBox {
|
|||||||
|
|
||||||
private Button cancelButton;
|
private Button cancelButton;
|
||||||
|
|
||||||
public ConfirmationDialog(final String dialogTitle, final HTML message,
|
public ConfirmationDialog(final String dialogTitle, final SafeHtml message,
|
||||||
final ConfirmationCallback callback) {
|
final ConfirmationCallback callback) {
|
||||||
super(/* auto hide */false, /* modal */true);
|
super(/* auto hide */false, /* modal */true);
|
||||||
setGlassEnabled(true);
|
setGlassEnabled(true);
|
||||||
@@ -59,11 +60,12 @@ public class ConfirmationDialog extends AutoCenterDialogBox {
|
|||||||
buttons.add(cancelButton);
|
buttons.add(cancelButton);
|
||||||
|
|
||||||
final FlowPanel center = new FlowPanel();
|
final FlowPanel center = new FlowPanel();
|
||||||
center.add(message);
|
final Widget msgWidget = message.toBlockWidget();
|
||||||
|
center.add(msgWidget);
|
||||||
center.add(buttons);
|
center.add(buttons);
|
||||||
add(center);
|
add(center);
|
||||||
|
|
||||||
message.setWidth("400px");
|
msgWidget.setWidth("400px");
|
||||||
|
|
||||||
setWidget(center);
|
setWidget(center);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ import com.google.gwt.user.client.ui.CheckBox;
|
|||||||
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
|
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
|
||||||
import com.google.gwt.user.client.ui.Label;
|
import com.google.gwt.user.client.ui.Label;
|
||||||
|
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
||||||
import com.google.gwtjsonrpc.client.RemoteJsonException;
|
import com.google.gwtjsonrpc.client.RemoteJsonException;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -232,29 +232,32 @@ public class ProjectBranchesScreen extends ProjectScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void deleteChecked() {
|
void deleteChecked() {
|
||||||
final StringBuilder message = new StringBuilder();
|
final SafeHtmlBuilder b = new SafeHtmlBuilder();
|
||||||
message.append("<b>").append(Gerrit.C.branchDeletionConfirmationMessage()).append("</b>");
|
b.openElement("b");
|
||||||
message.append("<p>");
|
b.append(Gerrit.C.branchDeletionConfirmationMessage());
|
||||||
|
b.closeElement("b");
|
||||||
|
|
||||||
|
b.openElement("p");
|
||||||
final HashSet<Branch.NameKey> ids = new HashSet<Branch.NameKey>();
|
final HashSet<Branch.NameKey> ids = new HashSet<Branch.NameKey>();
|
||||||
for (int row = 1; row < table.getRowCount(); row++) {
|
for (int row = 1; row < table.getRowCount(); row++) {
|
||||||
final Branch k = getRowItem(row);
|
final Branch k = getRowItem(row);
|
||||||
if (k != null && table.getWidget(row, 1) instanceof CheckBox
|
if (k != null && table.getWidget(row, 1) instanceof CheckBox
|
||||||
&& ((CheckBox) table.getWidget(row, 1)).getValue()) {
|
&& ((CheckBox) table.getWidget(row, 1)).getValue()) {
|
||||||
if (!ids.isEmpty()) {
|
if (!ids.isEmpty()) {
|
||||||
message.append(", <br>");
|
b.append(",").br();
|
||||||
}
|
}
|
||||||
message.append(k.getName());
|
b.append(k.getName());
|
||||||
ids.add(k.getNameKey());
|
ids.add(k.getNameKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message.append("</p>");
|
b.closeElement("p");
|
||||||
if (ids.isEmpty()) {
|
if (ids.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmationDialog confirmationDialog =
|
ConfirmationDialog confirmationDialog =
|
||||||
new ConfirmationDialog(Gerrit.C.branchDeletionDialogTitle(),
|
new ConfirmationDialog(Gerrit.C.branchDeletionDialogTitle(),
|
||||||
new HTML(message.toString()), new ConfirmationCallback() {
|
b.toSafeHtml(), new ConfirmationCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onOk() {
|
public void onOk() {
|
||||||
Util.PROJECT_SVC.deleteBranch(getProjectKey(), ids,
|
Util.PROJECT_SVC.deleteBranch(getProjectKey(), ids,
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import com.google.gwt.user.client.Element;
|
|||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
||||||
import com.google.gwt.user.client.ui.Image;
|
import com.google.gwt.user.client.ui.Image;
|
||||||
import com.google.gwt.user.client.ui.Panel;
|
import com.google.gwt.user.client.ui.Panel;
|
||||||
@@ -330,15 +329,15 @@ public class ApprovalTable extends Composite {
|
|||||||
|
|
||||||
private void askForConfirmation(final String groupName,
|
private void askForConfirmation(final String groupName,
|
||||||
final int memberCount) {
|
final int memberCount) {
|
||||||
final StringBuilder message = new StringBuilder();
|
final SafeHtmlBuilder b = new SafeHtmlBuilder();
|
||||||
message.append("<b>");
|
b.openElement("b");
|
||||||
message.append(Util.M.groupManyMembersConfirmation(groupName,
|
b.append(Util.M
|
||||||
memberCount));
|
.groupManyMembersConfirmation(groupName, memberCount));
|
||||||
message.append("</b>");
|
b.closeElement("b");
|
||||||
final ConfirmationDialog confirmationDialog =
|
final ConfirmationDialog confirmationDialog =
|
||||||
new ConfirmationDialog(Util.C
|
new ConfirmationDialog(Util.C
|
||||||
.approvalTableAddManyReviewersConfirmationDialogTitle(),
|
.approvalTableAddManyReviewersConfirmationDialogTitle(),
|
||||||
new HTML(message.toString()), new ConfirmationCallback() {
|
b.toSafeHtml(), new ConfirmationCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onOk() {
|
public void onOk() {
|
||||||
addReviewers(reviewers, true);
|
addReviewers(reviewers, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user