List of usage examples for com.vaadin.server FileDownloader extend
public void extend(EventTrigger eventTrigger)
From source file:org.apache.openaz.xacml.admin.components.PolicyEditor.java
License:Apache License
protected void initializeDownload() { ///*from ww w. j a v a 2 s .co m*/ // Create a stream resource pointing to the file // StreamResource r = new StreamResource(new StreamResource.StreamSource() { private static final long serialVersionUID = 1L; @Override public InputStream getStream() { try { return new FileInputStream(self.file); } catch (Exception e) { logger.error("Failed to open input stream " + self.file); } return null; } }, self.file.getName()); r.setCacheTime(-1); r.setMIMEType("application/xml"); // // Extend a downloader to attach to the Export Button // FileDownloader downloader = new FileDownloader(r); downloader.extend(this.buttonExport); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.MappingConfigurationPanel.java
License:BSD License
/** * Helper method to initialise this object. *///ww w . j a va 2 s. c o m @SuppressWarnings("serial") protected void init() { layout = new GridLayout(5, 6); layout.setSpacing(true); layout.setMargin(true); layout.setWidth("100%"); this.addStyleName(ValoTheme.PANEL_BORDERLESS); paramQueriesLayout = new VerticalLayout(); toolBarLayout = new HorizontalLayout(); toolBarLayout.setWidth("100%"); Button linkButton = new Button(); linkButton.setIcon(VaadinIcons.REPLY_ALL); linkButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); linkButton.setDescription("Return to search results"); linkButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); linkButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Navigator navigator = new Navigator(UI.getCurrent(), menuLayout.getContentContainer()); for (IkasanUIView view : topLevelNavigator.getIkasanViews()) { navigator.addView(view.getPath(), view.getView()); } saveRequiredMonitor.manageSaveRequired("mappingView"); navigator = new Navigator(UI.getCurrent(), mappingNavigator.getContainer()); for (IkasanUIView view : mappingNavigator.getIkasanViews()) { navigator.addView(view.getPath(), view.getView()); } } }); toolBarLayout.addComponent(linkButton); toolBarLayout.setExpandRatio(linkButton, 0.865f); this.editButton.setIcon(VaadinIcons.EDIT); this.editButton.setDescription("Edit the mapping configuration"); this.editButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.editButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.editButton.setVisible(false); this.editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { setEditable(true); mappingConfigurationFunctionalGroup.editButtonPressed(); } }); toolBarLayout.addComponent(this.editButton); toolBarLayout.setExpandRatio(this.editButton, 0.045f); this.saveButton.setIcon(VaadinIcons.HARDDRIVE); this.saveButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.saveButton.setDescription("Save the mapping configuration"); this.saveButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.saveButton.setVisible(false); this.saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { logger.info("Save button clicked!!"); save(); setEditable(false); Notification.show("Changes Saved!", "", Notification.Type.HUMANIZED_MESSAGE); mappingConfigurationFunctionalGroup.saveOrCancelButtonPressed(); } catch (InvalidValueException e) { // We can ignore this one as we have already dealt with the // validation messages using the validation framework. } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Cauget exception trying to save a Mapping Configuration!", sw.toString(), Notification.Type.ERROR_MESSAGE); } } }); toolBarLayout.addComponent(this.saveButton); toolBarLayout.setExpandRatio(this.saveButton, 0.045f); this.cancelButton.setIcon(VaadinIcons.CLOSE_CIRCLE); this.cancelButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.cancelButton.setDescription("Cancel the current edit"); this.cancelButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.cancelButton.setVisible(false); this.cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { setEditable(false); mappingConfigurationFunctionalGroup.saveOrCancelButtonPressed(); Navigator navigator = new Navigator(UI.getCurrent(), menuLayout.getContentContainer()); for (IkasanUIView view : topLevelNavigator.getIkasanViews()) { navigator.addView(view.getPath(), view.getView()); } saveRequiredMonitor.manageSaveRequired("mappingView"); navigator = new Navigator(UI.getCurrent(), mappingNavigator.getContainer()); for (IkasanUIView view : mappingNavigator.getIkasanViews()) { navigator.addView(view.getPath(), view.getView()); } } }); toolBarLayout.addComponent(this.cancelButton); toolBarLayout.setExpandRatio(this.cancelButton, 0.045f); FileDownloader fd = new FileDownloader(this.getMappingConfigurationExportStream()); fd.extend(exportMappingConfigurationButton); this.exportMappingConfigurationButton.setIcon(VaadinIcons.DOWNLOAD_ALT); this.exportMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.exportMappingConfigurationButton.setDescription("Export the current mapping configuration"); this.exportMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); toolBarLayout.addComponent(this.exportMappingConfigurationButton); toolBarLayout.setExpandRatio(this.exportMappingConfigurationButton, 0.045f); final GridLayout contentLayout = new GridLayout(1, 2); contentLayout.setWidth("100%"); contentLayout.addComponent(toolBarLayout); contentLayout.addComponent(createMappingConfigurationForm()); VerticalSplitPanel vpanel = new VerticalSplitPanel(contentLayout, createTableLayout(false)); vpanel.setStyleName(ValoTheme.SPLITPANEL_LARGE); paramQueriesLayout.setSpacing(true); Label configValueLabels = new Label("Source Configuration Value Queries:"); layout.addComponent(configValueLabels, 2, 2, 3, 2); Panel queryParamsPanel = new Panel(); queryParamsPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); queryParamsPanel.setHeight(100, Unit.PIXELS); queryParamsPanel.setWidth(100, Unit.PERCENTAGE); queryParamsPanel.setContent(paramQueriesLayout); this.layout.addComponent(queryParamsPanel, 2, 3, 3, 5); vpanel.setSplitPosition(325, Unit.PIXELS); this.setContent(vpanel); this.setSizeFull(); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.MappingConfigurationPanel.java
License:BSD License
/** * Helper method to create the layout of the table. * //from w w w .java 2 s.c o m * @param buttonsVisible are the buttons visible? * * @return the Layout associated with the table. */ protected Layout createTableLayout(boolean buttonsVisible) { VerticalLayout tableLayout = new VerticalLayout(); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); this.addNewRecordButton.setIcon(VaadinIcons.PLUS); this.addNewRecordButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.addNewRecordButton.setDescription("Add a mapping configuration value to the table below"); this.addNewRecordButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.addNewRecordButton.setVisible(buttonsVisible); this.addNewRecordButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { saveRequiredMonitor.setSaveRequired(true); try { mappingConfigurationFunctionalGroup.editButtonPressed(); mappingConfigurationConfigurationValuesTable.addNewRecord(); } catch (MappingConfigurationServiceException e) { e.printStackTrace(); } } }); final RemoveAllItemsAction removeAllItemsAction = new RemoveAllItemsAction( this.mappingConfigurationConfigurationValuesTable); this.deleteAllRecordsButton.setIcon(VaadinIcons.TRASH); this.deleteAllRecordsButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.deleteAllRecordsButton.setDescription("Delete all values from the table below"); this.deleteAllRecordsButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.deleteAllRecordsButton.setVisible(buttonsVisible); this.deleteAllRecordsButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { IkasanMessageDialog dialog = new IkasanMessageDialog("Delete all records!", "This action will delete all source and target mapping configurations " + "from the database. Are you sure you would like to proceed?", removeAllItemsAction); UI.getCurrent().addWindow(dialog); } }); this.importMappingConfigurationButton.setIcon(VaadinIcons.UPLOAD_ALT); this.importMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.importMappingConfigurationButton.setDescription("Import mapping configuration values"); this.importMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.importMappingConfigurationButton.setVisible(buttonsVisible); this.importMappingConfigurationButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { MappingConfigurationValuesImportWindow dialog = new MappingConfigurationValuesImportWindow( mappingConfigurationService, mappingConfiguration, mappingConfigurationConfigurationValuesTable, systemEventService); UI.getCurrent().addWindow(dialog); } }); this.exportMappingConfigurationValuesButton.setIcon(VaadinIcons.DOWNLOAD_ALT); this.exportMappingConfigurationValuesButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.exportMappingConfigurationValuesButton.setDescription("Export mapping configuration values"); this.exportMappingConfigurationValuesButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.exportMappingConfigurationValuesButton.setVisible(buttonsVisible); FileDownloader fd = new FileDownloader(this.getMappingConfigurationValuesExportStream()); fd.extend(exportMappingConfigurationValuesButton); Label spacer = new Label(" ", ContentMode.HTML); controlsLayout.addComponent(spacer); controlsLayout.setExpandRatio(spacer, 0.84f); controlsLayout.addComponent(this.addNewRecordButton); controlsLayout.setExpandRatio(this.addNewRecordButton, 0.04f); controlsLayout.addComponent(this.deleteAllRecordsButton); controlsLayout.setExpandRatio(this.deleteAllRecordsButton, 0.04f); controlsLayout.addComponent(this.importMappingConfigurationButton); controlsLayout.setExpandRatio(this.importMappingConfigurationButton, 0.04f); controlsLayout.addComponent(this.exportMappingConfigurationValuesButton); controlsLayout.setExpandRatio(this.exportMappingConfigurationValuesButton, 0.04f); tableLayout.addComponent(controlsLayout); tableLayout.addComponent(this.mappingConfigurationConfigurationValuesTable); return tableLayout; }
From source file:org.jumpmind.metl.ui.views.admin.LoggingPanel.java
License:Open Source License
public LoggingPanel(ApplicationContext context, TabbedPanel tabbedPanel) { this.context = context; this.tabbedPanel = tabbedPanel; this.backgroundRefresherService = context.getBackgroundRefresherService(); if (LogUtils.isFileEnabled()) { logFile = new File(LogUtils.getLogFilePath()); }//w w w . j av a 2 s . co m setSizeFull(); setSpacing(true); setMargin(true); HorizontalLayout topPanelLayout = new HorizontalLayout(); topPanelLayout.setWidth(100, Unit.PERCENTAGE); topPanelLayout.setSpacing(true); Button refreshButton = new Button("Refresh"); refreshButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { refresh(); } }); topPanelLayout.addComponent(refreshButton); topPanelLayout.setComponentAlignment(refreshButton, Alignment.BOTTOM_LEFT); bufferSize = new TextField(); bufferSize.setImmediate(true); bufferSize.setWidth(5, Unit.EM); bufferSize.setValue("1000"); bufferSize.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { refresh(); } }); topPanelLayout.addComponent(bufferSize); filter = new TextField(); filter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); filter.setInputPrompt("Filter"); filter.setIcon(FontAwesome.SEARCH); filter.setNullRepresentation(""); filter.setImmediate(true); filter.setTextChangeEventMode(TextChangeEventMode.LAZY); filter.setTextChangeTimeout(200); filter.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { refresh(); } }); topPanelLayout.addComponent(filter); topPanelLayout.setComponentAlignment(filter, Alignment.BOTTOM_LEFT); autoRefreshOn = new CheckBox("Auto Refresh"); autoRefreshOn.setValue(true); autoRefreshOn.setImmediate(true); topPanelLayout.addComponent(autoRefreshOn); topPanelLayout.setComponentAlignment(autoRefreshOn, Alignment.BOTTOM_LEFT); Label spacer = new Label(); topPanelLayout.addComponent(spacer); topPanelLayout.setExpandRatio(spacer, 1); if (logFile != null && logFile.exists()) { Button downloadButton = new Button("Download log file"); downloadButton.addStyleName(ValoTheme.BUTTON_LINK); downloadButton.addStyleName(ValoTheme.BUTTON_SMALL); FileDownloader fileDownloader = new FileDownloader(getLogFileResource()); fileDownloader.extend(downloadButton); topPanelLayout.addComponent(downloadButton); topPanelLayout.setComponentAlignment(downloadButton, Alignment.BOTTOM_RIGHT); } addComponent(topPanelLayout); logPanel = new Panel("Log Output"); logPanel.setSizeFull(); logView = new Label("", ContentMode.HTML); logView.setSizeUndefined(); logPanel.setContent(logView); addComponent(logPanel); setExpandRatio(logPanel, 1); refresh(); backgroundRefresherService.register(this); }
From source file:org.jumpmind.metl.ui.views.ExploreDirectoryView.java
License:Open Source License
protected Component fileLinkComponent(Table source, Object itemId, Object propertyId) { if (itemId instanceof FileInfo) { final FileInfo file = (FileInfo) itemId; if (!file.isDirectory()) { final Button button = new Button(file.getName()); button.addStyleName(ValoTheme.BUTTON_LINK); button.addStyleName(ValoTheme.BUTTON_SMALL); button.setIcon(FontAwesome.FILE); StreamResource resource = new StreamResource(() -> stream(file), file.getName()); FileDownloader fileDownloader = new FileDownloader(resource); fileDownloader.extend(button); return button; } else {/* ww w .j a v a 2 s . c o m*/ return new Label(file.getName()); } } else { return new Label(((DirectoryResource) itemId).getName()); } }
From source file:org.jumpmind.vaadin.ui.common.ReadOnlyTextAreaDialog.java
License:Open Source License
private void buildDownloadButton(String title) { downloadButton = new Button("Download"); final byte[] lobData = getLobData(title); if (lobData != null) { Resource resource = new StreamResource(new StreamSource() { private static final long serialVersionUID = 1L; public InputStream getStream() { return new ByteArrayInputStream(lobData); }/*from w w w .j a v a2 s .c om*/ }, title); FileDownloader fileDownloader = new FileDownloader(resource); fileDownloader.extend(downloadButton); buttonLayout.addComponent(downloadButton); buttonLayout.setComponentAlignment(downloadButton, Alignment.BOTTOM_CENTER); long fileSize = lobData.length; String sizeText = fileSize + " Bytes"; if (fileSize / 1024 > 0) { sizeText = Math.round(fileSize / 1024.0) + " kB"; fileSize /= 1024; } if (fileSize / 1024 > 0) { sizeText = Math.round(fileSize / 1024.0) + " MB"; fileSize /= 1024; } if (fileSize / 1024 > 0) { sizeText = Math.round(fileSize / 1024.0) + " GB"; } Label sizeLabel = new Label(sizeText); buttonLayout.addComponent(sizeLabel); buttonLayout.setExpandRatio(sizeLabel, 1.0f); buttonLayout.setComponentAlignment(sizeLabel, Alignment.BOTTOM_CENTER); } }
From source file:org.lunifera.vaaclipse.ui.preferences.addon.internal.impexp.ExportPreferences.java
License:Open Source License
@SuppressWarnings("restriction") @Override/*from ww w .ja v a 2 s . c om*/ protected void doAction() { // dlg.close(); List<PreferencesPage> selectedPages = getSelectedPages(); if (selectedPages.isEmpty()) { setStatusText("Preferences doesn't selected. Please select preferences above."); return; } IEclipsePreferences root = PreferencesService.getDefault().getRootNode(); ByteArrayOutputStream baos = new ByteArrayOutputStream(200); try { PreferencesService.getDefault().exportPreferences(root, new IPreferenceFilter[] { createFilter(selectedPages) }, baos); } catch (CoreException e) { logger.error("Exception when export preferences", e); return; } preferencesBytes = baos.toByteArray(); StringBuffer exportedPrefNames = toTextWithCatName(selectedPages); setStatusText("Preferences was exported: " + exportedPrefNames.toString()); if (downloadButton == null) { downloadButton = new Button(BaseTheme.BUTTON_LINK); downloadButton.addStyleName("download-button"); downloadButton.setCaption("Download preferences.epf"); layout.addComponent(downloadButton); FileDownloader fileDownloader = new FileDownloader(createResource()); fileDownloader.extend(downloadButton); } }
From source file:pl.exsio.ca.module.terrain.evidence.FilesDataTable.java
License:Open Source License
protected void addDownloadButtonColumn() { dataComponent.addGeneratedColumn("", new Table.ColumnGenerator() { @Override/*from w w w . j a v a2s . co m*/ 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 ww.ja va2 s . com 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 www . j a v a 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); }