Create an RPCSuggestOracle proxy and use it.
The RPCSuggestOracle class will proxy SuggestOracle requests to another SuggestOracle while keeping track of the latest request. Any response that belongs to a request which is not the latest request will be dropped to prevent invalid deliveries. Use this class ontop of the AccountSugestOracle, the AccountGroupSuggestOracle, and the ProjectNameSuggestOracle. Bug: issue 607 Change-Id: I33b2419cec5a8e9878c2eedb227b402bb9897455
This commit is contained in:
@@ -21,6 +21,7 @@ import com.google.gerrit.client.ui.FancyFlexTable;
|
|||||||
import com.google.gerrit.client.ui.HintTextBox;
|
import com.google.gerrit.client.ui.HintTextBox;
|
||||||
import com.google.gerrit.client.ui.ProjectLink;
|
import com.google.gerrit.client.ui.ProjectLink;
|
||||||
import com.google.gerrit.client.ui.ProjectNameSuggestOracle;
|
import com.google.gerrit.client.ui.ProjectNameSuggestOracle;
|
||||||
|
import com.google.gerrit.client.ui.RPCSuggestOracle;
|
||||||
import com.google.gerrit.common.data.AccountProjectWatchInfo;
|
import com.google.gerrit.common.data.AccountProjectWatchInfo;
|
||||||
import com.google.gerrit.reviewdb.AccountProjectWatch;
|
import com.google.gerrit.reviewdb.AccountProjectWatch;
|
||||||
import com.google.gerrit.reviewdb.Change.Status;
|
import com.google.gerrit.reviewdb.Change.Status;
|
||||||
@@ -62,7 +63,8 @@ public class MyWatchedProjectsScreen extends SettingsScreen {
|
|||||||
|
|
||||||
{
|
{
|
||||||
nameBox = new HintTextBox();
|
nameBox = new HintTextBox();
|
||||||
nameTxt = new SuggestBox(new ProjectNameSuggestOracle(), nameBox);
|
nameTxt = new SuggestBox(new RPCSuggestOracle(
|
||||||
|
new ProjectNameSuggestOracle()), nameBox);
|
||||||
nameBox.setVisibleLength(50);
|
nameBox.setVisibleLength(50);
|
||||||
nameBox.setHintText(Util.C.defaultProjectName());
|
nameBox.setHintText(Util.C.defaultProjectName());
|
||||||
nameBox.addKeyPressHandler(new KeyPressHandler() {
|
nameBox.addKeyPressHandler(new KeyPressHandler() {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import com.google.gerrit.client.Gerrit;
|
|||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.ui.AccountGroupSuggestOracle;
|
import com.google.gerrit.client.ui.AccountGroupSuggestOracle;
|
||||||
import com.google.gerrit.client.ui.HintTextBox;
|
import com.google.gerrit.client.ui.HintTextBox;
|
||||||
|
import com.google.gerrit.client.ui.RPCSuggestOracle;
|
||||||
import com.google.gerrit.common.data.ApprovalType;
|
import com.google.gerrit.common.data.ApprovalType;
|
||||||
import com.google.gerrit.common.data.ProjectDetail;
|
import com.google.gerrit.common.data.ProjectDetail;
|
||||||
import com.google.gerrit.reviewdb.ApprovalCategory;
|
import com.google.gerrit.reviewdb.ApprovalCategory;
|
||||||
@@ -100,7 +101,8 @@ public class AccessRightEditor extends Composite
|
|||||||
});
|
});
|
||||||
|
|
||||||
nameTxt = new HintTextBox();
|
nameTxt = new HintTextBox();
|
||||||
nameSug = new SuggestBox(new AccountGroupSuggestOracle(), nameTxt);
|
nameSug = new SuggestBox(new RPCSuggestOracle(
|
||||||
|
new AccountGroupSuggestOracle()), nameTxt);
|
||||||
nameTxt.setVisibleLength(50);
|
nameTxt.setVisibleLength(50);
|
||||||
nameTxt.setHintText(Util.C.defaultAccountGroupName());
|
nameTxt.setHintText(Util.C.defaultAccountGroupName());
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.google.gerrit.client.ui.AccountGroupSuggestOracle;
|
|||||||
import com.google.gerrit.client.ui.AccountScreen;
|
import com.google.gerrit.client.ui.AccountScreen;
|
||||||
import com.google.gerrit.client.ui.AddMemberBox;
|
import com.google.gerrit.client.ui.AddMemberBox;
|
||||||
import com.google.gerrit.client.ui.FancyFlexTable;
|
import com.google.gerrit.client.ui.FancyFlexTable;
|
||||||
|
import com.google.gerrit.client.ui.RPCSuggestOracle;
|
||||||
import com.google.gerrit.client.ui.SmallHeading;
|
import com.google.gerrit.client.ui.SmallHeading;
|
||||||
import com.google.gerrit.client.ui.TextSaveButtonListener;
|
import com.google.gerrit.client.ui.TextSaveButtonListener;
|
||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
import com.google.gerrit.common.data.AccountInfoCache;
|
||||||
@@ -143,7 +144,8 @@ public class AccountGroupScreen extends AccountScreen {
|
|||||||
|
|
||||||
ownerTxtBox = new NpTextBox();
|
ownerTxtBox = new NpTextBox();
|
||||||
ownerTxtBox.setVisibleLength(60);
|
ownerTxtBox.setVisibleLength(60);
|
||||||
ownerTxt = new SuggestBox(new AccountGroupSuggestOracle(), ownerTxtBox);
|
ownerTxt = new SuggestBox(new RPCSuggestOracle(
|
||||||
|
new AccountGroupSuggestOracle()), ownerTxtBox);
|
||||||
ownerPanel.add(ownerTxt);
|
ownerPanel.add(ownerTxt);
|
||||||
|
|
||||||
saveOwner = new Button(Util.C.buttonChangeGroupOwner());
|
saveOwner = new Button(Util.C.buttonChangeGroupOwner());
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package com.google.gerrit.client.ui;
|
|||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.admin.Util;
|
import com.google.gerrit.client.admin.Util;
|
||||||
import com.google.gerrit.client.ui.HintTextBox;
|
import com.google.gerrit.client.ui.HintTextBox;
|
||||||
|
import com.google.gerrit.client.ui.RPCSuggestOracle;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.dom.client.KeyCodes;
|
import com.google.gwt.event.dom.client.KeyCodes;
|
||||||
@@ -41,7 +42,8 @@ public class AddMemberBox extends Composite {
|
|||||||
addPanel = new FlowPanel();
|
addPanel = new FlowPanel();
|
||||||
addMember = new Button(Util.C.buttonAddGroupMember());
|
addMember = new Button(Util.C.buttonAddGroupMember());
|
||||||
nameTxtBox = new HintTextBox();
|
nameTxtBox = new HintTextBox();
|
||||||
nameTxt = new SuggestBox(new AccountSuggestOracle(), nameTxtBox);
|
nameTxt = new SuggestBox(new RPCSuggestOracle(
|
||||||
|
new AccountSuggestOracle()), nameTxtBox);
|
||||||
|
|
||||||
nameTxtBox.setVisibleLength(50);
|
nameTxtBox.setVisibleLength(50);
|
||||||
nameTxtBox.setHintText(Util.C.defaultAccountName());
|
nameTxtBox.setHintText(Util.C.defaultAccountName());
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
// 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.ui.SuggestOracle;
|
||||||
|
import com.google.gwt.user.client.ui.SuggestOracle.Callback;
|
||||||
|
import com.google.gwt.user.client.ui.SuggestOracle.Request;
|
||||||
|
import com.google.gwt.user.client.ui.SuggestOracle.Response;
|
||||||
|
|
||||||
|
/** This class will proxy SuggestOracle requests to another SuggestOracle
|
||||||
|
* while keeping track of the latest request. Any repsonse that belongs
|
||||||
|
* to a request which is not the latest request will be dropped to prevent
|
||||||
|
* invalid deliveries.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class RPCSuggestOracle extends SuggestOracle {
|
||||||
|
|
||||||
|
private SuggestOracle oracle;
|
||||||
|
private SuggestOracle.Request request;
|
||||||
|
private SuggestOracle.Callback callback;
|
||||||
|
private SuggestOracle.Callback myCallback = new SuggestOracle.Callback() {
|
||||||
|
public void onSuggestionsReady(SuggestOracle.Request req,
|
||||||
|
SuggestOracle.Response response) {
|
||||||
|
if (request == req) {
|
||||||
|
callback.onSuggestionsReady(req, response);
|
||||||
|
request = null;
|
||||||
|
callback = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public RPCSuggestOracle(SuggestOracle ora) {
|
||||||
|
oracle = ora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void requestSuggestions(SuggestOracle.Request req,
|
||||||
|
SuggestOracle.Callback cb) {
|
||||||
|
request = req;
|
||||||
|
callback = cb;
|
||||||
|
oracle.requestSuggestions(req, myCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisplayStringHTML() {
|
||||||
|
return oracle.isDisplayStringHTML();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user