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 c) 

Source Link

Document

Adds a new tab into TabSheet.

Usage

From source file:at.meikel.nentis.Nentis.java

License:Apache License

private void initInfo(TabSheet tabSheet) {
    VerticalLayout infoTab = new VerticalLayout();
    tabSheet.addTab(infoTab);
    tabSheet.getTab(infoTab).setCaption("Info");
    infoTab.addComponent(new Label("temp.dir:" + System.getProperty("temp.dir")));
}

From source file:at.meikel.nentis.Nentis.java

License:Apache License

private void initMain(TabSheet tabSheet) {
    final VerticalLayout mainTab = new VerticalLayout();
    tabSheet.addTab(mainTab);
    tabSheet.getTab(mainTab).setCaption("Main");

    final HorizontalLayout buttons = new HorizontalLayout();
    mainTab.addComponent(buttons);/*from  w w  w  .j  ava  2s  . c  o m*/

    final VerticalLayout state = new VerticalLayout();
    mainTab.addComponent(state);

    final VerticalLayout info = new VerticalLayout();
    mainTab.addComponent(info);

    Button createTicket = new Button("Create a new ticket");
    createTicket.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent clickEvent) {
            state.removeAllComponents();
            Ticket ticket = nentisApi.createTicket("Ticket (" + new Date() + ")");
            state.addComponent(
                    new Label("Ticket #" + ticket.getId() + " [" + ticket.getDescription() + "] created."));
        }
    });
    buttons.addComponent(createTicket);

    Button listAllTickets = new Button("List all existing tickets");
    listAllTickets.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent clickEvent) {
            state.removeAllComponents();
            List<Ticket> allTickets = nentisApi.getAllTickets();
            info.removeAllComponents();
            if (allTickets != null) {
                for (Ticket ticket : allTickets) {
                    info.addComponent(new Label(
                            "Ticket #" + ticket.getId() + " [" + ticket.getDescription() + "] created."));
                }
            }
        }
    });
    buttons.addComponent(listAllTickets);

    final Button openSubWindow = new Button("Open a sub window");
    openSubWindow.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent clickEvent) {
            buttons.removeComponent(openSubWindow);
            Window subWindow = new Window("Sub window");
            mainWindow.addWindow(subWindow);
        }
    });
    buttons.addComponent(openSubWindow);
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.pagemode.AbstractPageModContentFactoryImpl.java

License:Apache License

/**
 * Creates the page visit history.//from  w w  w .  j av a 2s. c  om
 *
 * @param pageName
 *            the page name
 * @param pageId
 *            the page id
 * @param panelContent
 *            the panel content
 */
protected final void createPageVisitHistory(final String pageName, final String pageId,
        final VerticalLayout panelContent) {

    final TabSheet tabsheet = new TabSheet();
    tabsheet.setWidth(100, Unit.PERCENTAGE);
    tabsheet.setHeight(100, Unit.PERCENTAGE);

    panelContent.addComponent(tabsheet);
    panelContent.setExpandRatio(tabsheet, ContentRatio.LARGE);

    final HorizontalLayout tabContentPageItemRankHistory = new HorizontalLayout();
    tabContentPageItemRankHistory.setWidth(100, Unit.PERCENTAGE);
    tabContentPageItemRankHistory.setHeight(100, Unit.PERCENTAGE);
    final Tab tabPageItemRankHistory = tabsheet.addTab(tabContentPageItemRankHistory);

    tabPageItemRankHistory.setCaption(CURRENT_PAGE_VISIT_HISTORY);
    adminChartDataManager.createApplicationActionEventPageElementDailySummaryChart(
            tabContentPageItemRankHistory, pageName, pageId);

    final HorizontalLayout tabContentPageModeSummary = new HorizontalLayout();
    tabContentPageModeSummary.setWidth(100, Unit.PERCENTAGE);
    tabContentPageModeSummary.setHeight(100, Unit.PERCENTAGE);
    final Tab tabPageModeSummary = tabsheet.addTab(tabContentPageModeSummary);
    tabPageModeSummary.setCaption(GENERAL_PAGE_MODE_PAGE_VISIT);

    adminChartDataManager.createApplicationActionEventPageModeDailySummaryChart(tabContentPageModeSummary,
            pageName);

}

From source file:com.hack23.cia.web.impl.ui.application.views.user.ballot.pagemode.BallotChartsPageModContentFactoryImpl.java

License:Apache License

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override/*  ww  w  .j a  v a2s .  c  o  m*/
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();

    final String pageId = getPageId(parameters);

    final DataContainer<ViewRiksdagenVoteDataBallotSummary, RiksdagenVoteDataBallotEmbeddedId> dataContainer = getApplicationManager()
            .getDataContainer(ViewRiksdagenVoteDataBallotSummary.class);

    final DataContainer<ViewRiksdagenVoteDataBallotPartySummary, RiksdagenVoteDataBallotPartyEmbeddedId> dataPartyContainer = getApplicationManager()
            .getDataContainer(ViewRiksdagenVoteDataBallotPartySummary.class);

    final List<ViewRiksdagenVoteDataBallotSummary> ballots = dataContainer.findListByEmbeddedProperty(
            ViewRiksdagenVoteDataBallotSummary.class, ViewRiksdagenVoteDataBallotSummary_.embeddedId,
            RiksdagenVoteDataBallotEmbeddedId.class, RiksdagenVoteDataBallotEmbeddedId_.ballotId, pageId);

    final List<ViewRiksdagenVoteDataBallotPartySummary> partyBallotList = dataPartyContainer
            .findListByEmbeddedProperty(ViewRiksdagenVoteDataBallotPartySummary.class,
                    ViewRiksdagenVoteDataBallotPartySummary_.embeddedId,
                    RiksdagenVoteDataBallotPartyEmbeddedId.class,
                    RiksdagenVoteDataBallotPartyEmbeddedId_.ballotId, pageId);

    if (!ballots.isEmpty()) {
        getBallotMenuItemFactory().createBallotMenuBar(menuBar, pageId);

        LabelFactory.createHeader2Label(panelContent, CHARTS);

        final TabSheet tabsheet = new TabSheet();
        tabsheet.setWidth(100, Unit.PERCENTAGE);
        tabsheet.setHeight(100, Unit.PERCENTAGE);

        panelContent.addComponent(tabsheet);
        panelContent.setExpandRatio(tabsheet, ContentRatio.LARGE);

        Collections.sort(ballots,
                (Comparator<ViewRiksdagenVoteDataBallotSummary>) (o1,
                        o2) -> (o1.getEmbeddedId().getIssue() + o2.getEmbeddedId().getConcern())
                                .compareTo(o1.getEmbeddedId().getIssue() + o2.getEmbeddedId().getConcern()));

        for (final ViewRiksdagenVoteDataBallotSummary viewRiksdagenVoteDataBallotSummary : ballots) {
            final HorizontalLayout tabContent = new HorizontalLayout();
            tabContent.setWidth(100, Unit.PERCENTAGE);
            tabContent.setHeight(100, Unit.PERCENTAGE);
            final Tab tab = tabsheet.addTab(tabContent);

            ballotChartDataManager.createChart(tab, tabContent, viewRiksdagenVoteDataBallotSummary);
        }

        final Map<String, List<ViewRiksdagenVoteDataBallotPartySummary>> concernIssuePartyBallotSummaryMap = createIssueConcernMap(
                partyBallotList);

        for (final List<ViewRiksdagenVoteDataBallotPartySummary> partyBallotSummaryList : concernIssuePartyBallotSummaryMap
                .values()) {
            final HorizontalLayout tabContent = new HorizontalLayout();
            tabContent.setWidth(100, Unit.PERCENTAGE);
            tabContent.setHeight(100, Unit.PERCENTAGE);
            final Tab tab = tabsheet.addTab(tabContent);

            ballotChartDataManager.createChart(tab, tabContent, partyBallotSummaryList);
        }

        panel.setCaption(BALLOT + pageId);
        getPageActionEventHelper().createPageEvent(ViewAction.VISIT_BALLOT_VIEW, ApplicationEventGroup.USER,
                NAME, parameters, pageId);
    }
    return panelContent;

}

From source file:com.morevaadin.vaadin7.html.HtmlIntegrationRoot.java

License:Apache License

@Override
protected void init(WrappedRequest request) {

    getPage().setTitle("HTML JavaScript integration examples");

    HorizontalLayout layout = new HorizontalLayout();

    layout.setSizeFull();/*from  www .  j a  v  a2  s.  c o m*/

    setContent(layout);

    TabSheet tabsheet = new TabSheet();

    layout.addComponent(tabsheet);

    tabsheet.addTab(new BasicHtmlIntegrationView()).setCaption("Basic HTML");
    tabsheet.addTab(new ConfigurableHtmlIntegrationView()).setCaption("Configurable HTML");
    tabsheet.addTab(new JavascriptIntegrationView()).setCaption("Javascript");
}

From source file:com.toptal.ui.view.MainView.java

License:Open Source License

/**
 * Ctor./*from w  w  w  . j  a  v  a  2s .c  o m*/
 * @param vui Vaadin UI entry point.
 */
public MainView(final VaadinUI vui) {
    super(vui);
    final TabSheet tabsheet = new TabSheet();
    this.entries = new EntryTab(this, "Entries").build();
    tabsheet.addTab(this.entries);
    this.weeks = new WeekTab(this, "Statistics").build();
    tabsheet.addTab(this.weeks);
    if (SecurityUtils.actualUser().isManager()) {
        this.users = Optional.of(new UserTab(this, "Users").build());
        tabsheet.addTab(this.users.get());
    } else {
        this.users = Optional.empty();
    }
    this.addComponent(this.header());
    this.addComponent(tabsheet);
}

From source file:com.trivago.mail.pigeon.web.components.mail.ActionButtonColumnGenerator.java

License:Apache License

@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
    HorizontalLayout hl = new HorizontalLayout();
    Button showNlConentButton = new Button();
    showNlConentButton.setDescription("View");
    showNlConentButton.setImmediate(true);
    showNlConentButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));

    showNlConentButton.addListener(new Button.ClickListener() {
        @Override//w  w w .  ja  v  a 2  s  .com
        public void buttonClick(Button.ClickEvent event) {
            Mail m = new Mail((Long) itemId);
            Window nlConentView = new Window("Newsletter Contents of ID " + itemId);
            // Create an empty tab sheet.
            TabSheet tabsheet = new TabSheet();

            Panel pText = new Panel("Text Content");
            Panel pHtml = new Panel("Text Content");
            RichTextArea textArea = new RichTextArea();
            textArea.setValue(m.getText());
            textArea.setReadOnly(true);

            RichTextArea richTextArea = new RichTextArea();
            richTextArea.setValue(m.getHtml());
            richTextArea.setReadOnly(true);

            pText.addComponent(textArea);
            pHtml.addComponent(richTextArea);

            richTextArea.setHeight("50%");
            richTextArea.setWidth("100%");
            textArea.setHeight("50%");
            textArea.setWidth("100%");

            nlConentView.setResizable(true);
            nlConentView.setWidth("800px");
            nlConentView.setHeight("600px");

            tabsheet.addTab(pText);
            tabsheet.getTab(pText).setCaption("Text Version");
            tabsheet.addTab(pHtml);
            tabsheet.getTab(pHtml).setCaption("Html Version");

            nlConentView.addComponent(tabsheet);
            source.getWindow().addWindow(nlConentView);
            nlConentView.setVisible(true);
        }
    });

    final Button showOpenendMails = new Button();
    showOpenendMails.setDescription("Show recipients of this mailling");
    showOpenendMails.setIcon(new ThemeResource("../runo/icons/16/users.png"));
    showOpenendMails.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Mail m = new Mail((Long) itemId);
            ModalRecipientListByMail modalRecipientListByMail = new ModalRecipientListByMail(m);
            source.getWindow().addWindow(modalRecipientListByMail);
            modalRecipientListByMail.setVisible(true);

        }
    });

    hl.addComponent(showNlConentButton);
    hl.addComponent(showOpenendMails);
    return hl;
}

From source file:com.trivago.mail.pigeon.web.components.recipients.ModalRecipientListByMail.java

License:Apache License

public ModalRecipientListByMail(Mail mail) {
    super("Recipient List for mailing " + mail.getSubject());
    setModal(true);//from w w  w  .  j a v a  2s  . com
    setWidth("900px");

    TabSheet tabsheet = new TabSheet();

    RecipientByMailList rl = new RecipientByMailList(mail);
    tabsheet.addTab(rl).setCaption("Recipient List");

    MailOpenChart chart = new MailOpenChart(mail);
    tabsheet.addTab(chart).setCaption("Statistics");

    addComponent(tabsheet);
}

From source file:com.trivago.mail.pigeon.web.components.templates.ModalAddTemplate.java

License:Apache License

public ModalAddTemplate(final TemplateList tl, final Long templateId) {
    setResizable(true);/*w ww  . j  a  v a 2s  .c  om*/
    setWidth("972px");
    setHeight("700px");
    Panel rootPanel = new Panel("Add new Template");
    TabSheet tSheet = new TabSheet();
    HorizontalLayout hLayout = new HorizontalLayout();

    final TextField title = new TextField("Template description");
    final TextField subject = new TextField("Newsletter Subject");

    final TextArea textContent = new TextArea("Text Version");
    textContent.setRows(40);
    textContent.setColumns(100);

    final CKEditorTextField htmlContent = new CKEditorTextField();
    htmlContent.setWidth("100%");
    htmlContent.setHeight("650px");

    // Load the content, if we receive a template id
    if (templateId != null) {
        MailTemplate mt = new MailTemplate(templateId);
        title.setValue(mt.getTitle());
        subject.setValue(mt.getSubject());
        textContent.setValue(mt.getText());
        htmlContent.setValue(mt.getHtml());
    }

    Button saveButton = new Button("Save");
    Button cancel = new Button("Cancel");

    saveButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean hasError = false;
            if (title.getValue().equals("")) {
                title.setComponentError(new UserError("Name must not be empty"));
                hasError = true;
            } else {
                title.setComponentError(null);
            }

            if (subject.getValue().equals("")) {
                subject.setComponentError(new UserError("Subject must not be empty"));
                hasError = true;
            } else {
                subject.setComponentError(null);
            }

            if (htmlContent.getValue().equals("")) {
                htmlContent.setComponentError(new UserError("Please provide some HTML content"));
                hasError = true;
            } else {
                htmlContent.setComponentError(null);
            }

            if (textContent.getValue().equals("")) {
                textContent.setComponentError(new UserError("Please provide some text content"));
                hasError = true;
            } else {
                textContent.setComponentError(null);
            }

            if (!hasError) {
                if (templateId == null) {
                    long templateId = Util.generateId();
                    try {
                        MailTemplate mt = new MailTemplate(templateId, title.getValue().toString(),
                                textContent.getValue().toString(), htmlContent.getValue().toString(),
                                subject.getValue().toString());
                        event.getButton().getWindow().setVisible(false);
                        event.getButton().getWindow().getParent()
                                .removeComponent(event.getButton().getWindow());
                        event.getButton().getWindow().getParent().showNotification("Saved successfully",
                                Notification.TYPE_HUMANIZED_MESSAGE);
                        tl.getBeanContainer().addItem(mt.getId(), mt);
                    } catch (RuntimeException e) {
                        // Should never happen ... hopefully :D
                    }
                } else {
                    MailTemplate mt = new MailTemplate(templateId);

                    mt.setHtml(htmlContent.getValue().toString());
                    mt.setSubject(subject.getValue().toString());
                    mt.setText(textContent.getValue().toString());
                    mt.setTitle(title.getValue().toString());

                    event.getButton().getWindow().setVisible(false);
                    event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow());
                    event.getButton().getWindow().getParent().showNotification("Saved successfully",
                            Notification.TYPE_HUMANIZED_MESSAGE);

                    final int beanIndex = tl.getBeanContainer().indexOfId(mt.getId());
                    tl.getBeanContainer().removeItem(mt.getId());
                    tl.getBeanContainer().addItemAt(beanIndex, mt.getId(), mt);
                }
                TemplateSelectBox.reloadSelect();
            }
        }
    });

    hLayout.addComponent(saveButton);
    hLayout.addComponent(cancel);
    hLayout.setSpacing(true);

    VerticalLayout metaDataLayout = new VerticalLayout();

    Panel textFieldPanel = new Panel("Meta Data");
    VerticalLayout metaLayout = new VerticalLayout();
    metaLayout.addComponent(title);
    metaLayout.addComponent(subject);
    textFieldPanel.addComponent(metaLayout);

    Panel helpPanel = new Panel("Template Documentation");
    assembleHelpComponents(helpPanel);

    metaDataLayout.addComponent(textFieldPanel);
    metaDataLayout.addComponent(helpPanel);

    tSheet.addTab(metaDataLayout).setCaption("Meta Data");

    VerticalLayout textLayout = new VerticalLayout();
    textLayout.addComponent(textContent);
    tSheet.addTab(textLayout).setCaption("Text Content");

    VerticalLayout htmlLayout = new VerticalLayout();
    htmlLayout.addComponent(htmlContent);
    tSheet.addTab(htmlLayout).setCaption("HTML Content");

    rootPanel.addComponent(tSheet);
    rootPanel.addComponent(hLayout);
    addComponent(rootPanel);
}

From source file:com.zklogtool.web.components.OpenSnapshotFileDialog.java

License:Apache License

public OpenSnapshotFileDialog(final TabSheet displayTabSheet, final Window windowHandle) {

    buildMainLayout();/*w w w . ja v a  2  s. c o m*/
    setCompositionRoot(mainLayout);

    openButton.addClickListener(new ClickListener() {

        DataState dataState;

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {

            File snapshot = new File(snapshotFileLabel.getValue());

            SnapshotFileReader snapReader = new SnapshotFileReader(snapshot, 0);

            SnapshotView snapshotView;

            if (!validateInputs()) {
                return;
            }

            try {

                dataState = snapReader.readFuzzySnapshot();

                snapshotView = new SnapshotView(dataState);

            } catch (CRCValidationException e) {

                snapshotFileLabel
                        .setComponentError(new UserError("CRC validation problem. File is probably corrupted"));
                return;

            } catch (IOException e) {

                snapshotFileLabel.setComponentError(new UserError("IO problem with file"));
                return;

            }

            HorizontalLayout horizontalLayout = new HorizontalLayout();
            horizontalLayout.setCaption(tabNameLabel.getValue());
            horizontalLayout.addComponent(snapshotView);
            horizontalLayout.setWidth("100%");
            horizontalLayout.setHeight("100%");
            Tab snapshotTab = displayTabSheet.addTab(horizontalLayout);
            snapshotTab.setClosable(true);
            displayTabSheet.setSelectedTab(snapshotTab);

            windowHandle.close();

        }

    });

}