bug fixed: choose contacts
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@69064 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9c7fb67f32
commit
96a3f9016c
|
@ -96,7 +96,7 @@ public class DialogShareFolder extends Dialog {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<InfoContactModel> result) {
|
public void onSuccess(List<InfoContactModel> result) {
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : result) {
|
for (InfoContactModel infoContactModel : result) {
|
||||||
suggestPanel.addRecipient(infoContactModel.getLogin());
|
suggestPanel.addRecipient(infoContactModel.getLogin());
|
||||||
}
|
}
|
||||||
|
@ -111,8 +111,7 @@ public class DialogShareFolder extends Dialog {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setFocusWidget(suggestPanel.getBox());
|
||||||
setFocusWidget(txtName);
|
|
||||||
add(txtName);
|
add(txtName);
|
||||||
add(lc);
|
add(lc);
|
||||||
addListners();
|
addListners();
|
||||||
|
@ -232,9 +231,14 @@ public class DialogShareFolder extends Dialog {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentSelected(ButtonEvent ce) {
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
|
||||||
|
suggestPanel.resetItemSelected();
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||||
suggestPanel.addRecipient(infoContactModel.getLogin());
|
suggestPanel.addRecipient(infoContactModel.getLogin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suggestPanel.boxSetFocus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class MultiValuePanel extends Composite {
|
||||||
FlowPanel panel = new FlowPanel();
|
FlowPanel panel = new FlowPanel();
|
||||||
// private HandlerManager eventBus;
|
// private HandlerManager eventBus;
|
||||||
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>();
|
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>();
|
||||||
private BulletList list = new BulletList();
|
private BulletList listBullet = new BulletList();
|
||||||
private SuggestBox box;
|
private SuggestBox box;
|
||||||
private ContactFetcher userFetch;
|
private ContactFetcher userFetch;
|
||||||
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
|
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
|
||||||
|
@ -48,14 +48,14 @@ public class MultiValuePanel extends Composite {
|
||||||
this.userFetch = userFetch;
|
this.userFetch = userFetch;
|
||||||
initWidget(panel);
|
initWidget(panel);
|
||||||
panel.setWidth("100%");
|
panel.setWidth("100%");
|
||||||
list.setStyleName("multivalue-panel-suggest");
|
listBullet.setStyleName("multivalue-panel-suggest");
|
||||||
final ListItem item = new ListItem();
|
final ListItem item = new ListItem();
|
||||||
final TextBox itemBox = new TextBox();
|
final TextBox itemBox = new TextBox();
|
||||||
itemBox.getElement().setAttribute("style", "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium; border: none;");
|
itemBox.getElement().setAttribute("style", "outline-color: -moz-use-text-color; outline-style: none; outline-width: medium; border: none;");
|
||||||
box = new SuggestBox(getSuggestions(), itemBox);
|
box = new SuggestBox(getSuggestions(), itemBox);
|
||||||
|
|
||||||
item.add(box);
|
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
|
// needed to be set on the itemBox instead of the box, otherwise backspace gets executed twice
|
||||||
itemBox.addKeyDownHandler(new KeyDownHandler() {
|
itemBox.addKeyDownHandler(new KeyDownHandler() {
|
||||||
|
@ -64,8 +64,8 @@ public class MultiValuePanel extends Composite {
|
||||||
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
|
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
|
||||||
if ("".equals(itemBox.getValue().trim())) {
|
if ("".equals(itemBox.getValue().trim())) {
|
||||||
|
|
||||||
if(list.getWidgetCount()>2){
|
if(listBullet.getWidgetCount()>2){
|
||||||
ListItem li = (ListItem) list.getWidget(list.getWidgetCount() - 2);
|
ListItem li = (ListItem) listBullet.getWidget(listBullet.getWidgetCount() - 2);
|
||||||
|
|
||||||
if(li.getWidget(0) instanceof Paragraph){
|
if(li.getWidget(0) instanceof Paragraph){
|
||||||
Paragraph p = (Paragraph) li.getWidget(0);
|
Paragraph p = (Paragraph) li.getWidget(0);
|
||||||
|
@ -73,7 +73,7 @@ public class MultiValuePanel extends Composite {
|
||||||
itemsSelected.remove(p.getText());
|
itemsSelected.remove(p.getText());
|
||||||
GWT.log("Removing selected item: " + p.getText() + "'");
|
GWT.log("Removing selected item: " + p.getText() + "'");
|
||||||
}
|
}
|
||||||
list.remove(li);
|
listBullet.remove(li);
|
||||||
itemBox.setFocus(true);
|
itemBox.setFocus(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,18 +84,20 @@ public class MultiValuePanel extends Composite {
|
||||||
|
|
||||||
box.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
|
box.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
|
||||||
public void onSelection(SelectionEvent<SuggestOracle.Suggestion> selectionEvent) {
|
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
|
box.getElement().setId("suggestion_box"); //needed for the focus on click
|
||||||
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
||||||
// box.setFocus(true);
|
// box.setFocus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void boxSetFocus(){
|
public void boxSetFocus(){
|
||||||
|
box.getElement().focus();
|
||||||
box.setFocus(true);
|
box.setFocus(true);
|
||||||
|
// panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlowPanel getFlowPanel(){
|
public FlowPanel getFlowPanel(){
|
||||||
|
@ -208,11 +210,21 @@ public class MultiValuePanel extends Composite {
|
||||||
}
|
}
|
||||||
return listUsers;
|
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
|
* insert the attachment item view in the flow panel
|
||||||
*/
|
*/
|
||||||
public void addRecipient(String fullName) {
|
public void addRecipient(String fullName) {
|
||||||
|
|
||||||
if (fullName != null) {
|
if (fullName != null) {
|
||||||
TextBox itemBox = new TextBox();
|
TextBox itemBox = new TextBox();
|
||||||
itemBox.setText(fullName);
|
itemBox.setText(fullName);
|
||||||
|
@ -224,7 +236,7 @@ public class MultiValuePanel extends Composite {
|
||||||
Span span = new Span("x");
|
Span span = new Span("x");
|
||||||
span.addClickHandler(new ClickHandler() {
|
span.addClickHandler(new ClickHandler() {
|
||||||
public void onClick(ClickEvent clickEvent) {
|
public void onClick(ClickEvent clickEvent) {
|
||||||
removeListItem(displayItem, list);
|
removeListItem(displayItem, listBullet);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -235,13 +247,18 @@ public class MultiValuePanel extends Composite {
|
||||||
itemsSelected.add(itemBox.getValue());
|
itemsSelected.add(itemBox.getValue());
|
||||||
GWT.log("Total: " + itemsSelected);
|
GWT.log("Total: " + itemsSelected);
|
||||||
|
|
||||||
list.insert(displayItem, list.getWidgetCount());
|
listBullet.insert(displayItem, listBullet.getWidgetCount());
|
||||||
itemBox.setValue("");
|
itemBox.setValue("");
|
||||||
itemBox.setFocus(true);
|
itemBox.setFocus(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearList() {
|
public void clearList() {
|
||||||
list.clear();
|
listBullet.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuggestBox getBox() {
|
||||||
|
return box;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue