List of usage examples for com.vaadin.ui TabSheet.SelectedTabChangeListener TabSheet.SelectedTabChangeListener
TabSheet.SelectedTabChangeListener
From source file:com.example.MongoDBContainerDemo.java
License:Apache License
@Override protected void init(VaadinRequest request) { this.setContent(tabSheet); try {/*from w w w .j a va 2 s. co m*/ mongoOperations = new MongoTemplate(new MongoClient(), "scratch"); } catch (UnknownHostException e) { e.printStackTrace(); } // mongoOperations.remove(new Query(), Person.class); // generateRecords(); final AbstractMongoDemo basic = new BasicMongoDemo(mongoOperations).initLayout(); final AbstractMongoDemo buffered = new BufferedMongoDemo(mongoOperations).initLayout(); tabSheet.addTab(basic, "Basic"); tabSheet.addTab(buffered, "Buffered"); tabSheet.setSelectedTab(basic); tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() { @Override public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) { if (tabSheet.getSelectedTab().equals(buffered)) { buffered.mongoContainer.refresh(); buffered.table.refreshRowCache(); } else { basic.mongoContainer.refresh(); basic.table.refreshRowCache(); } } }); }
From source file:com.expressui.core.view.form.TypedForm.java
License:Open Source License
private void initializeTabs(VerticalLayout layout) { final Set<String> tabNames = getFormFieldSet().getTabNames(); formTabSheet = new TabSheet(); setDebugId(formTabSheet, "formTabSheet"); formTabSheet.addStyleName("borderless"); formTabSheet.setSizeUndefined();/*from w w w . j av a 2 s .c om*/ int tabPosition = 0; for (String tabName : tabNames) { Assert.PROGRAMMING.isTrue(!tabName.isEmpty(), "Tab name may not be empty string"); Label emptyLabel = new Label(); emptyLabel.setSizeUndefined(); formTabSheet.addTab(emptyLabel, tabName, null); tabPositions.put(tabName, tabPosition++); } layout.addComponent(formTabSheet); formTabSheet.addListener(new TabSheet.SelectedTabChangeListener() { @Override public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) { String tabName = getCurrentlySelectedTabName(); form.getLayout().removeAllComponents(); FormGridLayout gridLayout = (FormGridLayout) form.getLayout(); gridLayout.setFormColumns(getFormFieldSet().getColumns(tabName)); gridLayout.setRows(getFormFieldSet().getRows(tabName)); Set<FormField> formFields = getFormFieldSet().getFormFields(tabName); for (FormField formField : formFields) { String propertyId = formField.getPropertyId(); Field field = formField.getField(); form.attachField(propertyId, field); } gridLayout.requestRepaint(); } }); }
From source file:com.purebred.core.view.FormComponent.java
License:Open Source License
private void initializeTabs(VerticalLayout layout) { final Set<String> tabNames = getFormFields().getTabNames(); tabSheet = new TabSheet(); tabSheet.addStyleName("borderless"); tabSheet.setSizeUndefined();//w w w.java2 s. c o m int tabPosition = 0; for (String tabName : tabNames) { Label emptyLabel = new Label(); emptyLabel.setSizeUndefined(); tabSheet.addTab(emptyLabel, tabName, null); tabPositions.put(tabName, tabPosition++); } layout.addComponent(tabSheet); tabSheet.addListener(new TabSheet.SelectedTabChangeListener() { @Override public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) { String tabName = getCurrentlySelectedTabName(); form.getLayout().removeAllComponents(); FormGridLayout gridLayout = (FormGridLayout) form.getLayout(); gridLayout.setFormColumns(getFormFields().getColumns(tabName)); gridLayout.setRows(getFormFields().getRows(tabName)); Set<FormField> formFields = getFormFields().getFormFields(tabName); for (FormField formField : formFields) { String propertyId = formField.getPropertyId(); Field field = formField.getField(); form.attachField(propertyId, field); } } }); }
From source file:com.vphakala.VaadinUI.java
@Override protected void init(VaadinRequest request) { customerTab = new CustomerUI(customerService); subscriberTab = new SubscriberUI(subscriberService); mainLayout = new TabSheet(); mainLayout.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() { public void selectedTabChange(SelectedTabChangeEvent event) { TabSheet tabsheet = event.getTabSheet(); Layout tab = (Layout) tabsheet.getSelectedTab(); if (tab == subscriberTab) { subscriberTab.setUIFields(customerTab.getEmail().getValue()); } else if (tab == customerTab) { // no action needed } else { Notification.show("*** shit happens ***"); }//www .j ava 2s . c o m } }); mainLayout.addTab(customerTab); mainLayout.addTab(subscriberTab); setContent(mainLayout); }