Example usage for com.vaadin.ui Label setContentMode

List of usage examples for com.vaadin.ui Label setContentMode

Introduction

In this page you can find the example usage for com.vaadin.ui Label setContentMode.

Prototype

public void setContentMode(ContentMode contentMode) 

Source Link

Document

Sets the content mode of the label.

Usage

From source file:org.sensorhub.ui.StorageAdminPanel.java

License:Mozilla Public License

protected void buildDataPanel(GridLayout form, IRecordStorageModule<?> storage) {
    // measurement outputs
    int i = 1;//from www  . j a  v a  2s. c  o  m
    if (storage.isEnabled()) {
        for (IRecordStoreInfo dsInfo : storage.getRecordStores().values()) {
            Panel panel = newPanel("Stream #" + i++);
            GridLayout panelLayout = ((GridLayout) panel.getContent());
            panelLayout.setSpacing(true);

            // stored time period
            double[] timeRange = storage.getRecordsTimeRange(dsInfo.getName());
            Label l = new Label("<b>Time Range:</b> " + new DateTimeFormat().formatIso(timeRange[0], 0) + " / "
                    + new DateTimeFormat().formatIso(timeRange[1], 0));
            l.setContentMode(ContentMode.HTML);
            panelLayout.addComponent(l, 0, 0, 1, 0);

            // time line
            panelLayout.addComponent(buildGantt(storage, dsInfo), 0, 1, 1, 1);

            // data structure
            DataComponent dataStruct = dsInfo.getRecordDescription();
            Component sweForm = new SWECommonForm(dataStruct);
            panelLayout.addComponent(sweForm);

            // data table
            panelLayout.addComponent(buildTable(storage, dsInfo));

            if (oldPanel != null)
                form.replaceComponent(oldPanel, panel);
            else
                form.addComponent(panel);
            oldPanel = panel;
        }
    }
}

From source file:org.sensorhub.ui.SWECommonForm.java

License:Mozilla Public License

protected Component buildWidget(DataComponent dataComponent, boolean showValues) {
    if (dataComponent instanceof DataRecord || dataComponent instanceof Vector) {
        VerticalLayout layout = new VerticalLayout();

        Label l = new Label();
        l.setContentMode(ContentMode.HTML);
        l.setValue(getCaption(dataComponent, false));
        l.setDescription(getTooltip(dataComponent));
        layout.addComponent(l);// www  .  j a v  a  2s.  c om

        VerticalLayout form = new VerticalLayout();
        form.setMargin(new MarginInfo(false, false, false, true));
        form.setSpacing(false);
        for (int i = 0; i < dataComponent.getComponentCount(); i++) {
            DataComponent c = dataComponent.getComponent(i);
            Component w = buildWidget(c, showValues);
            if (w != null)
                form.addComponent(w);
        }
        layout.addComponent(form);

        return layout;
    }

    else if (dataComponent instanceof DataArray) {
        DataArray dataArray = (DataArray) dataComponent;
        VerticalLayout layout = new VerticalLayout();

        Label l = new Label();
        l.setContentMode(ContentMode.HTML);
        l.setValue(getCaption(dataComponent, false));
        l.setDescription(getTooltip(dataComponent));
        layout.addComponent(l);

        VerticalLayout form = new VerticalLayout();
        form.setMargin(new MarginInfo(false, false, false, true));
        form.setSpacing(false);
        form.addComponent(buildWidget(dataArray.getElementType(), false));
        layout.addComponent(form);

        return layout;
    }

    else if (dataComponent instanceof DataChoice) {
        DataChoice dataChoice = (DataChoice) dataComponent;
        VerticalLayout layout = new VerticalLayout();

        Label l = new Label();
        l.setContentMode(ContentMode.HTML);
        l.setValue(getCaption(dataChoice, false));
        l.setDescription(getTooltip(dataChoice));
        layout.addComponent(l);

        return layout;
    }

    else if (dataComponent instanceof SimpleComponent) {
        Label l = new Label();
        l.setContentMode(ContentMode.HTML);
        l.setValue(getCaption(dataComponent, showValues));
        l.setDescription(getTooltip(dataComponent));
        return l;
    }

    return null;
}

From source file:org.vaadin.alump.ckeditor.demo.VaadinCKEditorUI.java

License:LGPL

private Component createSeparator() {
    Label separator = new Label("&nbsp;");
    separator.addStyleName("separator");
    separator.setContentMode(ContentMode.HTML);
    return separator;
}

From source file:org.vaadin.openesignforms.ckeditor.VaadinCKEditorUI.java

License:Open Source License

@Override
public void init(VaadinRequest request) {

    getPage().setTitle("Vaadin7 CKEditor UI");

    VerticalLayout mainView = new VerticalLayout();
    setContent(mainView);// w w w  . ja va  2s .com

    mainView.addComponent(new Button("Hit server"));

    Label separator = new Label("&nbsp;");
    separator.setContentMode(ContentMode.HTML);
    mainView.addComponent(separator);

    /* See http://ckeditor.com/latest/samples/plugins/toolbar/toolbar.html for the official info.
     * This is the full list as we know it in CKEditor 4.x
    [
    { name: 'document', items : [ 'Source','-','NewPage','Preview','Print','-','Templates' ] },
    { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
    { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
    { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
    '/',
    { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
    { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
    { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
    { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
    '/',
    { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
    { name: 'colors', items : [ 'TextColor','BGColor' ] },
    { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
    ]
     */

    final String editor1InitialValue = "<p>Thanks TinyMCEEditor for getting us started on the CKEditor integration.</p>\n\n<h1>Like TinyMCEEditor said, &quot;Vaadin rocks!&quot;</h1>\n\n<h1>And CKEditor is no slouch either.</h1>\n";

    CKEditorConfig config1 = new CKEditorConfig();
    config1.useCompactTags();
    config1.disableElementsPath();
    config1.setResizeDir(CKEditorConfig.RESIZE_DIR.HORIZONTAL);
    config1.disableSpellChecker();
    config1.setHeight("300px");

    final CKEditorTextField ckEditorTextField1 = new CKEditorTextField(config1);
    ckEditorTextField1.setHeight("440px"); // account for 300px editor plus toolbars
    mainView.addComponent(ckEditorTextField1);

    ckEditorTextField1.setValue(editor1InitialValue);
    ckEditorTextField1.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -761434593559159149L;

        public void valueChange(ValueChangeEvent event) {
            Notification.show("CKEditor v" + ckEditorTextField1.getVersion() + "/" + getVersion()
                    + " - #1 contents: " + event.getProperty().getValue().toString());
        }
    });
    // This selection change listener is commented out for general use, but it does appear to work in preliminary testing as of 
    // version 7.10.2 (15 July 2015) if you need it.
    /*
    ckEditorTextField1.addSelectionChangeListener(new SelectionChangeListener() {
       private static final long serialVersionUID = 1270295222444271706L;
            
       public void selectionChange(SelectionChangeEvent event) {
    if ( event.hasSelectedHtml() ) {
       Notification.show("CKEditor selected HTML: " + event.getSelectedHtml(), Type.ERROR_MESSAGE);
       ckEditorTextField1.focus();
    } else {
       Notification.show("CKEditor un-select reported", Type.ERROR_MESSAGE);
    }
       }
    });
    */

    Button resetTextButton1 = new Button("Reset editor #1");
    resetTextButton1.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 2872667648717255301L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (!ckEditorTextField1.isReadOnly()) {
                ckEditorTextField1.setValue(editor1InitialValue);
            }
        }
    });

    Button toggleReadOnlyButton1 = new Button("Toggle read-only editor #1");
    toggleReadOnlyButton1.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 8462908141468254844L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField1.setReadOnly(!ckEditorTextField1.isReadOnly());
        }
    });

    Button toggleViewWithoutEditorButton1 = new Button("Toggle view-without-editor #1");
    toggleViewWithoutEditorButton1.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 8122286299515325693L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField1.setViewWithoutEditor(!ckEditorTextField1.isViewWithoutEditor());
        }
    });

    Button toggleVisibleButton1 = new Button("Toggle visible editor #1");
    toggleVisibleButton1.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = -6715135605688427318L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField1.setVisible(!ckEditorTextField1.isVisible());
        }
    });
    HorizontalLayout buttonsLayout = new HorizontalLayout(resetTextButton1, toggleReadOnlyButton1,
            toggleViewWithoutEditorButton1, toggleVisibleButton1);
    buttonsLayout.setSpacing(true);
    mainView.addComponent(buttonsLayout);

    separator = new Label("&nbsp;");
    separator.setContentMode(ContentMode.HTML);
    mainView.addComponent(separator);

    // Now add in a second editor....
    final String editor2InitialValue = "<p>Here is editor #2.</p>\n\n<p>Hope you find this useful in your Vaadin projects.</p>\n";

    final CKEditorTextField ckEditorTextField2 = new CKEditorTextField();
    ckEditorTextField2.setWidth("600px");
    mainView.addComponent(ckEditorTextField2);

    CKEditorConfig config2 = new CKEditorConfig();
    config2.addCustomToolbarLine(
            "{ items : ['Source','Styles','Bold','VaadinSave','-','Undo','Redo','-','NumberedList','BulletedList'] }");
    config2.enableCtrlSWithVaadinSavePlugin();
    config2.addToRemovePlugins("scayt");
    ckEditorTextField2.setConfig(config2);
    ckEditorTextField2.setValue(editor2InitialValue);

    ckEditorTextField2.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1522230917891035997L;

        public void valueChange(ValueChangeEvent event) {
            Notification.show("CKEditor v" + ckEditorTextField2.getVersion() + "/" + getVersion()
                    + " - #2 contents: " + event.getProperty().getValue().toString());
        }
    });

    ckEditorTextField2.addVaadinSaveListener(new CKEditorTextField.VaadinSaveListener() {
        private static final long serialVersionUID = 3763779235559050613L;

        @Override
        public void vaadinSave(CKEditorTextField editor) {
            Notification.show("CKEditor v" + ckEditorTextField2.getVersion() + "/" + getVersion()
                    + " - #2 VaadinSave button pressed.");
        }

    });

    Button resetTextButton2 = new Button("Reset editor #2");
    resetTextButton2.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 4877506990872691752L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (!ckEditorTextField2.isReadOnly()) {
                ckEditorTextField2.setValue(editor2InitialValue);
            }
        }
    });

    Button toggleReadOnlyButton2 = new Button("Toggle read-only editor #2");
    toggleReadOnlyButton2.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 7388801260896778551L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField2.setReadOnly(!ckEditorTextField2.isReadOnly());
        }
    });

    Button toggleViewWithoutEditorButton2 = new Button("Toggle view-without-editor #2");
    toggleViewWithoutEditorButton2.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 6042124118599379679L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField2.setViewWithoutEditor(!ckEditorTextField2.isViewWithoutEditor());
        }
    });

    Button toggleVisibleButton2 = new Button("Toggle visible editor #2");
    toggleVisibleButton2.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = -3804977370320346348L;

        @Override
        public void buttonClick(ClickEvent event) {
            ckEditorTextField2.setVisible(!ckEditorTextField2.isVisible());
        }
    });

    buttonsLayout = new HorizontalLayout(resetTextButton2, toggleReadOnlyButton2,
            toggleViewWithoutEditorButton2, toggleVisibleButton2);
    buttonsLayout.setSpacing(true);
    mainView.addComponent(buttonsLayout);

    separator = new Label("&nbsp;");
    separator.setContentMode(ContentMode.HTML);
    mainView.addComponent(separator);

    buttonsLayout = new HorizontalLayout();
    buttonsLayout.setSpacing(true);
    mainView.addComponent(buttonsLayout);

    buttonsLayout.addComponent(new Button("Open Modal Subwindow", new ClickListener() {
        private static final long serialVersionUID = 7661931879334525618L;

        @Override
        public void buttonClick(ClickEvent event) {
            Window sub = new Window("Subwindow modal");
            VerticalLayout subLayout = new VerticalLayout();
            sub.setContent(subLayout);

            CKEditorConfig config = new CKEditorConfig();
            config.useCompactTags();
            config.disableElementsPath();
            config.disableSpellChecker();
            config.enableVaadinSavePlugin();
            // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
            // in a window that's on top of the main two editors of this demo app
            config.setBaseFloatZIndex(11000);
            config.setHeight("150px");

            final CKEditorTextField ckEditorTextField = new CKEditorTextField(config);
            ckEditorTextField.addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = -1308863170484877239L;

                public void valueChange(ValueChangeEvent event) {
                    Notification.show("CKEditor v" + ckEditorTextField2.getVersion() + "/" + getVersion()
                            + " - POPUP MODAL contents: " + event.getProperty().getValue().toString());
                }
            });
            ckEditorTextField.focus();

            subLayout.addComponent(ckEditorTextField);

            sub.setWidth("80%");
            sub.setModal(true);
            sub.center();

            event.getButton().getUI().addWindow(sub);
        }
    }));

    buttonsLayout.addComponent(new Button("Open Non-Modal Subwindow with 100% Height", new ClickListener() {
        private static final long serialVersionUID = 8895747367120494167L;

        @Override
        public void buttonClick(ClickEvent event) {
            Window sub = new Window("Subwindow non-modal 100% height");
            VerticalLayout subLayout = new VerticalLayout();
            sub.setContent(subLayout);
            sub.setWidth("80%");
            sub.setHeight("500px");

            subLayout.setSizeFull();

            CKEditorConfig config = new CKEditorConfig();
            config.useCompactTags();
            config.disableElementsPath();
            config.disableSpellChecker();
            config.enableVaadinSavePlugin();
            // set BaseFloatZIndex 1000 higher than CKEditor's default of 10000; probably a result of an editor opening
            // in a window that's on top of the main two editors of this demo app
            config.setBaseFloatZIndex(11000);
            config.setStartupFocus(true);
            config.setReadOnly(true);

            final CKEditorTextField ckEditorTextField = new CKEditorTextField(config);
            ckEditorTextField.setHeight("100%");
            ckEditorTextField.addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = 5592423527258867304L;

                public void valueChange(ValueChangeEvent event) {
                    Notification.show("CKEditor v" + ckEditorTextField.getVersion() + "/" + getVersion()
                            + " - POPUP NON-MODAL 100% HEIGHT contents: "
                            + event.getProperty().getValue().toString());
                }
            });
            subLayout.addComponent(ckEditorTextField);
            subLayout.setExpandRatio(ckEditorTextField, 10);

            final TextField textField = new TextField("TextField");
            textField.addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = 6686202497483757206L;

                public void valueChange(ValueChangeEvent event) {
                    Notification.show("TextField - POPUP NON-MODAL 100% HEIGHT contents: "
                            + event.getProperty().getValue().toString());
                }
            });
            subLayout.addComponent(textField);

            sub.center();

            event.getButton().getUI().addWindow(sub);
        }
    }));
}

From source file:org.vaadin.spring.samples.navigation.PrototypeScopedView.java

License:Apache License

@PostConstruct
void init() {//from ww  w  .  j a v  a  2  s . c  om
    LOGGER.info("I'm being created: {}", this);
    setMargin(true);
    setSpacing(true);

    final Label label = new Label(String.format(
            "This is a prototype scoped view. A new instance is created every time this view is shown. "
                    + "This particular instance is <b>%s</b>. If you navigate away from this view and back, you'll notice that the instance changes every time.",
            this));
    label.setContentMode(ContentMode.HTML);
    addComponent(label);

    addComponent(new Button("Invoke a UI scoped business object", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addComponent(new Label(uiScopedBusinessObject.sayHello()));
        }
    }));
}

From source file:org.vaadin.spring.samples.navigation.UIScopedView.java

License:Apache License

@PostConstruct
void init() {/*from  ww w .j a v a2  s  .  co m*/
    LOGGER.info("I'm being created: {}", this);
    setMargin(true);
    setSpacing(true);

    final Label label = new Label(String.format(
            "This is a UI scoped view. The same instance is used every time this view is shown. "
                    + "This particular instance is <b>%s</b>. If you navigate away from this view and back, you'll notice that the instance remains the same.",
            this));
    label.setContentMode(ContentMode.HTML);
    addComponent(label);

    addComponent(new Button("Invoke a UI scoped business object", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addComponent(new Label(uiScopedBusinessObject.sayHello()));
        }
    }));
}

From source file:org.vaadin.spring.samples.navigation.ViewScopedView.java

License:Apache License

@PostConstruct
void init() {// ww w.j a v  a2 s.  c o m
    LOGGER.info("I'm being created: {}", this);
    setMargin(true);
    setSpacing(true);

    final Label label = new Label(String.format(
            "This is a view scoped view. A new instance is created every time this view is shown. "
                    + "This particular instance is <b>%s</b>. If you navigate away from this view and back, you'll notice that the instance changes every time.",
            this));
    label.setContentMode(ContentMode.HTML);
    addComponent(label);

    addComponent(new Button("Invoke a UI scoped business object", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addComponent(new Label(uiScopedBusinessObject.sayHello()));
        }
    }));
    addComponent(viewScopedComponent);
    addComponent(new Button("Invoke a view scoped business object", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addComponent(new Label(viewScopedBusinessObject.sayHello()));
        }
    }));
}

From source file:org.vaadin.spring.samples.security.shared.views.HomeView.java

License:Apache License

public HomeView() {
    setSpacing(true);//from w  w w .  ja  v a2 s . com
    setMargin(true);

    Label header = new Label("Welcome to the Vaadin Shared Security Demo!");
    header.addStyleName(ValoTheme.LABEL_H1);
    addComponent(header);

    Label body = new Label(
            "<p>This application demonstrate how a Vaadin application can integrate with Spring Security when the security configuration has taken place outside of the Vaadin application.</p>"
                    + "<p>Please try it out by clicking and navigating around as different users. You can log in as <em>user/user</em> or <em>admin/admin</em>. Some of the protected "
                    + "features are hidden from the UI when you cannot access them, others are visible all the time.</p>"
                    + "<p>Also note that since we are using web socket based push, we do not have access to cookies and therefore cannot use Remember Me services.</p>");
    body.setContentMode(ContentMode.HTML);
    addComponent(body);
}

From source file:probe.com.view.body.quantcompare.PieChart.java

public PieChart(String title, double full, double found, final String notfound) {

    this.setWidth(200 + "px");
    this.setHeight(200 + "px");
    defaultKeyColorMap.put("Found", new Color(110, 177, 206));
    defaultKeyColorMap.put("Not found", new Color(219, 169, 1));
    otherSymbols.setGroupingSeparator('.');
    this.setStyleName("click");

    labels = new String[] { "Found", "Not found" };

    double foundPercent = ((found / full) * 100.0);
    df = new DecimalFormat("#.##", otherSymbols);
    valuesMap.put("Found", ((int) found) + " (" + df.format(foundPercent) + "%)");
    values = new Double[] { foundPercent, 100.0 - foundPercent };
    valuesMap.put("Not found", ((int) (full - found)) + " (" + df.format(100.0 - foundPercent) + "%)");

    String defaultImgURL = initPieChart(200, 200, title);
    chartImg.setSource(new ExternalResource(defaultImgURL));
    this.addComponent(chartImg);
    this.addLayoutClickListener(PieChart.this);

    popupLayout = new PopupView(null, popupBody);
    popupLayout.setHideOnMouseOut(false);
    popupBody.setWidth("300px");
    popupBody.setStyleName(Reindeer.LAYOUT_WHITE);
    popupBody.setHeightUndefined();/*from   w  ww . j  av a2  s  .  c o m*/
    this.addComponent(popupLayout);
    this.notfound = notfound.replace(" ", "").replace(",", "/n");

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setWidth("100%");
    topLayout.setHeight("20px");

    Label header = new Label("<b>Not Found (New Proteins)</b>");
    header.setStyleName(Reindeer.LABEL_SMALL);
    topLayout.addComponent(header);
    header.setContentMode(ContentMode.HTML);

    VerticalLayout closeBtn = new VerticalLayout();
    closeBtn.setWidth("10px");
    closeBtn.setHeight("10px");
    closeBtn.setStyleName("closebtn");
    topLayout.addComponent(closeBtn);
    topLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT);
    closeBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            popupLayout.setPopupVisible(false);
        }
    });
    popupBody.addComponent(topLayout);
    popupBody.addComponent(textArea);
    textArea.setWidth("100%");
    textArea.setHeight("150px");
    textArea.setValue(this.notfound);
    textArea.setReadOnly(true);
    popupBody.setSpacing(true);

    HorizontalLayout bottomLayout = new HorizontalLayout();
    bottomLayout.setWidth("100%");
    bottomLayout.setHeight("40px");
    bottomLayout.setMargin(new MarginInfo(false, true, true, true));
    popupBody.addComponent(bottomLayout);

    Button exportTableBtn = new Button("");
    exportTableBtn.setHeight("24px");
    exportTableBtn.setWidth("24px");
    exportTableBtn.setPrimaryStyleName("exportxslbtn");
    exportTableBtn.setDescription("Export table data");
    exportTableBtn.addClickListener(new Button.ClickListener() {

        private Table table;

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

            if (table == null) {
                table = new Table();
                table.addContainerProperty("Index", Integer.class, null, "", null, Table.Align.RIGHT);
                table.addContainerProperty("Accession", String.class, Table.Align.CENTER);
                table.setVisible(false);
                addComponent(table);
                int i = 1;
                for (String str : notfound.replace(" ", "").replace(",", "\n").split("\n")) {
                    table.addItem(new Object[] { i, str }, i++);
                }

            }

            ExcelExport csvExport = new ExcelExport(table, "Not found protein accessions (New proteins)");
            //                csvExport.setReportTitle("CSF-PR /  Not found protein accessions (New proteins) ");
            csvExport.setExportFileName("CSF-PR - Not found protein accessions" + ".xls");
            csvExport.setMimeType(CsvExport.EXCEL_MIME_TYPE);
            csvExport.setDisplayTotals(false);
            csvExport.setExcelFormatOfProperty("Index", "#0;[Red] #0");
            csvExport.export();

        }
    });

    bottomLayout.addComponent(exportTableBtn);
    bottomLayout.setComponentAlignment(exportTableBtn, Alignment.MIDDLE_RIGHT);

}

From source file:probe.com.view.body.QuantCompareDataLayout.java

public QuantCompareDataLayout(CSFPRHandler CSFPR_Handler) {
    this.setWidth("100%");
    this.setHeightUndefined();
    this.setStyleName(Reindeer.LAYOUT_WHITE);
    this.setSpacing(true);
    topLabelMarker = new VerticalLayout();
    this.addComponent(topLabelMarker);
    this.setExpandRatio(topLabelMarker, 0.01f);
    topLabelMarker.setHeight("10px");
    topLabelMarker.setWidth("20px");
    topLabelMarker.setStyleName(Reindeer.LAYOUT_WHITE);
    this.CSFPR_Handler = CSFPR_Handler;
    Map<String, QuantDatasetInitialInformationObject> quantDatasetInitialInformationObjectMap = CSFPR_Handler
            .getQuantDatasetInitialInformationObject();
    diseaseGroupNames = new TreeSet<String>();
    for (String diseaseCategory : quantDatasetInitialInformationObjectMap.keySet()) {
        QuantDatasetInitialInformationObject quantDatasetInitialInformationObject = quantDatasetInitialInformationObjectMap
                .get(diseaseCategory);//w  w  w .j a v a2  s.  com
        for (QuantDatasetObject qdsObject : quantDatasetInitialInformationObject.getQuantDatasetsList()
                .values()) {
            diseaseGroupNames.add(qdsObject.getPatientsSubGroup1().split("\n")[0].trim());
            diseaseGroupNames.add(qdsObject.getPatientsSubGroup2().split("\n")[0].trim());
        }

    }

    int width = 400;
    if (Page.getCurrent().getBrowserWindowWidth() < 800) {
        width = Page.getCurrent().getBrowserWindowWidth() / 2;
    }

    HorizontalLayout userDataLayout = new HorizontalLayout();
    userDataLayout.setSpacing(true);

    HorizontalLayout miniSelectDiseaseGroupsLayout = new HorizontalLayout();
    miniSelectDiseaseGroupsLayout.setStyleName("diseasegroupselectionresult");
    miniSelectDiseaseGroupsLayout.setSpacing(true);
    miniSelectDiseaseGroupsLayout.setWidthUndefined();
    miniselectionResultsLabel = new Label();
    //        miniselectionResultsLabel.setWidth("300px");
    miniSelectDiseaseGroupsLayout.addComponent(miniselectionResultsLabel);

    selectionResultsOverview = new Label();
    //        selectionResultsOverview.setWidth("300px");
    miniSelectDiseaseGroupsLayout.addComponent(selectionResultsOverview);
    selectionResultsOverview.setContentMode(ContentMode.HTML);

    userDataLayoutContainer = new HideOnClickLayout("User Data", userDataLayout, miniSelectDiseaseGroupsLayout,
            Alignment.TOP_LEFT, "info data", null);
    userDataLayoutContainer.setMargin(new MarginInfo(false, false, false, true));
    userDataLayoutContainer.setVisability(true);
    this.addComponent(userDataLayoutContainer);

    VerticalLayout leftUserDataLayout = new VerticalLayout();
    userDataLayout.addComponent(leftUserDataLayout);
    //select or enter new disease groups layout 

    selectionResultsLabel = new Label("Selection:");
    selectDiseaseGroupsContainer = initSelectEnterDatasetDiseaseGroups(width);
    //        selectDiseaseGroupsContainer.setVisability(true);
    selectDiseaseGroupsContainer.setReadOnly(true);
    leftUserDataLayout.addComponent(selectDiseaseGroupsContainer);

    proteinsDataCaptureLayout = initProteinsDataCapture(width);
    leftUserDataLayout.addComponent(proteinsDataCaptureLayout);

    ResultsOverviewLayout.setStyleName("compareresults");
    ResultsOverviewLayout.setWidth("350px");
    ResultsOverviewLayout.setHeightUndefined();
    ResultsOverviewLayout.setSpacing(true);
    ResultsOverviewLayout.setMargin(new MarginInfo(false, false, false, true));

    Label resultsTitleLabel = new Label("Results Overview");
    resultsTitleLabel.setContentMode(ContentMode.HTML);
    resultsTitleLabel.setStyleName("normalheader");
    resultsTitleLabel.setHeight("20px");
    ResultsOverviewLayout.addComponent(resultsTitleLabel);
    ResultsOverviewLayout.setComponentAlignment(resultsTitleLabel, Alignment.TOP_LEFT);

    resultContainer = new GridLayout(3, 5);
    resultContainer.setSpacing(true);
    resultContainer.setMargin(true);
    resultContainer.setHideEmptyRowsAndColumns(true);
    ResultsOverviewLayout.addComponent(resultContainer);
    ResultsOverviewLayout.setComponentAlignment(resultContainer, Alignment.TOP_LEFT);
    resultContainer.setWidth("100%");
    foundPublicationLabel = new Label();
    //        resultContainer.addComponent(foundPublicationLabel, 0, 0);

    foundStudiesLabel = new Label();
    //        resultContainer.addComponent(foundStudiesLabel, 1, 0);

    foundProteinsLabel = new Label();
    resultContainer.addComponent(foundProteinsLabel, 0, 0);

    newProteinsDownloadBtn = new Button();
    newProteinsDownloadBtn.setCaptionAsHtml(true);
    newProteinsDownloadBtn.setStyleName(Reindeer.BUTTON_LINK);
    //        ResultsOverviewLayout.addComponent(newProteinsDownloadBtn);
    newProteinsDownloadBtn.setDescription("Download new proteins (not found in CSF-PR) records");

    //        ResultsOverviewLayout.addComponent(newProteinsTextArea);
    newProteinsTextArea.setWidth("302px");
    newProteinsTextArea.setHeight("200px");
    newProteinsTextArea.setReadOnly(true);

    newProteinsDownloadBtn.addClickListener(QuantCompareDataLayout.this);
    newProteinsDownloadBtn.setId("notfounderrorbtn");
    userDataLayout.addComponent(ResultsOverviewLayout);

    this.addComponent(resultsLayout);
}