List of usage examples for com.vaadin.ui HorizontalLayout setWidth
@Override public void setWidth(String width)
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./* w w w.j a va 2 s. 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);/*from w ww . j a va2s . c o 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
/** * // w w w .j a v a2s .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 a2 s. c o 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.ProjInformationComponent.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. j av a 2 s.c om */ private void buildLayout(Boolean dataAvailable, String projectType) { vert.removeAllComponents(); // Table (containing datasets) section VerticalLayout tableSection = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); VerticalLayout projDescription = new VerticalLayout(); VerticalLayout projDescriptionContent = new VerticalLayout(); tableSectionContent.setMargin(new MarginInfo(false, false, false, false)); projDescriptionContent.setMargin(new MarginInfo(false, false, false, false)); descHorz.addComponent(descContent); descHorz.addComponent(descEdit); descHorz.setComponentAlignment(descEdit, Alignment.TOP_RIGHT); descHorz.setExpandRatio(descContent, 0.9f); descHorz.setExpandRatio(descEdit, 0.1f); projDescriptionContent.addComponent(descHorz); projDescriptionContent.addComponent(peopleInCharge); // descContent.setWidth("80%"); projDescriptionContent.addComponent(descriptionPanel); projDescriptionContent.addComponent(statusPanel); // longDescription.setWidth("80%"); // projDescriptionContent.addComponent(experimentLabel); // projDescriptionContent.addComponent(statusContent); // statusContent.setSpacing(true); // statusContent.setMargin(new MarginInfo(false, false, false, true)); if (projectType.equals("patient")) { String patientInfo = ""; Boolean available = false; SearchCriteria sampleSc = new SearchCriteria(); sampleSc.addMatchClause( MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, "Q_BIOLOGICAL_ENTITY")); SearchCriteria projectSc = new SearchCriteria(); projectSc.addMatchClause( MatchClause.createAttributeMatch(MatchClauseAttribute.PROJECT, projectBean.getCode())); sampleSc.addSubCriteria(SearchSubCriteria.createExperimentCriteria(projectSc)); SearchCriteria experimentSc = new SearchCriteria(); experimentSc.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, model.ExperimentType.Q_EXPERIMENTAL_DESIGN.name())); sampleSc.addSubCriteria(SearchSubCriteria.createExperimentCriteria(experimentSc)); List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample> samples = datahandler.getOpenBisClient() .getFacade().searchForSamples(sampleSc); for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample sample : samples) { if (sample.getProperties().get("Q_ADDITIONAL_INFO") != null) { available = true; String[] splitted = sample.getProperties().get("Q_ADDITIONAL_INFO").split(";"); for (String s : splitted) { String[] splitted2 = s.split(":"); patientInfo += String.format("<p><u>%s</u>: %s </p> ", splitted2[0], splitted2[1]); } } } if (available) { patientInformation.setValue(patientInfo); } else { patientInformation.setValue("No patient information provided."); } updateHLALayout(); projDescriptionContent.addComponent(patientInformation); projDescriptionContent.addComponent(hlaTypeLabel); // Vaccine Designer /* * Button vaccineDesigner = new Button("Vaccine Designer"); * vaccineDesigner.setStyleName(ValoTheme.BUTTON_PRIMARY); * vaccineDesigner.setIcon(FontAwesome.CUBES); * * vaccineDesigner.addClickListener(new ClickListener() { * * @Override public void buttonClick(ClickEvent event) { * * ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); StringBuilder * sb = new StringBuilder("type="); sb.append("vaccinedesign"); sb.append("&"); * sb.append("id="); sb.append(projectBean.getId()); message.add(sb.toString()); * message.add(VaccineDesignerView.navigateToLabel); state.notifyObservers(message); */ // UI.getCurrent().getNavigator() // .navigateTo(String.format(VaccineDesignerView.navigateToLabel)); // } // }); // projDescriptionContent.addComponent(vaccineDesigner); } projDescriptionContent.addComponent(tsvDownloadContent); projDescription.addComponent(projDescriptionContent); projDescriptionContent.setSpacing(true); projDescription.setMargin(new MarginInfo(false, false, true, true)); projDescription.setWidth("100%"); projDescription.setSpacing(true); // descriptionLabel.setWidth("100%"); // tableSection.addComponent(descriptionLabel); tableSectionContent.addComponent(this.datasetTable); projDescriptionContent.addComponent(contact); tableSection.setMargin(new MarginInfo(true, false, false, true)); tableSection.setSpacing(true); tableSection.addComponent(tableSectionContent); this.vert.addComponent(projDescription); datasetTable.setWidth("100%"); tableSection.setWidth("100%"); tableSectionContent.setWidth("100%"); // this.table.setSizeFull(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, true, false)); buttonLayout.setHeight(null); // buttonLayout.setWidth("100%"); 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(checkAll); buttonLayout.addComponent(uncheckAll); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); buttonLayout.addComponent(this.download); /** * 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()); } /* * Send message that in datasetview the following was selected. WorkflowViews get those messages * and save them, if it is valid information for them. */ this.datasetTable.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) datasetTable.getItem(next).getItemProperty("Dataset Type") .getValue(); message.add(datasetType); String project = (String) datasetTable.getItem(next).getItemProperty("Project").getValue(); String space = datahandler.getOpenBisClient().getProjectByCode(project).getSpaceCode();// .getIdentifier().split("/")[1]; message.add(project); message.add((String) datasetTable.getItem(next).getItemProperty("Sample").getValue()); // message.add((String) table.getItem(next).getItemProperty("Sample Type").getValue()); message.add((String) datasetTable.getItem(next).getItemProperty("dl_link").getValue()); message.add((String) datasetTable.getItem(next).getItemProperty("File Name").getValue()); message.add(space); // state.notifyObservers(message); } else { message.add("null"); } // TODO // state.notifyObservers(message); } }); this.datasetTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (!event.isDoubleClick()) { String datasetCode = (String) datasetTable.getItem(event.getItemId()).getItemProperty("CODE") .getValue(); String datasetFileName = (String) datasetTable.getItem(event.getItemId()) .getItemProperty("File Name").getValue(); URL url; try { Resource res = null; Object parent = datasetTable.getParent(event.getItemId()); if (parent != null) { String parentDatasetFileName = (String) datasetTable.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); 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 (visualize) { LOGGER.debug("Is resource null?: " + String.valueOf(res == null)); BrowserFrame frame = new BrowserFrame("", res); 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.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); if (dataAvailable) { this.vert.addComponent(tableSection); tableSection.addComponent(buttonLayout); projDescription.setMargin(new MarginInfo(false, false, false, true)); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.QbicmainportletUI.java
License:Open Source License
/** * builds page if user is not logged in//w w w .j a va 2 s. c o m */ private void buildNotLoggedinLayout() { // Mail to qbic ExternalResource resource = new ExternalResource("mailto:info@qbic.uni-tuebingen.de"); Link mailToQbicLink = new Link("", resource); mailToQbicLink.setIcon(new ThemeResource("mail9.png")); ThemeDisplay themedisplay = (ThemeDisplay) VaadinService.getCurrentRequest() .getAttribute(WebKeys.THEME_DISPLAY); // redirect to liferay login page Link loginPortalLink = new Link("", new ExternalResource(themedisplay.getURLSignIn())); loginPortalLink.setIcon(new ThemeResource("lock12.png")); // left part of the page VerticalLayout signIn = new VerticalLayout(); signIn.addComponent( new Label("<h3>Sign in to manage your projects and access your data:</h3>", ContentMode.HTML)); signIn.addComponent(loginPortalLink); signIn.setStyleName("no-user-login"); // right part of the page VerticalLayout contact = new VerticalLayout(); contact.addComponent( new Label("<h3>If you are interested in doing projects get in contact:</h3>", ContentMode.HTML)); contact.addComponent(mailToQbicLink); contact.setStyleName("no-user-login"); // build final layout, with some gaps between HorizontalLayout notSignedInLayout = new HorizontalLayout(); Label expandingGap1 = new Label(); expandingGap1.setWidth("100%"); notSignedInLayout.addComponent(expandingGap1); notSignedInLayout.addComponent(signIn); notSignedInLayout.addComponent(contact); notSignedInLayout.setExpandRatio(expandingGap1, 0.16f); notSignedInLayout.setExpandRatio(signIn, 0.36f); notSignedInLayout.setExpandRatio(contact, 0.36f); notSignedInLayout.setWidth("100%"); notSignedInLayout.setSpacing(true); setContent(notSignedInLayout); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SampleView.java
License:Open Source License
/** * //from w ww . j a v a 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, true, true)); buttonLayoutSection.addComponent(buttonLayout); buttonLayoutSection.setSpacing(true); buttonLayoutSection.setMargin(new MarginInfo(false, false, true, true)); return buttonLayoutSection; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SampleView.java
License:Open Source License
VerticalLayout initTable() { this.table = this.buildFilterTable(); VerticalLayout tableSection = new VerticalLayout(); VerticalLayout tableSectionContent = new VerticalLayout(); tableSection.setCaption("Experiments"); // 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);/*w ww.java 2 s .c om*/ 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:dhbw.clippinggorilla.userinterface.views.ArchiveView.java
public ArchiveView() { HorizontalLayout optionsLayout = new HorizontalLayout(); optionsLayout.setWidth("100%"); Grid<Clipping> gridClippings = new Grid<>(); Set<Clipping> clippings = ClippingUtils.getUserClippings(UserUtils.getCurrent(), LocalDate.now(ZoneId.of("Europe/Berlin"))); gridClippings.setItems(clippings);//w ww . j ava2s. co m InlineDateTimeField datePicker = new InlineDateTimeField(); datePicker.setValue(LocalDateTime.now(ZoneId.of("Europe/Berlin"))); datePicker.setLocale(Locale.GERMANY); datePicker.setResolution(DateTimeResolution.DAY); datePicker.addValueChangeListener(date -> { Set<Clipping> clippingsOfDate = ClippingUtils.getUserClippings(UserUtils.getCurrent(), date.getValue().toLocalDate()); gridClippings.setItems(clippingsOfDate); gridClippings.getDataProvider().refreshAll(); }); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM); formatter.withZone(ZoneId.of("Europe/Berlin")); Column columnTime = gridClippings.addColumn(c -> { return c.getDate().format(formatter); }); Language.setCustom(Word.TIME, s -> columnTime.setCaption(s)); Column columnAmountArticles = gridClippings.addColumn(c -> { long amountArticles = c.getArticles().values().stream().flatMap(l -> l.stream()).count(); amountArticles += c.getArticlesFromGroup().values().stream().flatMap(l -> l.stream()).count(); if (amountArticles != 1) { return amountArticles + " " + Language.get(Word.ARTICLES); } else { return amountArticles + " " + Language.get(Word.ARTICLE); } }); Language.setCustom(Word.ARTICLES, s -> { columnAmountArticles.setCaption(s); gridClippings.getDataProvider().refreshAll(); }); gridClippings.setHeight("100%"); gridClippings.setSelectionMode(Grid.SelectionMode.SINGLE); gridClippings.addSelectionListener(c -> { if (c.getFirstSelectedItem().isPresent()) { currentClipping = c.getFirstSelectedItem().get(); showClippingBy(currentClipping, currentSort); } }); optionsLayout.addComponents(datePicker, gridClippings); optionsLayout.setComponentAlignment(datePicker, Alignment.BOTTOM_CENTER); optionsLayout.setComponentAlignment(gridClippings, Alignment.BOTTOM_RIGHT); optionsLayout.setExpandRatio(gridClippings, 5); VerticalLayout sortLayout = new VerticalLayout(); comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY)); Language.setCustom(Word.SORT_BY, s -> { comboBoxSortOptions.setCaption(s); comboBoxSortOptions.getDataProvider().refreshAll(); }); comboBoxSortOptions.setItems(EnumSet.allOf(ClippingView.SortOptions.class)); comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName()); comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon()); comboBoxSortOptions.setValue(currentSort); comboBoxSortOptions.setTextInputAllowed(false); comboBoxSortOptions.setEmptySelectionAllowed(false); comboBoxSortOptions.addStyleName("comboboxsort"); comboBoxSortOptions.addValueChangeListener(e -> { currentSort = e.getValue(); showClippingBy(currentClipping, currentSort); }); comboBoxSortOptions.setVisible(false); sortLayout.setMargin(false); sortLayout.setSpacing(false); sortLayout.addComponent(comboBoxSortOptions); clippingArticlesLayout = new VerticalLayout(); clippingArticlesLayout.setSpacing(true); clippingArticlesLayout.setMargin(false); clippingArticlesLayout.setSizeFull(); addComponents(optionsLayout, sortLayout, clippingArticlesLayout); }
From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java
public Component createClippingRow(Article a) { Image imageNewsImage = new Image(); String url = a.getUrlToImage(); if (url == null || url.isEmpty()) { url = a.getSourceAsSource().getLogo().toExternalForm(); }//from w w w . ja v a2s. c om imageNewsImage.setSource(new ExternalResource(url)); imageNewsImage.addStyleName("articleimage"); VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage); layoutNewsImage.setMargin(false); layoutNewsImage.setSpacing(false); layoutNewsImage.setWidth("200px"); layoutNewsImage.setHeight("150px"); layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER); Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H2); labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN); labelHeadLine.setWidth("100%"); Label labelDescription = new Label(a.getDescription(), ContentMode.HTML); labelDescription.setWidth("100%"); Image imageSource = new Image(); Source s = a.getSourceAsSource(); URL logo; if (s != null) { logo = s.getLogo(); } else { Log.error("Source is null: " + a.getSource()); return new Label("INTERNAL ERROR"); } if (logo != null) { imageSource.setSource(new ExternalResource(logo)); } else { Log.error("Sourcelogo is null: " + s.getName()); } imageSource.setHeight("30px"); Label labelSource = new Label(a.getSourceAsSource().getName()); labelSource.addStyleName(ValoTheme.LABEL_SMALL); LocalDateTime time = a.getPublishedAtAsLocalDateTime(); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); formatter.withZone(ZoneId.of("Europe/Berlin")); Label labelDate = new Label(time.format(formatter)); labelDate.addStyleName(ValoTheme.LABEL_SMALL); Label labelAuthor = new Label(); labelAuthor.addStyleName(ValoTheme.LABEL_SMALL); labelAuthor.setWidth("100%"); if (a.getAuthor() != null && !a.getAuthor().isEmpty()) { labelAuthor.setValue(a.getAuthor()); } Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK); openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); HorizontalLayout layoutArticleOptions = new HorizontalLayout(); layoutArticleOptions.setWidth("100%"); layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite); layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT); layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER); layoutArticleOptions.setExpandRatio(labelAuthor, 5); VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions); layoutNewsText.setMargin(false); layoutNewsText.setWidth("100%"); HorizontalLayout layoutClipping = new HorizontalLayout(); layoutClipping.setWidth("100%"); layoutClipping.setMargin(true); layoutClipping.addComponents(layoutNewsImage, layoutNewsText); layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER); layoutClipping.setExpandRatio(layoutNewsText, 5); layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD); layoutClipping.addStyleName("tags"); return layoutClipping; }