List of usage examples for com.vaadin.ui HorizontalLayout getComponentCount
@Override public int getComponentCount()
From source file:de.symeda.sormas.ui.caze.CaseContactsView.java
License:Open Source License
public HorizontalLayout createStatusFilterBar() { HorizontalLayout statusFilterLayout = new HorizontalLayout(); statusFilterLayout.setSpacing(true); statusFilterLayout.setWidth("100%"); statusFilterLayout.addStyleName(CssStyles.VSPACE_3); statusButtons = new HashMap<>(); Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> { criteria.contactStatus(null);/*from w w w. j a v a 2 s . c om*/ navigateTo(criteria); }); CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER); statusAll.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusAll); statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all)); activeStatusButton = statusAll; for (ContactStatus status : ContactStatus.values()) { Button statusButton = new Button(status.toString(), e -> { criteria.contactStatus(status); navigateTo(criteria); }); statusButton.setData(status); CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER, CssStyles.BUTTON_FILTER_LIGHT); statusButton.setCaptionAsHtml(true); statusFilterLayout.addComponent(statusButton); statusButtons.put(statusButton, status.toString()); } statusFilterLayout .setExpandRatio(statusFilterLayout.getComponent(statusFilterLayout.getComponentCount() - 1), 1); // Bulk operation dropdown if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { statusFilterLayout.setWidth(100, Unit.PERCENTAGE); MenuBar bulkOperationsDropdown = new MenuBar(); MenuItem bulkOperationsItem = bulkOperationsDropdown .addItem(I18nProperties.getCaption(Captions.bulkActions), null); Command changeCommand = selectedItem -> { ControllerProvider.getContactController().showBulkContactDataEditComponent( grid.asMultiSelect().getSelectedItems(), getCaseRef().getUuid()); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H, changeCommand); Command cancelFollowUpCommand = selectedItem -> { ControllerProvider.getContactController() .cancelFollowUpOfAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE, cancelFollowUpCommand); Command lostToFollowUpCommand = selectedItem -> { ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp( grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK, lostToFollowUpCommand); Command deleteCommand = selectedItem -> { ControllerProvider.getContactController() .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() { public void run() { grid.deselectAll(); grid.reload(); } }); }; bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, deleteCommand); statusFilterLayout.addComponent(bulkOperationsDropdown); statusFilterLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT); statusFilterLayout.setExpandRatio(bulkOperationsDropdown, 1); } if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EXPORT)) { Button exportButton = new Button(I18nProperties.getCaption(Captions.export)); exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY); exportButton.setIcon(VaadinIcons.DOWNLOAD); StreamResource streamResource = new GridExportStreamResource(grid, "sormas_contacts", "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv"); FileDownloader fileDownloader = new FileDownloader(streamResource); fileDownloader.extend(exportButton); statusFilterLayout.addComponent(exportButton); statusFilterLayout.setComponentAlignment(exportButton, Alignment.MIDDLE_RIGHT); if (!UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) { statusFilterLayout.setExpandRatio(exportButton, 1); } } if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CREATE)) { newButton = new Button( I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, Captions.contactNewContact)); newButton.addStyleName(ValoTheme.BUTTON_PRIMARY); newButton.setIcon(VaadinIcons.PLUS_CIRCLE); newButton.addClickListener(e -> ControllerProvider.getContactController().create(this.getCaseRef())); statusFilterLayout.addComponent(newButton); statusFilterLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT); } statusFilterLayout.addStyleName("top-bar"); activeStatusButton = statusAll; return statusFilterLayout; }
From source file:edu.nps.moves.mmowgli.components.WordCloudPanel.java
License:Open Source License
private void addAButton(WordButton butt) { if (!isIE7)/* w w w . j a v a 2 s . c o m*/ meat.addComponent(butt); else { VerticalLayout vLay = (VerticalLayout) meat; int numLines = vLay.getComponentCount(); HorizontalLayout hL; if (numLines == 0) { hL = new HorizontalLayout(); vLay.addComponent(hL); vLay.setComponentAlignment(hL, Alignment.MIDDLE_CENTER); numLines = 1; } hL = (HorizontalLayout) vLay.getComponent(numLines - 1); hL.addComponent(butt); if (hL.getComponentCount() >= IE7MAXCOLCOUNT) { vLay.addComponent(hL = new HorizontalLayout()); vLay.setComponentAlignment(hL, Alignment.MIDDLE_CENTER); } } }
From source file:edu.nps.moves.mmowgliMobile.ui.ActionPlanRenderer2.java
License:Open Source License
private Component makeAuthors(String str, FullEntryView2 fullView) { authorListener.setView(fullView);//from w w w .j a v a 2 s . com String[] sa = str.split(","); VerticalLayout vlay = new VerticalLayout(); HorizontalLayout horl = new HorizontalLayout(); // won't wrap, so add new one every other time int i = 0; for (String s : sa) { Button b = new Button(s); b.addClickListener(authorListener); b.addStyleName("m-author-button"); horl.addComponent(b); if (++i % 2 == 0) { vlay.addComponent(horl); horl = new HorizontalLayout(); } } if (horl.getComponentCount() > 0) vlay.addComponent(horl); return vlay; /* s = s.replaceAll(",",", "); // add a space Label lab = new Label(s); lab.addStyleName("m-actionplan-text-authors"); return lab; */ }
From source file:fi.vtt.RVaadin.RContainer.java
License:Apache License
/** * A helper function to count how many TextFields there are in a parameter * layout.//from ww w .j a va 2 s . c om * * @param hl * {@link HorizontalLayout} corresponding to a parameter layout. * @return integer count */ private int countParametersInLayout(HorizontalLayout hl) { /* How many parameters we have in this layout? */ int i; for (i = 1; i <= hl.getComponentCount(); i++) { if (!(hl.getComponent(i - 1) instanceof TextField)) { /* Index i does not any more contain a TextField */ i--; break; } } /* * Now we know that there are i parameters in total (if someone has not * added an extra TextField into the layout once it was constructed). */ return i; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.execution.ExecutionWizardStep.java
License:Apache License
@Override public Component getContent() { Panel form = new Panel(TRANSLATOR.translate("step.detail")); if (getExecutionStep().getExecutionStart() == null) { //Set the start date. getExecutionStep().setExecutionStart(new Date()); }//from w w w.j a va 2 s.co m FormLayout layout = new FormLayout(); form.setContent(layout); form.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); BeanFieldGroup binder = new BeanFieldGroup(getExecutionStep().getStep().getClass()); binder.setItemDataSource(getExecutionStep().getStep()); TextArea text = new TextArea(TRANSLATOR.translate("general.text")); text.setConverter(new ByteToStringConverter()); binder.bind(text, "text"); text.setSizeFull(); layout.addComponent(text); Field notes = binder.buildAndBind(TRANSLATOR.translate("general.notes"), "notes", TextArea.class); notes.setSizeFull(); layout.addComponent(notes); if (getExecutionStep().getExecutionStart() != null) { start = new DateField(TRANSLATOR.translate("start.date")); start.setResolution(Resolution.SECOND); start.setDateFormat(VMSettingServer.getSetting("date.format").getStringVal()); start.setValue(getExecutionStep().getExecutionStart()); start.setReadOnly(true); layout.addComponent(start); } if (getExecutionStep().getExecutionEnd() != null) { end = new DateField(TRANSLATOR.translate("end.date")); end.setDateFormat(VMSettingServer.getSetting("date.format").getStringVal()); end.setResolution(Resolution.SECOND); end.setValue(getExecutionStep().getExecutionEnd()); end.setReadOnly(true); layout.addComponent(end); } binder.setReadOnly(true); //Space to record result if (getExecutionStep().getResultId() != null) { result.setValue(getExecutionStep().getResultId().getResultName()); } layout.addComponent(result); if (reviewer) {//Space to record review if (getExecutionStep().getReviewResultId() != null) { review.setValue(getExecutionStep().getReviewResultId().getReviewName()); } layout.addComponent(review); } //Add Reviewer name if (getExecutionStep().getReviewer() != null) { TextField reviewerField = new TextField(TRANSLATOR.translate("general.reviewer")); reviewerField.setValue(getExecutionStep().getReviewer().getFirstName() + " " + getExecutionStep().getReviewer().getLastName()); reviewerField.setReadOnly(true); layout.addComponent(reviewerField); } if (getExecutionStep().getReviewDate() != null) { reviewDate = new DateField(TRANSLATOR.translate("review.date")); reviewDate.setDateFormat(VMSettingServer.getSetting("date.format").getStringVal()); reviewDate.setResolution(Resolution.SECOND); reviewDate.setValue(getExecutionStep().getReviewDate()); reviewDate.setReadOnly(true); layout.addComponent(reviewDate); } if (VMSettingServer.getSetting("show.expected.result").getBoolVal()) { TextArea expectedResult = new TextArea(TRANSLATOR.translate("expected.result")); expectedResult.setConverter(new ByteToStringConverter()); binder.bind(expectedResult, "expectedResult"); expectedResult.setSizeFull(); layout.addComponent(expectedResult); } //Add the fields fields.clear(); getExecutionStep().getStep().getDataEntryList().forEach(de -> { switch (de.getDataEntryType().getId()) { case 1://String TextField tf = new TextField(TRANSLATOR.translate(de.getEntryName())); tf.setRequired(true); tf.setData(de.getEntryName()); if (VMSettingServer.getSetting("show.expected.result").getBoolVal()) { //Add expected result DataEntryProperty stringCase = DataEntryServer.getProperty(de, "property.match.case"); DataEntryProperty r = DataEntryServer.getProperty(de, "property.expected.result"); if (r != null && !r.getPropertyValue().equals("null")) { String error = TRANSLATOR.translate("expected.result") + ": " + r.getPropertyValue(); tf.setRequiredError(error); tf.setRequired(DataEntryServer.getProperty(de, "property.required").getPropertyValue() .equals("true")); tf.addValidator((Object val) -> { //We have an expected result and a match case requirement if (stringCase != null && stringCase.getPropertyValue().equals("true") ? !((String) val).equals(r.getPropertyValue()) : !((String) val).equalsIgnoreCase(r.getPropertyValue())) { throw new InvalidValueException(error); } }); } } fields.add(tf); //Set value if already recorded updateValue(tf); layout.addComponent(tf); break; case 2://Numeric NumberField field = new NumberField(TRANSLATOR.translate(de.getEntryName())); field.setSigned(true); field.setUseGrouping(true); field.setGroupingSeparator(','); field.setDecimalSeparator('.'); field.setConverter(new StringToDoubleConverter()); field.setRequired( DataEntryServer.getProperty(de, "property.required").getPropertyValue().equals("true")); field.setData(de.getEntryName()); Double min = null, max = null; for (DataEntryProperty prop : de.getDataEntryPropertyList()) { String value = prop.getPropertyValue(); if (prop.getPropertyName().equals("property.max")) { try { max = Double.parseDouble(value); } catch (NumberFormatException ex) { //Leave as null } } else if (prop.getPropertyName().equals("property.min")) { try { min = Double.parseDouble(value); } catch (NumberFormatException ex) { //Leave as null } } } //Add expected result if (VMSettingServer.getSetting("show.expected.result").getBoolVal() && (min != null || max != null)) { String error = TRANSLATOR.translate("error.out.of.range") + " " + (min == null ? " " : (TRANSLATOR.translate("property.min") + ": " + min)) + " " + (max == null ? "" : (TRANSLATOR.translate("property.max") + ": " + max)); field.setRequiredError(error); field.addValidator(new DoubleRangeValidator(error, min, max)); } fields.add(field); //Set value if already recorded updateValue(field); layout.addComponent(field); break; case 3://Boolean CheckBox cb = new CheckBox(TRANSLATOR.translate(de.getEntryName())); cb.setData(de.getEntryName()); cb.setRequired( DataEntryServer.getProperty(de, "property.required").getPropertyValue().equals("true")); if (VMSettingServer.getSetting("show.expected.result").getBoolVal()) { DataEntryProperty r = DataEntryServer.getProperty(de, "property.expected.result"); if (r != null) { //Add expected result String error = TRANSLATOR.translate("expected.result") + ": " + r.getPropertyValue(); cb.addValidator((Object val) -> { if (!val.toString().equals(r.getPropertyValue())) { throw new InvalidValueException(error); } }); } } fields.add(cb); //Set value if already recorded updateValue(cb); layout.addComponent(cb); break; case 4://Attachment Label l = new Label(TRANSLATOR.translate(de.getEntryName())); layout.addComponent(l); break; default: LOG.log(Level.SEVERE, "Unexpected field type: {0}", de.getDataEntryType().getId()); } }); //Add the Attachments HorizontalLayout attachments = new HorizontalLayout(); attachments.setCaption(TRANSLATOR.translate("general.attachment")); HorizontalLayout comments = new HorizontalLayout(); comments.setCaption(TRANSLATOR.translate("general.comments")); HorizontalLayout issues = new HorizontalLayout(); issues.setCaption(TRANSLATOR.translate("general.issue")); int commentCounter = 0; int issueCounter = 0; for (ExecutionStepHasIssue ei : getExecutionStep().getExecutionStepHasIssueList()) { issueCounter++; Button a = new Button("Issue #" + issueCounter); a.setIcon(VaadinIcons.BUG); a.addClickListener((Button.ClickEvent event) -> { displayIssue(new IssueServer(ei.getIssue())); }); a.setEnabled(!step.getLocked()); issues.addComponent(a); } for (ExecutionStepHasAttachment attachment : getExecutionStep().getExecutionStepHasAttachmentList()) { switch (attachment.getAttachment().getAttachmentType().getType()) { case "comment": { //Comments go in a different section commentCounter++; Button a = new Button("Comment #" + commentCounter); a.setIcon(VaadinIcons.CLIPBOARD_TEXT); a.addClickListener((Button.ClickEvent event) -> { if (!step.getLocked()) { //Prompt if user wants this removed MessageBox mb = getDeletionPrompt(attachment); mb.open(); } else { displayComment(new AttachmentServer(attachment.getAttachment().getAttachmentPK())); } }); a.setEnabled(!step.getLocked()); comments.addComponent(a); break; } default: { Button a = new Button(attachment.getAttachment().getFileName()); a.setEnabled(!step.getLocked()); a.setIcon(VaadinIcons.PAPERCLIP); a.addClickListener((Button.ClickEvent event) -> { if (!step.getLocked()) { //Prompt if user wants this removed MessageBox mb = getDeletionPrompt(attachment); mb.open(); } else { displayAttachment(new AttachmentServer(attachment.getAttachment().getAttachmentPK())); } }); attachments.addComponent(a); break; } } } if (attachments.getComponentCount() > 0) { layout.addComponent(attachments); } if (comments.getComponentCount() > 0) { layout.addComponent(comments); } if (issues.getComponentCount() > 0) { layout.addComponent(issues); } //Add the menu HorizontalLayout hl = new HorizontalLayout(); attach = new Button(TRANSLATOR.translate("add.attachment")); attach.setIcon(VaadinIcons.PAPERCLIP); attach.addClickListener((Button.ClickEvent event) -> { //Show dialog to upload file. Window dialog = new VMWindow(TRANSLATOR.translate("attach.file")); VerticalLayout vl = new VerticalLayout(); MultiFileUpload multiFileUpload = new MultiFileUpload() { @Override protected void handleFile(File file, String fileName, String mimeType, long length) { try { LOG.log(Level.FINE, "Received file {1} at: {0}", new Object[] { file.getAbsolutePath(), fileName }); //Process the file //Create the attachment AttachmentServer a = new AttachmentServer(); a.addFile(file, fileName); //Overwrite the default file name set in addFile. It'll be a temporary file name a.setFileName(fileName); a.write2DB(); //Now add it to this Execution Step if (getExecutionStep().getExecutionStepHasAttachmentList() == null) { getExecutionStep().setExecutionStepHasAttachmentList(new ArrayList<>()); } getExecutionStep().addAttachment(a); getExecutionStep().write2DB(); w.updateCurrentStep(); } catch (Exception ex) { LOG.log(Level.SEVERE, "Error creating attachment!", ex); } } }; multiFileUpload.setCaption(TRANSLATOR.translate("select.files.attach")); vl.addComponent(multiFileUpload); dialog.setContent(vl); dialog.setHeight(25, Sizeable.Unit.PERCENTAGE); dialog.setWidth(25, Sizeable.Unit.PERCENTAGE); ValidationManagerUI.getInstance().addWindow(dialog); }); hl.addComponent(attach); bug = new Button(TRANSLATOR.translate("create.issue")); bug.setIcon(VaadinIcons.BUG); bug.addClickListener((Button.ClickEvent event) -> { displayIssue(new IssueServer()); }); hl.addComponent(bug); comment = new Button(TRANSLATOR.translate("add.comment")); comment.setIcon(VaadinIcons.CLIPBOARD_TEXT); comment.addClickListener((Button.ClickEvent event) -> { AttachmentServer as = new AttachmentServer(); //Get comment type AttachmentType type = AttachmentTypeServer.getTypeForExtension("comment"); as.setAttachmentType(type); displayComment(as); }); hl.addComponent(comment); step.update(); attach.setEnabled(!step.getLocked()); bug.setEnabled(!step.getLocked()); comment.setEnabled(!step.getLocked()); result.setEnabled(!step.getLocked()); layout.addComponent(hl); return layout; }
From source file:org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout.java
License:Open Source License
protected void buildLayout() { final HorizontalLayout dropHintLayout = new HorizontalLayout(); if (hasCountMessage()) { dropHintLayout.addComponent(getCountMessageLabel()); }//from w w w . jav a2s.c o m final HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setId(UIComponentIdProvider.ACTION_BUTTON_LAYOUT); hLayout.setSpacing(true); hLayout.setSizeUndefined(); if (deleteWrapper != null) { hLayout.addComponent(deleteWrapper); hLayout.setComponentAlignment(deleteWrapper, Alignment.BOTTOM_LEFT); } if (noActionBtn != null) { hLayout.addComponent(noActionBtn); hLayout.setComponentAlignment(noActionBtn, Alignment.BOTTOM_LEFT); } if (bulkUploadStatusButton != null) { hLayout.addComponent(bulkUploadStatusButton); hLayout.setComponentAlignment(bulkUploadStatusButton, Alignment.BOTTOM_LEFT); } if (dropHintLayout.getComponentCount() > 0) { addComponent(dropHintLayout); setComponentAlignment(dropHintLayout, Alignment.BOTTOM_CENTER); } if (hLayout.getComponentCount() > 0) { addComponent(hLayout); setComponentAlignment(hLayout, Alignment.BOTTOM_CENTER); } setStyleName(SPUIStyleDefinitions.FOOTER_LAYOUT); setWidth("100%"); }
From source file:org.escidoc.browser.elabsmodul.views.InstrumentView.java
License:Open Source License
@Override public void resetLayout() { Preconditions.checkNotNull(this.dynamicLayout, "View's dynamiclayout is null."); HorizontalLayout tempParentLayout = null; for (Iterator<Component> iterator = this.dynamicLayout.getComponentIterator(); iterator.hasNext();) { Component component = iterator.next(); if (component instanceof HorizontalLayout) { tempParentLayout = (HorizontalLayout) component; } else {// w ww. ja v a2s . com LOG.error("DynamicLayout can contain only HorizontalLayouts as direct child element."); break; } if (tempParentLayout.getComponentCount() != 2) { continue; } if (LabsLayoutHelper.switchToLabelFromEditedField(tempParentLayout)) { this.setModifiedComponent(null); if (this.dynamicLayout.getComponentIndex(tempParentLayout) == 4) { this.instrumentBean .setESyncDaemon((String) ((Label) tempParentLayout.getComponent(1)).getValue()); } } else { LOG.error("Label change error, mod .component is not set to null"); } } }
From source file:org.escidoc.browser.elabsmodul.views.InvestigationSeriesView.java
License:Open Source License
@Override public void resetLayout() { Preconditions.checkNotNull(this.dynamicLayout, "View's dynamiclayout is null."); HorizontalLayout tempParentLayout = null; for (final Iterator<Component> iterator = this.dynamicLayout.getComponentIterator(); iterator.hasNext();) { final Component component = iterator.next(); if (component instanceof HorizontalLayout) { tempParentLayout = (HorizontalLayout) component; } else {//w w w.j a v a 2 s . co m LOG.error("DynamicLayout can contain only HorizontalLayouts as direct child element."); break; } if (tempParentLayout.getComponentCount() != 2) { continue; } if (LabsLayoutHelper.switchToLabelFromEditedField(tempParentLayout)) { setModifiedComponent(null); } } }
From source file:org.escidoc.browser.elabsmodul.views.InvestigationView.java
License:Open Source License
@Override public void resetLayout() { Preconditions.checkNotNull(this.dynamicLayout, "View's dynamiclayout is null."); HorizontalLayout tempParentLayout = null; for (final Iterator<Component> iterator = this.dynamicLayout.getComponentIterator(); iterator.hasNext();) { final Component component = iterator.next(); if (component instanceof HorizontalLayout) { tempParentLayout = (HorizontalLayout) component; } else {//w ww . j av a 2s. c om LOG.error("DynamicLayout can contain only HorizontalLayouts as direct child element."); break; } if (tempParentLayout.getComponentCount() != 2) { continue; } if (LabsLayoutHelper.switchToLabelFromEditedField(tempParentLayout)) { this.setModifiedComponent(null); if (dynamicLayout.getComponentIndex(tempParentLayout) == 2) { investigationBean .setDepositEndpoint((String) ((Label) tempParentLayout.getComponent(1)).getValue()); } } } }
From source file:org.escidoc.browser.elabsmodul.views.RigView.java
License:Open Source License
@Override public void resetLayout() { Preconditions.checkNotNull(this.dynamicLayout, "View's dynamiclayout is null."); HorizontalLayout tempParentLayout = null; for (Iterator<Component> iterator = this.dynamicLayout.getComponentIterator(); iterator.hasNext();) { Component component = iterator.next(); if (component instanceof HorizontalLayout) { tempParentLayout = (HorizontalLayout) component; } else {//from w w w . jav a2s. c o m LOG.error("DynamicLayout can contain only HorizontalLayouts as direct child element."); break; } if (tempParentLayout.getComponentCount() != 2) { continue; } if (LabsLayoutHelper.switchToLabelFromEditedField(tempParentLayout)) { this.setModifiedComponent(null); } } }