List of usage examples for com.vaadin.ui HorizontalLayout setResponsive
public void setResponsive(boolean responsive)
From source file:de.uni_tuebingen.qbic.qbicmainportlet.BiologicalSamplesComponent.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.// ww w . j ava 2 s .co 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(); HorizontalLayout sampletableSectionContent = new HorizontalLayout(); tableSection.setResponsive(true); tableSectionContent.setResponsive(true); sampletableSectionContent.setResponsive(true); tableSectionContent.setMargin(new MarginInfo(true, false, false, false)); sampletableSectionContent.setMargin(new MarginInfo(true, false, false, false)); // tableSectionContent.setCaption("Datasets"); // tableSectionContent.setIcon(FontAwesome.FLASK); tableSection.addComponent(new Label(String.format( "This view shows the sample sources (e.g., human, mouse) to be studied and the corresponding extracted samples. With sample sources, information specific to the subject (e.g., age or BMI in the case of patient data) can be stored. The extracted sample is a sample which has been extracted from the corresponding sample source. This is the raw sample material that can be later prepared for specific analytical methods such as MS or NGS.<br> " + "\n\n There are %s extracted samples coming from %s distinct sample sources in this study.", numberOfBioSamples, numberOfEntitySamples), ContentMode.HTML)); tableSectionContent.addComponent(sampleBioGrid); sampletableSectionContent.addComponent(sampleEntityGrid); sampleEntityGrid.setCaption("Sample Sources"); sampleBioGrid.setCaption("Extracted Samples"); tableSection.setMargin(new MarginInfo(true, false, true, true)); tableSection.setSpacing(true); tableSection.addComponent(sampletableSectionContent); tableSection.addComponent(exportSources); tableSection.addComponent(tableSectionContent); tableSection.addComponent(exportSamples); this.vert.addComponent(tableSection); sampleBioGrid.setWidth(100, Unit.PERCENTAGE); sampleEntityGrid.setWidth(100, Unit.PERCENTAGE); // sampleBioGrid.setHeightMode(HeightMode.ROW); // sampleEntityGrid.setHeightMode(HeightMode.ROW); // sampleBioGrid.setHeightByRows(Math.min(10, numberOfBioSamples)); // sampleEntityGrid.setHeightByRows(Math.min(10, 5)); tableSection.setSizeFull(); sampletableSectionContent.setSizeFull(); tableSectionContent.setSizeFull(); }
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.//w ww. jav a2s .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.SearchEngineView.java
License:Open Source License
public void initUI() { mainlayout = new Panel(); mainlayout.addStyleName(ValoTheme.PANEL_BORDERLESS); // Search bar // *----------- search text field .... search button-----------* VerticalLayout searchbar = new VerticalLayout(); searchbar.setWidth(100, Unit.PERCENTAGE); setResponsive(true);/* ww w . j a v a 2 s .c o m*/ searchbar.setResponsive(true); // searchbar.setWidth(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setResponsive(true); buttonLayout.setWidth(75, Unit.PERCENTAGE); // searchbar.setSpacing(true); final TextField searchfield = new TextField(); searchfield.setHeight("44px"); searchfield.setImmediate(true); searchfield.setResponsive(true); searchfield.setWidth(75, Unit.PERCENTAGE); buttonLayout.setSpacing(true); searchfield.setInputPrompt("search DB"); // searchfield.setCaption("QSearch"); // searchfield.setWidth(25.0f, Unit.EM); // searchfield.setWidth(60, Unit.PERCENTAGE); // TODO would be nice to have a autofill or something similar // searchFieldLayout.addComponent(searchfield); searchbar.addComponent(searchfield); searchbar.setComponentAlignment(searchfield, Alignment.MIDDLE_RIGHT); final NativeSelect navsel = new NativeSelect(); navsel.addItem("Whole DB"); navsel.addItem("Projects Only"); navsel.addItem("Experiments Only"); navsel.addItem("Samples Only"); navsel.setValue("Whole DB"); navsel.setHeight("20px"); navsel.setNullSelectionAllowed(false); navsel.setResponsive(true); navsel.setWidth(100, Unit.PERCENTAGE); navsel.addValueChangeListener(new Property.ValueChangeListener() { /** * */ private static final long serialVersionUID = -6896454887050432147L; @Override public void valueChange(ValueChangeEvent event) { // TODO Auto-generated method stub Notification.show((String) navsel.getValue()); switch ((String) navsel.getValue()) { case "Whole DB": datahandler.setShowOptions(Arrays.asList("Projects", "Experiments", "Samples")); break; case "Projects Only": datahandler.setShowOptions(Arrays.asList("Projects")); break; case "Experiments Only": datahandler.setShowOptions(Arrays.asList("Experiments")); break; case "Samples Only": datahandler.setShowOptions(Arrays.asList("Samples")); break; default: datahandler.setShowOptions(Arrays.asList("Projects", "Experiments", "Samples")); break; } } }); searchbar.addComponent(buttonLayout); searchbar.setComponentAlignment(buttonLayout, Alignment.MIDDLE_RIGHT); Button searchOk = new Button(""); searchOk.setStyleName(ValoTheme.BUTTON_TINY); // searchOk.addStyleName(ValoTheme.BUTTON_BORDERLESS); searchOk.setIcon(FontAwesome.SEARCH); searchOk.setSizeUndefined(); // searchOk.setWidth(15.0f, Unit.EM); searchOk.setResponsive(true); searchOk.setHeight("20px"); searchOk.addClickListener(new ClickListener() { private static final long serialVersionUID = -2409450448301908214L; @Override public void buttonClick(ClickEvent event) { String queryString = (String) searchfield.getValue().toString(); LOGGER.debug("the query was " + queryString); if (searchfield.getValue() == null || searchfield.getValue().toString().equals("") || searchfield.getValue().toString().trim().length() == 0) { Notification.show("Query field was empty!", Type.WARNING_MESSAGE); } else { try { /** * Sample foundSample = datahandler.getOpenBisClient() .getSampleByIdentifier( * matcher.group(0).toString()); */ datahandler.setSampleResults(querySamples(queryString)); datahandler.setExpResults(queryExperiments(queryString)); datahandler.setProjResults(queryProjects(queryString)); datahandler.setLastQueryString(queryString); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add("view" + queryString); message.add("searchresults"); state.notifyObservers(message); } catch (Exception e) { LOGGER.error("after query: ", e); Notification.show("No Sample found for given barcode.", Type.WARNING_MESSAGE); } } } }); // setClickShortcut() would add global shortcut, instead we // 'scope' the shortcut to the panel: mainlayout.addAction(new com.vaadin.ui.Button.ClickShortcut(searchOk, KeyCode.ENTER)); // searchfield.addItems(this.getSearchResults("Q")); searchfield.setDescription(infotext); searchfield.addValidator(new NullValidator("Field must not be empty", false)); searchfield.setValidationVisible(false); buttonLayout.addComponent(navsel); // buttonLayout.addComponent(new Label("")); buttonLayout.addComponent(searchOk); // searchFieldLayout.setComponentAlignment(searchOk, Alignment.TOP_RIGHT); // buttonLayout.setExpandRatio(searchOk, 1); // buttonLayout.setExpandRatio(navsel, 1); // searchFieldLayout.setSpacing(true); buttonLayout.setComponentAlignment(searchOk, Alignment.BOTTOM_RIGHT); // buttonLayout.setComponentAlignment(navsel, Alignment.BOTTOM_LEFT); buttonLayout.setExpandRatio(searchOk, 1); buttonLayout.setExpandRatio(navsel, 2); // searchbar.setMargin(new MarginInfo(true, false, true, false)); mainlayout.setContent(searchbar); // mainlayout.setComponentAlignment(searchbar, Alignment.MIDDLE_RIGHT); // mainlayout.setWidth(100, Unit.PERCENTAGE); setCompositionRoot(mainlayout); }