import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.themes.Reindeer; /** * * @author Neiron */ public class Phonebook extends MCS { Table table = new Table("Телефонный справочник"); final IndexedContainer c = TableUtil.getContainer(); /** * Создаёт Layout с таблицей телефонов */ public VerticalLayout getPhonebook () { //table init //size table.setWidth("100%"); table.setHeight("100%"); // connect data source table.setContainerDataSource(c); // turn on column reordering and collapsing table.setColumnReorderingAllowed(true); table.setColumnCollapsingAllowed(true); // set column headers table.setColumnHeaders(new String[]{"ФИО", "Отдел/Должность", "Внутрненний тел.", "Городской тел.", "Сотовый тел.", "Email"}); //table init end final VerticalLayout contentIndex = new VerticalLayout(); contentIndex.setMargin(true); Button button_filter = new Button("Фильтр"); button_filter.setStyleName(Reindeer.BUTTON_SMALL); button_filter.addListener(new Button.ClickListener() { @Override public void buttonClick (Button.ClickEvent event) { main.addWindow(filterWindow()); } }); //Filter end contentIndex.addComponent(button_filter); contentIndex.addComponent(table); return contentIndex; } public Window filterWindow () { // Filter start final Window window_filter = new Window("Фильтр"); window_filter.setHeight("320"); window_filter.setWidth("320"); window_filter.center(); window_filter.setStyleName(Reindeer.WINDOW_LIGHT); window_filter.setResizable(false); final GridLayout filter_grid = new GridLayout(2, 7); filter_grid.setSpacing(true); filter_grid.setSizeFull(); // FIO Label fio = new Label("ФИО"); filter_grid.addComponent(fio, 0, 0); final TextField fio_textfield = new TextField(); filter_grid.addComponent(fio_textfield, 1, 0); // Otdel Label otdel = new Label("Отдел, Должность"); filter_grid.addComponent(otdel, 0, 1); final TextField otdel_textfield = new TextField(); filter_grid.addComponent(otdel_textfield, 1, 1); // Tel V Label tel_v = new Label("Внут. тел."); filter_grid.addComponent(tel_v, 0, 2); final TextField tel_v_textfield = new TextField(); filter_grid.addComponent(tel_v_textfield, 1, 2); // Tel G Label tel_g = new Label("Город. тел."); filter_grid.addComponent(tel_g, 0, 3); final TextField tel_g_textfield = new TextField(); filter_grid.addComponent(tel_g_textfield, 1, 3); // Tel S Label tel_s = new Label("Сотов. тел."); filter_grid.addComponent(tel_s, 0, 4); final TextField tel_s_textfield = new TextField(); filter_grid.addComponent(tel_s_textfield, 1, 4); // Email Label email = new Label("Email"); filter_grid.addComponent(email, 0, 5); final TextField email_textfield = new TextField(); filter_grid.addComponent(email_textfield, 1, 5); final Button filter_button = new Button("Отфильтровать"); filter_button.addListener(new Button.ClickListener() { @Override public void buttonClick (Button.ClickEvent event) { c.removeAllContainerFilters(); c.addContainerFilter(TableUtil.PROPERTY_NAME, fio_textfield.toString(), true, true); c.addContainerFilter(TableUtil.PROPERTY_OTDEL, otdel_textfield.toString(), true, true); c.addContainerFilter(TableUtil.PROPERTY_TEL_V, tel_v_textfield.toString(), true, true); c.addContainerFilter(TableUtil.PROPERTY_TEL_G, tel_g_textfield.toString(), true, true); c.addContainerFilter(TableUtil.PROPERTY_TEL_S, tel_s_textfield.toString(), true, true); c.addContainerFilter(TableUtil.PROPERTY_EMAIL, email_textfield.toString(), true, true); } }); filter_grid.addComponent(filter_button, 0, 6); final Button filter_reset_button = new Button("Сбросить"); filter_reset_button.addListener(new Button.ClickListener() { @Override public void buttonClick (Button.ClickEvent event) { c.removeAllContainerFilters(); } }); filter_grid.addComponent(filter_reset_button, 1, 6); filter_grid.setComponentAlignment(filter_reset_button, Alignment.BOTTOM_LEFT); filter_grid.setComponentAlignment(filter_button, Alignment.BOTTOM_RIGHT); window_filter.addComponent(filter_grid); return window_filter; } }
All head already broke. The essence is as follows: there is a dynamic class, in it, using the getPhonebook ()
method, VerticalLayout
is built with a table of phone numbers. Also on this layer there is a button and a listener for it, the filterWindow()
method is hung on it, which draws a window with fields for filtering the list of numbers by parameters.
The problem is that the list filter window does not appear and no errors are reported. I concluded that it appeared in another dynamic copy. How to cure it?