List of usage examples for com.google.gwt.user.client.ui ListBox setItemText
public void setItemText(int index, String text)
From source file:com.ephesoft.dcma.gwt.core.client.view.MultipleSelectTwoSidedListBox.java
License:Open Source License
private void addUpButtonPressHandler(Button button, final ListBox list) { button.addClickHandler(new ClickHandler() { @Override//from w w w . ja va2 s . c o m public void onClick(ClickEvent clickEvent) { final int LIST_LENGTH = list.getItemCount(); if (list != null && LIST_LENGTH > 0 && !list.isItemSelected(0)) { // Map<Integer, String> selectedValues = new HashMap<Integer, String>(); String tempItemTextString; String tempItemValueString; List<Integer> selectedValuesIndex = new ArrayList<Integer>(0); for (int index = 0; index < LIST_LENGTH; index++) { if (list.isItemSelected(index)) { tempItemTextString = list.getItemText(index); tempItemValueString = list.getValue(index); if (index != 0) { // swap with the previous value in the list, exception being the the first value in the list list.setItemText(index, list.getItemText(index - 1)); list.setItemText(index - 1, tempItemTextString); list.setValue(index, list.getValue(index - 1)); list.setValue(index - 1, tempItemValueString); // populate the indexes of selected values, required to bring focus on them later selectedValuesIndex.add(index - 1); } else { selectedValuesIndex.add(0); } } } // remove current focus list.setSelectedIndex(-1); // set focus on selected indexes after swapping for (Integer index : selectedValuesIndex) { if (index != 0) { list.setItemSelected(index, true); } else { list.setItemSelected(0, true); } } } } }); }
From source file:com.ephesoft.dcma.gwt.core.client.view.MultipleSelectTwoSidedListBox.java
License:Open Source License
private void addDownButtonPressHandler(Button button, final ListBox listBox) { button.addClickHandler(new ClickHandler() { @Override// ww w . j a v a 2s .c om public void onClick(ClickEvent clickEvent) { final int LIST_LENGTH = listBox.getItemCount(); if (listBox != null && LIST_LENGTH > 0 && !listBox.isItemSelected(listBox.getItemCount() - 1)) { // Map<Integer, String> selectedValues = new HashMap<Integer, String>(); String tempString; String tempItemValueString; List<Integer> selectedValuesIndex = new ArrayList<Integer>(0); for (int index = LIST_LENGTH - 1; index > -1; index--) { if (listBox.isItemSelected(index)) { tempString = listBox.getItemText(index); tempItemValueString = listBox.getValue(index); if (index != LIST_LENGTH - 1) { // swap with the next value in the list, exception being the the last value in the list listBox.setItemText(index, listBox.getItemText(index + 1)); listBox.setItemText(index + 1, tempString); listBox.setValue(index, listBox.getValue(index + 1)); listBox.setValue(index + 1, tempItemValueString); // populate the indexes of selected values, required to bring focus on them later selectedValuesIndex.add(index + 1); } } } // remove current focus listBox.setSelectedIndex(-1); // set focus on selected indexes after swapping for (Integer index : selectedValuesIndex) { // boolean firstSelected = false; if (index != 0) { listBox.setItemSelected(index, true); } else { listBox.setItemSelected(0, true); } } } } }); }
From source file:com.google.gerrit.client.admin.ProjectInfoScreen.java
License:Apache License
private void setBool(ListBox box, InheritedBoolean inheritedBoolean) { int inheritedIndex = -1; for (int i = 0; i < box.getItemCount(); i++) { if (box.getValue(i).startsWith(InheritableBoolean.INHERIT.name())) { inheritedIndex = i;/*from w ww .j av a 2 s. c o m*/ } if (box.getValue(i).startsWith(inheritedBoolean.value.name())) { box.setSelectedIndex(i); } } if (inheritedIndex >= 0) { if (project.getParent(Gerrit.getConfig().getWildProject()) == null) { if (box.getSelectedIndex() == inheritedIndex) { for (int i = 0; i < box.getItemCount(); i++) { if (box.getValue(i).equals(InheritableBoolean.FALSE.name())) { box.setSelectedIndex(i); break; } } } box.removeItem(inheritedIndex); } else { box.setItemText(inheritedIndex, InheritableBoolean.INHERIT.name() + " (" + inheritedBoolean.inheritedValue + ")"); } } }
From source file:org.rstudio.studio.client.workbench.prefs.views.PaneLayoutPreferencesPane.java
License:Open Source License
private void updateTabSetLabels() { for (ListBox pane : allPanes_) { pane.setItemText(2, StringUtil.join(tabSet1ModuleList_.getValue(), ", ")); pane.setItemText(3, StringUtil.join(tabSet2ModuleList_.getValue(), ", ")); }/*from w ww .j a v a 2 s .co m*/ }