Example usage for com.vaadin.ui TabSheet addTab

List of usage examples for com.vaadin.ui TabSheet addTab

Introduction

In this page you can find the example usage for com.vaadin.ui TabSheet addTab.

Prototype

public Tab addTab(Component component, int position) 

Source Link

Document

Adds a new tab into TabSheet.

Usage

From source file:org.ow2.sirocco.cloudmanager.SecurityGroupDetailView.java

License:Open Source License

public SecurityGroupDetailView(final SecurityGroupView securityGroupView) {
    this.securityGroupView = securityGroupView;
    this.setSizeFull();
    this.setSpacing(true);
    this.setMargin(true);
    this.addStyleName("detailmargins");
    this.setVisible(false);
    this.title = new Label();
    this.title.setStyleName("detailTitle");
    this.addComponent(this.title);
    TabSheet tabSheet = new TabSheet();
    tabSheet.setSizeFull();/*from www. j  av  a 2  s  .  c  om*/

    VerticalLayout attributeTab = new VerticalLayout();
    attributeTab.setSizeFull();
    this.attributeTable = new Table();
    attributeTab.addComponent(this.attributeTable);
    this.attributeTable.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    this.attributeTable.setSizeFull();
    this.attributeTable.setPageLength(0);
    this.attributeTable.setSelectable(false);
    this.attributeTable.addContainerProperty("attribute", String.class, null);
    this.attributeTable.addContainerProperty("value", String.class, null);
    this.attributeTable.addContainerProperty("edit", Button.class, null);
    this.attributeTable.setColumnWidth("edit", 400);

    tabSheet.addTab(attributeTab, "Attributes");

    this.ruleView = new SecurityGroupRuleView();
    tabSheet.addTab(this.ruleView, "Rules");
    this.addComponent(tabSheet);
    this.setExpandRatio(tabSheet, 1.0f);
}

From source file:org.semanticsoft.vaaclipse.presentation.renderers.StackRenderer.java

License:Open Source License

private void addTab(TabSheet parentPane, MStackElement element, int pos) {
    MUILabel mLabel;//  w w  w  . ja  v  a2 s.  co  m
    if (element instanceof MPlaceholder)
        mLabel = (MUILabel) ((MPlaceholder) element).getRef();
    else
        mLabel = (MUILabel) element;

    boolean closable = false;
    if (mLabel instanceof MPart)
        closable = ((MPart) mLabel).isCloseable();

    Resource icon = mLabel.getIconURI() != null ? ResourceHelper.createResource(mLabel.getIconURI()) : null;
    //Tab tab = parentPane.addTab((com.vaadin.ui.Component) element.getWidget(), mLabel.getLocalizedLabel(), icon, pos);
    Tab tab = parentPane.addTab((com.vaadin.ui.Component) element.getWidget(), pos);
    tab.setCaption(mLabel.getLocalizedLabel());
    tab.setIcon(icon);
    tab.setClosable(closable);
    tab.setDescription(mLabel.getLocalizedTooltip());

    vaatab2Element.put((Component) element.getWidget(), element);
}

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  ww w.  j a  v a 2 s  .  com
    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.vaadin.addon.borderlayout.BorderlayoutUI.java

@Override
protected void init(VaadinRequest request) {
    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();/*from  ww  w  .  j a  v a2  s .  c  o  m*/
    setContent(tabs);

    tabs.addTab(getSimpleExamle(), "Basic functionality");
    tabs.addTab(getAnotherExample(), "Sequential add");
}

From source file:org.vaadin.alump.fancylayouts.demo.FancyLayoutsUI.java

License:Apache License

private ComponentContainer buildLayout() {

    CssLayout topLayout = new CssLayout();
    topLayout.setSizeFull();/*from  w w w . jav  a 2  s . 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   ww w.j  a  v  a 2s  .c o m
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:pl.exsio.frameset.vaadin.module.management.frames.FrameDetails.java

License:Open Source License

private VerticalLayout getFrameForm(EntityItem<VaadinFrame> item) {

    VerticalLayout formWrapper = new VerticalLayout();
    formWrapper.addComponent(/* w  w w.java2 s .com*/
            new Label(t("core.management.frames.edition.title") + ": " + t(item.getEntity().getTitle())));
    TabSheet tabs = new TabSheet();

    final BasicFrameDataForm basicData = new BasicFrameDataForm(item);
    final SecurityPermissionsForm permissions = this.createSecurityPermissionsForm(item);
    if (this.security.canWrite()) {
        tabs.addTab(new VerticalLayout() {
            {
                addComponent(basicData.init());
                setMargin(true);
            }
        }, t("core.management.frames.tab.basic_data"));
    }
    if (this.security.canAdminister()) {
        tabs.addTab(new VerticalLayout() {
            {
                addComponent(permissions.init());
                setMargin(true);
            }
        }, t("core.management.frames.tab.security"));
    }
    formWrapper.addComponent(tabs);
    formWrapper.setSpacing(true);
    return formWrapper;

}

From source file:pl.exsio.plupload.examples.ui.PluploadExamplesUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {

    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);// ww  w .  ja v a  2 s  . co m
    mainLayout.setMargin(true);
    this.setSizeFull();

    TabSheet container = new TabSheet();
    container.addTab(new Home(), "Home");
    container.addTab(new SimpleUploaderExample(), "Simple \"Plupload\"");
    container.addTab(new AdvancedUploaderExample(), "Advanced \"Plupload\"");
    container.addTab(new SimpleUploadManagerExample(), "Simple \"PluploadManager\"");
    container.addTab(new UploadManagerWithFileFilterExample(),
            "\"PluploadManager\" with file filter and drop zone");
    container.addTab(new UploadManagerWithImageResizeExample(), "\"PluploadManager\" with image resize");
    container.addTab(new FileUploaderFieldExample(), "\"PluploadField\" with File value");
    container.addTab(new ValidationByteArrayUploaderFieldExample(),
            "\"PluploadField\" with byte[] value and form validation");

    mainLayout.addComponent(container);
    container.setSizeFull();
    mainLayout.setSizeFull();

    this.setContent(mainLayout);

}

From source file:ru.codeinside.adm.ui.AdminApp.java

License:Mozilla Public License

@Override
public void init() {
    setUser(Flash.login());/*w w  w  . j a va  2 s .  co m*/
    setTheme("custom");

    TabSheet t = new TabSheet();
    t.addStyleName(Reindeer.TABSHEET_MINIMAL);
    t.setSizeFull();
    t.setCloseHandler(new DelegateCloseHandler());
    UserInfoPanel.addClosableToTabSheet(t, getUser().toString());
    TreeTableOrganization treeTableOrganization = new TreeTableOrganization();
    CrudNews showNews = new CrudNews();
    table = treeTableOrganization.getTreeTable();
    Tab orgsTab = t.addTab(treeTableOrganization, "");
    t.setSelectedTab(orgsTab);
    t.addTab(new GroupTab(), "");

    GwsSystemTab systemTab = new GwsSystemTab();
    t.addTab(systemTab, " ??");
    t.addListener(systemTab);

    GwsLazyTab gwsLazyTab = new GwsLazyTab();
    t.addTab(gwsLazyTab, "?  ??");
    t.addListener(gwsLazyTab);

    t.addTab(createEmployeeWidget(), "");
    RefreshableTab settings = createSettings();
    t.addTab(settings, "??");
    t.addListener(settings);

    Component businessCalendar = createBusinessCalendar();
    t.addTab(businessCalendar, "? ");

    LogTab logTab = new LogTab();
    t.addListener(logTab);
    t.addTab(logTab, "");
    t.addTab(showNews, "??");
    t.addTab(registryTab(), "?");
    setMainWindow(new Window(
            getUser() + " |  | -" + Activator.getContext().getBundle().getVersion(),
            t));
    AdminServiceProvider.get().createLog(Flash.getActor(), "Admin application", (String) getUser(), "login",
            null, true);
}

From source file:ru.codeinside.adm.ui.AdminApp.java

License:Mozilla Public License

private Component createEmployeeWidget() {
    final TabSheet tabSheet = new TabSheet();
    tabSheet.addStyleName(Reindeer.TABSHEET_MINIMAL);
    tabSheet.setSizeFull();/*from w  w  w  .ja  v  a 2 s .  co  m*/
    tabSheet.addTab(new EmployeeWidget(false, table), "?");
    tabSheet.addTab(new EmployeeWidget(true, table), "");
    tabSheet.addListener(new TabSheet.SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
            EmployeeWidget currentTab = (EmployeeWidget) tabSheet.getSelectedTab();
            currentTab.refreshList();
        }
    });
    return tabSheet;
}