Auto completion for "Cherry Pick..."-button.
Change-Id: I8b6ad2ea9c833ff267401426367fcc8d17fc437f
This commit is contained in:
@@ -13,7 +13,6 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package com.google.gerrit.client.changes;
|
package com.google.gerrit.client.changes;
|
||||||
|
|
||||||
import com.google.gerrit.client.Dispatcher;
|
import com.google.gerrit.client.Dispatcher;
|
||||||
import com.google.gerrit.client.FormatUtil;
|
import com.google.gerrit.client.FormatUtil;
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
@@ -22,10 +21,10 @@ import com.google.gerrit.client.download.DownloadPanel;
|
|||||||
import com.google.gerrit.client.patches.PatchUtil;
|
import com.google.gerrit.client.patches.PatchUtil;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.ui.AccountLinkPanel;
|
import com.google.gerrit.client.ui.AccountLinkPanel;
|
||||||
import com.google.gerrit.client.ui.CommentedActionDialog;
|
import com.google.gerrit.client.ui.ActionDialog;
|
||||||
|
import com.google.gerrit.client.ui.CherryPickDialog;
|
||||||
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
|
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
|
||||||
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
|
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
|
||||||
import com.google.gerrit.client.ui.SmallHeading;
|
|
||||||
import com.google.gerrit.common.PageLinks;
|
import com.google.gerrit.common.PageLinks;
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
import com.google.gerrit.common.data.ChangeDetail;
|
||||||
import com.google.gerrit.common.data.PatchSetDetail;
|
import com.google.gerrit.common.data.PatchSetDetail;
|
||||||
@@ -44,12 +43,10 @@ import com.google.gwt.user.client.ui.Anchor;
|
|||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
import com.google.gwt.user.client.ui.DisclosurePanel;
|
import com.google.gwt.user.client.ui.DisclosurePanel;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.FocusWidget;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
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.InlineLabel;
|
import com.google.gwt.user.client.ui.InlineLabel;
|
||||||
import com.google.gwt.user.client.ui.Panel;
|
import com.google.gwt.user.client.ui.Panel;
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
|
||||||
import com.google.gwtjsonrpc.common.VoidResult;
|
import com.google.gwtjsonrpc.common.VoidResult;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -387,7 +384,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(final ClickEvent event) {
|
public void onClick(final ClickEvent event) {
|
||||||
b.setEnabled(false);
|
b.setEnabled(false);
|
||||||
new CherryPickDialog(b) {
|
new CherryPickDialog(b, changeDetail.getChange().getProject()) {
|
||||||
{
|
{
|
||||||
sendButton.setText(Util.C.buttonCherryPickChangeSend());
|
sendButton.setText(Util.C.buttonCherryPickChangeSend());
|
||||||
message.setText(Util.M.cherryPickedChangeDefaultMessage(
|
message.setText(Util.M.cherryPickedChangeDefaultMessage(
|
||||||
@@ -673,44 +670,4 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|||||||
patchTable.setActive(active);
|
patchTable.setActive(active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract class ActionDialog extends CommentedActionDialog<ChangeDetail> {
|
|
||||||
public ActionDialog(final FocusWidget enableOnFailure, final boolean redirect,
|
|
||||||
String dialogTitle, String dialogHeading) {
|
|
||||||
super(dialogTitle, dialogHeading, new ChangeDetailCache.IgnoreErrorCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeDetail result) {
|
|
||||||
if (redirect) {
|
|
||||||
Gerrit.display(PageLinks.toChange(result.getChange().getId()));
|
|
||||||
} else {
|
|
||||||
super.onSuccess(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
enableOnFailure.setEnabled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private abstract class CherryPickDialog extends ActionDialog {
|
|
||||||
private TextBox newBranch;
|
|
||||||
|
|
||||||
CherryPickDialog(final FocusWidget enableOnFailure) {
|
|
||||||
super(enableOnFailure, true, Util.C.cherryPickTitle(), Util.C.cherryPickCommitMessage());
|
|
||||||
|
|
||||||
newBranch = new TextBox();
|
|
||||||
newBranch.setVisibleLength(65);
|
|
||||||
setFocusOn(newBranch);
|
|
||||||
message.setCharacterWidth(70);
|
|
||||||
panel.insert(newBranch, 0);
|
|
||||||
panel.insert(new SmallHeading(Util.C.headingCherryPickBranch()), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDestinationBranch() {
|
|
||||||
return newBranch.getText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// 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.ui;
|
||||||
|
|
||||||
|
import com.google.gerrit.client.Gerrit;
|
||||||
|
import com.google.gerrit.client.changes.ChangeDetailCache;
|
||||||
|
import com.google.gerrit.common.PageLinks;
|
||||||
|
import com.google.gerrit.common.data.ChangeDetail;
|
||||||
|
import com.google.gwt.user.client.ui.FocusWidget;
|
||||||
|
|
||||||
|
public abstract class ActionDialog extends CommentedActionDialog<ChangeDetail> {
|
||||||
|
public ActionDialog(final FocusWidget enableOnFailure, final boolean redirect,
|
||||||
|
String dialogTitle, String dialogHeading) {
|
||||||
|
super(dialogTitle, dialogHeading, new ChangeDetailCache.IgnoreErrorCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ChangeDetail result) {
|
||||||
|
if (redirect) {
|
||||||
|
Gerrit.display(PageLinks.toChange(result.getChange().getId()));
|
||||||
|
} else {
|
||||||
|
super.onSuccess(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
enableOnFailure.setEnabled(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
// 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.ui;
|
||||||
|
|
||||||
|
import com.google.gerrit.client.changes.Util;
|
||||||
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
|
import com.google.gerrit.common.data.ListBranchesResult;
|
||||||
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
import com.google.gwt.user.client.ui.FocusWidget;
|
||||||
|
import com.google.gwt.user.client.ui.SuggestBox;
|
||||||
|
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
||||||
|
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
||||||
|
import com.google.gwtexpui.safehtml.client.HighlightSuggestOracle;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class CherryPickDialog extends ActionDialog {
|
||||||
|
private SuggestBox newBranch;
|
||||||
|
private List<Branch> branches;
|
||||||
|
|
||||||
|
public CherryPickDialog(final FocusWidget enableOnFailure, Project.NameKey project) {
|
||||||
|
super(enableOnFailure, true, Util.C.cherryPickTitle(), Util.C
|
||||||
|
.cherryPickCommitMessage());
|
||||||
|
com.google.gerrit.client.account.Util.PROJECT_SVC.listBranches(project,
|
||||||
|
new GerritCallback<ListBranchesResult>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(ListBranchesResult result) {
|
||||||
|
branches = result.getBranches();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
newBranch = new SuggestBox(new HighlightSuggestOracle() {
|
||||||
|
@Override
|
||||||
|
protected void onRequestSuggestions(Request request, Callback done) {
|
||||||
|
LinkedList<BranchSuggestion> suggestions =
|
||||||
|
new LinkedList<BranchSuggestion>();
|
||||||
|
for (final Branch b : branches) {
|
||||||
|
if (b.getName().indexOf(request.getQuery()) >= 0) {
|
||||||
|
suggestions.add(new BranchSuggestion(b));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
done.onSuggestionsReady(request, new Response(suggestions));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
newBranch.setWidth("70ex");
|
||||||
|
message.setCharacterWidth(70);
|
||||||
|
panel.insert(newBranch, 0);
|
||||||
|
panel.insert(new SmallHeading(Util.C.headingCherryPickBranch()), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void center() {
|
||||||
|
super.center();
|
||||||
|
GlobalKey.dialog(this);
|
||||||
|
newBranch.setFocus(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDestinationBranch() {
|
||||||
|
return newBranch.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
class BranchSuggestion implements Suggestion {
|
||||||
|
private Branch branch;
|
||||||
|
|
||||||
|
public BranchSuggestion(Branch branch) {
|
||||||
|
this.branch = branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayString() {
|
||||||
|
return branch.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getReplacementString() {
|
||||||
|
return branch.getShortName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user