|
|
|
@ -35,7 +35,7 @@ public class MultiValuePanel extends Composite {
|
|
|
|
|
FlowPanel panel = new FlowPanel();
|
|
|
|
|
// private HandlerManager eventBus;
|
|
|
|
|
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>();
|
|
|
|
|
private BulletList list = new BulletList();
|
|
|
|
|
private BulletList listBullet = new BulletList();
|
|
|
|
|
private SuggestBox box;
|
|
|
|
|
private ContactFetcher userFetch;
|
|
|
|
|
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
|
|
|
|
@ -48,14 +48,14 @@ public class MultiValuePanel extends Composite {
|
|
|
|
|
this.userFetch = userFetch;
|
|
|
|
|
initWidget(panel);
|
|
|
|
|
panel.setWidth("100%");
|
|
|
|
|
list.setStyleName("multivalue-panel-suggest");
|
|
|
|
|
listBullet.setStyleName("multivalue-panel-suggest");
|
|
|
|
|
final ListItem item = new ListItem();
|
|
|
|
|
final TextBox itemBox = new TextBox();
|
|
|
|
|
itemBox.getElement().setAttribute("style", "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium; border: none;");
|
|
|
|
|
box = new SuggestBox(getSuggestions(), itemBox);
|
|
|
|
|
|
|
|
|
|
item.add(box);
|
|
|
|
|
list.add(item);
|
|
|
|
|
listBullet.add(item);
|
|
|
|
|
|
|
|
|
|
// needed to be set on the itemBox instead of the box, otherwise backspace gets executed twice
|
|
|
|
|
itemBox.addKeyDownHandler(new KeyDownHandler() {
|
|
|
|
@ -64,8 +64,8 @@ public class MultiValuePanel extends Composite {
|
|
|
|
|
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
|
|
|
|
|
if ("".equals(itemBox.getValue().trim())) {
|
|
|
|
|
|
|
|
|
|
if(list.getWidgetCount()>2){
|
|
|
|
|
ListItem li = (ListItem) list.getWidget(list.getWidgetCount() - 2);
|
|
|
|
|
if(listBullet.getWidgetCount()>2){
|
|
|
|
|
ListItem li = (ListItem) listBullet.getWidget(listBullet.getWidgetCount() - 2);
|
|
|
|
|
|
|
|
|
|
if(li.getWidget(0) instanceof Paragraph){
|
|
|
|
|
Paragraph p = (Paragraph) li.getWidget(0);
|
|
|
|
@ -73,7 +73,7 @@ public class MultiValuePanel extends Composite {
|
|
|
|
|
itemsSelected.remove(p.getText());
|
|
|
|
|
GWT.log("Removing selected item: " + p.getText() + "'");
|
|
|
|
|
}
|
|
|
|
|
list.remove(li);
|
|
|
|
|
listBullet.remove(li);
|
|
|
|
|
itemBox.setFocus(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -84,18 +84,20 @@ public class MultiValuePanel extends Composite {
|
|
|
|
|
|
|
|
|
|
box.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
|
|
|
|
|
public void onSelection(SelectionEvent<SuggestOracle.Suggestion> selectionEvent) {
|
|
|
|
|
chosenContactItem(itemBox, list);
|
|
|
|
|
chosenContactItem(itemBox, listBullet);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
panel.add(list);
|
|
|
|
|
panel.add(listBullet);
|
|
|
|
|
box.getElement().setId("suggestion_box"); //needed for the focus on click
|
|
|
|
|
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
|
|
|
|
// box.setFocus(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void boxSetFocus(){
|
|
|
|
|
box.getElement().focus();
|
|
|
|
|
box.setFocus(true);
|
|
|
|
|
// panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FlowPanel getFlowPanel(){
|
|
|
|
@ -208,11 +210,21 @@ public class MultiValuePanel extends Composite {
|
|
|
|
|
}
|
|
|
|
|
return listUsers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void resetItemSelected(){
|
|
|
|
|
|
|
|
|
|
listBullet.clear();
|
|
|
|
|
itemsSelected.clear();
|
|
|
|
|
ListItem item = new ListItem();
|
|
|
|
|
item.add(box);
|
|
|
|
|
listBullet.add(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* insert the attachment item view in the flow panel
|
|
|
|
|
*/
|
|
|
|
|
public void addRecipient(String fullName) {
|
|
|
|
|
|
|
|
|
|
if (fullName != null) {
|
|
|
|
|
TextBox itemBox = new TextBox();
|
|
|
|
|
itemBox.setText(fullName);
|
|
|
|
@ -224,7 +236,7 @@ public class MultiValuePanel extends Composite {
|
|
|
|
|
Span span = new Span("x");
|
|
|
|
|
span.addClickHandler(new ClickHandler() {
|
|
|
|
|
public void onClick(ClickEvent clickEvent) {
|
|
|
|
|
removeListItem(displayItem, list);
|
|
|
|
|
removeListItem(displayItem, listBullet);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -235,13 +247,18 @@ public class MultiValuePanel extends Composite {
|
|
|
|
|
itemsSelected.add(itemBox.getValue());
|
|
|
|
|
GWT.log("Total: " + itemsSelected);
|
|
|
|
|
|
|
|
|
|
list.insert(displayItem, list.getWidgetCount());
|
|
|
|
|
listBullet.insert(displayItem, listBullet.getWidgetCount());
|
|
|
|
|
itemBox.setValue("");
|
|
|
|
|
itemBox.setFocus(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clearList() {
|
|
|
|
|
list.clear();
|
|
|
|
|
listBullet.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SuggestBox getBox() {
|
|
|
|
|
return box;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|