List of usage examples for com.vaadin.ui TabSheet TabSheet
public TabSheet()
From source file:org.s23m.cell.editor.semanticdomain.ui.components.MultitabPanel.java
License:Mozilla Public License
private void createMultitabPanel() { addStyleName(Runo.PANEL_LIGHT);/* w w w.j a v a 2 s . c o m*/ getLayout().setMargin(true); // Search results tab content searchResultPanel = new Panel(); final VerticalLayout searchLayer = new VerticalLayout(); searchLayer.setHeight(SEARCH_RESULTS_PANEL_HEIGHT); searchResultPanel.addStyleName(Runo.PANEL_LIGHT); searchLayer.addComponent(searchResultPanel); // Details form tab content final VerticalLayout detailsFormLayout = new VerticalLayout(); detailsFormLayout.setMargin(true); detailsForm = new Form() { @SuppressWarnings("unchecked") @Override public void setReadOnly(final boolean readOnly) { super.setReadOnly(readOnly); final BeanItem<DetailsData> dataSrc = (BeanItem<DetailsData>) detailsForm.getItemDataSource(); final Set detailsInstance = dataSrc.getBean().getInstance(); if (!InstanceGetter.hasModifiableName(detailsInstance)) { for (final String id : DetailsData.getNameFieldIds()) { final Field f = detailsForm.getField(id); f.setReadOnly(true); } } } }; detailsForm.setCaption("Instance Details"); detailsForm.setImmediate(true); detailsForm.setWriteThrough(false); final DetailsData detailsData = new DetailsData(Root.root); final BeanItem<DetailsData> detailsItem = new BeanItem<DetailsData>(detailsData); final FormFieldFactory formFieldFactory = new PanelFormFieldFactory(); detailsForm.setFormFieldFactory(formFieldFactory); //addImageUploadControls(detailsData); detailsForm.setItemDataSource(detailsItem); detailsForm.setVisibleItemProperties(DetailsData.getDisplayOrder()); detailsForm.setFooter(new VerticalLayout()); final HorizontalLayout formButtonBar = new HorizontalLayout(); formButtonBar.setSpacing(true); formButtonBar.setHeight(BUTTON_BAR_HEIGHT); final Layout footer = detailsForm.getFooter(); footer.addComponent(formButtonBar); editBtn = new Button(EDIT_BUTTON_LABEL, this, FORM_EVENT_HANDLER); saveBtn = new Button(SAVE_BUTTON_LABEL, this, FORM_EVENT_HANDLER); saveBtn.setVisible(false); cancelBtn = new Button(CANCEL_BUTTON_LABEL, this, FORM_EVENT_HANDLER); cancelBtn.setVisible(false); formButtonBar.addComponent(editBtn); formButtonBar.setComponentAlignment(editBtn, Alignment.TOP_RIGHT); formButtonBar.addComponent(saveBtn); formButtonBar.addComponent(cancelBtn); detailsFormLayout.addComponent(detailsForm); tabSheet = new TabSheet(); tabSheet.setWidth(TAB_SHEET_WIDTH_RATIO); tabSheet.setHeight("90%"); tabSheet.addTab(searchLayer, SEARCH_TAB_LABEL, EditorIcon.SEARCH.getIconImage()); tabSheet.addTab(detailsFormLayout, DETAILS_TAB_LABEL, EditorIcon.DETAILS.getIconImage()); tabSheet.addTab(new AdminFormLayout(this), ADMIN_TAB_LABEL, EditorIcon.ADMIN.getIconImage()); //tabSheet.addTab(new GraphVisualizationLayout(this), VISUALIZATION_TAB, EditorIcon.ADMIN.getIconImage()); addComponent(tabSheet); }
From source file:org.sensorhub.ui.GenericConfigForm.java
License:Mozilla Public License
protected Component buildTabs(final String propId, final ContainerProperty prop, final FieldGroup fieldGroup) { GridLayout layout = new GridLayout(); layout.setWidth(100.0f, Unit.PERCENTAGE); // title bar//from w ww . j a v a 2 s . c om HorizontalLayout titleBar = new HorizontalLayout(); titleBar.setMargin(new MarginInfo(true, false, false, false)); titleBar.setSpacing(true); String label = prop.getLabel(); if (label == null) label = DisplayUtils.getPrettyName((String) propId); Label sectionLabel = new Label(label); sectionLabel.setDescription(prop.getDescription()); sectionLabel.addStyleName(STYLE_H3); sectionLabel.addStyleName(STYLE_COLORED); titleBar.addComponent(sectionLabel); layout.addComponent(titleBar); // create one tab per item in container final MyBeanItemContainer<Object> container = prop.getValue(); final TabSheet tabs = new TabSheet(); tabs.setSizeFull(); int i = 1; for (Object itemId : container.getItemIds()) { MyBeanItem<Object> childBeanItem = (MyBeanItem<Object>) container.getItem(itemId); IModuleConfigForm subform = AdminUI.getInstance().generateForm(childBeanItem.getBean().getClass()); subform.build(null, childBeanItem); ((MarginHandler) subform).setMargin(new MarginInfo(true, false, true, false)); allForms.add(subform); Tab tab = tabs.addTab(subform, "Item #" + (i++)); tab.setClosable(true); // store item id so we can map a tab with the corresponding bean item ((AbstractComponent) subform).setData(itemId); } // draw icon on last tab to add new items tabs.addTab(new VerticalLayout(), "", UIConstants.ADD_ICON); // catch close event to delete item tabs.setCloseHandler(new CloseHandler() { private static final long serialVersionUID = 1L; @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { final Tab tab = tabs.getTab(tabContent); final ConfirmDialog popup = new ConfirmDialog( "Are you sure you want to delete " + tab.getCaption() + "?</br>All settings will be lost."); popup.addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; @Override public void windowClose(CloseEvent e) { if (popup.isConfirmed()) { // retrieve id of item shown on tab AbstractComponent tabContent = (AbstractComponent) tab.getComponent(); Object itemId = tabContent.getData(); // remove from UI int deletedTabPos = tabs.getTabPosition(tab); tabs.removeTab(tab); tabs.setSelectedTab(deletedTabPos - 1); // remove from container container.removeItem(itemId); } } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } }); // catch select event on '+' tab to add new item tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { private static final long serialVersionUID = 1L; public void selectedTabChange(SelectedTabChangeEvent event) { Component selectedTab = event.getTabSheet().getSelectedTab(); final Tab tab = tabs.getTab(selectedTab); final int selectedTabPos = tabs.getTabPosition(tab); // case of + tab to add new item if (tab.getCaption().equals("")) { tabs.setSelectedTab(selectedTabPos - 1); try { // show popup to select among available module types String title = "Please select the desired option"; Map<String, Class<?>> typeList = GenericConfigForm.this.getPossibleTypes(propId); ObjectTypeSelectionPopup popup = new ObjectTypeSelectionPopup(title, typeList, new ObjectTypeSelectionCallback() { public void typeSelected(Class<?> objectType) { try { // add new item to container MyBeanItem<Object> childBeanItem = container.addBean( objectType.newInstance(), ((String) propId) + PROP_SEP); // generate form for new item IModuleConfigForm subform = AdminUI.getInstance() .generateForm(childBeanItem.getBean().getClass()); subform.build(null, childBeanItem); ((MarginHandler) subform) .setMargin(new MarginInfo(true, false, true, false)); allForms.add(subform); // add new tab and select it Tab newTab = tabs.addTab(subform, "Item #" + (selectedTabPos + 1), null, selectedTabPos); newTab.setClosable(true); tabs.setSelectedTab(newTab); } catch (Exception e) { Notification.show("Error", e.getMessage(), Notification.Type.ERROR_MESSAGE); } } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } catch (Exception e) { e.printStackTrace(); } } } }); // also register commit handler fieldGroup.addCommitHandler(new CommitHandler() { private static final long serialVersionUID = 1L; @Override public void preCommit(CommitEvent commitEvent) throws CommitException { } @Override public void postCommit(CommitEvent commitEvent) throws CommitException { // make sure new items are transfered to model prop.setValue(prop.getValue()); } }); layout.addComponent(tabs); return layout; }
From source file:org.tltv.gantt.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { ganttListener = null;/*from www . jav a 2s. com*/ createGantt(); MenuBar menu = controlsMenuBar(); Panel controls = createControls(); TabSheet tabsheet = new TabSheet(); tabsheet.setSizeFull(); Component wrapper = UriFragmentWrapperFactory.wrapByUriFragment(UI.getCurrent().getPage().getUriFragment(), gantt); if (wrapper instanceof GanttListener) { ganttListener = (GanttListener) wrapper; } final VerticalLayout layout = new VerticalLayout(); layout.setStyleName("demoContentLayout"); layout.setSizeFull(); layout.addComponent(menu); layout.addComponent(controls); layout.addComponent(wrapper); layout.setExpandRatio(wrapper, 1); setContent(layout); }
From source file:org.vaadin.addon.borderlayout.BorderlayoutUI.java
@Override protected void init(VaadinRequest request) { TabSheet tabs = new TabSheet(); tabs.setSizeFull();/*from ww w . j a v a 2 s .co m*/ setContent(tabs); tabs.addTab(getSimpleExamle(), "Basic functionality"); tabs.addTab(getAnotherExample(), "Sequential add"); }
From source file:org.vaadin.addon.twitter.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { Responsive.makeResponsive(this); CssLayout info = new CssLayout(); info.setStyleName("tw-docs"); info.addComponent(markdown.get(0));// ww w . j ava 2 s.c o m TabSheet tabSheet = new TabSheet(); tabSheet.setStyleName("tw-demo-tab"); tabSheet.addStyleName(ValoTheme.TABSHEET_CENTERED_TABS); tabSheet.setSizeFull(); tabSheet.addTab(new TimelineDemo()).setCaption("Timeline"); tabSheet.addTab(new TweetDemo()).setCaption("Single Tweet"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Follow)).setCaption("Follow Button"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Share)).setCaption("Share Button"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Hashtag)).setCaption("Hashtag Button"); tabSheet.addTab(new ButtonDemo(TweetButton.Type.Mention)).setCaption("Mention Button"); tabSheet.addSelectedTabChangeListener(event -> { Component old = info.getComponent(0); Component newComp = markdown.get(tabSheet.getTabPosition(tabSheet.getTab(tabSheet.getSelectedTab()))); info.replaceComponent(old, newComp); }); final MHorizontalLayout layout = new MHorizontalLayout(info, tabSheet).withExpand(info, 4) .withExpand(tabSheet, 6).withFullWidth().withFullHeight().withMargin(false).withSpacing(true); setContent(new MPanel(layout).withFullWidth().withFullHeight().withStyleName(ValoTheme.PANEL_WELL, "root-container")); }
From source file:org.vaadin.addons.filterbuilder.FilterBuilderUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle("FilterBuilder demo"); HorizontalSplitPanel content = new HorizontalSplitPanel(); content.setSizeFull();//from w w w .j av a 2 s . c o m // Left pane leftPane = new VerticalLayout(); { leftPane.setSizeFull(); leftPane.setMargin(true); leftPane.setSpacing(true); filterField = new TextField(); filterField.setInputPrompt("Write your filter here"); filterField.setIcon(FontAwesome.SEARCH); filterField.addStyleName("filter-field inline-icon"); filterField.setWidth(100, Unit.PERCENTAGE); filterField.setTextChangeEventMode(TextField.TextChangeEventMode.LAZY); filterField.setTextChangeTimeout(1000); filterField.addTextChangeListener(this); leftPane.addComponent(filterField); filterLabel = new Label(); filterLabel.setWidth(100, Unit.PERCENTAGE); try { dataSource = new BeanItemContainer<>(TestCaseBean.class, TestCaseBean.loadMockData()); dataSource.removeContainerProperty("address"); dataSource.addNestedContainerProperty("address.country"); dataSource.addNestedContainerProperty("address.city"); dataSource.addNestedContainerProperty("address.street"); dataSource.addNestedContainerProperty("address.address"); } catch (Exception e) { logger.error("Could not load mock data"); } table = new Table(null, dataSource); table.setSizeFull(); table.setVisibleColumns("id", "firstName", "lastName", "jobTitle", "dob", "salary", "address.country", "address.city", "address.street", "address.address", "unemployed"); table.setSelectable(true); leftPane.addComponent(table); leftPane.setExpandRatio(table, 1); } content.setFirstComponent(leftPane); // Right pane rightPane = new TabSheet(); { rightPane.setSizeFull(); VerticalLayout lastUsedFiltersPane = new VerticalLayout(); lastUsedFiltersPane.setSizeFull(); lastUsedFiltersPane.setMargin(true); lastUsedFiltersPane.setSpacing(true); lastUsedFilters = new IndexedContainer(); lastUsedFilters.addContainerProperty("filter", String.class, null); lastUsedFiltersTable = new Table(); lastUsedFiltersTable.setSizeFull(); lastUsedFiltersTable.setContainerDataSource(lastUsedFilters); lastUsedFiltersTable.setSortEnabled(false); lastUsedFiltersTable.setSelectable(true); lastUsedFiltersTable.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); lastUsedFiltersTable.addItemClickListener(this); final Button removeFilterButton = new Button("Remove", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (lastUsedFiltersTable.getValue() != null) { lastUsedFilters.removeItem(lastUsedFiltersTable.getValue()); lastUsedFiltersTable.setValue(null); } } }); removeFilterButton.setEnabled(false); lastUsedFiltersTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { removeFilterButton.setEnabled(lastUsedFiltersTable.getValue() != null); } }); lastUsedFiltersPane.addComponents(lastUsedFiltersTable, removeFilterButton); lastUsedFiltersPane.setExpandRatio(lastUsedFiltersTable, 1); rightPane.addTab(lastUsedFiltersPane).setCaption("Last used filters"); VerticalLayout dateFormatsPane = new VerticalLayout(); dateFormatsPane.setMargin(true); dateFormats = new IndexedContainer(); dateFormats.addContainerProperty("format", String.class, null); for (SimpleDateFormat dateFormat : FilterBuilder.DATE_FORMATS) { final Item item = dateFormats.addItem(dateFormat.toPattern()); item.getItemProperty("format").setValue(dateFormat.toPattern()); } dateFormatsTable = new Table(); dateFormatsTable.setWidth(100, Unit.PERCENTAGE); dateFormatsTable.setContainerDataSource(dateFormats); dateFormatsTable.setSortEnabled(false); dateFormatsTable.setSelectable(true); dateFormatsTable.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); dateFormatsPane.addComponent(dateFormatsTable); rightPane.addTab(dateFormatsPane).setCaption("Known date formats"); } VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); content.setSecondComponent(rightPane); content.setSplitPosition(80, Unit.PERCENTAGE); setContent(content); logger.debug("UI initialized"); }
From source file:org.vaadin.addons.sitekit.flow.AbstractFlowViewlet.java
License:Apache License
@Override public final void attach() { super.attach(); final GridLayout layout = new GridLayout(1, 3); layout.setSizeFull();//from ww w . j a va 2 s . co m this.setCompositionRoot(layout); layout.setRowExpandRatio(1, 1.0f); layout.setMargin(false); layout.setSpacing(true); topLayout = new HorizontalLayout(); layout.addComponent(topLayout, 0, 0); topBackButton = new Button(getSite().localize("button-back")); topBackButton.setEnabled(false); topBackButton.addListener(this); topLayout.addComponent(topBackButton); topLayout.setExpandRatio(topBackButton, 0.0f); topPathLabel = new Label("", Label.CONTENT_XHTML); topLayout.addComponent(topPathLabel); topLayout.setComponentAlignment(topPathLabel, Alignment.MIDDLE_LEFT); topLayout.setExpandRatio(topPathLabel, 1f); topRightLayout = new HorizontalLayout(); topLayout.addComponent(topRightLayout); topLayout.setComponentAlignment(topRightLayout, Alignment.MIDDLE_RIGHT); topLayout.setExpandRatio(topRightLayout, 0.0f); topLayout.setWidth(100, Unit.PERCENTAGE); bottomLayout = new HorizontalLayout(); layout.addComponent(bottomLayout, 0, 2); bottomBackButton = new Button(getSite().localize("button-back")); bottomBackButton.setEnabled(false); bottomBackButton.addListener(this); bottomLayout.addComponent(bottomBackButton); bottomLayout.setExpandRatio(bottomBackButton, 0f); bottomPathLabel = new Label("", Label.CONTENT_XHTML); bottomLayout.addComponent(bottomPathLabel); bottomLayout.setExpandRatio(bottomPathLabel, 1f); bottomLayout.setComponentAlignment(bottomPathLabel, Alignment.MIDDLE_LEFT); bottomRightLayout = new HorizontalLayout(); bottomLayout.addComponent(bottomRightLayout); bottomLayout.setComponentAlignment(bottomRightLayout, Alignment.MIDDLE_RIGHT); bottomLayout.setExpandRatio(bottomRightLayout, 0f); bottomLayout.setWidth(100, Unit.PERCENTAGE); tabSheet = new TabSheet(); tabSheet.setStyleName("flow-sheet"); tabSheet.hideTabs(true); tabSheet.setSizeFull(); layout.addComponent(tabSheet, 0, 1); addFlowlets(); tabSheet.setSelectedTab((Component) getRootFlowlet()); }
From source file:org.vaadin.alump.fancylayouts.demo.FancyLayoutsUI.java
License:Apache License
private ComponentContainer buildLayout() { CssLayout topLayout = new CssLayout(); topLayout.setSizeFull();/*from ww w . j a v a 2s.c o m*/ TabSheet tabs = new TabSheet(); topLayout.addComponent(tabs); tabs.setSizeFull(); tabs.addTab(buildWelcome(), "Welcome"); tabs.addTab(new ImageDemo(), "FancyImage"); tabs.addTab(new PanelDemo(), "FancyPanel"); tabs.addTab(new CssLayoutDemo(), "FancyLayout"); NotificationsDemo notDemo = new NotificationsDemo(); tabs.addTab(notDemo, "FancyNotifications"); // Add notification to top most UI elements you have. Then just give it // as reference to child components. notifications = new FancyNotifications(); topLayout.addComponent(notifications); notDemo.init(notifications); return topLayout; }
From source file:org.vaadin.arborgraph.demo.DemoApplication.java
License:Open Source License
@SuppressWarnings("serial") @Override/*from w w w.j av a 2s. com*/ public void init() { VerticalLayout aboutLayout = new VerticalLayout(); aboutLayout.setSizeFull(); aboutLayout.addComponent(new Label(getBlah(), Label.CONTENT_XHTML)); final ArborGraph graph = new ArborGraph(); graph.setSizeFull(); Button exampleGraphButton = new Button("Show Example", new ClickListener() { public void buttonClick(ClickEvent event) { graph.showGraph(getDemoBranch()); } }); Label orLabel = new Label("<i>or</i>", Label.CONTENT_XHTML); orLabel.setSizeUndefined(); final TextField jsonTextfield = new TextField(); jsonTextfield.setWidth(100, Sizeable.UNITS_PERCENTAGE); jsonTextfield.setNullRepresentation(""); Button jsonBranchButton = new Button("Display Json Branch", new ClickListener() { public void buttonClick(ClickEvent event) { graph.showGraph(jsonTextfield.getValue().toString()); } }); Label helpLabel = getHelpLabel(getBranchExplanation()); HorizontalLayout graphButtonLayout = new HorizontalLayout(); graphButtonLayout.setWidth(100, Sizeable.UNITS_PERCENTAGE); graphButtonLayout.setSpacing(true); graphButtonLayout.setMargin(false, false, true, false); graphButtonLayout.addComponent(exampleGraphButton); graphButtonLayout.addComponent(orLabel); graphButtonLayout.setComponentAlignment(orLabel, Alignment.MIDDLE_CENTER); graphButtonLayout.addComponent(jsonBranchButton); graphButtonLayout.addComponent(helpLabel); graphButtonLayout.setComponentAlignment(helpLabel, Alignment.MIDDLE_CENTER); graphButtonLayout.addComponent(jsonTextfield); graphButtonLayout.setExpandRatio(jsonTextfield, .9f); VerticalLayout graphLayout = new VerticalLayout(); graphLayout.setSizeFull(); graphLayout.setMargin(true, false, false, false); graphLayout.setSpacing(true); graphLayout.addComponent(graphButtonLayout); graphLayout.addComponent(graph); graphLayout.setExpandRatio(graph, .9f); TabSheet tabSheet = new TabSheet(); tabSheet.setStyleName(Reindeer.TABSHEET_MINIMAL); tabSheet.setSizeFull(); tabSheet.addTab(aboutLayout, "About"); tabSheet.addTab(graphLayout, "Graph"); VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); mainLayout.setMargin(true); mainLayout.addComponent(tabSheet); mainLayout.setExpandRatio(tabSheet, .9f); Window mainWindow = new Window("Arbor-Vaadin"); mainWindow.setSizeFull(); mainWindow.setContent(mainLayout); setTheme("arbor"); setMainWindow(mainWindow); }
From source file:org.vaadin.chronographer.demo.TimelineUI.java
License:Apache License
private void createTabSheet() { tabsheet = new TabSheet(); tabsheet.setId("timeline-tabsheet"); tabsheet.addTab(new SimpleTimelineExample(), "Simple example"); tabsheet.addTab(new MultipleTimelinesExample(), "Multiple timelines"); tabsheet.addTab(new ComplexTimeLineExample(), "Complex example"); }