List of usage examples for com.vaadin.ui Window setResizable
public void setResizable(boolean resizable)
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;// ww w. jav a2 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.LevelComponent.java
License:Open Source License
/** * Precondition: {DatasetView#table} has to be initialized. e.g. with * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the * Layout of this view.//from w w w .j ava 2 s. co m */ private void buildLayout() { this.vert.removeAllComponents(); this.vert.setWidth("100%"); // Table (containing datasets) section VerticalLayout tableSectionDatasets = new VerticalLayout(); VerticalLayout tableSectionSamples = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); HorizontalLayout sampletableSectionContent = new HorizontalLayout(); tableSectionContent.setMargin(new MarginInfo(false, false, false, false)); sampletableSectionContent.setMargin(new MarginInfo(false, false, false, false)); // tableSectionContent.setCaption("Datasets"); // tableSectionContent.setIcon(FontAwesome.FLASK); descriptionLabel.setWidth("100%"); tableSectionDatasets.addComponent(descriptionLabel); sampletableSectionContent.addComponent(sampleGrid); tableSectionContent.addComponent(this.datasetTable); tableSectionDatasets.setMargin(new MarginInfo(true, false, false, true)); tableSectionDatasets.setSpacing(true); tableSectionSamples.setMargin(new MarginInfo(true, false, true, true)); tableSectionSamples.setSpacing(true); tableSectionDatasets.addComponent(tableSectionContent); tableSectionSamples.addComponent(sampletableSectionContent); tableSectionSamples.addComponent(exportSamples); this.vert.addComponent(tableSectionDatasets); sampleGrid.setWidth("100%"); datasetTable.setWidth("100%"); tableSectionDatasets.setWidth("100%"); tableSectionSamples.setWidth("100%"); sampletableSectionContent.setWidth("100%"); tableSectionContent.setWidth("100%"); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, false, true)); buttonLayout.setHeight(null); buttonLayout.setSpacing(true); this.download.setEnabled(false); buttonLayout.setSpacing(true); Button checkAll = new Button("Select all datasets"); checkAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : datasetTable.getItemIds()) { ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(true); } } }); Button uncheckAll = new Button("Unselect all datasets"); uncheckAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : datasetTable.getItemIds()) { ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(false); } } }); buttonLayout.addComponent(exportData); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); // buttonLayout.addComponent(visualize); buttonLayout.addComponent(this.download); String content = "<p> In case of multiple file selections, Project Browser will create a tar archive.</p>" + "<hr>" + "<p> If you need help on extracting a tar archive file, follow the tips below: </p>" + "<p>" + FontAwesome.WINDOWS.getHtml() + " Windows </p>" + "<p> To open/extract TAR file on Windows, you can use 7-Zip, Easy 7-Zip, PeaZip.</p>" + "<hr>" + "<p>" + FontAwesome.APPLE.getHtml() + " MacOS </p>" + "<p> To open/extract TAR file on Mac, you can use Mac OS built-in utility Archive Utility,<br> or third-part freeware. </p>" + "<hr>" + "<p>" + FontAwesome.LINUX.getHtml() + " Linux </p>" + "<p> You need to use command tar. The tar is the GNU version of tar archiving utility. <br> " + "To extract/unpack a tar file, type: $ tar -xvf file.tar</p>"; PopupView tooltip = new PopupView(new helpers.ToolTip(content)); tooltip.setHeight("44px"); HorizontalLayout help = new HorizontalLayout(); help.setSizeFull(); HorizontalLayout helpContent = new HorizontalLayout(); // helpContent.setSizeFull(); help.setMargin(new MarginInfo(false, false, false, true)); Label helpText = new Label("Attention: Click here before Download!"); helpContent.addComponent(new Label(FontAwesome.QUESTION_CIRCLE.getHtml(), ContentMode.HTML)); helpContent.addComponent(helpText); helpContent.addComponent(tooltip); helpContent.setSpacing(true); help.addComponent(helpContent); help.setComponentAlignment(helpContent, Alignment.TOP_CENTER); /** * prepare download. */ download.setResource(new ExternalResource("javascript:")); download.setEnabled(false); for (final Object itemId : this.datasetTable.getItemIds()) { setCheckedBox(itemId, (String) this.datasetTable.getItem(itemId).getItemProperty("CODE").getValue()); } this.datasetTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (!event.isDoubleClick() & !((boolean) datasetTable.getItem(event.getItemId()) .getItemProperty("isDirectory").getValue())) { String datasetCode = (String) datasetTable.getItem(event.getItemId()).getItemProperty("CODE") .getValue(); String datasetFileName = (String) datasetTable.getItem(event.getItemId()) .getItemProperty("File Name").getValue(); URL url = null; try { Resource res = null; Object parent = datasetTable.getParent(event.getItemId()); if (parent != null) { String parentDatasetFileName = (String) datasetTable.getItem(parent) .getItemProperty("File Name").getValue(); try { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, parentDatasetFileName + "/" + URLEncoder.encode(datasetFileName, "UTF-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { try { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, URLEncoder.encode(datasetFileName, "UTF-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Window subWindow = new Window(); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.setSizeFull(); subWindow.setContent(subContent); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); Boolean visualize = false; if (datasetFileName.endsWith(".pdf")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("application/pdf"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".png")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("application/png"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".qcML")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/xml"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".alleles")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".tsv")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".log")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".html")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/html"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".GSvar")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (visualize) { BrowserFrame frame = new BrowserFrame("", res); frame.setSizeFull(); subContent.addComponent(frame); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setSizeUndefined(); subWindow.setHeight("75%"); subWindow.setWidth("75%"); subWindow.setResizable(false); frame.setSizeFull(); frame.setHeight("100%"); // frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.9), Unit.PIXELS); // Open it in the UI ui.addWindow(subWindow); } } catch (MalformedURLException e) { LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s", datasetCode)); helpers.Utils.Notification("No file attached.", "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data", "error"); // Notification // .show( // "Given dataset has no file attached to it!! Please Contact your project manager. Or // check whether it already has some data", // Notification.Type.ERROR_MESSAGE); } } } }); this.vert.addComponent(help); this.vert.addComponent(buttonLayout); this.vert.addComponent(tableSectionSamples); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjInformationComponent.java
License:Open Source License
private void initUI() { vert = new VerticalLayout(); descHorz = new HorizontalLayout(); // horz = new HorizontalLayout(); statusPanel = new Panel(); descriptionPanel = new Panel(); datasetTable = buildFilterTable();/*from ww w . j a va 2s . c o m*/ peopleInCharge = new Accordion(); setResponsive(true); vert.setResponsive(true); descHorz.setResponsive(true); statusPanel.setResponsive(true); descriptionPanel.setResponsive(true); vert.setMargin(new MarginInfo(true, true, false, false)); setSizeFull(); vert.setSizeFull(); descHorz.setSizeFull(); statusPanel.setSizeFull(); descriptionPanel.setSizeFull(); investigator = new Label("", ContentMode.HTML); contactPerson = new Label("", ContentMode.HTML); projectManager = new Label("", ContentMode.HTML); final VerticalLayout layoutI = new VerticalLayout(investigator); final VerticalLayout layoutC = new VerticalLayout(contactPerson); final VerticalLayout layoutP = new VerticalLayout(projectManager); layoutI.setMargin(true); layoutC.setMargin(true); layoutP.setMargin(true); peopleInCharge.addTab(layoutI, "Investigator"); peopleInCharge.addTab(layoutC, "Contact Person"); peopleInCharge.addTab(layoutP, "Project Manager"); descEdit = new Button("Edit"); descEdit.setIcon(FontAwesome.PENCIL); descEdit.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); descEdit.setResponsive(true); descEdit.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { changeMetadata.updateUI(projectBean); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.addComponent(changeMetadata); Window subWindow = new Window("Edit Metadata"); 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.setSizeFull(); subWindow.addCloseListener(new CloseListener() { /** * */ private static final long serialVersionUID = -1329152609834711109L; @Override public void windowClose(CloseEvent e) { ProjectBean updatedBean = datahandler.getProjectFromDB(projectBean.getId()); updateUI(updatedBean, projectType); } }); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(subWindow); } }); // horz.addComponent(descEdit); // horz.setComponentAlignment(descEdit, Alignment.TOP_RIGHT); // horz.setExpandRatio(investigator, 0.4f); // horz.setExpandRatio(contactPerson, 0.4f); // horz.setExpandRatio(descEdit, 0.2f); contact = new Label("", ContentMode.HTML); patientInformation = new Label("No patient information provided.", ContentMode.HTML); experimentLabel = new Label(""); statusContent = new VerticalLayout(); hlaTypeLabel = new Label("Not available.", ContentMode.HTML); hlaTypeLabel.setStyleName("patientview"); this.setCompositionRoot(vert); // this.setCompositionRoot(mainLayout); }
From source file:dhbw.clippinggorilla.userinterface.windows.ActivateWindow.java
public static Window get() { Window window = new Window(); window.setModal(true);/*from w ww . j a v a2 s . c o m*/ window.setResizable(false); window.setDraggable(false); window.setCaption(Language.get(Word.ACTIVATION_CODE)); window.addCloseShortcut(ShortcutAction.KeyCode.ENTER, null); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setMargin(false); windowLayout.setSizeUndefined(); FormLayout forms = new FormLayout(); forms.setMargin(true); forms.setSizeUndefined(); Button save = new Button(Language.get(Word.ACTIVATE)); TextField activationCode = new TextField(Language.get(Word.ACTIVATION_CODE)); activationCode.setMaxLength(6); activationCode.focus(); activationCode.addValueChangeListener(e -> { if (activationCode.getValue().length() > 5) { save.setEnabled(true); activationCode.setComponentError(null); } else { save.setEnabled(false); activationCode.setComponentError(new UserError(Language.get(Word.ACTIVATION_CODE_SIX_CHARS), AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_CODE_SIX_CHARS)); } }); forms.addComponent(activationCode); Button resendMail = new Button(Language.get(Word.RESEND_ACTIVATION_CODE)); resendMail.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); resendMail.addClickListener(ce -> { try { UserUtils.resendActivationMail(UserUtils.getCurrent()); VaadinUtils.infoNotification(Language.get(Word.RESEND_ACTIVATION_CODE_SUCCESSFUL)); } catch (EmailException ex) { VaadinUtils.errorNotification(Language.get(Word.RESEND_ACTIVATION_CODE_FAILED)); } }); forms.addComponent(resendMail); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE); Label placeholder = new Label(); Button cancel = new Button(Language.get(Word.CANCEL)); cancel.setIcon(VaadinIcons.CLOSE); cancel.addClickListener(ce -> { window.close(); }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); save.setEnabled(false); save.setIcon(VaadinIcons.CHECK); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addClickListener(ce -> { try { String code = activationCode.getValue(); User user = UserUtils.getCurrent(); if (UserUtils.activateUser(user, code)) { VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_SUCCESSFUL)); window.close(); } else { activationCode.setValue(""); VaadinUtils.errorNotification(Language.get(Word.ACTIVATION_FAILED)); } } catch (NumberFormatException e) { } }); save.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); footer.setSizeUndefined(); footer.setWidth("100%"); footer.addComponents(placeholder, cancel, save); footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER); windowLayout.addComponent(forms); windowLayout.addComponent(footer); window.setContent(windowLayout); return window; }
From source file:dhbw.clippinggorilla.userinterface.windows.PDFWindow.java
public static Window get(Path pdfFile) { Window window = new Window(); window.setModal(true);/*from w ww.j av a 2 s.c o m*/ window.setResizable(false); window.setWidth("90%"); window.setHeight("90%"); window.addCloseShortcut(ShortcutAction.KeyCode.ENTER, null); BrowserFrame e = new BrowserFrame(pdfFile.getFileName().toString(), new FileResource(pdfFile.toFile())); e.setSizeFull(); window.setContent(e); return window; }
From source file:edu.kit.dama.ui.commons.util.UIUtils7.java
License:Apache License
public static void openResourceSubWindow(File sourceFile) { boolean fileAccessible = sourceFile != null && sourceFile.exists() && sourceFile.canRead(); // Set subwindow for displaying file resource final Window window = new Window(fileAccessible ? sourceFile.getName() : "Information"); window.center();/*from ww w. ja v a 2 s. co m*/ // Set window layout VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setSizeFull(); if (fileAccessible) { // Set resource that has to be embedded final Embedded resource = new Embedded(null, new FileResource(sourceFile)); if ("application/octet-stream".equals(resource.getMimeType())) { window.setWidth("570px"); window.setHeight("150px"); windowLayout.setMargin(true); Label attentionNote = new Label( "A file preview is not possible as the file type is not supported by your browser."); attentionNote.setContentMode(ContentMode.HTML); Link fileURL = new Link("Click here for downloading the file.", new FileResource(sourceFile)); windowLayout.addComponent(attentionNote); windowLayout.addComponent(fileURL); windowLayout.setComponentAlignment(attentionNote, Alignment.MIDDLE_CENTER); windowLayout.setComponentAlignment(fileURL, Alignment.MIDDLE_CENTER); } else { window.setResizable(true); window.setWidth("800px"); window.setHeight("500px"); final Image image = new Image(null, new FileResource(sourceFile)); image.setSizeFull(); windowLayout.addComponent(image); } } else { //file is not accessible window.setWidth("570px"); window.setHeight("150px"); windowLayout.setMargin(true); Label attentionNote = new Label("Provided file cannot be accessed."); attentionNote.setContentMode(ContentMode.HTML); windowLayout.addComponent(attentionNote); windowLayout.setComponentAlignment(attentionNote, Alignment.MIDDLE_CENTER); } window.setContent(windowLayout); UI.getCurrent().addWindow(window); }
From source file:edu.nps.moves.mmowgli.components.MmowgliDialogContent.java
License:Open Source License
public static void throwUpDialog2() { Window w = new Window(); w.setClosable(false);// ww w . j a v a2 s . c o m w.setResizable(true); w.setStyleName("m-mmowglidialog2"); w.addStyleName("m-transparent"); // don't know why I need this, .mmowglidialog sets it too w.setWidth("600px"); w.setHeight("400px"); MmowgliDialogContent con = new MmowgliDialogContent(); w.setContent(con); con.setSizeFull(); con.initGui(); con.setTitleString("Yippee ki awol!"); UI.getCurrent().addWindow(w); w.center(); }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageBase.java
License:Open Source License
@SuppressWarnings("serial") @HibernateUserRead/* w w w . j a v a2 s . co m*/ public void checkUserLimitsTL() { Serializable uid = Mmowgli2UI.getGlobals().getUserID(); if (uid != NO_LOGGEDIN_USER_ID) { // can't do this check if we don't have a user yet MSysOut.println(DEBUG_LOGS, "User.getTL() in RegistrationPageBase.checkUserLimitsTL()"); User u = User.getTL(uid); if (u != null) // why should it be? if (u.getUserName() != null) // why should it be? if (u.isGameMaster())//getUserName().toLowerCase().startsWith("gm_")) return; } int maxIn = Game.getTL().getMaxUsersOnline(); // List<User> lis = (List<User>)HibernateContainers.getSession().createCriteria(User.class).add(Restrictions.eq("online", true)).list(); // if(lis.size()>=maxIn) { if (Mmowgli2UI.getGlobals().getSessionCount() >= maxIn) { // new improved lockedOut = true; VerticalLayout vl = new VerticalLayout(); vl.setWidth("325px"); vl.addStyleName("m-errorNotificationEquivalent"); vl.setSpacing(false); vl.setMargin(true); Label lab = new Label("We're loaded to the max with players right now."); lab.setSizeUndefined(); vl.addComponent(lab); lab = new Label("Idle players are timed-out after 15 minutes."); lab.setSizeUndefined(); vl.addComponent(lab); lab = new Label("Please try again later."); lab.setSizeUndefined(); vl.addComponent(lab); Window win = new Window("Sorry, but...."); win.setSizeUndefined(); win.addStyleName("m-transparent"); win.setWidth("308px"); win.setResizable(false); win.setContent(vl); openPopupWindowInMainWindow(win, 400); win.setModal(false); win.addCloseListener(new CloseListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void windowClose(CloseEvent e) { HSess.init(); Mmowgli2UI.getAppUI().quitAndGoTo(GameLinks.getTL().getGameFullLink()); HSess.close(); } }); } }
From source file:facs.components.BookAdmin.java
License:Open Source License
private Component deletedBookingsGrid() { VerticalLayout devicesLayout = new VerticalLayout(); devicesLayout.setCaption("Trash"); // HorizontalLayout buttonLayout = new HorizontalLayout(); // there will now be space around the test component // components added to the test component will now not stick together but have space between // them/*from ww w.jav a2s .c o m*/ devicesLayout.setMargin(true); devicesLayout.setSpacing(true); // buttonLayout.setMargin(true); // buttonLayout.setSpacing(true); // buttonLayout.addComponent(add); BeanItemContainer<BookingBean> booking = getDeletedBookings(); GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(booking); gpc.addGeneratedProperty("restore", new PropertyValueGenerator<String>() { /** * */ private static final long serialVersionUID = 4082425701384202280L; @Override public String getValue(Item item, Object itemId, Object propertyId) { // return FontAwesome.TRASH_O.getHtml(); // The caption return "Restore"; // The caption } @Override public Class<String> getType() { return String.class; } }); gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() { /** * */ private static final long serialVersionUID = 1307493624895857513L; @Override public String getValue(Item item, Object itemId, Object propertyId) { // return FontAwesome.TRASH_O.getHtml(); // The caption return "Purge"; // The caption } @Override public Class<String> getType() { return String.class; } }); devicesGridTrash = new Grid(gpc); // Create a grid devicesGridTrash.setWidth("100%"); devicesGridTrash.setSelectionMode(SelectionMode.SINGLE); devicesGridTrash.getColumn("delete").setRenderer(new HtmlRenderer()); devicesGridTrash.getColumn("restore").setRenderer(new HtmlRenderer()); setRenderers(devicesGridTrash); devicesGridTrash.setColumnOrder("ID", "deviceName", "service", "start", "end", "username", "phone", "price"); // Render a button that deletes the data row (item) /* * devicesGrid.addColumn("delete", FontIcon.class).setWidth(35) .setRenderer(new * FontIconRenderer(new RendererClickListener() { * * @Override public void click(RendererClickEvent e) { Notification.show("Deleted item " + * e.getItemId()); } })); */ devicesGridTrash.getColumn("delete") .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() { /** * */ private static final long serialVersionUID = 302628105070456680L; @Override public void click(RendererClickEvent event) { try { Window cd = new Window("Purge Booking"); cd.setHeight("200px"); cd.setWidth("400px"); cd.setResizable(false); GridLayout dialogLayout = new GridLayout(3, 3); Button okButton = new Button("Yes"); okButton.addStyleName(ValoTheme.BUTTON_DANGER); Button cancelButton = new Button("No, I'm actually not sure!"); cancelButton.addStyleName(ValoTheme.BUTTON_PRIMARY); Label information = new Label("Are you sure you want to purge this item?"); information.addStyleName(ValoTheme.LABEL_NO_MARGIN); okButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 3739260172118651857L; @Override public void buttonClick(ClickEvent okEvent) { purgeBooking((BookingBean) event.getItemId()); cd.close(); Notification("The booking was purged!", "At the end, you are the admin, you have the power.", ""); } }); cancelButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = -3931200823633220160L; @Override public void buttonClick(ClickEvent okEvent) { cd.close(); } }); dialogLayout.addComponent(information, 0, 0, 2, 0); dialogLayout.addComponent(okButton, 0, 1); dialogLayout.addComponent(cancelButton, 1, 1); dialogLayout.setMargin(true); dialogLayout.setSpacing(true); cd.setContent(dialogLayout); cd.center(); UI.getCurrent().addWindow(cd); } catch (Exception e) { e.printStackTrace(); } FieldGroup fieldGroup = devicesGridTrash.getEditorFieldGroup(); fieldGroup.addCommitHandler(new FieldGroup.CommitHandler() { /** * */ private static final long serialVersionUID = 3799806709907688919L; @Override public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException { } @Override public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException { Notification("Successfully Updated", "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.", "success"); refreshGrid(); } private void refreshGrid() { getDeletedBookings(); } }); } })); devicesGridTrash.getColumn("restore") .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() { /** * */ private static final long serialVersionUID = -9104571186503913834L; @Override public void click(RendererClickEvent event) { restoreBooking((BookingBean) event.getItemId()); } })); // devicesGrid.setEditorEnabled(true); // devicesLayout.addComponent(buttonLayout); devicesLayout.addComponent(devicesGridTrash); // TODO filtering // HeaderRow filterRow = devicesGrid.prependHeaderRow(); return devicesLayout; }
From source file:facs.components.Booking.java
License:Open Source License
private Component myUpcomingBookings() { VerticalLayout devicesLayout = new VerticalLayout(); // devicesLayout.setCaption("My Bookings"); // there will now be space around the test component // components added to the test component will now not stick together but have space between // them/* www . j ava 2s .c o m*/ devicesLayout.setMargin(true); devicesLayout.setSpacing(true); Date serverTime = new WebBrowser().getCurrentDate(); Date nextDayTime = new Date(serverTime.getTime() + (1000 * 60 * 60 * 24)); BeanItemContainer<BookingBean> users = getMyUpcomingBookings(bookingModel.getLDAP(), nextDayTime); // System.out.println(bookingModel.getLDAP()); GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(users); gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() { /** * */ private static final long serialVersionUID = 1263377339178640406L; @Override public String getValue(Item item, Object itemId, Object propertyId) { // return FontAwesome.TRASH_O.getHtml(); // The caption return "Trash"; // The caption } @Override public Class<String> getType() { return String.class; } }); /* * * try { * * FreeformQuery query = new FreeformQuery( * "SELECT * FROM booking INNER JOIN user ON booking.user_ldap = user.user_ldap WHERE deleted IS NULL AND booking.user_ldap ='" * + bookingModel.getLDAP() + "';", DBManager.getDatabaseInstanceAlternative(), "booking_id"); * SQLContainer container = new SQLContainer(query); * * // System.out.println("Print Container: " + container.size()); * container.setAutoCommit(isEnabled()); * * myBookings = new Grid(container); * * } catch (Exception e) { e.printStackTrace(); } * * myBookings.setColumnOrder("booking_id", "confirmation", "device_name", "service", "start", * "end", "kostenstelle", "price", "project"); * * myBookings.removeColumn("user_ldap"); myBookings.removeColumn("timestamp"); * myBookings.removeColumn("deleted"); myBookings.removeColumn("user_name"); * myBookings.removeColumn("group_id"); myBookings.removeColumn("workgroup_id"); * myBookings.removeColumn("email"); myBookings.removeColumn("phone"); * myBookings.removeColumn("admin_panel"); myBookings.removeColumn("user_id"); * * myBookings.getColumn("booking_id").setHeaderCaption("Booking ID"); */ upcomingBookings = new Grid(gpc); // Create a grid upcomingBookings.setStyleName("my-style"); upcomingBookings.setWidth("100%"); upcomingBookings.setSelectionMode(SelectionMode.SINGLE); upcomingBookings.setEditorEnabled(false); upcomingBookings.setColumnOrder("ID", "confirmation", "deviceName", "service", "start", "end", "username", "phone", "price"); upcomingBookings.getColumn("price").setHeaderCaption("Approx. Price"); // System.out.println(myBookings.getColumns()); setRenderers(upcomingBookings); devicesLayout.addComponent(upcomingBookings); upcomingBookings.getColumn("delete") .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() { /** * */ private static final long serialVersionUID = 302628105070456680L; @Override public void click(RendererClickEvent event) { try { Window cd = new Window("Delete Booking"); cd.setHeight("200px"); cd.setWidth("400px"); cd.setResizable(false); GridLayout dialogLayout = new GridLayout(3, 3); Button okButton = new Button("Yes"); okButton.addStyleName(ValoTheme.BUTTON_DANGER); Button cancelButton = new Button("No, I'm actually not sure!"); cancelButton.addStyleName(ValoTheme.BUTTON_PRIMARY); Label information = new Label("Are you sure you want to trash this item?"); information.addStyleName(ValoTheme.LABEL_NO_MARGIN); okButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 1778157399909757369L; @Override public void buttonClick(ClickEvent okEvent) { purgeBooking((BookingBean) event.getItemId()); booking.setSelectedTab(myUpcomingBookings()); cd.close(); showNotification("The booking was deleted!", "You wanted to delete an upcoming booking and it wasn't within the next 24 hours. All good, item purged."); } }); cancelButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = -8957620319158438769L; @Override public void buttonClick(ClickEvent okEvent) { cd.close(); } }); dialogLayout.addComponent(information, 0, 0, 2, 0); dialogLayout.addComponent(okButton, 0, 1); dialogLayout.addComponent(cancelButton, 1, 1); dialogLayout.setMargin(true); dialogLayout.setSpacing(true); cd.setContent(dialogLayout); cd.center(); UI.getCurrent().addWindow(cd); } catch (Exception e) { e.printStackTrace(); } } })); // TODO filtering // HeaderRow filterRow = devicesGrid.prependHeaderRow(); return devicesLayout; }