List of usage examples for com.google.gwt.user.client.ui ListBox getItemCount
public int getItemCount()
From source file:ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils.java
License:Apache License
/** * Selects given <var>value</var> of given <var>listBox</var>. *//*from ww w . j a v a 2 s . c o m*/ public final static void setSelectedItem(final ListBox listBox, final String value) { assert listBox != null : "Unspecified list box."; assert value != null : "Unspecified value."; for (int index = 0; index < listBox.getItemCount(); index++) { if (listBox.getItemText(index).equals(value)) { listBox.setSelectedIndex(index); return; } } throw new IllegalArgumentException("Given value '" + value + "' not found in given list box."); }
From source file:com.codenvy.ide.client.propertiespanel.connectors.base.parameter.ParameterViewImpl.java
License:Open Source License
/** * Select item in the field./*w w w . j ava2 s .c o m*/ * * @param field * field that needs to be changed * @param type * a new selected item */ private void selectType(@Nonnull ListBox field, @Nullable String type) { for (int i = 0; i < field.getItemCount(); i++) { if (field.getValue(i).equals(type)) { field.setItemSelected(i, true); return; } } }
From source file:com.cognitivemedicine.metricsdashboard.client.charts.ChartEditorPanel.java
License:Apache License
private void setListBoxValue(ListBox list, String value) { for (int i = 0; i < list.getItemCount(); i++) { if (list.getValue(i).equals(value)) { list.setSelectedIndex(i);//from w ww. j a va 2s.co m return; } } }
From source file:com.cognitivemedicine.metricsdashboard.client.dashboard.DashboardSettingsPanel.java
License:Apache License
/** * Updates the dashboard settings panel when a dashboard is loaded * //from w w w .j a va 2 s .c om * @param settings */ public void updateDashboardSettings(DashboardSettings settings) { Granularity g = settings.getGranularity(); ListBox list = null; if (g != null) { list = granularitySetting.getList(); for (int i = 0; i < list.getItemCount(); i++) { if (list.getValue(i).equals(g.getSymbol())) { list.setSelectedIndex(i); granularitySetting.getCheckBox().setValue(true); break; } } } else { granularitySetting.getCheckBox().setValue(false); } Period p = settings.getPeriod(); if (p != null) { list = periodSetting.getList(); for (int i = 0; i < list.getItemCount(); i++) { if (list.getValue(i).equals(p.getSymbol())) { list.setSelectedIndex(i); periodSetting.getCheckBox().setValue(true); datetimePicker.setAmPm(settings.getAmPm()); datetimePicker.setHours(settings.getHours()); datetimePicker.setMinutes(settings.getMinutes()); datetimePicker.setDate(settings.getEndDate()); break; } } } else { periodSetting.getCheckBox().setValue(false); } }
From source file:com.controlj.addon.gwttree.client.TreeOptions.java
License:Open Source License
public void showDialog() { VerticalPanel dialogContents = new VerticalPanel(); dialogContents.setSpacing(4);/* ww w .j a v a 2 s.com*/ // Add the tree type radio buttons RadioButton dynamicChoice = createTreeChoice("treeTypeGroup", "Dynamic Tree", false); RadioButton staticChoice = createTreeChoice("treeTypeGroup", "Static Tree", true); if (state.isStaticTree) staticChoice.setValue(true); else dynamicChoice.setValue(true); dialogContents.add(dynamicChoice); dialogContents.add(staticChoice); // Add filtering support dialogContents.add(new Label("Filter by trend name (leave empty to not filter)")); HorizontalPanel sourcesPanel = new HorizontalPanel(); sourcesPanel.setSpacing(10); final ListBox sourceListBox = new ListBox(true); sourceListBox.setSize("10em", "5em"); for (String sourceName : state.sourceNames) sourceListBox.addItem(sourceName); sourcesPanel.add(sourceListBox); VerticalPanel sourcesButtonPanel = new VerticalPanel(); sourcesButtonPanel.add(new Button("Add...", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { final TextBox textBox = new TextBox(); Dialog.showInputDialog("Add Filter", textBox, new Dialog.Handler() { @Override public void setupButtons(final Button ok, final Button cancel) { textBox.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent keyPressEvent) { if (keyPressEvent.getCharCode() == (char) 13) ok.click(); else if (keyPressEvent.getCharCode() == (char) 27) cancel.click(); } }); } @Override public void dialogClosed(boolean wasCancelled) { String name = textBox.getText().trim(); if (!wasCancelled && !name.isEmpty()) { state.sourceNames.add(name); sourceListBox.addItem(name); } } }); textBox.setFocus(true); } })); sourcesButtonPanel.add(new Button("Remove", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { int count = sourceListBox.getItemCount(); for (int i = count - 1; i >= 0; i--) if (sourceListBox.isItemSelected(i)) { state.sourceNames.remove(sourceListBox.getItemText(i)); sourceListBox.removeItem(i); } } })); sourcesPanel.add(sourcesButtonPanel); dialogContents.add(sourcesPanel); final State originalState = state.copy(); Dialog.showInputDialog("Tree Options", dialogContents, new Dialog.Handler() { @Override public void setupButtons(Button ok, Button cancel) { } @Override public void dialogClosed(boolean wasCancelled) { if (wasCancelled) state = originalState; else if (!state.equals(originalState)) handler.optionsChanged(TreeOptions.this); } }); }
From source file:com.databasepreservation.visualization.client.common.utils.ListboxUtils.java
public static final void removeItemByValue(ListBox listbox, String value) { List<Integer> indexesToRemove = new ArrayList<>(); // going from the end to the start so remove is easier for (int i = listbox.getItemCount() - 1; i >= 0; i--) { if (listbox.getValue(i).equals(value)) { indexesToRemove.add(i);//from ww w . j a va 2 s. c om } } for (Integer index : indexesToRemove) { listbox.removeItem(index); } }
From source file:com.databasepreservation.visualization.client.common.utils.ListboxUtils.java
public static final int insertItemByAlphabeticOrder(ListBox listbox, String item, String value) { int indexToInsert = -1; for (int i = 0; i < listbox.getItemCount(); i++) { String itemText = listbox.getItemText(i); if (itemText.compareToIgnoreCase(item) > 0) { indexToInsert = i;/*from www . j a va 2 s . c om*/ break; } } if (indexToInsert < 0) { indexToInsert = listbox.getItemCount(); } listbox.insertItem(item, value, indexToInsert); return indexToInsert; }
From source file:com.databasepreservation.visualization.client.common.utils.ListboxUtils.java
public static final void copyValues(ListBox listBoxOrigin, ListBox listBoxDestination) { for (int i = 0; i < listBoxOrigin.getItemCount(); i++) { listBoxDestination.addItem(listBoxOrigin.getItemText(i), listBoxOrigin.getValue(i)); }//w w w . j a v a 2 s .c o m }
From source file:com.databasepreservation.visualization.client.common.utils.ListboxUtils.java
public static void select(ListBox listBox, String field) { boolean found = false; for (int i = 0; i < listBox.getItemCount() && !found; i++) { if (listBox.getValue(i).equals(field)) { listBox.setSelectedIndex(i); found = true;/*ww w . j a v a 2 s. c o m*/ } } }
From source file:com.dawg6.web.dhcalc.client.BasePanel.java
License:Open Source License
protected void setFieldValue(ListBox field, String value) { try {//from www . j av a 2s. com for (int i = 0; i < field.getItemCount(); i++) { String v = field.getValue(i); if (v.equals(value)) { field.setSelectedIndex(i); return; } } field.setSelectedIndex(0); } catch (Exception e) { field.setSelectedIndex(0); } }