List of usage examples for com.vaadin.server FileDownloader FileDownloader
public FileDownloader(Resource resource)
From source file:de.uni_tuebingen.qbic.qbicmainportlet.HomeView.java
License:Open Source License
private void setExportButton() { buttonLayoutSection.removeAllComponents(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight(null);//from w ww . j ava 2s. c om buttonLayout.setWidth("100%"); buttonLayoutSection.addComponent(buttonLayout); buttonLayout.addComponent(this.export); StreamResource sr = Utils.getTSVStream(Utils.containerToString(currentBean.getProjects()), "project_overview"); FileDownloader fileDownloader = new FileDownloader(sr); fileDownloader.extend(this.export); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.LevelComponent.java
License:Open Source License
public void updateUI(String type, String id, String filterFor) { sampleGrid = new Grid(); typeString = type;/*w w w. j ava 2 s .c o m*/ idString = id; filterString = filterFor; if (id == null) return; try { HierarchicalContainer datasetContainer = new HierarchicalContainer(); datasetContainer.addContainerProperty("Select", CheckBox.class, null); datasetContainer.addContainerProperty("Project", String.class, null); datasetContainer.addContainerProperty("Sample", String.class, null); datasetContainer.addContainerProperty("Description", String.class, null); // datasetContainer.addContainerProperty("Sample Type", String.class, null); datasetContainer.addContainerProperty("File Name", String.class, null); datasetContainer.addContainerProperty("File Type", String.class, null); datasetContainer.addContainerProperty("Dataset Type", String.class, null); datasetContainer.addContainerProperty("Registration Date", String.class, null); datasetContainer.addContainerProperty("Validated", Boolean.class, null); datasetContainer.addContainerProperty("File Size", String.class, null); datasetContainer.addContainerProperty("file_size_bytes", Long.class, null); datasetContainer.addContainerProperty("dl_link", String.class, null); datasetContainer.addContainerProperty("isDirectory", Boolean.class, null); datasetContainer.addContainerProperty("CODE", String.class, null); List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> retrievedDatasetsAll = null; List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> retrievedDatasets = new ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>(); Map<String, ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>> datasetFilter = new HashMap<String, ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>>(); // clear download queue for new view PortletSession portletSession = ((QbicmainportletUI) UI.getCurrent()).getPortletSession(); portletSession.setAttribute("qbic_download", new HashMap<String, AbstractMap.SimpleEntry<String, Long>>(), PortletSession.APPLICATION_SCOPE); Map<String, Sample> checkedTestSamples = new HashMap<String, Sample>(); switch (type) { case "project": String projectIdentifier = id; retrievedDatasetsAll = datahandler.getOpenBisClient() .getDataSetsOfProjectByIdentifierWithSearchCriteria(projectIdentifier); for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet ds : retrievedDatasetsAll) { ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> values = datasetFilter .get(ds.getSampleIdentifierOrNull()); if (values == null) { values = new ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>(); datasetFilter.put(ds.getSampleIdentifierOrNull(), values); } values.add(ds); } if (filterFor.equals("measured")) { BeanItemContainer<TestSampleBean> samplesContainer = new BeanItemContainer<TestSampleBean>( TestSampleBean.class); // List<Sample> allSamples = // datahandler.getOpenBisClient() // .getSamplesOfProjectBySearchService(projectIdentifier); List<Sample> allSamples = datahandler.getOpenBisClient() .getSamplesWithParentsAndChildrenOfProjectBySearchService(id); for (Sample sample : allSamples) { checkedTestSamples.put(sample.getCode(), sample); if (sample.getSampleTypeCode().equals("Q_TEST_SAMPLE")) { // samplesContainer.addBean(new SampleBean(sample.getIdentifier(), sample.getCode(), // sample.getSampleTypeCode(), null, null, null, sample.getProperties(), null, // null)); Map<String, String> sampleProperties = sample.getProperties(); TestSampleBean newBean = new TestSampleBean(); newBean.setCode(sample.getCode()); newBean.setId(sample.getIdentifier()); newBean.setType(sample.getSampleTypeCode()); newBean.setSampleType(sampleProperties.get("Q_SAMPLE_TYPE")); newBean.setAdditionalInfo(sampleProperties.get("Q_ADDITIONAL_INFO")); newBean.setExternalDB(sampleProperties.get("Q_EXTERNALDB_ID")); newBean.setSecondaryName(sampleProperties.get("Q_SECONDARY_NAME")); newBean.setProperties(sampleProperties); samplesContainer.addBean(newBean); ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> foundDataset = datasetFilter .get(sample.getIdentifier()); if (foundDataset != null) { retrievedDatasets.addAll(foundDataset); } for (Sample child : sample.getChildren()) { foundDataset = datasetFilter.get(child.getIdentifier()); if (foundDataset != null) { retrievedDatasets.addAll(foundDataset); } } } else if (sample.getSampleTypeCode().equals("Q_MHC_LIGAND_EXTRACT")) { // samplesContainer.addBean(new SampleBean(sample.getIdentifier(), sample.getCode(), // sample.getSampleTypeCode(), null, null, null, sample.getProperties(), null, // null)); Map<String, String> sampleProperties = sample.getProperties(); TestSampleBean newBean = new TestSampleBean(); newBean.setCode(sample.getCode()); newBean.setId(sample.getIdentifier()); newBean.setType(sample.getSampleTypeCode()); newBean.setSampleType(sampleProperties.get("Q_MHC_CLASS")); newBean.setAdditionalInfo(sampleProperties.get("Q_ANTIBODY")); newBean.setExternalDB(sampleProperties.get("Q_EXTERNALDB_ID")); newBean.setSecondaryName(sampleProperties.get("Q_SECONDARY_NAME")); newBean.setProperties(sampleProperties); samplesContainer.addBean(newBean); ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> foundDataset = datasetFilter .get(sample.getIdentifier()); if (foundDataset != null) { retrievedDatasets.addAll(foundDataset); } for (Sample child : sample.getChildren()) { foundDataset = datasetFilter.get(child.getIdentifier()); if (foundDataset != null) { retrievedDatasets.addAll(foundDataset); } } } } numberOfSamples = samplesContainer.size(); samples = samplesContainer; final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(samples); gpc.removeContainerProperty("id"); gpc.removeContainerProperty("type"); sampleGrid.setContainerDataSource(gpc); sampleGrid.setColumnReorderingAllowed(true); gpc.addGeneratedProperty("edit", new PropertyValueGenerator<String>() { @Override public String getValue(Item item, Object itemId, Object propertyId) { return "Edit"; } @Override public Class<String> getType() { return String.class; } }); sampleGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { BeanItem selected = (BeanItem) samples.getItem(event.getItemId()); TestSampleBean selectedExp = (TestSampleBean) selected.getBean(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(selectedExp.getId()); message.add("sample"); state.notifyObservers(message); } }); sampleGrid.getColumn("edit").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { BeanItem selected = (BeanItem) samples.getItem(event.getItemId()); TestSampleBean selectedSample = (TestSampleBean) selected.getBean(); Window subWindow = new Window("Edit Metadata"); changeMetadata.updateUI(selectedSample.getId(), selectedSample.getType()); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.addComponent(changeMetadata); subWindow.setContent(subContent); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setIcon(FontAwesome.PENCIL); subWindow.setHeight("75%"); subWindow.setResizable(false); subWindow.addCloseListener(new CloseListener() { /** * */ private static final long serialVersionUID = -1329152609834711109L; @Override public void windowClose(CloseEvent e) { updateUI(typeString, idString, filterString); } }); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(subWindow); } })); sampleGrid.getColumn("edit").setHeaderCaption(""); sampleGrid.getColumn("edit").setWidth(70); sampleGrid.setColumnOrder("edit", "secondaryName", "sampleType", "code", "properties", "additionalInfo", "externalDB"); helpers.GridFunctions.addColumnFilters(sampleGrid, gpc); numberOfSamples = samplesContainer.size(); sampleGrid.setCaption("Measured Samples"); this.datasetTable.setCaption("Raw Data"); numberOfDatasets = retrievedDatasets.size(); this.datasetTable.setPageLength(Math.max(3, Math.min(numberOfDatasets, 10))); // sampleGrid.setHeightMode(HeightMode.ROW); // sampleGrid.setHeightByRows(numberOfSamples); } else if (filterFor.equals("results")) { BeanItemContainer<TestSampleBean> samplesContainer = new BeanItemContainer<TestSampleBean>( TestSampleBean.class); List<Sample> allSamples = datahandler.getOpenBisClient() .getSamplesWithParentsAndChildrenOfProjectBySearchService(projectIdentifier); for (Sample sample : allSamples) { checkedTestSamples.put(sample.getCode(), sample); if (!sample.getSampleTypeCode().equals("Q_TEST_SAMPLE") && !sample.getSampleTypeCode().equals("Q_MICROARRAY_RUN") && !sample.getSampleTypeCode().equals("Q_MS_RUN") && !sample.getSampleTypeCode().equals("Q_BIOLOGICAL_SAMPLE") && !sample.getSampleTypeCode().equals("Q_BIOLOGICAL_ENTITY") && !sample.getSampleTypeCode().equals("Q_NGS_SINGLE_SAMPLE_RUN")) { Map<String, String> sampleProperties = sample.getProperties(); TestSampleBean newBean = new TestSampleBean(); newBean.setCode(sample.getCode()); newBean.setId(sample.getIdentifier()); newBean.setType(prettyNameMapper.getPrettyName(sample.getSampleTypeCode())); newBean.setAdditionalInfo(sampleProperties.get("Q_ADDITIONAL_INFO")); newBean.setSecondaryName(sampleProperties.get("Q_SECONDARY_NAME")); newBean.setProperties(sampleProperties); samplesContainer.addBean(newBean); ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> foundDataset = datasetFilter .get(sample.getIdentifier()); if (foundDataset != null) { for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet ds : foundDataset) { // we don't want to show project data or log files in the results tab if (ds.getDataSetTypeCode().equals("Q_PROJECT_DATA")) { if (ds.getProperties().get("Q_ATTACHMENT_TYPE").equals("INFORMATION")) { continue; } else { retrievedDatasets.add(ds); } } else if (ds.getDataSetTypeCode().contains("LOGS")) { continue; } else { retrievedDatasets.add(ds); } } // retrievedDatasets.addAll(foundDataset); } } } // numberOfSamples = samplesContainer.size(); samples = samplesContainer; final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(samples); gpc.removeContainerProperty("id"); gpc.removeContainerProperty("sampleType"); sampleGrid.setContainerDataSource(gpc); sampleGrid.setColumnReorderingAllowed(true); sampleGrid.setColumnOrder("secondaryName", "type", "code", "properties"); numberOfSamples = samplesContainer.size(); // sampleGrid.setHeightMode(HeightMode.ROW); // sampleGrid.setHeightByRows(numberOfSamples); sampleGrid.setCaption("Workflow Runs"); helpers.GridFunctions.addColumnFilters(sampleGrid, gpc); this.datasetTable.setCaption("Result Files"); datasetTable.setColumnHeader("Sample", "Workflow Run"); sampleGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { BeanItem selected = (BeanItem) samples.getItem(event.getItemId()); TestSampleBean selectedExp = (TestSampleBean) selected.getBean(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(selectedExp.getId()); message.add("sample"); state.notifyObservers(message); } }); numberOfDatasets = retrievedDatasets.size(); this.datasetTable.setPageLength(Math.max(3, Math.min(numberOfDatasets, 10))); } break; case "experiment": String experimentIdentifier = id; retrievedDatasets = datahandler.getOpenBisClient() .getDataSetsOfExperimentByCodeWithSearchCriteria(experimentIdentifier); break; case "sample": String sampleIdentifier = id; String sampleCode = sampleIdentifier.split("/")[2]; retrievedDatasets = datahandler.getOpenBisClient().getDataSetsOfSample(sampleCode); break; default: retrievedDatasets = new ArrayList<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet>(); break; } BeanItemContainer<DatasetBean> forExport = new BeanItemContainer(DatasetBean.class); numberOfDatasets = retrievedDatasets.size(); if (numberOfDatasets == 0 & filterFor.equals("measured")) { descriptionLabel = new Label(String.format( "This project contains %s measured samples for which %s raw data dataset(s) have been registered.", numberOfSamples, 0), ContentMode.HTML); helpers.Utils.Notification("No raw data available.", "No raw data is available for this project. Please contact the project manager if this is not expected.", "warning"); } else if (numberOfDatasets == 0 & filterFor.equals("results")) { descriptionLabel = new Label(String.format("This project contains %s result datasets.", 0), ContentMode.HTML); helpers.Utils.Notification("No results available.", "No result data is available for this project. Please contact the project manager if this is not expected.", "warning"); } else { Map<String, String> samples = new HashMap<String, String>(); // project same for all datasets String projectCode = retrievedDatasets.get(0).getExperimentIdentifier().split("/")[2]; for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet dataset : retrievedDatasets) { samples.put(dataset.getCode(), dataset.getSampleIdentifierOrNull().split("/")[2]); } List<DatasetBean> dsBeans = datahandler.queryDatasetsForFolderStructure(retrievedDatasets); for (DatasetBean d : dsBeans) { Date date = d.getRegistrationDate(); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd hh:mm a"); String dateString = sd.format(date); // Timestamp ts = Timestamp.valueOf(dateString); String sampleID = samples.get(d.getCode()); forExport.addBean(d); Sample dsSample = checkedTestSamples.get(sampleID); String secNameDS = d.getProperties().get("Q_SECONDARY_NAME"); String secName = datahandler.getSecondaryName(dsSample, secNameDS); registerDatasetInTable(d, datasetContainer, projectCode, sampleID, dateString, null, secName); } if (filterFor.equals("measured")) { descriptionLabel = new Label(String.format( "This project contains %s measured samples for which %s raw data dataset(s) have been registered.", numberOfSamples, dsBeans.size()), ContentMode.HTML); } else if (filterFor.equals("results")) { descriptionLabel = new Label( String.format("This project contains %s result datasets.", dsBeans.size()), ContentMode.HTML); } } this.setContainerDataSource(datasetContainer); if (fileDownloaderData != null) this.exportData.removeExtension(fileDownloaderData); StreamResource srData = Utils.getTSVStream(Utils.containerToString(forExport), String.format("%s_%s_", id.substring(1).replace("/", "_"), datasetTable.getCaption().replace(" ", "_"))); fileDownloaderData = new FileDownloader(srData); fileDownloaderData.extend(exportData); if (fileDownloaderSamples != null) this.exportSamples.removeExtension(fileDownloaderSamples); StreamResource srSamples = Utils.getTSVStream(Utils.containerToString(samples), String.format("%s_%s_", id.substring(1).replace("/", "_"), sampleGrid.getCaption().replaceAll(" ", "_"))); fileDownloaderSamples = new FileDownloader(srSamples); fileDownloaderSamples.extend(exportSamples); } catch (Exception e) { e.printStackTrace(); LOGGER.error(String.format("getting dataset failed for dataset %s %s", type, id), e.getStackTrace()); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java
License:Open Source License
void updateContentButtonLayout() { if (fileDownloader != null) this.export.removeExtension(fileDownloader); StreamResource sr = Utils.getTSVStream(Utils.containerToString(currentBean.getExperiments()), currentBean.getId());/*from ww w .ja v a 2 s .co m*/ fileDownloader = new FileDownloader(sr); fileDownloader.extend(this.export); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SampleView.java
License:Open Source License
void updateContentButtonLayout() { if (fileDownloader != null) this.export.removeExtension(fileDownloader); StreamResource sr = Utils.getTSVStream(Utils.containerToString(currentBean.getDatasets()), currentBean.getId());// w w w . j av a2s .c o m fileDownloader = new FileDownloader(sr); fileDownloader.extend(this.export); }
From source file:dhbw.clippinggorilla.userinterface.views.DocumentsView.java
private Component generateLine(Path file, GridLayout layout) { Label fileName = new Label(file.getFileName().toString()); layout.addComponent(fileName);//w w w . j a va 2 s.c om layout.setComponentAlignment(fileName, Alignment.MIDDLE_LEFT); Button downloadButton = new Button(); downloadButton.setIcon(VaadinIcons.DOWNLOAD); FileDownloader downloader = new FileDownloader(new FileResource(file.toFile())); downloader.extend(downloadButton); layout.addComponent(downloadButton); layout.setComponentAlignment(downloadButton, Alignment.MIDDLE_CENTER); if (file.getFileName().toString().endsWith("pdf")) { Button viewButton = new Button(); viewButton.setIcon(VaadinIcons.EYE); viewButton.addClickListener(ce -> UI.getCurrent().addWindow(PDFWindow.get(file))); layout.addComponent(viewButton); layout.setComponentAlignment(viewButton, Alignment.MIDDLE_CENTER); } else { layout.addComponent(new Label(" ")); } return layout; }
From source file:edu.kit.dama.ui.admin.LandingPageComponent.java
License:Apache License
public final void update(DigitalObject object, boolean privileged) { if (object == null) { UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(1, 1); builder.fill(new Label("Access to digital object not permitted."), 0, 0); mainLayout = builder.getLayout(); mainLayout.setMargin(true);/*from w ww . j a v a2 s . c o m*/ mainLayout.setSpacing(true); mainLayout.setStyleName("landing"); HorizontalLayout hLayout = new HorizontalLayout(mainLayout); hLayout.setSizeFull(); hLayout.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(hLayout); } else { final TextField oidField = new TextField(); Button searchButton = new Button("Search"); Button metsButton = new Button("METS"); final Button dcButton = new Button("DublinCore"); Button dataButton = new Button("Download"); VerticalLayout metadataDownloadButtons = new VerticalLayout(dcButton, metsButton); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(3, 6); StreamResource metsResource = new StreamResource(() -> { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); MetsBuilder.init(object).createMinimalMetsDocument(UserData.WORLD_USER).write(bout); return new ByteArrayInputStream(bout.toByteArray()); } catch (Exception ex) { LOGGER.error("Failed to provide METS document.", ex); UIComponentTools.showError( "Failed to initialize METS document for download. Cause: " + ex.getMessage()); return null; } }, object.getDigitalObjectIdentifier() + ".mets.xml"); StreamResource dcResource = new StreamResource(() -> { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DublinCoreHelper.writeDublinCoreDocument(object, UserData.WORLD_USER, bout); return new ByteArrayInputStream(bout.toByteArray()); } catch (ParserConfigurationException ex) { LOGGER.error("Failed to provide DC document.", ex); UIComponentTools .showError("Failed to initialize DC document for download. Cause: " + ex.getMessage()); return null; } }, object.getDigitalObjectIdentifier() + ".dc.xml"); StreamResource dataResource = new StreamResource(() -> { IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager(); mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext()); try { IAuthorizationContext ctx = new AuthorizationContext(new UserId(Constants.WORLD_USER_ID), new GroupId(Constants.WORLD_USER_ID), Role.GUEST); if (accessGranted(object, ctx) || accessGranted(object, UIHelper.getSessionContext())) { Response response = new PublicDownloadHandler().prepareStream(object); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return (InputStream) response.getEntity(); } else { LOGGER.error("Preparation of the public download for object " + object.getDigitalObjectIdentifier() + " returned status " + response.getStatus() + ". Aborting."); } } throw new IOException("Public access not available."); } catch (IOException ex) { LOGGER.error( "Failed to provide data stream for object " + object.getDigitalObjectIdentifier() + ".", ex); UIComponentTools.showError( "Failed to initialize data stream for public download. Probably, the digital object is not publicly available."); return null; } }, object.getDigitalObjectIdentifier() + ".zip"); Map<String, String> dcElementMap = new HashMap<>(); try { dcElementMap = DublinCoreHelper.createDublinCoreElementMap(object, UserData.WORLD_USER); } catch (ParserConfigurationException ex) { LOGGER.error( "Failed to create DC metadata for object with id " + object.getDigitalObjectIdentifier(), ex); } oidField.setValue(object.getDigitalObjectIdentifier()); FileDownloader metsDownloader = new FileDownloader(metsResource); metsDownloader.extend(metsButton); FileDownloader dcDownloader = new FileDownloader(dcResource); dcDownloader.extend(dcButton); FileDownloader dataDownloader = new FileDownloader(dataResource); dataDownloader.extend(dataButton); oidField.setSizeFull(); searchButton.setWidth("128px"); searchButton.addClickListener((Button.ClickEvent event) -> { String oid = oidField.getValue(); Page.getCurrent().setLocation( URI.create(UIHelper.getWebAppUrl().toString() + "?landing&oid=" + oid).toString()); }); dcButton.setWidth("128px"); metsButton.setWidth("128px"); dataButton.setWidth("128px"); metadataDownloadButtons.setComponentAlignment(dcButton, Alignment.TOP_LEFT); metadataDownloadButtons.setComponentAlignment(metsButton, Alignment.TOP_LEFT); //build layout Label oidLabel = new Label("<u>Object Id</u>", ContentMode.HTML); builder.fillRow(oidLabel, 0, 0, 1); oidLabel.addStyleName("myboldcaption"); builder.addComponent(oidField, 0, 1, 2, 1).addComponent(searchButton, 2, 1); Label dcMetadataLabel = new Label("<u>DC Metadata</u>", ContentMode.HTML); builder.fillRow(dcMetadataLabel, 0, 2, 1); dcMetadataLabel.addStyleName("myboldcaption"); Set<Map.Entry<String, String>> entries = dcElementMap.entrySet(); Table dcTable = new Table(); dcTable.setPageLength(entries.size() + 1); dcTable.addContainerProperty("dc:key", String.class, "-"); dcTable.addContainerProperty("dc:value", String.class, "-"); entries.forEach((entry) -> { Object newItemId = dcTable.addItem(); Item row1 = dcTable.getItem(newItemId); row1.getItemProperty("dc:key").setValue(entry.getKey()); row1.getItemProperty("dc:value").setValue(entry.getValue()); }); dcTable.setWidth("640px"); dcTable.addStyleName("myboldcaption"); builder.addComponent(dcTable, 0, 3, 2, 1); builder.addComponent(metadataDownloadButtons, 2, 3, 1, 1); builder.fillRow(new Label("<u>Data Access</u>", ContentMode.HTML), 0, 4, 1); long bytes = DataOrganizationUtils.getAssociatedDataSize(object.getDigitalObjectId()); String formatted = AbstractFile.formatSize(bytes); Label oidDownloadLabel = new Label( object.getDigitalObjectIdentifier() + ".zip (approx. " + formatted + ")"); oidDownloadLabel.addStyleName("myboldcaption"); builder.addComponent(oidDownloadLabel, 0, 5, 2, 1); builder.addComponent(dataButton, 2, 5, 1, 1); mainLayout = builder.getLayout(); mainLayout.setRowExpandRatio(0, .1f); mainLayout.setRowExpandRatio(1, .1f); mainLayout.setRowExpandRatio(2, .6f); mainLayout.setRowExpandRatio(3, .1f); mainLayout.setRowExpandRatio(4, .1f); mainLayout.setColumnExpandRatio(0, .1f); mainLayout.setColumnExpandRatio(1, .8f); mainLayout.setColumnExpandRatio(2, .1f); } mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setStyleName("landing"); HorizontalLayout hLayout = new HorizontalLayout(mainLayout); hLayout.setSizeFull(); hLayout.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(hLayout); }
From source file:edu.kit.dama.ui.repo.components.EntryRenderPanel.java
License:Apache License
/** * Setup the download button for download-mode. The button click will be * linked to a download of the zipped version of the digital object's data. * If no data is available/accessible, the button will be disabled. *//*from w w w. j av a 2s. c o m*/ private void setupDownloadButton() { boolean haveDownload = false; try { //obtain the zip file node IFileNode zipNode = DigitalObjectPersistenceHelper.getDataZipFileNode(object, AuthorizationContext.factorySystemContext()); if (zipNode != null) { //zip file node is valid, check URL final String zipUrl = zipNode.getLogicalFileName().asString(); if (zipUrl != null) { try { //URL seems to be valid, try to get file input stream final File toDownload = new File(new URL(zipUrl).toURI()); final FileInputStream fin = new FileInputStream(toDownload); final FileDownloader downloader = new FileDownloader(new StreamResource(new StreamSource() { @Override public InputStream getStream() { return fin; } }, object.getDigitalObjectIdentifier() + ".zip")); downloader.extend(downloadButton); //obtain stored file size from the according attribute IAttribute[] attribs = zipNode.getAttributes().toArray(new IAttribute[] {}); long size = -1; if (attribs != null) { for (IAttribute attrib : attribs) { if ("size".equals(attrib.getKey())) { try { size = Long.parseLong(attrib.getValue()); } catch (NumberFormatException ex) { //no long } } } } downloadButton .setDescription("Download file " + toDownload.getName() + " (" + size + " bytes)"); haveDownload = true; } catch (MalformedURLException | URISyntaxException | FileNotFoundException ex) { LOGGER.error("Failed to setup download.", ex); downloadButton.setDescription("Failed to obtain data URL."); } } else { downloadButton.setDescription("No data available, yet."); } } else { downloadButton.setDescription("No data available, yet."); } } catch (UnauthorizedAccessAttemptException ex) { LOGGER.error("No data available, yet.", ex); downloadButton.setDescription("No data available, yet."); } //set button only enabled if the data is there and can be accessed downloadButton.setEnabled(haveDownload); }
From source file:facs.components.Statistics.java
License:Open Source License
private Component initialGrid() { VerticalLayout gridLayout = new VerticalLayout(); createInvoice.setEnabled(false);//from w w w .j av a 2 s. com downloadInvoice.setEnabled(false); String buttonRefreshTitle = "Refresh"; Button refresh = new Button(buttonRefreshTitle); refresh.setIcon(FontAwesome.REFRESH); refresh.setDescription("Click here to reload the data from the database!"); refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY); refresh.addClickListener(new ClickListener() { private static final long serialVersionUID = -3610721151565496269L; @Override public void buttonClick(ClickEvent event) { refreshDataSources(); } }); Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss"); System.out.println(ft.format(dNow) + " INFO Statistics accessed! - User: " + LiferayAndVaadinUtils.getUser().getScreenName()); // Add some generated properties IndexedContainer container = getEmptyContainer(); gpcontainer = new GeneratedPropertyContainer(container); Grid grid = new Grid(gpcontainer); grid.setWidth("100%"); setRenderers(grid); fillRows(grid); // compute total costs float totalCosts = 0.0f; for (Object itemId : gpcontainer.getItemIds()) totalCosts += ((Number) gpcontainer.getContainerProperty(itemId, costCaption).getValue()).floatValue(); // compute total time in milliseconds long total = 0; for (Object itemId : gpcontainer.getItemIds()) { long s = ((Date) gpcontainer.getContainerProperty(itemId, startCaption).getValue()).getTime(); long e = ((Date) gpcontainer.getContainerProperty(itemId, endCaption).getValue()).getTime(); total += e - s; } // set footer to contain total cost and time in hours:minutes FooterRow footer = grid.appendFooterRow(); FooterCell footerCellCost = footer.getCell(costCaption); footerCellCost.setText(String.format("%1$.2f total", totalCosts)); FooterCell footerCellEnd = footer.getCell(endCaption); footerCellEnd.setText(Formatter.toHoursAndMinutes(total)); // "%1$.0f hours" // Set up a filter for all columns HeaderRow filterRow = grid.appendHeaderRow(); addRowFilter(filterRow, deviceCaption, container, footer, gpcontainer); addRowFilter(filterRow, kostenstelleCaption, container, footer, gpcontainer); Label infoLabel = new Label( DBManager.getDatabaseInstance().getUserNameByUserID(LiferayAndVaadinUtils.getUser().getScreenName()) + " " + LiferayAndVaadinUtils.getUser().getScreenName()); infoLabel.addStyleName("h4"); // createInvoice.setSizeFull(); // downloadInvoice.setSizeFull(); gridLayout.setWidth("100%"); gridLayout.setCaption("Statistics"); // add components to the grid layout // gridLayout.addComponent(infoLabel, 0, 0, 3, 0); // gridLayout.addComponent(grid, 0, 1, 5, 1); // gridLayout.addComponent(createInvoice, 0, 3); // gridLayout.addComponent(downloadInvoice, 1, 3); gridLayout.addComponent(grid); gridLayout.addComponent(refresh); gridLayout.addComponent(createInvoice); gridLayout.addComponent(downloadInvoice); gridLayout.setMargin(true); gridLayout.setSpacing(true); // grid.setEditorEnabled(true); grid.setSelectionMode(SelectionMode.SINGLE); grid.addSelectionListener(new SelectionListener() { /** * */ private static final long serialVersionUID = -2683274060620429050L; @Override public void select(SelectionEvent event) { // Notification.show("Select row: " + grid.getSelectedRow() + " Name: " // + gpcontainer.getContainerProperty(grid.getSelectedRow(), nameCaption).getValue()); downloadInvoice.setEnabled(false); ReceiverPI = (String) gpcontainer.getContainerProperty(grid.getSelectedRow(), nameCaption) .getValue(); createInvoice.setEnabled(true); } }); createInvoice.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = 5512585967145932560L; private File bill; private FileDownloader fileDownloader; @Override public void buttonClick(ClickEvent event) { String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); Paths.get(basepath, "WEB-INF/billingTemplates"); // System.out.println("Basepath: " + basepath); try { int setUserId = DBManager.getDatabaseInstance().findUserByFullName(ReceiverPI); if (setUserId > 0) { Billing billing = new Billing(Paths.get(basepath, "WEB-INF/billingTemplates").toFile(), "Angebot.tex"); UserBean user = setUserId > 0 ? DBManager.getDatabaseInstance().getUserById(setUserId) : null; billing.setReceiverPI(ReceiverPI); billing.setReceiverInstitution(user.getInstitute()); billing.setReceiverStreet(user.getStreet()); billing.setReceiverPostalCode(user.getPostcode()); billing.setReceiverCity(user.getCity()); billing.setSenderName("Dr. rer. nat. Stella Autenrieth"); billing.setSenderFunction("Leiterin"); billing.setSenderPostalCode("72076"); billing.setSenderCity("Tbingen"); billing.setSenderStreet("Otfried-Mller-Strae 10"); billing.setSenderPhone("+49 (0) 7071 29-83156"); billing.setSenderEmail("stella.autenrieth@med.uni-tuebingen.de"); billing.setSenderUrl("www.medizin.uni-tuebingen.de"); billing.setSenderFaculty("Medizinischen Fakultt"); if (user.getKostenstelle() != null) billing.setProjectDescription("Kostenstelle: " + user.getKostenstelle()); else billing.setProjectDescription("Keine kostenstelle verfgbar."); billing.setProjectShortDescription("Dieses Angebot beinhaltet jede Menge Extras."); if (user.getProject() != null) billing.setProjectNumber("Kostenstelle: " + user.getKostenstelle()); else billing.setProjectNumber("Keine project nummer verfgbar."); float cost = ((Number) gpcontainer.getContainerProperty(grid.getSelectedRow(), costCaption) .getValue()).floatValue(); long s = ((Date) gpcontainer.getContainerProperty(grid.getSelectedRow(), startCaption) .getValue()).getTime(); long e = ((Date) gpcontainer.getContainerProperty(grid.getSelectedRow(), endCaption) .getValue()).getTime(); long timeFrame = e - s; Date start = ((Date) gpcontainer.getContainerProperty(grid.getSelectedRow(), startCaption) .getValue()); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy"); String date = ft.format(start); String description = "No Description is Available"; String time_frame = Formatter.toHoursAndMinutes(timeFrame); ArrayList<CostEntry> entries = new ArrayList<CostEntry>(); entries.add(billing.new CostEntry(date, time_frame, description, cost)); billing.setCostEntries(entries); float totalCosts = 0.0f; // calculates the total cost of items // for (Object itemId : gpcontainer.getItemIds()) { // totalCosts += // ((Number) gpcontainer.getContainerProperty(itemId, costCaption).getValue()) // .floatValue(); // } totalCosts = ((Number) gpcontainer.getContainerProperty(grid.getSelectedRow(), costCaption) .getValue()).floatValue(); billing.setTotalCost(String.format("%1$.2f", totalCosts)); bill = billing.createPdf(); // System.out.println(bill.getAbsolutePath()); if (fileDownloader != null) downloadInvoice.removeExtension(fileDownloader); fileDownloader = new FileDownloader(new FileResource(bill)); fileDownloader.extend(downloadInvoice); downloadInvoice.setEnabled(true); showSuccessfulNotification("Congratulations!", "Invoice is created and available for download."); downloadInvoice.setEnabled(true); } else { createInvoice.setEnabled(false); downloadInvoice.setEnabled(false); showErrorNotification("No such user found!", "An error occured while trying to create the invoice. The common problem occurs to be: this no such user in the database."); } } catch (Exception e) { showErrorNotification("What the heck!", "An error occured while trying to create the invoice. The common problem occurs to be: this no such user or it can not run program 'pdflatex'."); e.printStackTrace(); } // for all entries /* * try { Billing billing = new Billing(Paths.get(basepath, * "WEB-INF/billingTemplates").toFile(), "Angebot.tex"); * billing.setRecieverInstitution("BER - Berliner Flughafen"); * billing.setRecieverPI("Klaus Something"); * billing.setRecieverStreet("am berliner flughafen 12"); * billing.setRecieverPostalCode("D-12345"); billing.setRecieverCity("Berlin"); * * billing.setSenderName("Dr. rer. nat. Stella Autenrieth"); * billing.setSenderFunction("Leiterin"); billing.setSenderPostalCode("72076"); * billing.setSenderCity("Tbingen"); billing.setSenderStreet("Otfried-Mller-Strae 10"); * billing.setSenderPhone("+49 (0) 7071 29-83156"); * billing.setSenderEmail("stella.autenrieth@med.uni-tuebingen.de"); * billing.setSenderUrl("www.medizin.uni-tuebingen.de"); * billing.setSenderFaculty("Medizinischen Fakultt"); * * billing.setProjectDescription("Dieses Angebot beinhaltet jede Menge Extras."); * billing.setProjectShortDescription("jede Menge Extras."); * billing.setProjectNumber("QA2014016"); * * ArrayList<CostEntry> entries = new ArrayList<CostEntry>(); for (Object itemId : * gpcontainer.getItemIds()) { float cost = ((Number) * gpcontainer.getContainerProperty(itemId, costCaption).getValue()) .floatValue(); long s = * ((Date) gpcontainer.getContainerProperty(itemId, startCaption).getValue()) .getTime(); * long e = ((Date) gpcontainer.getContainerProperty(itemId, * endCaption).getValue()).getTime(); long timeFrame = e - s; Date start = ((Date) * gpcontainer.getContainerProperty(itemId, startCaption).getValue()); SimpleDateFormat ft = * new SimpleDateFormat("dd.MM.yyyy"); String date = ft.format(start); String description = * "No Description is Available"; String time_frame = * Formatter.toHoursAndMinutes(timeFrame); entries.add(billing.new CostEntry(date, * time_frame, description, cost)); } billing.setCostEntries(entries); float totalCosts = * 0.0f; for (Object itemId : gpcontainer.getItemIds()) { totalCosts += ((Number) * gpcontainer.getContainerProperty(itemId, costCaption).getValue()) .floatValue(); } * * billing.setTotalCost(String.format("%1$.2f", totalCosts)); * * bill = billing.createPdf(); System.out.println(bill.getAbsolutePath()); if * (fileDownloader != null) downloadBill.removeExtension(fileDownloader); fileDownloader = * new FileDownloader(new FileResource(bill)); fileDownloader.extend(downloadBill); * downloadBill.setEnabled(true); showSuccessfulNotification("Congratulations!", * "Invoice is created and available for download."); } catch (Exception e) { * showErrorNotification( "What the heck!", * "An error occured while trying to create the invoice. The common problem occurs to be: cannot run program 'pdflatex'" * ); e.printStackTrace(); } */ } }); return gridLayout; }
From source file:facs.components.Statistics.java
License:Open Source License
private Component newMatchedGrid() { Button createInvoiceMatched = new Button("Create Invoice"); Button downloadInvoiceMatched = new Button("Download Invoice"); String buttonRefreshTitle = "Refresh"; Button refreshMatched = new Button(buttonRefreshTitle); refreshMatched.setIcon(FontAwesome.REFRESH); refreshMatched.setDescription("Click here to reload the data from the database!"); refreshMatched.addStyleName(ValoTheme.BUTTON_FRIENDLY); createInvoiceMatched.setEnabled(false); downloadInvoiceMatched.setEnabled(false); Grid matchedGrid;/* w w w. j a v a2 s. c o m*/ refreshMatched.addClickListener(new ClickListener() { private static final long serialVersionUID = -3610721151565496269L; @Override public void buttonClick(ClickEvent event) { refreshDataSources(); } }); IndexedContainer mcontainer = getEmptyContainer(); GeneratedPropertyContainer mpc = new GeneratedPropertyContainer(mcontainer); VerticalLayout matchedLayout = new VerticalLayout(); matchedGrid = new Grid(mpc); setRenderers(matchedGrid); fillMatchedRows(matchedGrid); // compute total costs float totalCosts = 0.0f; for (Object itemId : mpc.getItemIds()) totalCosts += ((Number) mpc.getContainerProperty(itemId, costCaption).getValue()).floatValue(); // compute total time in milliseconds long total = 0; for (Object itemId : mpc.getItemIds()) { long s = ((Date) mpc.getContainerProperty(itemId, startCaption).getValue()).getTime(); long e = ((Date) mpc.getContainerProperty(itemId, endCaption).getValue()).getTime(); total += e - s; } // set footer to contain total cost and time in hours:minutes FooterRow footer = matchedGrid.appendFooterRow(); FooterCell footerCellCost = footer.getCell(costCaption); footerCellCost.setText(String.format("%1$.2f total", totalCosts)); FooterCell footerCellEnd = footer.getCell(endCaption); footerCellEnd.setText(Formatter.toHoursAndMinutes(total)); // "%1$.0f hours" // Set up a filter for all columns HeaderRow filterRow = matchedGrid.appendHeaderRow(); addRowFilter(filterRow, deviceCaption, mcontainer, footer, mpc); addRowFilter(filterRow, kostenstelleCaption, mcontainer, footer, mpc); matchedLayout.setMargin(true); matchedLayout.setSpacing(true); // devicesGrid.setWidth("100%"); matchedGrid.setSizeFull(); matchedGrid.setSelectionMode(SelectionMode.SINGLE); matchedLayout.addComponent(matchedGrid); matchedGrid.setSelectionMode(SelectionMode.SINGLE); matchedGrid.addSelectionListener(new SelectionListener() { /** * */ private static final long serialVersionUID = -2683274060620429050L; @Override public void select(SelectionEvent event) { // Notification.show("Select row: " + grid.getSelectedRow() + " Name: " // + gpcontainer.getContainerProperty(grid.getSelectedRow(), nameCaption).getValue()); downloadInvoiceMatched.setEnabled(false); ReceiverPI = (String) mpc.getContainerProperty(matchedGrid.getSelectedRow(), nameCaption) .getValue(); createInvoiceMatched.setEnabled(true); } }); createInvoiceMatched.addClickListener(new ClickListener() { private File bill; private FileDownloader fileDownloader; @Override public void buttonClick(ClickEvent event) { String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); Paths.get(basepath, "WEB-INF/billingTemplates"); // System.out.println("Basepath: " + basepath); try { int setUserId = DBManager.getDatabaseInstance().findUserByFullName(ReceiverPI); if (setUserId > 0) { Billing billing = new Billing(Paths.get(basepath, "WEB-INF/billingTemplates").toFile(), "Angebot.tex"); UserBean user = setUserId > 0 ? DBManager.getDatabaseInstance().getUserById(setUserId) : null; billing.setReceiverPI(ReceiverPI); billing.setReceiverInstitution(user.getInstitute()); billing.setReceiverStreet(user.getStreet()); billing.setReceiverPostalCode(user.getPostcode()); billing.setReceiverCity(user.getCity()); billing.setSenderName("Dr. rer. nat. Stella Autenrieth"); billing.setSenderFunction("Leiterin"); billing.setSenderPostalCode("72076"); billing.setSenderCity("Tbingen"); billing.setSenderStreet("Otfried-Mller-Strae 10"); billing.setSenderPhone("+49 (0) 7071 29-83156"); billing.setSenderEmail("stella.autenrieth@med.uni-tuebingen.de"); billing.setSenderUrl("www.medizin.uni-tuebingen.de"); billing.setSenderFaculty("Medizinischen Fakultt"); if (user.getKostenstelle() != null) billing.setProjectDescription("Kostenstelle: " + user.getKostenstelle()); else billing.setProjectDescription("Keine kostenstelle verfgbar."); billing.setProjectShortDescription("Dieses Angebot beinhaltet jede Menge Extras."); if (user.getProject() != null) billing.setProjectNumber("Kostenstelle: " + user.getKostenstelle()); else billing.setProjectNumber("Keine project nummer verfgbar."); float cost = ((Number) mpc.getContainerProperty(matchedGrid.getSelectedRow(), costCaption) .getValue()).floatValue(); long s = ((Date) mpc.getContainerProperty(matchedGrid.getSelectedRow(), startCaption) .getValue()).getTime(); long e = ((Date) mpc.getContainerProperty(matchedGrid.getSelectedRow(), endCaption) .getValue()).getTime(); long timeFrame = e - s; Date start = ((Date) mpc.getContainerProperty(matchedGrid.getSelectedRow(), startCaption) .getValue()); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy"); String date = ft.format(start); String description = "No Description is Available"; String time_frame = Formatter.toHoursAndMinutes(timeFrame); ArrayList<CostEntry> entries = new ArrayList<CostEntry>(); entries.add(billing.new CostEntry(date, time_frame, description, cost)); billing.setCostEntries(entries); float totalCosts = 0.0f; totalCosts = ((Number) mpc.getContainerProperty(matchedGrid.getSelectedRow(), costCaption) .getValue()).floatValue(); billing.setTotalCost(String.format("%1$.2f", totalCosts)); bill = billing.createPdf(); // System.out.println(bill.getAbsolutePath()); if (fileDownloader != null) downloadInvoiceMatched.removeExtension(fileDownloader); fileDownloader = new FileDownloader(new FileResource(bill)); fileDownloader.extend(downloadInvoiceMatched); downloadInvoiceMatched.setEnabled(true); showSuccessfulNotification("Congratulations!", "Invoice is created and available for download."); downloadInvoiceMatched.setEnabled(true); } else { createInvoiceMatched.setEnabled(false); downloadInvoiceMatched.setEnabled(false); showErrorNotification("No such user found!", "An error occured while trying to create the invoice. The common problem occurs to be: this no such user in the database."); } } catch (Exception e) { showErrorNotification("What the heck!", "An error occured while trying to create the invoice. The common problem occurs to be: this no such user or it can not run program 'pdflatex'."); e.printStackTrace(); } } }); matchedLayout.addComponent(refreshMatched); matchedLayout.addComponent(createInvoiceMatched); matchedLayout.addComponent(downloadInvoiceMatched); return matchedLayout; }
From source file:fr.univlorraine.mondossierweb.views.CalendrierView.java
License:Apache License
/** * Initialise la vue//from www .j av a 2 s . c o m */ @PostConstruct public void init() { //On vrifie le droit d'accder la vue if (UI.getCurrent() instanceof MainUI && (userController.isEnseignant() || userController.isEtudiant()) && MainUI.getCurrent() != null && MainUI.getCurrent().getEtudiant() != null) { /* Style */ setMargin(true); setSpacing(true); //Si on n'a pas dj essayer de rcuprer le calendrier if (!MainUI.getCurrent().getEtudiant().isCalendrierRecupere()) { etudiantController.recupererCalendrierExamens(); } /* Titre */ HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setWidth("100%"); Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale())); title.addStyleName(ValoTheme.LABEL_H1); titleLayout.addComponent(title); titleLayout.setComponentAlignment(title, Alignment.MIDDLE_LEFT); //Test si on a des diplomes ou des etapes if (MainUI.getCurrent().getEtudiant().getCalendrier() != null && MainUI.getCurrent().getEtudiant().getCalendrier().size() > 0) { Button pdfButton = new Button(); pdfButton.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); pdfButton.addStyleName("button-big-icon"); pdfButton.addStyleName("red-button-icon"); pdfButton.setIcon(FontAwesome.FILE_PDF_O); pdfButton.setDescription( applicationContext.getMessage(NAME + ".btn.pdf.description", null, getLocale())); if (PropertyUtils.isPushEnabled()) { MyFileDownloader fd = new MyFileDownloader(calendrierController.exportPdf()); fd.extend(pdfButton); } else { FileDownloader fd = new FileDownloader(calendrierController.exportPdf()); fd.setOverrideContentType(false); fd.extend(pdfButton); } titleLayout.addComponent(pdfButton); titleLayout.setComponentAlignment(pdfButton, Alignment.MIDDLE_RIGHT); } addComponent(titleLayout); VerticalLayout globalLayout = new VerticalLayout(); globalLayout.setSizeFull(); globalLayout.setSpacing(true); /* Message d'info */ if (applicationContext.getMessage(NAME + ".message.info", null, getLocale()) != null) { Panel panelVue = new Panel(); HorizontalLayout vueLayout = new HorizontalLayout(); vueLayout.setMargin(true); vueLayout.setSpacing(true); vueLayout.setSizeFull(); Label vueLabel = new Label( applicationContext.getMessage(NAME + ".message.info", null, getLocale())); vueLabel.setContentMode(ContentMode.HTML); vueLabel.setStyleName(ValoTheme.LABEL_SMALL); vueLayout.addComponent(vueLabel); vueLayout.setExpandRatio(vueLabel, 1); panelVue.setContent(vueLayout); globalLayout.addComponent(panelVue); } /* Le Calendrier */ Panel panelCalendrier = new Panel( applicationContext.getMessage(NAME + ".calendrier.title", null, getLocale())); panelCalendrier.setSizeFull(); if (MainUI.getCurrent().getEtudiant() != null && MainUI.getCurrent().getEtudiant().getCalendrier() != null && MainUI.getCurrent().getEtudiant().getCalendrier().size() > 0) { BeanItemContainer<Examen> bic = new BeanItemContainer<>(Examen.class, MainUI.getCurrent().getEtudiant().getCalendrier()); Table calendrierTable = new Table(null, bic); calendrierTable.setWidth("100%"); String[] colonnes_to_create = CAL_FIELDS; if (configController.isAffNumPlaceExamen()) { colonnes_to_create = CAL_FIELDS_AVEC_PLACE; } for (String fieldName : colonnes_to_create) { calendrierTable.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".table." + fieldName, null, getLocale())); } calendrierTable.addGeneratedColumn("batiment", new BatimentColumnGenerator()); calendrierTable.addGeneratedColumn("salle", new SalleColumnGenerator()); calendrierTable.setColumnHeader("batiment", applicationContext.getMessage(NAME + ".table.batiment", null, getLocale())); calendrierTable.setColumnHeader("salle", applicationContext.getMessage(NAME + ".table.salle", null, getLocale())); String[] colonnes_to_display = CAL_FIELDS_ORDER; if (configController.isAffNumPlaceExamen()) { colonnes_to_display = CAL_FIELDS_ORDER_AVEC_PLACE; } calendrierTable.setVisibleColumns((Object[]) colonnes_to_display); calendrierTable.setColumnCollapsingAllowed(true); calendrierTable.setColumnReorderingAllowed(true); calendrierTable.setSelectable(false); calendrierTable.setImmediate(true); calendrierTable.setStyleName("noscrollabletable"); calendrierTable.setPageLength(calendrierTable.getItemIds().size()); panelCalendrier.setContent(calendrierTable); } else { HorizontalLayout labelExamenLayout = new HorizontalLayout(); labelExamenLayout.setMargin(true); labelExamenLayout.setSizeFull(); Label aucunExamen = new Label( applicationContext.getMessage(NAME + ".examen.aucun", null, getLocale())); aucunExamen.setStyleName(ValoTheme.LABEL_COLORED); aucunExamen.addStyleName(ValoTheme.LABEL_BOLD); labelExamenLayout.addComponent(aucunExamen); panelCalendrier.setContent(labelExamenLayout); } globalLayout.addComponent(panelCalendrier); addComponent(globalLayout); } }