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:
Francesco Mangiacrapa 2016-06-01 14:57:33 +00:00
parent 9aa990a944
commit 1752abcd8e
3 changed files with 81 additions and 56 deletions

View File

@ -42,10 +42,6 @@ import com.google.gwt.user.client.ui.Label;
*/ */
public class DialogShareFolder extends Dialog { public class DialogShareFolder extends Dialog {
/**
*
*/
private int widthDialog = 535; private int widthDialog = 535;
private int heightTextArea = 100; private int heightTextArea = 100;
private TextField<String> txtName; private TextField<String> txtName;
@ -75,7 +71,6 @@ public class DialogShareFolder extends Dialog {
setWidth(widthDialog); setWidth(widthDialog);
setButtons(Dialog.OKCANCEL); setButtons(Dialog.OKCANCEL);
setHeading("Share folder: "+folder.getName()); setHeading("Share folder: "+folder.getName());
txtName = new TextField<String>(); txtName = new TextField<String>();
@ -95,9 +90,7 @@ public class DialogShareFolder extends Dialog {
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION); textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
textAreaDescription.setHeight(heightTextArea); textAreaDescription.setHeight(heightTextArea);
textAreaDescription.setWidth(380); textAreaDescription.setWidth(380);
textAreaDescription.setValue(folder.getDescription()); textAreaDescription.setValue(folder.getDescription());
// textAreaDescription.setReadOnly(true);
final LayoutContainer lc = new LayoutContainer(); final LayoutContainer lc = new LayoutContainer();
lc.setStyleAttribute("margin-top", "10px"); lc.setStyleAttribute("margin-top", "10px");

View File

@ -105,11 +105,9 @@ public class MultiDragContact extends Dialog {
setGropUserStoreSorter(storeSource); setGropUserStoreSorter(storeSource);
setGropUserStoreSorter(storeTarget); setGropUserStoreSorter(storeTarget);
ContentPanel cpAlreadyShared = new ContentPanel(); ContentPanel cpAlreadyShared = new ContentPanel();
cpAlreadyShared.setSize(WIDTH_CP, HEIGHT_CONTAINER_TEXT_AREA); cpAlreadyShared.setSize(WIDTH_CP, HEIGHT_CONTAINER_TEXT_AREA);
cpAlreadyShared.setHeaderVisible(false); cpAlreadyShared.setHeaderVisible(false);
cpAlreadyShared.setLayout(new FitLayout()); cpAlreadyShared.setLayout(new FitLayout());
VerticalPanel vpShared = new VerticalPanel(); VerticalPanel vpShared = new VerticalPanel();

View File

@ -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.SuggestBox;
import com.google.gwt.user.client.ui.SuggestOracle; import com.google.gwt.user.client.ui.SuggestOracle;
import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.TextBox;
/** /**
* The Class MultiValuePanel.
*
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR
* @version 0.2 Gen 2013 modified by Francesco Mangiacrapa * @version 0.2 Gen 2013 modified by Francesco Mangiacrapa
* Facebook style autocompleter * Facebook style autocompleter
*
*/ */
public class MultiValuePanel extends Composite { public class MultiValuePanel extends Composite {
@ -37,23 +39,25 @@ public class MultiValuePanel extends Composite {
private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>(); private HashMap<String, InfoContactModel> users = new HashMap<String, InfoContactModel>();
private BulletList listBullet = 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();
/** /**
* * Instantiates a new multi value panel.
* @param userFetch the ContactFetcher *
* @param userFetch the ContactFetcher
*/ */
public MultiValuePanel(ContactFetcher userFetch) { public MultiValuePanel(ContactFetcher userFetch) {
this.userFetch = userFetch; this.userFetch = userFetch;
initWidget(panel); initWidget(panel);
panel.setWidth("100%"); panel.setWidth("100%");
listBullet.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("autocomplete", "off");
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);
listBullet.add(item); listBullet.add(item);
@ -63,22 +67,22 @@ public class MultiValuePanel extends Composite {
// handle backspace // handle backspace
if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) { if (event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE) {
if ("".equals(itemBox.getValue().trim())) { if ("".equals(itemBox.getValue().trim())) {
if(listBullet.getWidgetCount()>2){ if(listBullet.getWidgetCount()>2){
ListItem li = (ListItem) listBullet.getWidget(listBullet.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);
// GWT.log("p "+p.getText() +" is removable : " + p.isRemovable()); // 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()); itemsSelected.remove(p.getText());
GWT.log("Removing selected item: " + p.getText() + "'"); GWT.log("Removing selected item: " + p.getText() + "'");
listBullet.remove(li); listBullet.remove(li);
} }
itemBox.setFocus(true); itemBox.setFocus(true);
} }
} }
} }
} }
} }
@ -93,22 +97,30 @@ public class MultiValuePanel extends Composite {
panel.add(listBullet); 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 set focus.
*/
public void boxSetFocus(){ public void boxSetFocus(){
box.getElement().focus(); box.getElement().focus();
box.setFocus(true); box.setFocus(true);
// panel.getElement().setAttribute("onclick", "document.getElementById('suggestion_box').focus()");
} }
/**
* Gets the flow panel.
*
* @return the flow panel
*/
public FlowPanel getFlowPanel(){ public FlowPanel getFlowPanel(){
return panel; return panel;
} }
/** /**
* actually insert the contact in the flow panel * actually insert the contact in the flow panel.
* @param itemBox *
* @param list * @param itemBox the item box
* @param list the list
*/ */
private void chosenContactItem(final TextBox itemBox, final BulletList list) { private void chosenContactItem(final TextBox itemBox, final BulletList list) {
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) { if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
@ -136,16 +148,18 @@ public class MultiValuePanel extends Composite {
itemBox.setFocus(true); itemBox.setFocus(true);
} }
} }
/** /**
* * Gets the selected user.
*
* @return the selected contacts (user logins e.g. pino.pini) * @return the selected contacts (user logins e.g. pino.pini)
*/ */
public List<InfoContactModel> getSelectedUser() { public List<InfoContactModel> getSelectedUser() {
if (users == null) if (users == null)
return new ArrayList<InfoContactModel>(); return new ArrayList<InfoContactModel>();
else { else {
List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>(); List<InfoContactModel> toReturn = new ArrayList<InfoContactModel>();
for (String login : itemsSelected) { for (String login : itemsSelected) {
InfoContactModel wsuser = users.get(login); InfoContactModel wsuser = users.get(login);
if(wsuser!= null && !toReturn.contains(wsuser)){ 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) { private void removeListItem(ListItem displayItem, BulletList list) {
GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null); GWT.log("Removing: " + displayItem.getWidget(0).getElement().getInnerHTML(), null);
itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML()); itemsSelected.remove(displayItem.getWidget(0).getElement().getInnerHTML());
@ -163,76 +183,82 @@ public class MultiValuePanel extends Composite {
} }
/** /**
* Gets the suggestions.
* *
* @return names of possible contacts * @return names of possible contacts
*/ */
private MultiWordSuggestOracle getSuggestions() { private MultiWordSuggestOracle getSuggestions() {
userFetch.getListContact(contacts, false); userFetch.getListContact(contacts, false);
return oracle; return oracle;
} }
/**
* Update suggestions.
*
* @param result the result
*/
public void updateSuggestions(List<InfoContactModel> result) { public void updateSuggestions(List<InfoContactModel> result) {
oracle.clear(); oracle.clear();
for (InfoContactModel wsUser : result) { for (InfoContactModel wsUser : result) {
oracle.add(wsUser.getName()); oracle.add(wsUser.getName());
} }
} }
private AsyncCallback<List<InfoContactModel>> contacts = new AsyncCallback<List<InfoContactModel>>() { private AsyncCallback<List<InfoContactModel>> contacts = new AsyncCallback<List<InfoContactModel>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
} }
@Override @Override
public void onSuccess(List<InfoContactModel> result) { public void onSuccess(List<InfoContactModel> result) {
users.clear(); users.clear();
for (InfoContactModel wsUser : result) { for (InfoContactModel wsUser : result) {
oracle.add(wsUser.getName()); oracle.add(wsUser.getName());
users.put(wsUser.getName(), wsUser); users.put(wsUser.getName(), wsUser);
}
}
};
}
}
};
/**
* Reset item selected.
*/
public void resetItemSelected(){ public void resetItemSelected(){
listBullet.clear(); listBullet.clear();
itemsSelected.clear(); itemsSelected.clear();
ListItem item = new ListItem(); ListItem item = new ListItem();
item.add(box); item.add(box);
listBullet.add(item); listBullet.add(item);
} }
/** /**
* * Adds the recipient.
* @param contact *
* @param displayRemoveItem * @param fullName the full name
* @param displayRemoveItem the display remove item
*/ */
public void addRecipient(String fullName, boolean displayRemoveItem) { public void addRecipient(String fullName, boolean displayRemoveItem) {
if (fullName != null) { if (fullName != null) {
TextBox itemBox = new TextBox(); TextBox itemBox = new TextBox();
itemBox.setText(fullName); itemBox.setText(fullName);
itemBox.setValue(fullName); itemBox.setValue(fullName);
final ListItem displayItem = new ListItem(); final ListItem displayItem = new ListItem();
Paragraph p = new Paragraph(fullName); Paragraph p = new Paragraph(fullName);
displayItem.add(p); displayItem.add(p);
if(displayRemoveItem){ if(displayRemoveItem){
displayItem.setStyleName("multivalue-panel-token-ws"); displayItem.setStyleName("multivalue-panel-token-ws");
p.setRemovable(true); p.setRemovable(true);
@ -242,15 +268,15 @@ public class MultiValuePanel extends Composite {
removeListItem(displayItem, listBullet); removeListItem(displayItem, listBullet);
} }
}); });
displayItem.add(span); displayItem.add(span);
} }
else{ else{
displayItem.setStyleName("multivalue-panel-token-ws-notselectable"); displayItem.setStyleName("multivalue-panel-token-ws-notselectable");
p.setRemovable(false); p.setRemovable(false);
} }
GWT.log("Adding selected wp item '" + itemBox.getValue()); GWT.log("Adding selected wp item '" + itemBox.getValue());
itemsSelected.add(itemBox.getValue()); itemsSelected.add(itemBox.getValue());
@ -260,15 +286,23 @@ public class MultiValuePanel extends Composite {
itemBox.setValue(""); itemBox.setValue("");
itemBox.setFocus(true); itemBox.setFocus(true);
} }
} }
/**
* Clear list.
*/
public void clearList() { public void clearList() {
listBullet.clear(); listBullet.clear();
} }
/**
* Gets the box.
*
* @return the box
*/
public SuggestBox getBox() { public SuggestBox getBox() {
return box; return box;
} }
} }