gwt.material.design.client.ui.MaterialListBox Java Examples

The following examples show how to use gwt.material.design.client.ui.MaterialListBox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListBoxView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
protected void generateAllowBlankItems(MaterialListBox listBox) {
    listBox.clear();
    for (int i = 1; i <= 5; i++) {
        listBox.addItem("Option " + i);
    }
    lstAllowBlank.reload();
}
 
Example #2
Source File: QueryOptionsView.java    From lumongo with Apache License 2.0 4 votes vote down vote up
public QueryOptionsView(UIQueryResults uiQueryResults) {
	setMargin(15);
	setPadding(10);

	uiQueryObject = uiQueryResults.getUiQueryObject();
	if (uiQueryObject == null) {
		uiQueryObject = new UIQueryObject();
	}

	if (!uiQueryResults.getJsonDocs().isEmpty()) {
		MaterialBadge resultsBadge = new MaterialBadge("Total Results: " + NumberFormat.getFormat("#,##0").format(uiQueryResults.getTotalResults()));
		add(resultsBadge);
		add(new Br());
	}

	MaterialButton executeButton = new MaterialButton("Execute", IconType.SEARCH);
	executeButton.addClickHandler(clickEvent -> runSearch());
	executeButton.setMarginRight(2);
	add(executeButton);

	MaterialButton resetButton = new MaterialButton("Reset", IconType.REFRESH);
	resetButton.addClickHandler(clickEvent -> MainController.get().goTo(new QueryPlace(null)));
	add(resetButton);

	MaterialListBox indexesListBox = new MaterialListBox();
	indexesListBox.setMultipleSelect(true);
	Option selectOneIndexOption = new Option("Select Indexes");
	selectOneIndexOption.setDisabled(true);
	indexesListBox.add(selectOneIndexOption);

	fieldNameCollapsible = new MaterialCollapsible();
	fieldNameCollapsible.setAccordion(false);
	for (IndexInfo indexInfo : uiQueryResults.getIndexes()) {
		createFieldNameCollapsible(indexInfo);

		Option option = new Option(indexInfo.getName());
		if (uiQueryObject.getIndexNames().contains(indexInfo.getName())) {
			option.setSelected(true);
			fieldItems.get(indexInfo.getName()).setVisible(true);
		}
		indexesListBox.add(option);
	}
	indexesListBox.addValueChangeHandler(valueChangeEvent -> {
		for (String indexName : fieldItems.keySet()) {
			fieldItems.get(indexName).setVisible(false);
		}
		for (String itemsSelected : indexesListBox.getItemsSelected()) {
			uiQueryObject.getIndexNames().add(itemsSelected);
			fieldItems.get(itemsSelected).setVisible(true);
		}
	});

	add(indexesListBox);
	add(fieldNameCollapsible);

	CustomTextBox searchBox = new CustomTextBox(true);
	searchBox.setPlaceHolder("q=*:*");
	searchBox.setValue(uiQueryObject.getQuery());
	searchBox.addKeyUpHandler(clickEvent -> {
		if (clickEvent.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
			uiQueryObject.setQuery(searchBox.getValue());
			runSearch();
		}
	});

	searchBox.getButton().setTitle("Execute Query");
	searchBox.getButton().addClickHandler(clickEvent -> {
		uiQueryObject.setQuery(searchBox.getValue());
		runSearch();
	});

	add(searchBox);

	CustomTextBox rowsIntegerBox = new CustomTextBox();
	rowsIntegerBox.setPlaceHolder("rows (defaults to 10)");
	if (uiQueryObject != null && uiQueryObject.getRows() != 10) {
		rowsIntegerBox.setValue(uiQueryObject.getRows() + "");
	}
	rowsIntegerBox.getTextBox().addChangeHandler(changeEvent -> uiQueryObject.setRows(Integer.valueOf(rowsIntegerBox.getValue())));
	rowsIntegerBox.addKeyUpHandler(clickEvent -> {
		if (clickEvent.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
			runSearch();
		}
	});

	add(rowsIntegerBox);

	filterQueryDiv = new Div();
	if (!uiQueryObject.getFilterQueries().isEmpty()) {
		for (String fq : uiQueryObject.getFilterQueries()) {
			createFilterQueryWidget(fq);
		}
	}
	else {
		createFilterQueryWidget(null);
	}

	add(filterQueryDiv);

}