Added auto-complete off
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@128970 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9aa990a944
commit
1752abcd8e
|
@ -42,10 +42,6 @@ import com.google.gwt.user.client.ui.Label;
|
|||
*/
|
||||
public class DialogShareFolder extends Dialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
private int widthDialog = 535;
|
||||
private int heightTextArea = 100;
|
||||
private TextField<String> txtName;
|
||||
|
@ -75,7 +71,6 @@ public class DialogShareFolder extends Dialog {
|
|||
|
||||
setWidth(widthDialog);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
|
||||
setHeading("Share folder: "+folder.getName());
|
||||
|
||||
txtName = new TextField<String>();
|
||||
|
@ -95,9 +90,7 @@ public class DialogShareFolder extends Dialog {
|
|||
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
|
||||
textAreaDescription.setHeight(heightTextArea);
|
||||
textAreaDescription.setWidth(380);
|
||||
|
||||
textAreaDescription.setValue(folder.getDescription());
|
||||
// textAreaDescription.setReadOnly(true);
|
||||
|
||||
final LayoutContainer lc = new LayoutContainer();
|
||||
lc.setStyleAttribute("margin-top", "10px");
|
||||
|
|
|
@ -105,11 +105,9 @@ public class MultiDragContact extends Dialog {
|
|||
setGropUserStoreSorter(storeSource);
|
||||
setGropUserStoreSorter(storeTarget);
|
||||
|
||||
|
||||
ContentPanel cpAlreadyShared = new ContentPanel();
|
||||
cpAlreadyShared.setSize(WIDTH_CP, HEIGHT_CONTAINER_TEXT_AREA);
|
||||
cpAlreadyShared.setHeaderVisible(false);
|
||||
|
||||
cpAlreadyShared.setLayout(new FitLayout());
|
||||
|
||||
VerticalPanel vpShared = new VerticalPanel();
|
||||
|
|
|
@ -22,11 +22,13 @@ import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
|||
import com.google.gwt.user.client.ui.SuggestBox;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
|
||||
/**
|
||||
* The Class MultiValuePanel.
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
* @version 0.2 Gen 2013 modified by Francesco Mangiacrapa
|
||||
* Facebook style autocompleter
|
||||
*
|
||||
*/
|
||||
public class MultiValuePanel extends Composite {
|
||||
|
||||
|
@ -37,23 +39,25 @@ public class MultiValuePanel extends Composite {
|
|||
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>();
|
||||
private BulletList listBullet = new BulletList();
|
||||
private SuggestBox box;
|
||||
private ContactFetcher userFetch;
|
||||
private ContactFetcher userFetch;
|
||||
private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userFetch the ContactFetcher
|
||||
* Instantiates a new multi value panel.
|
||||
*
|
||||
* @param userFetch the ContactFetcher
|
||||
*/
|
||||
public MultiValuePanel(ContactFetcher userFetch) {
|
||||
this.userFetch = userFetch;
|
||||
initWidget(panel);
|
||||
panel.setWidth("100%");
|
||||
panel.setWidth("100%");
|
||||
listBullet.setStyleName("multivalue-panel-suggest");
|
||||
final ListItem item = new ListItem();
|
||||
final TextBox itemBox = new TextBox();
|
||||
itemBox.getElement().setAttribute("autocomplete", "off");
|
||||
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);
|
||||
listBullet.add(item);
|
||||
|
||||
|
@ -63,22 +67,22 @@ public class MultiValuePanel extends Composite {
|
|||
// handle backspace
|
||||
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
|
||||
if ("".equals(itemBox.getValue().trim())) {
|
||||
|
||||
|
||||
if(listBullet.getWidgetCount()>2){
|
||||
ListItem li = (ListItem) listBullet.getWidget(listBullet.getWidgetCount() - 2);
|
||||
|
||||
|
||||
if(li.getWidget(0) instanceof Paragraph){
|
||||
Paragraph p = (Paragraph) li.getWidget(0);
|
||||
// GWT.log("p "+p.getText() +" is removable : " + p.isRemovable());
|
||||
if (itemsSelected.contains(p.getText()) && (p.isRemovable()==true)) {
|
||||
if (itemsSelected.contains(p.getText()) && p.isRemovable()==true) {
|
||||
itemsSelected.remove(p.getText());
|
||||
GWT.log("Removing selected item: " + p.getText() + "'");
|
||||
listBullet.remove(li);
|
||||
}
|
||||
|
||||
|
||||
itemBox.setFocus(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,22 +97,30 @@ public class MultiValuePanel extends Composite {
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Box set focus.
|
||||
*/
|
||||
public void boxSetFocus(){
|
||||
box.getElement().focus();
|
||||
box.setFocus(true);
|
||||
// panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the flow panel.
|
||||
*
|
||||
* @return the flow panel
|
||||
*/
|
||||
public FlowPanel getFlowPanel(){
|
||||
return panel;
|
||||
}
|
||||
|
||||
/**
|
||||
* actually insert the contact in the flow panel
|
||||
* @param itemBox
|
||||
* @param list
|
||||
* actually insert the contact in the flow panel.
|
||||
*
|
||||
* @param itemBox the item box
|
||||
* @param list the list
|
||||
*/
|
||||
private void chosenContactItem(final TextBox itemBox, final BulletList list) {
|
||||
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
|
||||
|
@ -136,16 +148,18 @@ public class MultiValuePanel extends Composite {
|
|||
itemBox.setFocus(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets the selected user.
|
||||
*
|
||||
* @return the selected contacts (user logins e.g. pino.pini)
|
||||
*/
|
||||
public List<InfoContactModel> getSelectedUser() {
|
||||
if (users == null)
|
||||
if (users == null)
|
||||
return new ArrayList<InfoContactModel>();
|
||||
else {
|
||||
List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>();
|
||||
|
||||
|
||||
for (String login : itemsSelected) {
|
||||
InfoContactModel wsuser = users.get(login);
|
||||
if(wsuser!= null && !toReturn.contains(wsuser)){
|
||||
|
@ -156,6 +170,12 @@ public class MultiValuePanel extends Composite {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the list item.
|
||||
*
|
||||
* @param displayItem the display item
|
||||
* @param list the list
|
||||
*/
|
||||
private void removeListItem(ListItem displayItem, BulletList list) {
|
||||
GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null);
|
||||
itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML());
|
||||
|
@ -163,76 +183,82 @@ public class MultiValuePanel extends Composite {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the suggestions.
|
||||
*
|
||||
* @return names of possible contacts
|
||||
*/
|
||||
private MultiWordSuggestOracle getSuggestions() {
|
||||
|
||||
userFetch.getListContact(contacts, false);
|
||||
|
||||
return oracle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update suggestions.
|
||||
*
|
||||
* @param result the result
|
||||
*/
|
||||
public void updateSuggestions(List<InfoContactModel> result) {
|
||||
|
||||
oracle.clear();
|
||||
|
||||
for (InfoContactModel wsUser : result) {
|
||||
oracle.add(wsUser.getName());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private AsyncCallback<List<InfoContactModel>> contacts = new AsyncCallback<List<InfoContactModel>>() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<InfoContactModel> result) {
|
||||
|
||||
|
||||
users.clear();
|
||||
|
||||
|
||||
for (InfoContactModel wsUser : result) {
|
||||
oracle.add(wsUser.getName());
|
||||
users.put(wsUser.getName(), wsUser);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset item selected.
|
||||
*/
|
||||
public void resetItemSelected(){
|
||||
|
||||
|
||||
listBullet.clear();
|
||||
itemsSelected.clear();
|
||||
ListItem item = new ListItem();
|
||||
item.add(box);
|
||||
listBullet.add(item);
|
||||
listBullet.add(item);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param contact
|
||||
* @param displayRemoveItem
|
||||
* Adds the recipient.
|
||||
*
|
||||
* @param fullName the full name
|
||||
* @param displayRemoveItem the display remove item
|
||||
*/
|
||||
public void addRecipient(String fullName, boolean displayRemoveItem) {
|
||||
|
||||
|
||||
if (fullName != null) {
|
||||
|
||||
TextBox itemBox = new TextBox();
|
||||
itemBox.setText(fullName);
|
||||
itemBox.setValue(fullName);
|
||||
final ListItem displayItem = new ListItem();
|
||||
|
||||
|
||||
Paragraph p = new Paragraph(fullName);
|
||||
displayItem.add(p);
|
||||
|
||||
|
||||
if(displayRemoveItem){
|
||||
displayItem.setStyleName("multivalue-panel-token-ws");
|
||||
p.setRemovable(true);
|
||||
|
@ -242,15 +268,15 @@ public class MultiValuePanel extends Composite {
|
|||
removeListItem(displayItem, listBullet);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
displayItem.add(span);
|
||||
}
|
||||
else{
|
||||
displayItem.setStyleName("multivalue-panel-token-ws-notselectable");
|
||||
p.setRemovable(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GWT.log("Adding selected wp item '" + itemBox.getValue());
|
||||
itemsSelected.add(itemBox.getValue());
|
||||
|
@ -260,15 +286,23 @@ public class MultiValuePanel extends Composite {
|
|||
itemBox.setValue("");
|
||||
itemBox.setFocus(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear list.
|
||||
*/
|
||||
public void clearList() {
|
||||
listBullet.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the box.
|
||||
*
|
||||
* @return the box
|
||||
*/
|
||||
public SuggestBox getBox() {
|
||||
return box;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue