List of usage examples for com.vaadin.ui HorizontalLayout setMargin
@Override public void setMargin(boolean enabled)
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./* www .jav a 2s .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.// www . j a v a2s. c om */ 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); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ExperimentComponent.java
License:Open Source License
private void initUI() { expSteps = new VerticalLayout(); expSteps.setWidth(100.0f, Unit.PERCENTAGE); expSteps.setMargin(new MarginInfo(true, true, true, true)); expSteps.setSpacing(true);// ww w .j a v a2 s . c om export = new Button("Export as TSV"); export.setIcon(FontAwesome.DOWNLOAD); VerticalLayout buttonLayoutSection = new VerticalLayout(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight(null); buttonLayout.setWidth("100%"); buttonLayout.addComponent(this.export); buttonLayout.setMargin(new MarginInfo(false, false, false, false)); buttonLayoutSection.addComponent(buttonLayout); buttonLayoutSection.setSpacing(true); buttonLayoutSection.setMargin(new MarginInfo(false, false, false, false)); experiments = new Grid(); experiments.setReadOnly(true); experiments.setWidth(100.0f, Unit.PERCENTAGE); experiments.setCaption("Registered Experimental Steps"); // experiments.setContainerDataSource(new // BeanItemContainer<ExperimentBean>(ExperimentBean.class)); expSteps.addComponent(new Label( "This view shows the experimental steps which have been registered for this project. Experimental steps contain real biological experiments as well as executed computational workflows on project data", ContentMode.HTML)); expSteps.addComponent(experiments); expSteps.addComponent(buttonLayoutSection); setCompositionRoot(expSteps); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ExperimentView.java
License:Open Source License
/** * /*from w ww .j av a 2 s. c o m*/ * @return */ HorizontalLayout initButtonLayout() { this.export = new Button("Export as TSV"); buttonLayoutSection = new VerticalLayout(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, true, true)); buttonLayout.setHeight(null); buttonLayout.setWidth("100%"); buttonLayoutSection.setSpacing(true); buttonLayoutSection.addComponent(buttonLayout); buttonLayoutSection.setMargin(new MarginInfo(false, false, true, true)); buttonLayout.addComponent(this.export); return buttonLayout; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ExperimentView.java
License:Open Source License
/** * /*from w w w .j a v a 2 s. c o m*/ * @return * */ VerticalLayout initStatistics() { VerticalLayout statistics = new VerticalLayout(); HorizontalLayout statContent = new HorizontalLayout(); // statContent.setCaption("Statistics"); // statContent.setIcon(FontAwesome.BAR_CHART_O); // int numberOfDatasets = dh.datasetMap.get(experimentBean.getId()).size(); statContentLabel = new Label(""); statContent.addComponent(statContentLabel); statContent.setMargin(new MarginInfo(true, false, true, true)); // statContent.addComponent(new Label(String.format("%s dataset(s).",numberOfDatasets ))); // statContent.setMargin(true); // statContent.setMargin(new MarginInfo(false, false, false, true)); // statContent.setSpacing(true); /* * if (numberOfDatasets > 0) { * * String lastSample = "No samples available"; if (experimentBean.getLastChangedSample() != * null) { lastSample = experimentBean.getLastChangedSample();// .split("/")[2]; } * statContent.addComponent(new Label(String.format( "Last change %s", String.format( * "occurred in sample %s (%s)", lastSample, * experimentBean.getLastChangedDataset().toString())))); } */ statistics.addComponent(statContent); // statistics.setMargin(true); // Properties of experiment // VerticalLayout properties = new VerticalLayout(); // VerticalLayout propertiesContent = new VerticalLayout(); // propertiesContent.setCaption("Properties"); // propertiesContent.setIcon(FontAwesome.LIST_UL); // propertiesContentLabel = new Label("", ContentMode.HTML); // propertiesContent.addComponent(propertiesContentLabel); // properties.addComponent(propertiesContent); // propertiesContent.setMargin(new MarginInfo(true, false, false, true)); // properties.setMargin(true); // statistics.addComponent(properties); statistics.setMargin(new MarginInfo(true, false, true, true)); statistics.setSpacing(true); return statistics; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ExperimentView.java
License:Open Source License
VerticalLayout initTable() { this.table = this.buildFilterTable(); this.tableClickChangeTreeView(); VerticalLayout tableSection = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); // tableSectionContent.setCaption("Registered Samples"); // tableSectionContent.setIcon(FontAwesome.FLASK); tableSectionContent.addComponent(this.table); tableSectionContent.setMargin(new MarginInfo(true, true, false, true)); // tableSectionContent.setMargin(true); // tableSection.setMargin(true); tableSection.setMargin(new MarginInfo(true, false, false, true)); // this.table.setWidth("100%"); tableSection.setWidth("100%"); tableSectionContent.setWidth("100%"); tableSection.addComponent(tableSectionContent); this.export = new Button("Export as TSV"); buttonLayoutSection = new VerticalLayout(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, false, true)); buttonLayout.setHeight(null);/*ww w .ja v a 2 s . c o m*/ buttonLayout.setWidth("100%"); buttonLayoutSection.setSpacing(true); buttonLayoutSection.addComponent(buttonLayout); buttonLayoutSection.setMargin(new MarginInfo(true, false, true, false)); buttonLayout.addComponent(this.export); tableSection.addComponent(buttonLayoutSection); return tableSection; }
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.// ww w.j a va 2s . c om */ 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.PatientView.java
License:Open Source License
VerticalLayout initTable() { registeredExperiments = this.buildFilterTable(); this.tableClickChangeTreeView(); VerticalLayout tableSection = new VerticalLayout(); VerticalLayout tableSectionContent = new VerticalLayout(); tableSection.setCaption("Exp. Steps"); // tableSectionContent.setCaption("Registered Experiments"); // tableSectionContent.setIcon(FontAwesome.FLASK); tableSectionContent.addComponent(registeredExperiments); tableSectionContent.setMargin(new MarginInfo(true, false, false, true)); tableSection.setMargin(new MarginInfo(true, false, false, true)); registeredExperiments.setWidth("100%"); tableSection.setWidth("100%"); tableSectionContent.setWidth("100%"); tableSection.addComponent(tableSectionContent); this.export = new Button("Export as TSV"); buttonLayoutSection = new VerticalLayout(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight(null);// w ww .j a v a2 s. co m buttonLayout.setWidth("100%"); buttonLayout.addComponent(this.export); buttonLayout.setMargin(new MarginInfo(false, false, true, false)); buttonLayoutSection.addComponent(buttonLayout); buttonLayoutSection.setSpacing(true); buttonLayoutSection.setMargin(new MarginInfo(false, false, true, true)); tableSection.addComponent(buttonLayoutSection); return tableSection; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java
License:Open Source License
/** * //ww w . j a va 2s . c om * @return */ Component initButtonLayout() { this.export = new Button("Export as TSV"); buttonLayoutSection = new VerticalLayout(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight(null); buttonLayout.setWidth("100%"); buttonLayout.addComponent(this.export); buttonLayout.setMargin(new MarginInfo(false, false, false, true)); buttonLayoutSection.addComponent(buttonLayout); buttonLayoutSection.setSpacing(true); buttonLayoutSection.setMargin(new MarginInfo(false, false, false, true)); return buttonLayoutSection; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java
License:Open Source License
VerticalLayout initTable() { this.table = this.buildFilterTable(); this.tableClickChangeTreeView(); VerticalLayout tableSection = new VerticalLayout(); VerticalLayout tableSectionContent = new VerticalLayout(); tableSection.setCaption("Exp. Steps"); // tableSectionContent.setCaption("Registered Experiments"); // tableSectionContent.setIcon(FontAwesome.FLASK); tableSectionContent.addComponent(this.table); tableSectionContent.setMargin(new MarginInfo(true, false, false, true)); tableSection.setMargin(new MarginInfo(true, false, false, true)); this.table.setWidth("100%"); tableSection.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS); tableSectionContent.setWidth("100%"); tableSection.addComponent(tableSectionContent); this.export = new Button("Export as TSV"); buttonLayoutSection = new VerticalLayout(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight(null);/*from w ww.j a v a 2 s. com*/ buttonLayout.setWidth("100%"); buttonLayout.addComponent(this.export); buttonLayout.setMargin(new MarginInfo(false, false, true, false)); buttonLayoutSection.addComponent(buttonLayout); buttonLayoutSection.setSpacing(true); buttonLayoutSection.setMargin(new MarginInfo(false, false, true, true)); tableSection.addComponent(buttonLayoutSection); return tableSection; }