Example usage for com.vaadin.server Resource Resource

List of usage examples for com.vaadin.server Resource Resource

Introduction

In this page you can find the example usage for com.vaadin.server Resource Resource.

Prototype

Resource

Source Link

Usage

From source file:org.opennms.features.vaadin.jmxconfiggenerator.ui.ResultView.java

License:Open Source License

public ResultView() {
    // available content
    tabContentMap.put(OutputDataKey.JmxDataCollectionConfig,
            new TabContent(OutputDataKey.JmxDataCollectionConfig));
    tabContentMap.put(OutputDataKey.SnmpGraphProperties, new TabContent(OutputDataKey.SnmpGraphProperties));
    tabContentMap.put(OutputDataKey.CollectdConfigSnippet, new TabContent(OutputDataKey.CollectdConfigSnippet));

    // we have to sort the keys, because map.keySet or map.values do not return a sorted
    // collection which results in non deterministic ui results.
    List<OutputDataKey> keyList = new ArrayList<>(tabContentMap.keySet());
    Collections.sort(keyList, new Comparator<OutputDataKey>() {
        @Override//from   w  w w  .ja  va 2 s.  c  o  m
        public int compare(OutputDataKey o1, OutputDataKey o2) {
            return o1.name().compareTo(o2.name());
        }
    });

    // add all tabs
    for (OutputDataKey eachKey : keyList) {
        TabContent eachContent = tabContentMap.get(eachKey);
        tabSheet.addTab(eachContent, eachContent.getCaption());
    }

    tabSheet.setSizeFull();
    tabSheet.setSelectedTab(0); // select first component!
    tabSheet.addStyleName(Reindeer.TABSHEET_BORDERLESS);

    buttonPanel.getNext().setCaption("download all");
    buttonPanel.getNext().setDescription("Download a zip file containing the JMX datacollection configuration");
    buttonPanel.getNext().setIcon(Config.Icons.BUTTON_SAVE);

    // this is a dummy resource as we are going to set the real
    // resource when entering the view.
    fileDownloader = new FileDownloader(new Resource() {
        @Override
        public String getMIMEType() {
            return "application/unknown";
        }
    });
    fileDownloader.extend(buttonPanel.getNext());

    setSizeFull();

    addComponent(tabSheet);
    addComponent(buttonPanel);
    setExpandRatio(tabSheet, 1);
}