@Override protected List<FormItem> createFormItems(EnhancedDynamicForm form) { List<FormItem> items = new ArrayList<FormItem>(); TextItem nameItem = new TextItem(BundleGroupsDataSource.FIELD_NAME); nameItem.setShowTitle(true); nameItem.setSelectOnFocus(true); nameItem.setTabIndex(1); nameItem.setAttribute(EnhancedDynamicForm.OUTPUT_AS_HTML_ATTRIBUTE, true); items.add(nameItem); TextItem descriptionItem = new TextItem(BundleGroupsDataSource.FIELD_DESCRIPTION); descriptionItem.setShowTitle(true); descriptionItem.setTabIndex(5); descriptionItem.setColSpan(form.getNumCols()); descriptionItem.setAttribute(EnhancedDynamicForm.OUTPUT_AS_HTML_ATTRIBUTE, true); items.add(descriptionItem); return items; }
private HLayout createSearchLayout() { HLayout searchLayout = new HLayout(); searchLayout.setWidth100(); searchLayout.setHeight(20); searchLayout.setMembersMargin(15); i_searchForm = new DynamicForm(); i_searchForm.setWidth(250); i_searchForm.setHeight100(); i_searchForm.setAlign(Alignment.LEFT); i_searchForm.setAutoFocus(true); i_searchTextItem = new TextItem(); i_searchTextItem.setTitle("Search"); i_searchTextItem.setWidth(200); i_searchTextItem.setHint(SEARCH_HINT); i_searchTextItem.setShowHintInField(true); i_searchTextItem.setCanFocus(true); i_searchTextItem.setSelectOnFocus(true); i_searchTextItem.addKeyUpHandler( new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { event.getKeyName(); // ignore the arrow keys if (isValidSearchText()) { i_searchListGrid.getData(i_searchTextItem.getValueAsString()); i_addButton.setDisabled(true); } } }); i_searchForm.setFields(i_searchTextItem); // add button to a Vlayout so we can position it correctly with the form // search text. VLayout buttonVlayout = new VLayout(); buttonVlayout.setWidth(40); buttonVlayout.setAlign(VerticalAlignment.CENTER); buttonVlayout.setMargin(2); i_clearButton = new IButton(CLEAR_BUTTON_TITLE); i_clearButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { i_searchTextItem.setValue(""); i_rowsRetrievedLabel.setContents(""); i_searchListGrid.clearData(); i_addButton.setDisabled(true); } }); buttonVlayout.addMember(i_clearButton); // add Label to a Vlayout so we can position it correctly with the form // search text. VLayout labelVlayout = new VLayout(); labelVlayout.setWidth(100); labelVlayout.setAlign(VerticalAlignment.BOTTOM); labelVlayout.setMargin(2); i_rowsRetrievedLabel = new Label(); i_rowsRetrievedLabel.setWrap(false); i_rowsRetrievedLabel.setWidth100(); i_rowsRetrievedLabel.setHeight(23); labelVlayout.addMember(i_rowsRetrievedLabel); searchLayout.addMember(i_searchForm); searchLayout.addMember(buttonVlayout); searchLayout.addMember(labelVlayout); return searchLayout; }