List of usage examples for com.vaadin.ui Window center
public void center()
From source file:de.catma.ui.repository.SourceDocumentPanel.java
License:Open Source License
private void initActions() { btAddDocument.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { final AddSourceDocWizardResult wizardResult = new AddSourceDocWizardResult(); AddSourceDocWizardFactory factory = new AddSourceDocWizardFactory(new WizardProgressListener() { public void wizardCompleted(WizardCompletedEvent event) { event.getWizard().removeListener(this); boolean generateStarterKit = repository.getSourceDocuments().isEmpty(); try { repository.insert(wizardResult.getSourceDocument()); if (generateStarterKit) { generateStarterKit(wizardResult.getSourceDocument()); }//from ww w . j av a2s . co m } catch (IOException e) { ((CatmaApplication) getApplication()) .showAndLogError("Error adding the Source Document!", e); } } public void wizardCancelled(WizardCancelledEvent event) { event.getWizard().removeListener(this); } public void stepSetChanged(WizardStepSetChangedEvent event) { /*not needed*/} public void activeStepChanged(WizardStepActivationEvent event) { /*not needed*/} }, wizardResult, repository); Window sourceDocCreationWizardWindow = factory.createWizardWindow("Add new Source Document", "85%", "98%"); getApplication().getMainWindow().addWindow(sourceDocCreationWizardWindow); sourceDocCreationWizardWindow.center(); } }); btOpenDocument.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { final Object value = documentsTree.getValue(); handleOpenDocumentRequest(value); } }); documentsTree.addListener(this); miMoreDocumentActions.addItem("Analyze Document", new Command() { public void menuSelected(MenuItem selectedItem) { handleAnalyzeDocumentRequest(); } }); miMoreDocumentActions.addItem("Remove Document", new Command() { public void menuSelected(MenuItem selectedItem) { handleSourceDocumentRemovalRequest(); } }); miMoreDocumentActions.addItem("Export Document", new Command() { public void menuSelected(MenuItem selectedItem) { handleSourceDocumentExportRequest(); } }); miMoreDocumentActions.addItem("Export Document as UTF-8 plain text", new Command() { public void menuSelected(MenuItem selectedItem) { handleSourceDocumentExportUTF8Request(); } }); miMoreDocumentActions.addItem("Share Document", new Command() { public void menuSelected(MenuItem selectedItem) { handleShareSourceDocumentRequest(); } }); miMoreDocumentActions.addSeparator(); miMoreDocumentActions.addItem("Create User Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { handleUserMarkupCollectionCreation(); } }); miMoreDocumentActions.addItem("Reindex User Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { Object value = documentsTree.getValue(); handleUserMarkupCollectionReindexRequest(value); } }); miMoreDocumentActions.addItem("Import User Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { handleUserMarkupCollectionImportRequest(); } }); miMoreDocumentActions.addItem("Export User Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { Object value = documentsTree.getValue(); handleUserMarkupCollectionExportRequest(value, false); } }); miMoreDocumentActions.addItem("Export User Markup Collection with text", new Command() { public void menuSelected(MenuItem selectedItem) { Object value = documentsTree.getValue(); handleUserMarkupCollectionExportRequest(value, true); } }); miMoreDocumentActions.addItem("Remove User Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { handleUserMarkupRemoval(); } }); miMoreDocumentActions.addItem("Share User Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { handleShareUmcRequest(); } }); /* miMoreDocumentActions.addSeparator(); miMoreDocumentActions.addItem("Create Static Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { // TODO Auto-generated method stub } }); miMoreDocumentActions.addItem("Import Static Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { // TODO Auto-generated method stub } }); miMoreDocumentActions.addItem("Export Static Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { // TODO Auto-generated method stub } }); miMoreDocumentActions.addItem("Remove Static Markup Collection", new Command() { public void menuSelected(MenuItem selectedItem) { // TODO Auto-generated method stub } }); */ btEditContentInfo.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { btEditContentInfo.setVisible(false); btSaveContentInfoChanges.setVisible(true); btDiscardContentInfoChanges.setVisible(true); contentInfoForm.setReadOnly(false); } }); btSaveContentInfoChanges.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { btEditContentInfo.setVisible(true); btSaveContentInfoChanges.setVisible(false); btDiscardContentInfoChanges.setVisible(false); contentInfoForm.commit(); contentInfoForm.setReadOnly(true); Object value = documentsTree.getValue(); @SuppressWarnings("unchecked") BeanItem<ContentInfoSet> item = (BeanItem<ContentInfoSet>) contentInfoForm.getItemDataSource(); ContentInfoSet contentInfoSet = item.getBean(); if (value instanceof UserMarkupCollectionReference) { repository.update((UserMarkupCollectionReference) value, contentInfoSet); } else if (value instanceof SourceDocument) { repository.update((SourceDocument) value, contentInfoSet); } } }); btDiscardContentInfoChanges.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { btEditContentInfo.setVisible(true); btSaveContentInfoChanges.setVisible(false); btDiscardContentInfoChanges.setVisible(false); contentInfoForm.discard(); contentInfoForm.setReadOnly(true); } }); documentsTree.addListener(new ItemClickListener() { public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { Object item = event.getItemId(); handleOpenDocumentRequest(item); } } }); }
From source file:de.dimm.vsm.vaadin.GuiElems.FileSystem.FSTreePanel.java
private static void showPreviewWindow(final VSMCMain main, final List<IPreviewData> pData) throws IllegalArgumentException, NullPointerException { Window win = LeuchtTisch.createPreviewWindow(main, pData); win.center(); main.getApp().getMainWindow().addWindow(win); }
From source file:de.dimm.vsm.vaadin.VSMCMain.java
public <T> void SelectObject(Class<T> t, String caption, String buttonCaption, List<T> list, final SelectObjectCallback cb) { if (list.size() == 1) { cb.SelectedAction(list.get(0));//ww w.j a v a 2 s .co m return; } final NativeSelect sel = new NativeSelect(caption); sel.setNewItemsAllowed(false); sel.setInvalidAllowed(false); sel.setNullSelectionAllowed(false); for (int i = 0; i < list.size(); i++) { Object object = list.get(i); sel.addItem(object); } if (!list.isEmpty()) sel.setValue(list.get(0)); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); NativeButton ok = new NativeButton(buttonCaption); final Window win = new Window(Txt("Auswahl") + " " + caption); win.setWidth("350px"); win.center(); ok.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { getRootWin().removeWindow(win); cb.SelectedAction(sel.getValue()); } }); vl.addComponent(sel); sel.setWidth("80%"); vl.addComponent(ok); vl.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT); vl.setSizeFull(); win.addComponent(vl); getRootWin().addWindow(win); }
From source file:de.metas.ui.web.vaadin.report.VaadinJRViewerProvider.java
License:Open Source License
@Override public void openViewer(final byte[] data, final OutputType type, final String title, final ProcessInfo pi) throws JRException { final StreamResource pdfResource = new StreamResource(() -> new ByteArrayInputStream(data), "report.pdf"); final Window window = new Window(); window.setCaption(title);//from w w w .ja v a2 s . c om window.setStyleName(STYLE); window.center(); window.setWidth(800, Unit.PIXELS); window.setHeight(600, Unit.PIXELS); final BrowserFrame pdfComp = new BrowserFrame(); pdfComp.setPrimaryStyleName(STYLE + "-content"); pdfComp.setSizeFull(); pdfComp.setSource(pdfResource); window.setContent(pdfComp); UI.getCurrent().addWindow(window); }
From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java
License:Open Source License
public static Window createPopupWindow() { Window window = new Window(null); window.setModal(true);/* w w w .j av a 2s . c om*/ window.setSizeUndefined(); window.setResizable(false); window.center(); return window; }
From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java
License:Open Source License
public static Window showSimplePopupWindow(String caption, String contentText) { Window window = new Window(null); window.setModal(true);// ww w . jav a2 s.c om window.setSizeUndefined(); window.setResizable(false); window.center(); VerticalLayout popupLayout = new VerticalLayout(); popupLayout.setMargin(true); popupLayout.setSpacing(true); popupLayout.setSizeUndefined(); Label contentLabel = new Label(contentText); contentLabel.setWidth(100, Unit.PERCENTAGE); popupLayout.addComponent(contentLabel); Button okayButton = new Button(I18nProperties.getCaption(Captions.actionOkay)); okayButton.addClickListener(e -> { window.close(); }); CssStyles.style(okayButton, ValoTheme.BUTTON_PRIMARY); popupLayout.addComponent(okayButton); popupLayout.setComponentAlignment(okayButton, Alignment.BOTTOM_RIGHT); window.setCaption(caption); window.setContent(popupLayout); UI.getCurrent().addWindow(window); return window; }
From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java
License:Open Source License
public static Window showPopupWindow(Component content) { Window window = new Window(null); window.setModal(true);//from w w w. j a va 2s . co m window.setSizeUndefined(); window.setResizable(false); window.center(); window.setContent(content); UI.getCurrent().addWindow(window); return window; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.BiologicalSamplesComponent.java
License:Open Source License
/** * /*from ww w.jav a 2 s. c o m*/ * @param id */ public void updateUI(String id) { currentID = id; sampleBioGrid = new Grid(); sampleEntityGrid = new Grid(); sampleEntityGrid.addSelectionListener(new SelectionListener() { @Override public void select(SelectionEvent event) { BeanItem<BiologicalEntitySampleBean> selectedBean = samplesEntity .getItem(sampleEntityGrid.getSelectedRow()); if (selectedBean == null) { TextField filterField = (TextField) sampleBioGrid.getHeaderRow(1).getCell("biologicalEntity") .getComponent(); filterField.setValue(""); } else { TextField filterField = (TextField) sampleBioGrid.getHeaderRow(1).getCell("biologicalEntity") .getComponent(); filterField.setValue(selectedBean.getBean().getCode()); // samplesBio.addContainerFilter("biologicalEntity", // selectedBean.getBean().getSecondaryName(), false, false); } } }); if (id == null) return; BeanItemContainer<BiologicalSampleBean> samplesBioContainer = new BeanItemContainer<BiologicalSampleBean>( BiologicalSampleBean.class); BeanItemContainer<BiologicalEntitySampleBean> samplesEntityContainer = new BeanItemContainer<BiologicalEntitySampleBean>( BiologicalEntitySampleBean.class); List<Sample> allSamples = datahandler.getOpenBisClient() .getSamplesWithParentsAndChildrenOfProjectBySearchService(id); List<VocabularyTerm> terms = null; Map<String, String> termsMap = new HashMap<String, String>(); for (Sample sample : allSamples) { if (sample.getSampleTypeCode().equals(sampleTypes.Q_BIOLOGICAL_ENTITY.toString())) { Map<String, String> sampleProperties = sample.getProperties(); BiologicalEntitySampleBean newEntityBean = new BiologicalEntitySampleBean(); newEntityBean.setCode(sample.getCode()); newEntityBean.setId(sample.getIdentifier()); newEntityBean.setType(sample.getSampleTypeCode()); newEntityBean.setAdditionalInfo(sampleProperties.get("Q_ADDITIONAL_INFO")); newEntityBean.setExternalDB(sampleProperties.get("Q_EXTERNALDB_ID")); newEntityBean.setSecondaryName(sampleProperties.get("Q_SECONDARY_NAME")); String organismID = sampleProperties.get("Q_NCBI_ORGANISM"); newEntityBean.setOrganism(organismID); if (terms != null) { if (termsMap.containsKey(organismID)) { newEntityBean.setOrganismName(termsMap.get(organismID)); } else { for (VocabularyTerm term : terms) { if (term.getCode().equals(organismID)) { newEntityBean.setOrganismName(term.getLabel()); break; } } } } else { for (Vocabulary vocab : datahandler.getOpenBisClient().getFacade().listVocabularies()) { if (vocab.getCode().equals("Q_NCBI_TAXONOMY")) { terms = vocab.getTerms(); for (VocabularyTerm term : vocab.getTerms()) { if (term.getCode().equals(organismID)) { newEntityBean.setOrganismName(term.getLabel()); termsMap.put(organismID, term.getLabel()); break; } } break; } } } newEntityBean.setProperties(sampleProperties); newEntityBean.setGender(sampleProperties.get("Q_GENDER")); samplesEntityContainer.addBean(newEntityBean); // for (Sample child : datahandler.getOpenBisClient().getChildrenSamples(sample)) { for (Sample realChild : sample.getChildren()) { if (realChild.getSampleTypeCode().equals(sampleTypes.Q_BIOLOGICAL_SAMPLE.toString())) { // Sample realChild = // datahandler.getOpenBisClient().getSampleByIdentifier(child.getIdentifier()); Map<String, String> sampleBioProperties = realChild.getProperties(); BiologicalSampleBean newBean = new BiologicalSampleBean(); newBean.setCode(realChild.getCode()); newBean.setId(realChild.getIdentifier()); newBean.setType(realChild.getSampleTypeCode()); newBean.setPrimaryTissue(sampleBioProperties.get("Q_PRIMARY_TISSUE")); newBean.setTissueDetailed(sampleBioProperties.get("Q_TISSUE_DETAILED")); newBean.setBiologicalEntity(sample.getCode()); newBean.setAdditionalInfo(sampleBioProperties.get("Q_ADDITIONAL_INFO")); newBean.setExternalDB(sampleBioProperties.get("Q_EXTERNALDB_ID")); newBean.setSecondaryName(sampleBioProperties.get("Q_SECONDARY_NAME")); newBean.setProperties(sampleBioProperties); samplesBioContainer.addBean(newBean); } } } } numberOfBioSamples = samplesBioContainer.size(); numberOfEntitySamples = samplesEntityContainer.size(); samplesBio = samplesBioContainer; samplesEntity = samplesEntityContainer; sampleEntityGrid.removeAllColumns(); final GeneratedPropertyContainer gpcEntity = new GeneratedPropertyContainer(samplesEntity); gpcEntity.removeContainerProperty("id"); gpcEntity.removeContainerProperty("type"); gpcEntity.removeContainerProperty("organismName"); gpcEntity.removeContainerProperty("organism"); sampleEntityGrid.setContainerDataSource(gpcEntity); sampleEntityGrid.setColumnReorderingAllowed(true); gpcEntity.addGeneratedProperty("Organism", new PropertyValueGenerator<String>() { @Override public Class<String> getType() { return String.class; } @Override public String getValue(Item item, Object itemId, Object propertyId) { String ncbi = String.format( "http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Undef&name=%s&lvl=0&srchmode=1&keep=1&unlock' target='_blank'>%s</a>", item.getItemProperty("organism").getValue(), item.getItemProperty("organismName").getValue()); String link = String.format("<a href='%s", ncbi); return link; } }); sampleEntityGrid.getColumn("Organism").setRenderer(new HtmlRenderer()); final GeneratedPropertyContainer gpcBio = new GeneratedPropertyContainer(samplesBio); gpcBio.removeContainerProperty("id"); gpcBio.removeContainerProperty("type"); sampleBioGrid.setContainerDataSource(gpcBio); sampleBioGrid.setColumnReorderingAllowed(true); sampleBioGrid.setColumnOrder("secondaryName", "code"); gpcEntity.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; } }); gpcBio.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; } }); sampleEntityGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { BeanItem selected = (BeanItem) samplesEntity.getItem(event.getItemId()); BiologicalEntitySampleBean selectedExp = (BiologicalEntitySampleBean) 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); } }); sampleEntityGrid.getColumn("edit").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { BeanItem selected = (BeanItem) samplesEntity.getItem(event.getItemId()); BiologicalEntitySampleBean selectedSample = (BiologicalEntitySampleBean) 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.addCloseListener(new CloseListener() { /** * */ private static final long serialVersionUID = -1329152609834711109L; @Override public void windowClose(CloseEvent e) { updateUI(currentID); } }); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(subWindow); } })); sampleEntityGrid.getColumn("edit").setWidth(70); sampleEntityGrid.getColumn("edit").setHeaderCaption(""); sampleEntityGrid.setColumnOrder("edit", "secondaryName", "Organism", "properties", "code", "additionalInfo", "gender", "externalDB"); sampleBioGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { BeanItem selected = (BeanItem) samplesBio.getItem(event.getItemId()); BiologicalSampleBean selectedExp = (BiologicalSampleBean) 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); } }); sampleBioGrid.getColumn("edit").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { BeanItem selected = (BeanItem) samplesBio.getItem(event.getItemId()); try { BiologicalSampleBean selectedSample = (BiologicalSampleBean) selected.getBean(); Window subWindow = new Window(); 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.setResizable(false); subWindow.addCloseListener(new CloseListener() { /** * */ private static final long serialVersionUID = -1329152609834711109L; @Override public void windowClose(CloseEvent e) { updateUI(currentID); } }); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(subWindow); } catch (NullPointerException e) { System.err.println("NullPointerException while trying to set metadata: " + e.getMessage()); } } })); sampleBioGrid.getColumn("edit").setWidth(70); sampleBioGrid.getColumn("edit").setHeaderCaption(""); sampleBioGrid.setColumnOrder("edit", "secondaryName", "primaryTissue", "properties", "tissueDetailed", "code", "additionalInfo", "biologicalEntity", "externalDB"); sampleBioGrid.getColumn("biologicalEntity").setHeaderCaption("Source"); helpers.GridFunctions.addColumnFilters(sampleBioGrid, gpcBio); helpers.GridFunctions.addColumnFilters(sampleEntityGrid, gpcEntity); if (fileDownloaderSources != null) exportSources.removeExtension(fileDownloaderSources); StreamResource srSource = Utils.getTSVStream(Utils.containerToString(samplesEntityContainer), String.format("%s_%s_", id.substring(1).replace("/", "_"), "sample_sources")); fileDownloaderSources = new FileDownloader(srSource); fileDownloaderSources.extend(exportSources); if (fileDownloaderSamples != null) exportSamples.removeExtension(fileDownloaderSamples); StreamResource srSamples = Utils.getTSVStream(Utils.containerToString(samplesBioContainer), String.format("%s_%s_", id.substring(1).replace("/", "_"), "extracted_samples")); fileDownloaderSamples = new FileDownloader(srSamples); fileDownloaderSamples.extend(exportSamples); this.buildLayout(); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.DatasetComponent.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 www .ja v a2 s . c o m*/ */ private void buildLayout() { this.vert.removeAllComponents(); this.vert.setSizeFull(); vert.setResponsive(true); // Table (containing datasets) section VerticalLayout tableSection = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); tableSection.setResponsive(true); tableSectionContent.setResponsive(true); // tableSectionContent.setCaption("Datasets"); // tableSectionContent.setIcon(FontAwesome.FLASK); // tableSection.addComponent(new Label(String.format("This project contains %s dataset(s).", // numberOfDatasets))); tableSectionContent.setMargin(new MarginInfo(true, false, true, false)); tableSection.addComponent(headerLabel); tableSectionContent.addComponent(this.table); vert.setMargin(new MarginInfo(false, true, false, false)); tableSection.setMargin(new MarginInfo(true, false, false, true)); // tableSectionContent.setMargin(true); // tableSection.setMargin(true); tableSection.addComponent(tableSectionContent); this.vert.addComponent(tableSection); table.setSizeFull(); tableSection.setSizeFull(); tableSectionContent.setSizeFull(); // this.table.setSizeFull(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, true, true)); buttonLayout.setHeight(null); // buttonLayout.setWidth("100%"); buttonLayout.setSpacing(true); buttonLayout.setResponsive(true); // final Button visualize = new Button(VISUALIZE_BUTTON_CAPTION); Button checkAll = new Button("Select all datasets"); checkAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : table.getItemIds()) { ((CheckBox) table.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 : table.getItemIds()) { ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(false); } } }); 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-party 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>"; export.setIcon(FontAwesome.DOWNLOAD); 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); buttonLayout.addComponent(export); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); // buttonLayout.addComponent(visualize); buttonLayout.addComponent(this.download); /** * prepare download. */ download.setEnabled(false); download.setResource(new ExternalResource("javascript:")); // visualize.setEnabled(false); for (final Object itemId : this.table.getItemIds()) { setCheckedBox(itemId, (String) this.table.getItem(itemId).getItemProperty("CODE").getValue()); } this.table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (!event.isDoubleClick() & !((boolean) table.getItem(event.getItemId()).getItemProperty("isDirectory").getValue())) { String datasetCode = (String) table.getItem(event.getItemId()).getItemProperty("CODE") .getValue(); String datasetFileName = (String) table.getItem(event.getItemId()).getItemProperty("File Name") .getValue(); URL url; try { Resource res = null; Object parent = table.getParent(event.getItemId()); if (parent != null) { String parentDatasetFileName = (String) table.getItem(parent) .getItemProperty("File Name").getValue(); url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, parentDatasetFileName + "/" + datasetFileName); } else { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, datasetFileName); } 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(".GSvar")) { 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 (visualize) { // LOGGER.debug("Is resource null?: " + String.valueOf(res == null)); BrowserFrame frame = new BrowserFrame("", res); 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)); 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(buttonLayout); this.vert.addComponent(help); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.DatasetView.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 2s. c o m */ private void buildLayout() { this.vert.removeAllComponents(); int browserWidth = UI.getCurrent().getPage().getBrowserWindowWidth(); int browserHeight = UI.getCurrent().getPage().getBrowserWindowHeight(); this.vert.setWidth("100%"); this.setWidth(String.format("%spx", (browserWidth * 0.6))); // this.setHeight(String.format("%spx", (browserHeight * 0.8))); VerticalLayout statistics = new VerticalLayout(); HorizontalLayout statContent = new HorizontalLayout(); statContent.setCaption("Statistics"); statContent.setIcon(FontAwesome.BAR_CHART_O); statContent.addComponent(new Label(String.format("%s registered dataset(s).", numberOfDatasets))); statContent.setMargin(true); statContent.setSpacing(true); statistics.addComponent(statContent); statistics.setMargin(true); this.vert.addComponent(statistics); // Table (containing datasets) section VerticalLayout tableSection = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); tableSectionContent.setCaption("Registered Datasets"); tableSectionContent.setIcon(FontAwesome.FLASK); tableSectionContent.addComponent(this.table); tableSectionContent.setMargin(true); tableSection.setMargin(true); tableSection.addComponent(tableSectionContent); this.vert.addComponent(tableSection); table.setWidth("100%"); tableSection.setWidth("100%"); tableSectionContent.setWidth("100%"); // this.table.setSizeFull(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight(null); buttonLayout.setWidth("100%"); buttonLayout.setSpacing(false); final Button visualize = new Button(VISUALIZE_BUTTON_CAPTION); buttonLayout.addComponent(this.download); buttonLayout.addComponent(visualize); Button checkAll = new Button("Select all datasets"); checkAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : table.getItemIds()) { ((CheckBox) table.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 : table.getItemIds()) { ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(false); } } }); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); /** * prepare download. */ download.setResource(new ExternalResource("javascript:")); download.setEnabled(false); visualize.setEnabled(false); for (final Object itemId : this.table.getItemIds()) { setCheckedBox(itemId, (String) this.table.getItem(itemId).getItemProperty("CODE").getValue()); } /* * Update the visualize button. It is only enabled, if the files can be visualized. */ this.table.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = -4875903343717437913L; /** * check for what selection can be visualized. If so, enable the button. TODO change to * checked. */ @Override public void valueChange(ValueChangeEvent event) { // Nothing selected or more than one selected. Set<Object> selectedValues = (Set<Object>) event.getProperty().getValue(); if (selectedValues == null || selectedValues.size() == 0 || selectedValues.size() > 1) { visualize.setEnabled(false); return; } // if one selected check whether its dataset type is either fastqc or qcml. // For now we only visulize these two file types. Iterator<Object> iterator = selectedValues.iterator(); Object next = iterator.next(); String datasetType = (String) table.getItem(next).getItemProperty("Dataset Type").getValue(); String fileName = (String) table.getItem(next).getItemProperty("File Name").getValue(); // TODO: No hardcoding!! // if (datasetType.equals("FASTQC") || datasetType.equals("QCML") || // datasetType.equals("BAM") // || datasetType.equals("VCF")) { if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_RESULTS") && (fileName.endsWith(".html") || fileName.endsWith(".qcML"))) { visualize.setEnabled(true); } else if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_LOGS") && (fileName.endsWith(".err") || fileName.endsWith(".out"))) { visualize.setEnabled(true); } else { visualize.setEnabled(false); } } }); // TODO Workflow Views should get those data and be happy /* * Send message that in datasetview the following was selected. WorkflowViews get those messages * and save them, if it is valid information for them. */ this.table.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = -3554627008191389648L; @Override public void valueChange(ValueChangeEvent event) { // Nothing selected or more than one selected. Set<Object> selectedValues = (Set<Object>) event.getProperty().getValue(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("DataSetView"); if (selectedValues != null && selectedValues.size() == 1) { Iterator<Object> iterator = selectedValues.iterator(); Object next = iterator.next(); String datasetType = (String) table.getItem(next).getItemProperty("Dataset Type").getValue(); message.add(datasetType); String project = (String) table.getItem(next).getItemProperty("Project").getValue(); String space = datahandler.getOpenBisClient().getProjectByCode(project).getSpaceCode();// .getIdentifier().split("/")[1]; message.add(project); message.add((String) table.getItem(next).getItemProperty("Sample").getValue()); // message.add((String) table.getItem(next).getItemProperty("Sample Type").getValue()); message.add((String) table.getItem(next).getItemProperty("dl_link").getValue()); message.add((String) table.getItem(next).getItemProperty("File Name").getValue()); message.add(space); // state.notifyObservers(message); } else { message.add("null"); } // TODO // state.notifyObservers(message); } }); // TODO get the GV to work here. Together with reverse proxy // Assumes that table Value Change listner is enabling or disabling the button if preconditions // are not fullfilled visualize.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = 9015273307461506369L; @Override public void buttonClick(ClickEvent event) { Set<Object> selectedValues = (Set<Object>) table.getValue(); Iterator<Object> iterator = selectedValues.iterator(); Object next = iterator.next(); String datasetCode = (String) table.getItem(next).getItemProperty("CODE").getValue(); String datasetFileName = (String) table.getItem(next).getItemProperty("File Name").getValue(); URL url; try { Object parent = table.getParent(next); if (parent != null) { String parentDatasetFileName = (String) table.getItem(parent).getItemProperty("File Name") .getValue(); url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, parentDatasetFileName + "/" + datasetFileName); } else { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, datasetFileName); } Window subWindow = new Window( "QC of Sample: " + (String) table.getItem(next).getItemProperty("Sample").getValue()); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subWindow.setContent(subContent); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); // Put some components in it Resource res = null; String datasetType = (String) table.getItem(next).getItemProperty("Dataset Type").getValue(); final RequestHandler rh = new ProxyForGenomeViewerRestApi(); boolean rhAttached = false; if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_RESULTS") && datasetFileName.endsWith(".qcML")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("application/xml"); res = streamres; } else if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_RESULTS") && datasetFileName.endsWith(".html")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/html"); res = streamres; } else if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_LOGS") && (datasetFileName.endsWith(".err") || datasetFileName.endsWith(".out"))) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; } else if (datasetType.equals("FASTQC")) { res = new ExternalResource(url); } else if (datasetType.equals("BAM") || datasetType.equals("VCF")) { String filePath = (String) table.getItem(next).getItemProperty("dl_link").getValue(); filePath = String.format("/store%s", filePath.split("store")[1]); String fileId = (String) table.getItem(next).getItemProperty("File Name").getValue(); // fileId = "control.1kg.panel.samples.vcf.gz"; // UI.getCurrent().getSession().addRequestHandler(rh); rhAttached = true; ThemeDisplay themedisplay = (ThemeDisplay) VaadinService.getCurrentRequest() .getAttribute(WebKeys.THEME_DISPLAY); String hostTmp = "http://localhost:7778/vizrest/rest";// "http://localhost:8080/web/guest/mainportlet?p_p_id=QbicmainportletApplicationPortlet_WAR_QBiCMainPortlet_INSTANCE_5pPd5JQ8uGOt&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&p_p_col_id=column-1&p_p_col_count=1"; // hostTmp += // "&qbicsession=" + UI.getCurrent().getSession().getAttribute("gv-restapi-session") // + "&someblabla="; // String hostTmp = themedisplay.getURLPortal() + // UI.getCurrent().getPage().getLocation().getPath() + "?qbicsession=" + // UI.getCurrent().getSession().getAttribute("gv-restapi-session") + "&someblabla=" ; // String host = Base64.encode(hostTmp.getBytes()); String title = (String) table.getItem(next).getItemProperty("Sample").getValue(); // res = // new ExternalResource( // String // .format( // "http://localhost:7778/genomeviewer/?host=%s&title=%s&fileid=%s&featuretype=alignments&filepath=%s&removeZeroGenotypes=false", // host, title, fileId, filePath)); } BrowserFrame frame = new BrowserFrame("", res); if (rhAttached) { frame.addDetachListener(new DetachListener() { /** * */ private static final long serialVersionUID = 1534523447730906543L; @Override public void detach(DetachEvent event) { UI.getCurrent().getSession().removeRequestHandler(rh); } }); } frame.setSizeFull(); subContent.addComponent(frame); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setSizeFull(); frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.8), 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)); 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(buttonLayout); }