Example usage for com.vaadin.server FileDownloader FileDownloader

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

Introduction

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

Prototype

public FileDownloader(Resource resource) 

Source Link

Document

Creates a new file downloader for the given resource.

Usage

From source file:pl.exsio.ca.module.terrain.evidence.FilesDataTable.java

License:Open Source License

protected void addDownloadButtonColumn() {
    dataComponent.addGeneratedColumn("", new Table.ColumnGenerator() {

        @Override/* w w w .  j ava  2  s .c  om*/
        public Component generateCell(final Table source, final Object itemId, final Object columnId) {

            final Button download = new Button("", FontAwesome.DOWNLOAD);
            final TerrainFile terrainFile = ((EntityItem<TerrainFile>) dataComponent.getItem(itemId))
                    .getEntity();
            Resource res = new StreamResource(new StreamSource() {

                @Override
                public InputStream getStream() {
                    return new ByteArrayInputStream(terrainFile.getData());
                }
            }, terrainFile.getName());
            FileDownloader fd = new FileDownloader(res);
            fd.extend(download);
            download.setImmediate(true);
            download.setStyleName("link");
            return download;
        }
    });
}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.ComparisonsSelectionOverviewBubbleChart.java

public ComparisonsSelectionOverviewBubbleChart(final QuantCentralManager Quant_Central_Manager,
        final CSFPRHandler CSFPR_Handler, int chartWidth, int chartHeight,
        Set<QuantDiseaseGroupsComparison> selectedComparisonList,
        List<QuantProtein> searchQuantificationProtList) {

    userDataCounter = 0;/*from w  w  w. j  a  v a 2  s.  co m*/
    this.searchQuantificationProtList = searchQuantificationProtList;
    Map<String, String> diseaseHashedColorMap = Quant_Central_Manager.getDiseaseHashedColorMap();
    for (String str : diseaseHashedColorMap.keySet()) {
        diseaseColorMap.put(str, Color.decode(diseaseHashedColorMap.get(str)));
    }
    this.width = chartWidth;
    this.height = 600;
    this.CSFPR_Handler = CSFPR_Handler;
    this.setWidth(width + "px");
    this.setHeightUndefined();
    this.Quant_Central_Manager = Quant_Central_Manager;
    this.Quant_Central_Manager.registerStudySelectionListener(ComparisonsSelectionOverviewBubbleChart.this);
    this.setSpacing(true);

    //init toplayout
    topLayout.setHeight(30 + "px");
    topLayout.setSpacing(true);
    topLayout.setMargin(new MarginInfo(false, false, true, false));
    this.addComponent(topLayout);

    Label overviewLabel = new Label("<font style='margin-left :50px;'>Overview</font> ");
    overviewLabel.setContentMode(ContentMode.HTML);
    topLayout.addComponent(overviewLabel);
    overviewLabel.setStyleName("subtitle");
    overviewLabel.setWidth("120px");

    InfoPopupBtn info = new InfoPopupBtn(
            "The bubble chart give an overview for the proteins existed in the selected comparisons.<br/>The diameter of the bubble represents the number of the proteins in the selected comparison and the color represents the trend<br/>");
    info.setWidth("16px");
    info.setHeight("16px");
    topLayout.addComponent(info);
    this.topLayout.setVisible(false);

    //end of toplayout
    //init chartlayout
    this.chartLayoutContainer.setVisible(false);
    this.addComponent(chartLayoutContainer);
    chartLayoutContainer.setWidth(width + "px");
    chartLayoutContainer.setHeight(height + "px");

    chartLayoutContainer.addComponent(chartImage, "left: " + 0 + "px; top: " + 0 + "px;");
    chartLayoutContainer.addComponent(chartLayout, "left: " + 0 + "px; top: " + 0 + "px;");
    chartLayout.setWidth(width + "px");
    chartLayout.setHeight(height + "px");
    chartLayout.addLayoutClickListener(ComparisonsSelectionOverviewBubbleChart.this);

    //end of chartlayout
    //init bottomlayout 
    bottomLayout.setWidth("100%");
    this.addComponent(bottomLayout);
    this.setComponentAlignment(bottomLayout, Alignment.BOTTOM_RIGHT);
    bottomLayout.setVisible(false);
    HorizontalLayout btnContainerLayout = new HorizontalLayout();
    btnContainerLayout.setSpacing(true);
    //        btnContainerLayout.setMargin(new MarginInfo(false, false, false, false));
    btnContainerLayout.setWidthUndefined();
    btnContainerLayout.setHeightUndefined();
    //        btnContainerLayout.addStyleName("leftspacer");
    bottomLayout.addComponent(btnContainerLayout);
    bottomLayout.setComponentAlignment(btnContainerLayout, Alignment.TOP_RIGHT);

    TrendLegend legendLayout = new TrendLegend("bubblechart");
    legendLayout.setWidthUndefined();
    legendLayout.setHeight("24px");
    btnContainerLayout.addComponent(legendLayout);
    btnContainerLayout.setComponentAlignment(legendLayout, Alignment.TOP_RIGHT);
    //        btnContainerLayout.setExpandRatio(legendLayout, 600);
    //        btnContainerLayout.setExpandRatio(btnContainerLayout, 210);

    //         VerticalLayout stableBtnWrapper = new VerticalLayout();
    ////        stableBtnWrapper.setWidth("64px");
    //        HorizontalLayout stableBtn = new HorizontalLayout();
    //        stableBtnWrapper.addComponent(stableBtn);
    //        stableBtnWrapper.setComponentAlignment(stableBtn, Alignment.TOP_LEFT);
    //        btnContainerLayout.addComponent(stableBtnWrapper);
    groupSwichBtn = new GroupSwichBtn(Quant_Central_Manager, searchQuantificationProtList);
    btnContainerLayout.addComponent(groupSwichBtn);

    final VerticalLayout appliedIcon = new VerticalLayout();
    appliedIcon.setStyleName("appliedicon");
    appliedIcon.setWidth("24px");
    appliedIcon.setHeight("24px");
    appliedIcon.setDescription("Hide stable proteins");
    btnContainerLayout.addComponent(appliedIcon);
    //        stableBtn.setStyleName("stablebtn");
    //        stableBtn.setHeight("24px");
    //        Label stableLabel = new Label("Equal");
    //        stableLabel.setWidth("44px");
    //        stableBtn.addComponent(stableLabel);

    appliedIcon.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            if (appliedIcon.getStyleName().equalsIgnoreCase("appliedicon")) {
                appliedIcon.setStyleName("unappliedicon");
                Quant_Central_Manager.updateSignificantOnlySelection(true);
                appliedIcon.setDescription("Show stable proteins");
            } else {
                appliedIcon.setStyleName("appliedicon");
                Quant_Central_Manager.updateSignificantOnlySelection(false);
                appliedIcon.setDescription("Hide stable proteins");
            }
        }
    });

    exportPdfBtn = new Button("");
    exportPdfBtn.setWidth("24px");
    exportPdfBtn.setHeight("24px");
    exportPdfBtn.setPrimaryStyleName("exportpdfbtn");
    exportPdfBtn.setDescription("Export chart image");
    StreamResource myResource = createResource();
    FileDownloader fileDownloader = new FileDownloader(myResource);
    fileDownloader.extend(exportPdfBtn);
    btnContainerLayout.addComponent(exportPdfBtn);

    VerticalLayout unselectAllBtn = new VerticalLayout();
    unselectAllBtn.setStyleName("unselectallbtn");
    btnContainerLayout.addComponent(unselectAllBtn);
    btnContainerLayout.setComponentAlignment(unselectAllBtn, Alignment.TOP_LEFT);
    unselectAllBtn.setDescription("Clear selection");
    unselectAllBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            Quant_Central_Manager.setBubbleChartQuantProteinsSelection(new HashSet<String>(), "");
            resetChart();

        }
    });

    final VerticalLayout selectMultiBtn = new VerticalLayout();
    selectMultiBtn.setStyleName("selectmultiselectedbtn");
    btnContainerLayout.addComponent(selectMultiBtn);
    btnContainerLayout.setComponentAlignment(selectMultiBtn, Alignment.TOP_LEFT);
    selectMultiBtn.setDescription("Multiple selection");
    activeMultiSelect = true;
    selectMultiBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            if (selectMultiBtn.getStyleName().equalsIgnoreCase("selectmultiselectedbtn")) {
                selectMultiBtn.setStyleName("selectmultibtn");
                activeMultiSelect = false;

            } else {
                selectMultiBtn.setStyleName("selectmultiselectedbtn");
                activeMultiSelect = true;

            }
        }
    });

    //end of btns layout
    //init empty layout
    emptySelectionLayout = new VerticalLayout();
    this.addComponent(emptySelectionLayout);
    emptySelectionLayout.setWidth(100 + "%");
    emptySelectionLayout.setHeightUndefined();

    VerticalLayout spacer = new VerticalLayout();
    spacer.setHeight("100px");
    spacer.setWidth("10px");
    spacer.setStyleName(Reindeer.LAYOUT_WHITE);
    emptySelectionLayout.addComponent(spacer);
    emptySelectionLayout.setComponentAlignment(spacer, Alignment.BOTTOM_RIGHT);

    Label startLabel = new Label(
            "<center><h2 style='color:gray;'><b>Select comparison from the table</b></h2></center>");
    startLabel.setContentMode(ContentMode.HTML);

    emptySelectionLayout.addComponent(startLabel);
    emptySelectionLayout.setComponentAlignment(startLabel, Alignment.MIDDLE_CENTER);

    Image handleft = new Image();
    handleft.setSource(new ThemeResource("img/handleft.png"));
    emptySelectionLayout.addComponent(handleft);
    emptySelectionLayout.setComponentAlignment(handleft, Alignment.MIDDLE_CENTER);

    //init bubble chart
}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.ComparisonsSelectionOverviewBubbleChart.java

public ComparisonsSelectionOverviewBubbleChart(final QuantCentralManager Quant_Central_Manager,
        final CSFPRHandler CSFPR_Handler, int chartWidth, int chartHeight,
        Set<QuantDiseaseGroupsComparison> selectedComparisonList,
        List<QuantProtein> searchQuantificationProtList,
        QuantDiseaseGroupsComparison userCustomizedComparison) {
    this.userCustomizedComparison = userCustomizedComparison;
    userDataCounter = 1;//from   ww w .  ja va  2s  .  c o  m
    this.searchQuantificationProtList = searchQuantificationProtList;
    Map<String, String> diseaseHashedColorMap = Quant_Central_Manager.getDiseaseHashedColorMap();
    for (String str : diseaseHashedColorMap.keySet()) {
        diseaseColorMap.put(str, Color.decode(diseaseHashedColorMap.get(str)));
    }
    this.width = chartWidth;
    this.height = 600;
    this.CSFPR_Handler = CSFPR_Handler;
    this.setWidth(width + "px");
    this.setHeightUndefined();
    this.Quant_Central_Manager = Quant_Central_Manager;
    this.Quant_Central_Manager.registerStudySelectionListener(ComparisonsSelectionOverviewBubbleChart.this);
    this.setSpacing(true);

    //init toplayout
    topLayout.setHeight(30 + "px");
    topLayout.setSpacing(true);
    topLayout.setMargin(new MarginInfo(false, false, true, false));
    this.addComponent(topLayout);

    Label overviewLabel = new Label("<font style='margin-left :50px;'>Overview</font> ");
    overviewLabel.setContentMode(ContentMode.HTML);
    topLayout.addComponent(overviewLabel);
    overviewLabel.setStyleName("subtitle");
    overviewLabel.setWidth("120px");

    InfoPopupBtn info = new InfoPopupBtn(
            "The bubble chart give an overview for the proteins existed in the selected comparisons.<br/>The diameter of the bubble represents the number of the proteins in the selected comparison and the color represents the trend<br/>");
    info.setWidth("16px");
    info.setHeight("16px");
    topLayout.addComponent(info);

    //end of toplayout
    //init chartlayout
    this.chartLayoutContainer.setVisible(false);
    this.addComponent(chartLayoutContainer);

    this.addComponent(chartLayoutContainer);
    chartLayoutContainer.setWidth(width + "px");
    chartLayoutContainer.setHeight(height + "px");

    chartLayoutContainer.addComponent(chartImage, "left: " + 0 + "px; top: " + 0 + "px;");
    chartLayoutContainer.addComponent(chartLayout, "left: " + 0 + "px; top: " + 0 + "px;");
    chartLayout.setWidth(width + "px");
    chartLayout.setHeight(height + "px");
    chartLayout.addLayoutClickListener(ComparisonsSelectionOverviewBubbleChart.this);

    //end of chartlayout
    //init bottomlayout 
    bottomLayout.setWidth("100%");
    this.addComponent(bottomLayout);
    this.setComponentAlignment(bottomLayout, Alignment.BOTTOM_RIGHT);
    bottomLayout.setVisible(false);
    HorizontalLayout btnContainerLayout = new HorizontalLayout();
    btnContainerLayout.setSpacing(true);
    //        btnContainerLayout.setMargin(new MarginInfo(false, false, false, false));
    btnContainerLayout.setWidthUndefined();
    btnContainerLayout.setHeightUndefined();
    //        btnContainerLayout.addStyleName("leftspacer");
    bottomLayout.addComponent(btnContainerLayout);
    bottomLayout.setComponentAlignment(btnContainerLayout, Alignment.TOP_RIGHT);

    TrendLegend legendLayout = new TrendLegend("bubblechart");
    legendLayout.setWidthUndefined();
    legendLayout.setHeight("24px");
    btnContainerLayout.addComponent(legendLayout);
    btnContainerLayout.setComponentAlignment(legendLayout, Alignment.TOP_RIGHT);

    Quant_Central_Manager.insertNoftfication("Quantitative Datasets",
            "Remeber you can flip the disease group comparisons using (Swich disease groups button)<img src='VAADIN/themes/dario-theme/img/flip-v-updated.png' height='25px' width='25' alt='Reorder and select' Align='center'/> ",
            width, width, "flipnotification");

    //        btnContainerLayout.setExpandRatio(legendLayout, 600);
    //        btnContainerLayout.setExpandRatio(btnContainerLayout, 210);

    //         VerticalLayout stableBtnWrapper = new VerticalLayout();
    ////        stableBtnWrapper.setWidth("64px");
    //        HorizontalLayout stableBtn = new HorizontalLayout();
    //        stableBtnWrapper.addComponent(stableBtn);
    //        stableBtnWrapper.setComponentAlignment(stableBtn, Alignment.TOP_LEFT);
    //        btnContainerLayout.addComponent(stableBtnWrapper);
    groupSwichBtn = new GroupSwichBtn(Quant_Central_Manager, searchQuantificationProtList);
    btnContainerLayout.addComponent(groupSwichBtn);
    final VerticalLayout appliedIcon = new VerticalLayout();
    appliedIcon.setStyleName("appliedicon");
    appliedIcon.setWidth("24px");
    appliedIcon.setHeight("24px");
    appliedIcon.setDescription("Hide stable proteins");
    btnContainerLayout.addComponent(appliedIcon);
    //        stableBtn.setStyleName("stablebtn");
    //        stableBtn.setHeight("24px");
    //        Label stableLabel = new Label("Equal");
    //        stableLabel.setWidth("44px");
    //        stableBtn.addComponent(stableLabel);

    appliedIcon.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            if (appliedIcon.getStyleName().equalsIgnoreCase("appliedicon")) {
                appliedIcon.setStyleName("unappliedicon");
                Quant_Central_Manager.updateSignificantOnlySelection(true);
                appliedIcon.setDescription("Show stable proteins");
            } else {
                appliedIcon.setStyleName("appliedicon");
                Quant_Central_Manager.updateSignificantOnlySelection(false);
                appliedIcon.setDescription("Hide stable proteins");
            }
        }
    });

    exportPdfBtn = new Button("");
    exportPdfBtn.setWidth("24px");
    exportPdfBtn.setHeight("24px");
    exportPdfBtn.setPrimaryStyleName("exportpdfbtn");
    exportPdfBtn.setDescription("Export chart image");
    StreamResource myResource = createResource();
    FileDownloader fileDownloader = new FileDownloader(myResource);
    fileDownloader.extend(exportPdfBtn);
    btnContainerLayout.addComponent(exportPdfBtn);

    VerticalLayout unselectAllBtn = new VerticalLayout();
    unselectAllBtn.setStyleName("unselectallbtn");
    btnContainerLayout.addComponent(unselectAllBtn);
    btnContainerLayout.setComponentAlignment(unselectAllBtn, Alignment.TOP_LEFT);
    unselectAllBtn.setDescription("Clear selection");
    unselectAllBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            Quant_Central_Manager.setBubbleChartQuantProteinsSelection(new HashSet<String>(), "");
            resetChart();

        }
    });

    final VerticalLayout selectMultiBtn = new VerticalLayout();
    selectMultiBtn.setStyleName("selectmultiselectedbtn");
    btnContainerLayout.addComponent(selectMultiBtn);
    btnContainerLayout.setComponentAlignment(selectMultiBtn, Alignment.TOP_LEFT);
    selectMultiBtn.setDescription("Multiple selection");
    activeMultiSelect = true;
    selectMultiBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            if (selectMultiBtn.getStyleName().equalsIgnoreCase("selectmultiselectedbtn")) {
                selectMultiBtn.setStyleName("selectmultibtn");
                activeMultiSelect = false;

            } else {
                selectMultiBtn.setStyleName("selectmultiselectedbtn");
                activeMultiSelect = true;

            }
        }
    });

    //end of btns layout
    //init empty layout
    emptySelectionLayout = new VerticalLayout();
    this.addComponent(emptySelectionLayout);
    emptySelectionLayout.setWidth(width + "px");
    emptySelectionLayout.setHeightUndefined();

    VerticalLayout spacer = new VerticalLayout();
    spacer.setHeight("100px");
    spacer.setWidth("10px");
    spacer.setStyleName(Reindeer.LAYOUT_WHITE);
    emptySelectionLayout.addComponent(spacer);
    emptySelectionLayout.setComponentAlignment(spacer, Alignment.BOTTOM_RIGHT);

    Label startLabel = new Label(
            "<center><h2 style='color:gray;'><b>Select comparison from the table</b></h2></center>");
    startLabel.setContentMode(ContentMode.HTML);

    emptySelectionLayout.addComponent(startLabel);
    emptySelectionLayout.setComponentAlignment(startLabel, Alignment.MIDDLE_CENTER);

    Image handleft = new Image();
    handleft.setSource(new ThemeResource("img/handleft.png"));
    emptySelectionLayout.addComponent(handleft);
    emptySelectionLayout.setComponentAlignment(handleft, Alignment.MIDDLE_CENTER);

}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.interactivepiechartfilters.StudiesPieChartFiltersContainerLayout.java

/**
 *
 * @param Quant_Central_Manager/*w  ww .j  av a2 s .  c  om*/
 * @param handler
 */
public StudiesPieChartFiltersContainerLayout(QuantCentralManager Quant_Central_Manager,
        final CSFPRHandler handler) {

    int layoutHeight = Page.getCurrent().getBrowserWindowHeight() - 200;
    int layoutWidth = Page.getCurrent().getBrowserWindowWidth() - 200;
    this.setWidth(layoutWidth + "px");
    this.setHeight(layoutHeight + "px");
    int filterWidth = layoutWidth / 3;
    this.setSpacing(true);
    boolean[] activeFilters = Quant_Central_Manager.getActiveFilters();
    Map<Integer, QuantDatasetObject> quantDatasetArr = Quant_Central_Manager.getFilteredDatasetsList();

    internalSelectionManager = new PieChartsSelectionManager(Quant_Central_Manager);
    if (quantDatasetArr == null) {
        return;
    }
    this.setRows(4);
    this.setColumns(4);
    int colCounter = 0;
    int rowCounter = 0;
    this.chartSet.clear();
    for (int x = 0; x < activeFilters.length; x++) {
        String filterId = "";
        if (activeFilters[x]) {
            Map<String, List<Integer>> dsIndexesMap = new HashMap<String, List<Integer>>();
            //                List<Object> valueSet = new ArrayList<Object>();
            switch (x) {
            case 0:
                //                        filterId = "identifiedProteinsNumber";
                //                        for (QuantDatasetObject pb : quantDatasetArr) {
                //                            if (pb == null) {
                //                                continue;
                //                            }
                //                            int value = pb.getIdentifiedProteinsNumber();
                //                            valueSet.add(value);
                //                        }
                break;

            case 1:
                //                        filterId = "quantifiedProteinsNumber";
                //                        for (QuantDatasetObject pb : quantDatasetArr) {
                //                            if (pb == null) {
                //                                continue;
                //                            }
                //                            int value = pb.getQuantifiedProteinsNumber();
                //                            valueSet.add(value);
                //
                //                        }
                break;

            case 2:
                //                        filterId = "analyticalMethod";
                //                        for (QuantDatasetObject pb : quantDatasetArr.values()) {
                //                            if (pb == null) {
                //                                continue;
                //                            }
                //                            String value = pb.getAnalyticalMethod();
                //                            valueSet.add(value);
                //
                //                        }
                break;

            case 3:
                //                        filterId = "rawDataUrl";
                //                        for (QuantDatasetObject pb : quantDatasetArr.values()) {
                //
                //                            if (pb == null) {
                //                                continue;
                //                            }
                //                            if (!dsIndexesMap.containsKey(pb.getRawDataUrl())) {
                //                                List<Integer> list = new ArrayList<Integer>();
                //                                dsIndexesMap.put(pb.getRawDataUrl(), list);
                //
                //                            }
                //                            List<Integer> list = dsIndexesMap.get(pb.getRawDataUrl());
                //                            list.add(pb.getUniqId());
                //                            dsIndexesMap.put(pb.getRawDataUrl(), list);
                //                            valueSet.add(pb.getRawDataUrl());
                //
                //                        }
                break;
            case 4:

                filterId = "year";
                for (QuantDatasetObject pb : quantDatasetArr.values()) {
                    if (pb == null) {
                        continue;
                    }
                    if (!dsIndexesMap.containsKey(pb.getYear() + "")) {
                        List<Integer> list = new ArrayList<Integer>();
                        dsIndexesMap.put(pb.getYear() + "", list);

                    }
                    List<Integer> list = dsIndexesMap.get(pb.getYear() + "");
                    list.add(pb.getDsKey());
                    dsIndexesMap.put(pb.getYear() + "", list);
                    int value = pb.getYear();
                    //                            valueSet.add(value);
                }
                break;
            case 5:
                filterId = "typeOfStudy";
                for (QuantDatasetObject pb : quantDatasetArr.values()) {
                    if (pb == null) {
                        continue;
                    }
                    if (!dsIndexesMap.containsKey(pb.getTypeOfStudy())) {
                        List<Integer> list = new ArrayList<Integer>();
                        dsIndexesMap.put(pb.getTypeOfStudy(), list);

                    }
                    if (pb.getTypeOfStudy().trim().equalsIgnoreCase("")) {
                        pb.setTypeOfStudy("Not Available");
                    }
                    List<Integer> list = dsIndexesMap.get(pb.getTypeOfStudy());
                    list.add(pb.getDsKey());
                    dsIndexesMap.put(pb.getTypeOfStudy(), list);
                    String value = pb.getTypeOfStudy();
                    //                            valueSet.add(value);
                }
                break;
            case 6:
                filterId = "sampleType";
                for (QuantDatasetObject pb : quantDatasetArr.values()) {
                    if (pb == null) {
                        continue;
                    }
                    if (pb.getSampleType().trim().equalsIgnoreCase("")) {
                        pb.setSampleType("Not Available");
                    }
                    if (!dsIndexesMap.containsKey(pb.getSampleType())) {
                        List<Integer> list = new ArrayList<Integer>();
                        dsIndexesMap.put(pb.getSampleType(), list);

                    }
                    List<Integer> list = dsIndexesMap.get(pb.getSampleType());
                    list.add(pb.getDsKey());
                    dsIndexesMap.put(pb.getSampleType(), list);
                    String value = pb.getSampleType();
                    //                            valueSet.add(value);
                }
                break;
            case 7:
                filterId = "sampleMatching";
                for (QuantDatasetObject pb : quantDatasetArr.values()) {
                    if (pb == null) {
                        continue;
                    }
                    if (pb.getSampleMatching().trim().equalsIgnoreCase("")) {
                        pb.setSampleMatching("Not Available");
                    }
                    if (!dsIndexesMap.containsKey(pb.getSampleMatching())) {
                        List<Integer> list = new ArrayList<Integer>();
                        dsIndexesMap.put(pb.getSampleMatching(), list);

                    }
                    List<Integer> list = dsIndexesMap.get(pb.getSampleMatching());
                    list.add(pb.getDsKey());
                    dsIndexesMap.put(pb.getSampleMatching(), list);

                    String value = pb.getSampleMatching();
                    //                            valueSet.add(value);
                }
                break;
            case 8:
                filterId = "technology";
                for (QuantDatasetObject pb : quantDatasetArr.values()) {
                    if (pb == null) {
                        continue;
                    }
                    String value = pb.getTechnology();
                    if (value == null || value.equalsIgnoreCase("")) {
                        value = "Not Available";
                    }
                    if (!dsIndexesMap.containsKey(value)) {
                        List<Integer> list = new ArrayList<Integer>();
                        dsIndexesMap.put(value, list);

                    }
                    List<Integer> list = dsIndexesMap.get(value);
                    list.add(pb.getDsKey());
                    dsIndexesMap.put(value, list);
                    //                            valueSet.add(value);
                }
                break;
            case 9:

                filterId = "analyticalApproach";
                for (QuantDatasetObject pb : quantDatasetArr.values()) {
                    if (pb == null) {
                        continue;
                    }
                    String value = pb.getAnalyticalApproach();
                    if (value == null || value.trim().equalsIgnoreCase("")) {
                        pb.setAnalyticalApproach("Not Available");
                        value = "Not Available";
                    }
                    if (!dsIndexesMap.containsKey(value)) {
                        List<Integer> list = new ArrayList<Integer>();
                        dsIndexesMap.put(value, list);

                    }
                    List<Integer> list = dsIndexesMap.get(pb.getAnalyticalApproach());
                    list.add(pb.getDsKey());
                    dsIndexesMap.put(value, list);
                    //                            valueSet.add(value);
                }
                break;
            case 10:
                filterId = "enzyme";
                for (QuantDatasetObject pb : quantDatasetArr.values()) {
                    if (pb == null) {
                        continue;
                    }
                    String value = pb.getEnzyme();
                    if (value == null || value.trim().equalsIgnoreCase("")) {
                        value = "Not Available";
                        pb.setEnzyme(value);
                    }
                    if (!dsIndexesMap.containsKey(value)) {
                        List<Integer> list = new ArrayList<Integer>();
                        dsIndexesMap.put(value, list);

                    }
                    List<Integer> list = dsIndexesMap.get(value);
                    list.add(pb.getDsKey());
                    dsIndexesMap.put(value, list);
                    //                            valueSet.add(value);
                }
                break;
            case 11:
                filterId = "shotgunTargeted";
                for (QuantDatasetObject pb : quantDatasetArr.values()) {
                    if (pb == null) {
                        continue;
                    }
                    String value = pb.getShotgunTargeted();
                    if (value == null || value.trim().equalsIgnoreCase("")) {
                        value = "Not Available";
                        pb.setShotgunTargeted(value);
                    }
                    if (!dsIndexesMap.containsKey(value)) {
                        List<Integer> list = new ArrayList<Integer>();
                        dsIndexesMap.put(value, list);

                    }
                    List<Integer> list = dsIndexesMap.get(value);
                    list.add(pb.getDsKey());
                    dsIndexesMap.put(value, list);
                    //                            valueSet.add(value);
                }
                break;

            case 12:
                //                        filterId = "quantificationBasis";
                //                        for (QuantDatasetObject pb : quantDatasetArr.values()) {
                //                            if (pb == null) {
                //                                continue;
                //                            }
                //                            String value = pb.getQuantificationBasis();
                //                            if (value == null || value.trim().equalsIgnoreCase("")) {
                //                                value = "Not Available";
                //                                pb.setQuantificationBasis(value);
                //                            }
                //                            if (!dsIndexesMap.containsKey(value)) {
                //                                List<Integer> list = new ArrayList<Integer>();
                //                                dsIndexesMap.put(value, list);
                //
                //                            }
                //                            List<Integer> list = dsIndexesMap.get(value);
                //                            list.add(pb.getDsKey());
                //                            dsIndexesMap.put(value, list);
                //                            valueSet.add(value);
                //                        }
                break;
            case 13:
                filterId = "quantBasisComment";
                for (QuantDatasetObject pb : quantDatasetArr.values()) {
                    if (pb == null) {
                        continue;
                    }
                    String value = pb.getQuantBasisComment();
                    if (value == null || value.trim().equalsIgnoreCase("")) {
                        value = "Not Available";
                        pb.setQuantBasisComment(value);
                    }
                    if (!dsIndexesMap.containsKey(value)) {
                        List<Integer> list = new ArrayList<Integer>();
                        dsIndexesMap.put(value, list);

                    }
                    List<Integer> list = dsIndexesMap.get(value);
                    list.add(pb.getDsKey());
                    dsIndexesMap.put(value, list);
                    //                            valueSet.add(value);
                }
                break;
            case 14:
                //                        for (QuantDatasetObject pb : QuantDatasetListObject) {
                //                            int value = pb.getQuantifiedProteinsNumber();
                //                            valueSet.add(value);
                //                        }
                break;
            case 15:
                //                        for (QuantDatasetObject pb : QuantDatasetListObject) {
                //                            int value = pb.getPatientsGroup1Number();
                //                            valueSet.add(value);
                //                        }
                break;
            case 16:
                //                        for (QuantDatasetObject pb : QuantDatasetListObject) {
                //                            int value = pb.getPatientsGroup2Number();
                //                            valueSet.add(value);
                //                        }
                break;
            case 17:
                //                        for (QuantDatasetObject pb : QuantDatasetListObject) {
                //                            String value = pb.getNormalizationStrategy();
                //                            valueSet.add(value);
                //                        }
                break;

            }
            //                if (!valueSet.isEmpty()) {
            //do we need valueSet;;
            JfreeDivaPieChartFilter iFilter = new JfreeDivaPieChartFilter(filterId, x, internalSelectionManager,
                    dsIndexesMap, filterWidth);
            chartSet.add(iFilter.getChart());
            //                    fullFilterList.put(filterId, valueSet);
            this.addComponent(iFilter, colCounter++, rowCounter);
            this.setComponentAlignment(iFilter, Alignment.MIDDLE_CENTER);
            if (colCounter == 3) {
                colCounter = 0;
                rowCounter++;
            }
        }

        //            }
    }
    Quant_Central_Manager.setStudiesOverviewPieChart(chartSet);
    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setHeight("23px");
    btnLayout.setWidthUndefined();
    btnLayout.setSpacing(true);
    btnLayout.setStyleName(Reindeer.LAYOUT_WHITE);
    if (colCounter == 3) {
        this.addComponent(btnLayout, 2, ++rowCounter);
    } else {
        this.addComponent(btnLayout, 2, rowCounter);
    }

    this.setComponentAlignment(btnLayout, Alignment.MIDDLE_CENTER);
    Button applyFilters = new Button("Apply");
    applyFilters.setDescription("Apply the selected filters");
    applyFilters.setPrimaryStyleName("resetbtn");
    applyFilters.setWidth("50px");
    applyFilters.setHeight("24px");

    btnLayout.addComponent(applyFilters);
    applyFilters.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            pieChartFiltersBtn.closePupupWindow();
        }
    });

    //        Button unselectAllBtn = new Button("Unselect All");
    //        unselectAllBtn.setStyleName(Reindeer.BUTTON_SMALL);
    //        btnLayout.addComponent(unselectAllBtn);
    //        unselectAllBtn.addClickListener(new Button.ClickListener() {
    //
    //            @Override
    //            public void buttonClick(Button.ClickEvent event) {
    //
    //                internalSelectionManager.unselectAll();
    //
    //            }
    //        });
    //        
    Button unselectAllBtn = new Button("Clear");
    unselectAllBtn.setPrimaryStyleName("resetbtn");
    unselectAllBtn.setWidth("50px");
    unselectAllBtn.setHeight("24px");
    btnLayout.addComponent(unselectAllBtn);
    btnLayout.setComponentAlignment(unselectAllBtn, Alignment.TOP_LEFT);
    unselectAllBtn.setDescription("Clear All Selections");
    unselectAllBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            internalSelectionManager.unselectAll();
        }
    });

    Button resetFiltersBtn = new Button("Reset");
    resetFiltersBtn.setPrimaryStyleName("resetbtn");
    resetFiltersBtn.setWidth("50px");
    resetFiltersBtn.setHeight("24px");
    btnLayout.addComponent(resetFiltersBtn);
    resetFiltersBtn.setDescription("Reset all applied filters");
    resetFiltersBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            internalSelectionManager.resetToInitState();
            internalSelectionManager.resetCentralSelectionManager();
        }
    });

    Button exportChartsBtn = new Button("");

    exportChartsBtn.setWidth("24px");
    exportChartsBtn.setHeight("24px");
    exportChartsBtn.setPrimaryStyleName("exportpdfbtn");
    btnLayout.addComponent(exportChartsBtn);
    exportChartsBtn.setDescription("Export all charts filters as pdf file");
    //        exportChartsBtn.addClickListener(new Button.ClickListener() {
    //            @Override
    //            public void buttonClick(Button.ClickEvent event) {
    //               String url = handler.exportImgAsPdf(chartSet, "piechart_filters.pdf");
    //                FileResource res = new FileResource(new File(url));
    //                Page.getCurrent().open(res, "_blank", true);
    //            }
    //        });

    StreamResource myResource = createResource(handler);
    FileDownloader fileDownloader = new FileDownloader(myResource);
    fileDownloader.extend(exportChartsBtn);
    pieChartFiltersBtn = new PopupInteractiveDSFiltersLayout(this);
}

From source file:processes.SheetBarcodesReadyRunnable.java

License:Open Source License

private void attachDownloadToButton() {
    FileResource sheetSource = creator.createAndDLSheet(projectCode, projectName, investigator, contact,
            barcodeBeans, view.getHeaders());
    FileDownloader sheetDL = new FileDownloader(sheetSource);
    sheetDL.extend(view.getDownloadButton());
}

From source file:processes.TubeBarcodesReadyRunnable.java

License:Open Source License

private void attachDownloadToButton() {
    FileResource pdfSource = creator.zipAndDownloadBarcodes(barcodeBeans);
    FileDownloader pdfDL = new FileDownloader(pdfSource);
    pdfDL.extend(view.getDownloadButton());
}

From source file:qbic.vaadincomponents.TSVDownloadComponent.java

License:Open Source License

protected void armDownloadButton(Button b, StreamResource stream, int dlnum) {
    if (downloaders.size() < dlnum) {
        FileDownloader dl = new FileDownloader(stream);
        dl.extend(b);/*ww w  .j av a 2s.c  om*/
        downloaders.add(dl);
    } else
        downloaders.get(dlnum - 1).setFileDownloadResource(stream);
    b.setEnabled(true);
}

From source file:roart.client.MyVaadinUI.java

void addListTable(VerticalLayout ts, List<ResultItem> strarr) {
    if (strarr.size() <= 1) {
        return;/*  w  w  w .ja  va 2s.co  m*/
    }

    SearchDisplay display = SearchService.getSearchDisplay(getCurrent());
    boolean dodownload = (boolean) getSession().getAttribute("download");

    Table table = new Table("Table");
    table.setWidth("90%");
    int columns = strarr.get(0).get().size();
    for (int i = 0; i < strarr.size(); i++) {
        if (strarr.get(i).get().size() != columns) {
            System.out.println("column differs " + columns + " found " + strarr.get(i).get().size());
            break;
        }
    }
    for (int i = 0; i < columns; i++) {
        if (display.highlightmlt && i == IndexFiles.HIGHLIGHTMLTCOLUMN
                && strarr.get(0).get().get(IndexFiles.HIGHLIGHTMLTCOLUMN).equals("Highlight and similar")) {
            table.addContainerProperty(strarr.get(0).get().get(i), Button.class, null);
            continue;
        }
        table.addContainerProperty(strarr.get(0).get().get(i), String.class, null);
    }
    if (dodownload) {
        if (columns > IndexFiles.FILENAMECOLUMN
                && strarr.get(0).get().get(IndexFiles.FILENAMECOLUMN).equals("Filename")) {
            table.addGeneratedColumn("Download", new ColumnGenerator() {
                @Override
                public Object generateCell(Table source, Object itemId, Object columnId) {
                    String nodename = (String) source.getItem(itemId).getItemProperty("Node").getValue();
                    String filename = (String) source.getItem(itemId).getItemProperty("Filename").getValue();
                    if (nodename != null && !nodename.equals(ControlService.nodename)) {
                        return null;
                    }
                    if (filename == null) {
                        return null;
                    }
                    if (false) {
                        return null;
                    }
                    final FileObject fo = FileSystemDao.get(filename);
                    if (filename.startsWith(FileSystemDao.FILE) || filename.startsWith(FileSystemDao.HDFS)) {
                        filename = filename.substring(5);
                    }
                    int i = filename.lastIndexOf("/");
                    String fn = filename.substring(i + 1);
                    StreamResource resource = new StreamResource(new StreamSource() {
                        @Override
                        public InputStream getStream() {
                            try {
                                return FileSystemDao.getInputStream(fo);
                            } catch (Exception e) {
                                log.error(Constants.EXCEPTION, e);
                                return null;
                            }
                        }
                    }, fn);
                    //FileResource resource = new FileResource(new File(filename));
                    Button button = new Button("Download");
                    button.setStyleName(BaseTheme.BUTTON_LINK);
                    FileDownloader downloader = new FileDownloader(resource);
                    downloader.extend(button);
                    return button;
                }
            });
        }
    }
    for (int i = 1; i < strarr.size(); i++) {
        ResultItem str = strarr.get(i);
        if (display.highlightmlt && columns > IndexFiles.HIGHLIGHTMLTCOLUMN
                && strarr.get(0).get().get(IndexFiles.HIGHLIGHTMLTCOLUMN).equals("Highlight and similar")) {
            String text = (String) str.get().get(IndexFiles.HIGHLIGHTMLTCOLUMN);
            if (text != null) {
                String md5 = (String) str.get().get(1);
                str.get().set(IndexFiles.HIGHLIGHTMLTCOLUMN, getSimilar(text, md5));
            }
        }
        table.addItem(str.getarr(), i);
    }
    //table.setPageLength(table.size());
    ts.addComponent(table);
}

From source file:ui.button.ViewCVButton.java

License:Apache License

@Override
public void buttonClick(ClickEvent event) {
    PdfUtility pdfUtility = new PdfUtility(userId, language, new DescendingStartComparator(), null, null);
    pdfUtility.createPdf();/*from   w w w.  j a v  a2 s  .  co m*/
    StreamResource streamResource = pdfUtility.getStreamResource();
    FileDownloader downloader = new FileDownloader(streamResource);
    downloader.extend(this);
}

From source file:ui.window.PdfWindow.java

public PdfWindow(Integer userId, String language) {
    setCaption("Save CV");
    setSizeFull();/*from w  w  w  .  j ava2s.  c  o m*/
    setResizable(true);
    setWidth("25%");
    setHeight("25%");
    center();
    PdfUtility pdfUtility = new PdfUtility(userId, language, new DescendingEndComparator(), null, new Date());
    pdfUtility.createPdf();
    StreamResource streamResource = pdfUtility.getStreamResource();
    FileDownloader downloader = new FileDownloader(streamResource);
    LifetimeButtonLink downloadButton = new LifetimeButtonLink("Save CV", FontAwesome.SAVE);
    downloader.extend(downloadButton);
    // Here we create a new StreamResource which downloads our StreamSource,
    // which is our pdf.
    setContent(downloadButton);
}