Refactoring: Merge AddMemberBox and AddIncludedGroupBox
Merge AddMemberBox and AddIncludedGroupBox into one class since most of the coding is identical. This refactoring is a preparation for allowing groups being added as reviewers for a change. Otherwise to implement this feature it would be needed to introduce a third class AddAccountOrAccountGroupBox which would again be almost identical in coding. The idea is to just have one class which can be used for all three cases. Signed-off-by: Edwin Kempin <edwin.kempin@sap.com> Change-Id: I667b6ba1ce8390c18e6ec2f1ef16d64f93926c01
This commit is contained in:
@@ -27,6 +27,7 @@ import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.SuggestBox;
|
||||
import com.google.gwt.user.client.ui.SuggestBox.DefaultSuggestionDisplay;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
||||
|
||||
public class AddMemberBox extends Composite {
|
||||
@@ -37,14 +38,20 @@ public class AddMemberBox extends Composite {
|
||||
private boolean submitOnSelection;
|
||||
|
||||
public AddMemberBox() {
|
||||
this(Util.C.buttonAddGroupMember(), Util.C.defaultAccountName(),
|
||||
new AccountSuggestOracle());
|
||||
}
|
||||
|
||||
public AddMemberBox(final String buttonLabel, final String hint,
|
||||
final SuggestOracle suggestOracle) {
|
||||
addPanel = new FlowPanel();
|
||||
addMember = new Button(Util.C.buttonAddGroupMember());
|
||||
addMember = new Button(buttonLabel);
|
||||
nameTxtBox = new HintTextBox();
|
||||
nameTxt = new SuggestBox(new RPCSuggestOracle(
|
||||
new AccountSuggestOracle()), nameTxtBox);
|
||||
suggestOracle), nameTxtBox);
|
||||
|
||||
nameTxtBox.setVisibleLength(50);
|
||||
nameTxtBox.setHintText(Util.C.defaultAccountName());
|
||||
nameTxtBox.setHintText(hint);
|
||||
nameTxtBox.addKeyPressHandler(new KeyPressHandler() {
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
@@ -76,10 +83,6 @@ public class AddMemberBox extends Composite {
|
||||
initWidget(addPanel);
|
||||
}
|
||||
|
||||
public void setAddButtonText(final String text) {
|
||||
addMember.setText(text);
|
||||
}
|
||||
|
||||
public void addClickHandler(final ClickHandler handler) {
|
||||
addMember.addClickHandler(handler);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user