List of usage examples for com.vaadin.ui HorizontalLayout setIcon
@Override public void setIcon(Resource icon)
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 av a 2s .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.SearchForUsers.java
License:Open Source License
public SearchForUsers() { this.vert = new VerticalLayout(); this.table = buildFilterTable(); this.table.setSelectable(true); // this.table.setSizeFull(); this.button = new Button("Show Users"); this.button.addClickListener(this); this.button.setIcon(FontAwesome.SEARCH); this.button.setDescription("Click button to show user information"); VerticalLayout searchSection = new VerticalLayout(); HorizontalLayout searchContent = new HorizontalLayout(); searchSection.setMargin(true);/* w w w . j av a2 s . c o m*/ searchContent.setMargin(true); searchContent.addComponent(this.button); searchSection.addComponent(searchContent); VerticalLayout tableSection = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); tableSectionContent.setIcon(FontAwesome.USERS); tableSectionContent.setCaption("Connected Users"); tableSectionContent.addComponent(this.table); tableSectionContent.setMargin(true); tableSection.setMargin(true); tableSection.addComponent(tableSectionContent); this.vert.addComponent(searchSection); this.vert.addComponent(tableSection); vert.setSpacing(true); this.setContent(vert); }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildUserTab(User user) { HorizontalLayout root = new HorizontalLayout(); root.setCaption(Language.get(Word.PROFILE)); root.setIcon(VaadinIcons.USER); root.setWidth("100%"); root.setSpacing(true);/*from w w w . ja v a 2 s . c om*/ root.setMargin(true); FormLayout details = new FormLayout(); details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(details); firstNameField = new TextField(Language.get(Word.FIRST_NAME)); firstNameField.setValue(user.getFirstName()); firstNameField.setMaxLength(20); firstNameField.addValueChangeListener(event -> { String firstNameError = UserUtils.checkName(event.getValue()); if (!firstNameError.isEmpty()) { firstNameField.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(firstNameError); saveButton.setEnabled(setError(firstNameField, true)); } else { firstNameField.setComponentError(null); boolean enabled = setError(firstNameField, false); saveButton.setEnabled(enabled); } }); setError(firstNameField, false); lastNameField = new TextField(Language.get(Word.LAST_NAME)); lastNameField.setValue(user.getLastName()); lastNameField.setMaxLength(20); lastNameField.addValueChangeListener(event -> { String lastNameError = UserUtils.checkName(event.getValue()); if (!lastNameError.isEmpty()) { lastNameField.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(lastNameError); saveButton.setEnabled(setError(lastNameField, true)); } else { lastNameField.setComponentError(null); saveButton.setEnabled(setError(lastNameField, false)); } }); setError(lastNameField, false); usernameField = new TextField(Language.get(Word.USERNAME)); usernameField.setValue(user.getUsername()); usernameField.setMaxLength(20); usernameField.addValueChangeListener(event -> { if (!event.getValue().equals(user.getUsername())) { String userNameError = UserUtils.checkUsername(event.getValue()); if (!userNameError.isEmpty()) { usernameField.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(userNameError); saveButton.setEnabled(setError(usernameField, true)); } else { usernameField.setComponentError(null); saveButton.setEnabled(setError(usernameField, false)); } } else { usernameField.setComponentError(null); saveButton.setEnabled(setError(usernameField, false)); } }); setError(usernameField, false); emailField = new TextField(Language.get(Word.EMAIL)); emailField.setValue(user.getEmail()); emailField.setMaxLength(256); emailField.addValueChangeListener(event -> { if (!event.getValue().equals(user.getEmail())) { String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase()); if (!email1Error.isEmpty()) { emailField.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(email1Error); saveButton.setEnabled(setError(emailField, true)); } else { emailField.setComponentError(null); saveButton.setEnabled(setError(emailField, false)); } } else { emailField.setComponentError(null); saveButton.setEnabled(setError(emailField, false)); } }); setError(emailField, false); oldPasswordField = new PasswordField(Language.get(Word.OLD_PASSWORD)); oldPasswordField.setValue(""); oldPasswordField.setMaxLength(51); oldPasswordField.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password1Error = UserUtils.checkPassword(event.getValue()); if (!password1Error.isEmpty()) { oldPasswordField.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); saveButton.setEnabled(setError(oldPasswordField, true)); } else { oldPasswordField.setComponentError(null); saveButton.setEnabled(setError(oldPasswordField, false)); } } else { oldPasswordField.setComponentError(null); saveButton.setEnabled(setError(oldPasswordField, false)); } }); setError(oldPasswordField, false); ProgressBar strength = new ProgressBar(); password1Field = new PasswordField(Language.get(Word.PASSWORD)); password1Field.setValue(""); password1Field.setMaxLength(51); password1Field.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password1Error = UserUtils.checkPassword(event.getValue()); strength.setValue(UserUtils.calculatePasswordStrength(event.getValue())); if (!password1Error.isEmpty()) { password1Field.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password1Error); saveButton.setEnabled(setError(password1Field, true)); } else { password1Field.setComponentError(null); saveButton.setEnabled(setError(password1Field, false)); } } else { password1Field.setComponentError(null); saveButton.setEnabled(setError(password1Field, false)); } }); setError(password1Field, false); strength.setWidth("184px"); strength.setHeight("1px"); password2Field = new PasswordField(Language.get(Word.PASSWORD_AGAIN)); password2Field.setValue(""); password2Field.setMaxLength(51); password2Field.addValueChangeListener(event -> { if (!event.getValue().isEmpty()) { String password2Error = UserUtils.checkPassword(event.getValue()) + UserUtils.checkSecondPassword(password1Field.getValue(), event.getValue()); if (!password2Error.isEmpty()) { password2Field.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(password2Error); saveButton.setEnabled(setError(password2Field, true)); } else { password2Field.setComponentError(null); saveButton.setEnabled(setError(password2Field, false)); } } else { password2Field.setComponentError(null); saveButton.setEnabled(setError(password2Field, false)); } }); setError(password2Field, false); details.addComponents(firstNameField, lastNameField, usernameField, emailField, oldPasswordField, password1Field, strength, password2Field); return root; }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildClippingsTab(User user) { HorizontalLayout root = new HorizontalLayout(); root.setCaption(Language.get(Word.CLIPPINGS)); root.setIcon(VaadinIcons.NEWSPAPER); root.setWidth("100%"); root.setSpacing(true);// w w w . j a v a2 s .co m root.setMargin(true); FormLayout formLayoutClippingDetails = new FormLayout(); formLayoutClippingDetails.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(formLayoutClippingDetails); CheckBox checkBoxReceiveEmails = new CheckBox(); checkBoxReceiveEmails.setValue(UserUtils.getEmailNewsletter(user)); checkBoxReceiveEmails.addValueChangeListener(v -> UserUtils.setEmailNewsletter(user, v.getValue())); HorizontalLayout layoutCheckBoxReceiveEmails = new HorizontalLayout(checkBoxReceiveEmails); layoutCheckBoxReceiveEmails.setCaption(Language.get(Word.EMAIL_SUBSCRIPTION)); layoutCheckBoxReceiveEmails.setMargin(false); layoutCheckBoxReceiveEmails.setSpacing(false); HorizontalLayout layoutAddNewClippingTime = new HorizontalLayout(); layoutAddNewClippingTime.setMargin(false); layoutAddNewClippingTime.setCaption(Language.get(Word.ADD_CLIPPING_TIME)); layoutAddNewClippingTime.setWidth("100%"); InlineDateTimeField dateFieldNewClippingTime = new InlineDateTimeField(); LocalDateTime value = LocalDateTime.now(ZoneId.of("Europe/Berlin")); dateFieldNewClippingTime.setValue(value); dateFieldNewClippingTime.setLocale(VaadinSession.getCurrent().getLocale()); dateFieldNewClippingTime.setResolution(DateTimeResolution.MINUTE); dateFieldNewClippingTime.addStyleName("time-only"); Button buttonAddClippingTime = new Button(); buttonAddClippingTime.setIcon(VaadinIcons.PLUS); buttonAddClippingTime.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonAddClippingTime.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttonAddClippingTime.addClickListener(e -> { LocalTime generalTime = dateFieldNewClippingTime.getValue().toLocalTime(); layoutClippingTimes.addComponent(getTimeRow(user, generalTime)); UserUtils.addClippingSendTime(user, generalTime); }); layoutAddNewClippingTime.addComponents(dateFieldNewClippingTime, buttonAddClippingTime); layoutAddNewClippingTime.setComponentAlignment(dateFieldNewClippingTime, Alignment.MIDDLE_LEFT); layoutAddNewClippingTime.setComponentAlignment(buttonAddClippingTime, Alignment.MIDDLE_CENTER); layoutAddNewClippingTime.setExpandRatio(dateFieldNewClippingTime, 5); layoutClippingTimes = new VerticalLayout(); layoutClippingTimes.setMargin(new MarginInfo(true, false, false, true)); layoutClippingTimes.setCaption(Language.get(Word.CLIPPING_TIMES)); layoutClippingTimes.setWidth("100%"); layoutClippingTimes.addStyleName("times"); Set<LocalTime> userTimes = user.getClippingTime(); userTimes.forEach(t -> layoutClippingTimes.addComponent(getTimeRow(user, t))); formLayoutClippingDetails.addComponents(layoutCheckBoxReceiveEmails, layoutAddNewClippingTime, layoutClippingTimes); return root; }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
private Component getHorizontalLayout() { HorizontalLayout controls = new HorizontalLayout(); controls.setSpacing(true);/*from w w w.j a v a 2 s . c o m*/ controls.setStyleName("inline"); final VerticalLayout main = new VerticalLayout(); final HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setMargin(true); hl.setCaption("Layout Caption"); hl.setIcon(new ThemeResource("../runo/icons/16/document.png")); hl.addComponent(createImageFixedHeight()); hl.addComponent(createImageFixedHeight()); hl.addComponent(createImageFixedHeight()); controls.addComponent( new StyleController(hl, BennuTheme.LAYOUT_BIG, BennuTheme.LAYOUT_INSET, BennuTheme.LAYOUT_SECTION)); controls.addComponent(new SpacingController(hl)); controls.addComponent(new MarginController(hl)); main.addComponent(controls); main.addComponent(hl); return main; }