List of usage examples for com.vaadin.ui FormLayout FormLayout
public FormLayout()
From source file:org.apache.usergrid.chop.webapp.view.chart.layout.ChartLayout.java
License:Apache License
private FormLayout addFormLayout() { FormLayout formLayout = new FormLayout(); formLayout.setWidth("250px"); formLayout.setHeight("250px"); formLayout.addStyleName("outlined"); formLayout.setSpacing(true);//from w w w.j av a2 s . c om addComponent(formLayout, "left: 10px; top: 10px;"); return formLayout; }
From source file:org.apache.usergrid.chop.webapp.view.user.UserLayout.java
License:Apache License
private FormLayout addFormLayout(int x, int y) { FormLayout formLayout = new FormLayout(); formLayout.setWidth(String.format("%spx", x)); formLayout.setHeight(String.format("%spx", y)); formLayout.addStyleName("outlined"); formLayout.setSpacing(true);//from www. j a va2 s . c om addComponent(formLayout, "left: 350px; top: 50px;"); return formLayout; }
From source file:org.axonframework.examples.addressbook.vaadin.ui.SearchView.java
License:Apache License
public SearchView() { setCaption("Search for contacts"); setSizeFull();//from w w w.j a v a 2 s. c o m FormLayout formLayout = new FormLayout(); setContent(formLayout); tf = new TextField("Search term"); fieldToSearch = new NativeSelect("Field to search"); saveSearch = new CheckBox("Save search"); searchName = new TextField("Search name"); Button search = new Button("Search"); search.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { performSearch(); } }); for (int i = 0; i < ContactContainer.NATURAL_COL_ORDER.length; i++) { fieldToSearch.addItem(ContactContainer.NATURAL_COL_ORDER[i]); fieldToSearch.setItemCaption(ContactContainer.NATURAL_COL_ORDER[i], ContactContainer.COL_HEADERS_ENGLISH[i]); } fieldToSearch.setValue("name"); fieldToSearch.setNullSelectionAllowed(false); saveSearch.setValue(true); addComponent(tf); addComponent(fieldToSearch); addComponent(saveSearch); addComponent(searchName); addComponent(search); saveSearch.setImmediate(true); saveSearch.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { searchName.setVisible(event.getButton().booleanValue()); } }); }
From source file:org.azrul.langkuik.framework.customtype.attachment.AttachmentCustomTypeUICreator.java
@Override public Component createUIForForm(final C currentBean, final Class<? extends CustomType> attachmentClass, final String pojoFieldName, final BeanView beanView, final DataAccessObject<C> conatainerClassDao, final DataAccessObject<? extends CustomType> customTypeDao, final RelationManagerFactory relationManagerFactory, final Configuration config, final ComponentState componentState, final Window window) { final FormLayout form = new FormLayout(); final DataAccessObject<AttachmentCustomType> attachmentDao = ((DataAccessObject<AttachmentCustomType>) customTypeDao); final Collection<AttachmentCustomType> attachments = attachmentDao.find(currentBean, pojoFieldName, null, true, 0, Integer.parseInt(config.get("uploadCountLimit"))); final WebEntityItemContainer attachmentIC = new WebEntityItemContainer(attachmentClass); if (!attachments.isEmpty()) { attachmentIC.addAll(attachments); }//from ww w. j a v a 2 s .c o m final ListSelect attachmentList = new ListSelect("", attachmentIC); createAtachmentList(attachmentList, attachments, config, beanView, form); final String relativePath = currentBean.getClass().getCanonicalName() + File.separator + conatainerClassDao.getIdentifierValue(currentBean); final String fullPath = config.get("attachmentRepository") + File.separator + relativePath; MyUploadHandler<C> uploadFinishHandler = new MyUploadHandler<>(currentBean, Integer.parseInt(config.get("uploadCountLimit").trim()), pojoFieldName, fullPath, relativePath, attachmentList, attachmentIC, customTypeDao, attachmentClass, relationManagerFactory); //File upload/download/delete buttons HorizontalLayout attachmentButtons = new HorizontalLayout(); attachmentButtons.setSpacing(true); UploadStateWindow uploadStateWindow = new UploadStateWindow(); MultiFileUpload fileUpload = new MultiFileUpload(uploadFinishHandler, uploadStateWindow); uploadFinishHandler.setFileUpload(fileUpload); fileUpload.getSmartUpload().setEnabled(true); fileUpload.getSmartUpload().setMaxFileSize(Integer.parseInt(config.get("uploadSizeLimit").trim())); fileUpload.getSmartUpload().setUploadButtonCaptions("Upload files", "Upload files"); fileUpload.getSmartUpload().setId("Upload files"); fileUpload.setId("Upload files2"); Button deleteAttachmentBtn = new Button("Delete file", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList .getValue(); if (!attachments.isEmpty()) { customTypeDao.unlinkAndDelete(attachments, currentBean, pojoFieldName, relationManagerFactory.create(currentBean.getClass(), attachmentClass)); Collection<AttachmentCustomType> a = attachmentDao.find(currentBean, pojoFieldName, null, true, 0, Integer.parseInt(config.get("uploadCountLimit"))); attachmentIC.removeAllItems(); attachmentIC.addAll(a); attachmentIC.refreshItems(); } } }); deleteAttachmentBtn.setId(deleteAttachmentBtn.getCaption()); Button downloadAttachmentBtn = new Button("Download file", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<AttachmentCustomType> attachments = (Collection<AttachmentCustomType>) attachmentList .getValue(); if (!attachments.isEmpty()) { AttachmentCustomType attachment = attachments.iterator().next(); final String fullPath = config.get("attachmentRepository") + File.separator + attachment.getRelativeLocation() + File.separator + attachment.getFileName(); FileResource res = new FileResource(new File(fullPath)); beanView.setViewResource("DOWNLOAD", res); ResourceReference rr = ResourceReference.create(res, beanView, "DOWNLOAD"); Page.getCurrent().open(rr.getURL(), null); } } }); downloadAttachmentBtn.setId(downloadAttachmentBtn.getCaption()); Button closeWindowBtn = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { window.close(); } }); closeWindowBtn.setId(closeWindowBtn.getCaption()); if (componentState.equals(ComponentState.EDITABLE)) { attachmentButtons.addComponent(fileUpload); attachmentButtons.addComponent(deleteAttachmentBtn); } if (componentState.equals(ComponentState.EDITABLE) || componentState.equals(ComponentState.READ_ONLY)) { attachmentButtons.addComponent(downloadAttachmentBtn); } attachmentButtons.addComponent(closeWindowBtn); form.addComponent(attachmentButtons); form.setMargin(true); //beanView.addComponent(form); return form; }
From source file:org.azrul.langkuik.framework.webgui.BeanView.java
@Override public void enter(final ViewChangeListener.ViewChangeEvent vcevent) { setCurrentView(vcevent.getViewName()); //reset form//from ww w. ja v a2s . co m this.removeAllComponents(); //determine user details UserDetails userDetails = null; Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (!(auth instanceof AnonymousAuthenticationToken)) { userDetails = (UserDetails) auth.getPrincipal(); } else { return; } final Set<String> currentUserRoles = new HashSet<>(); for (GrantedAuthority grantedAuth : userDetails.getAuthorities()) { currentUserRoles.add(grantedAuth.getAuthority()); } //determine entity rights EntityRight entityRight = null; EntityUserMap[] entityUserMaps = ((WebEntity) currentBean.getClass().getAnnotation(WebEntity.class)) .userMap(); for (EntityUserMap e : entityUserMaps) { if (currentUserRoles.contains(e.role()) || ("*").equals(e.role())) { entityRight = e.right(); break; } } if (entityRight == null) { //if entityRight=EntityRight.NONE, still allow to go through because field level might be accessible //Not accessible return; } //create bean utils final BeanUtils beanUtils = new BeanUtils(); //rebuild pageParameter.getBreadcrumb() BreadCrumbBuilder.buildBreadCrumb(vcevent.getNavigator(), pageParameter.getBreadcrumb(), pageParameter.getHistory()); //rebuild components if (currentBean == null) { return; } //refresh current item C newBean = dao.refresh(currentBean); if (newBean != null) { currentBean = newBean; } final BeanFieldGroup fieldGroup = new BeanFieldGroup(currentBean.getClass()); fieldGroup.setItemDataSource(currentBean); final FormLayout form = new FormLayout(); Map<String, Map<Integer, FieldContainer>> groups = beanUtils.createGroupsFromBean(currentBean.getClass()); //render form according to tab if (groups.size() == 1) { createForm(entityRight, currentUserRoles, groups, fieldGroup, pageParameter.getCustomTypeDaos(), vcevent.getNavigator(), form); } else { TabSheet tabSheet = new TabSheet(); for (String group : groups.keySet()) { if (("All").equals(group)) { createForm(entityRight, currentUserRoles, groups, group, fieldGroup, pageParameter.getCustomTypeDaos(), vcevent.getNavigator(), form); } else { FormLayout tab = new FormLayout(); createForm(entityRight, currentUserRoles, groups, group, fieldGroup, pageParameter.getCustomTypeDaos(), vcevent.getNavigator(), tab); tabSheet.addTab(tab, group); } } form.addComponent(tabSheet); } //Navigation and actions HorizontalLayout navButtons = new HorizontalLayout(); navButtons.setSpacing(true); Button saveAndBackBtn = new Button("Save and back", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { fieldGroup.commit(); currentBean = (C) fieldGroup.getItemDataSource().getBean(); currentBean = saveBean(currentBean, parentBean, beanUtils, currentUserRoles); if (!pageParameter.getHistory().isEmpty()) { String currentView = pageParameter.getHistory().pop().getViewHandle(); String lastView = pageParameter.getHistory().peek().getViewHandle(); vcevent.getNavigator().removeView(currentView); vcevent.getNavigator().navigateTo(lastView); } } catch (FieldGroup.CommitException ex) { handleFieldsError(fieldGroup); } } }); navButtons.addComponent(saveAndBackBtn); saveAndBackBtn.setId(saveAndBackBtn.getCaption()); form.addComponent(navButtons); form.setMargin(new MarginInfo(true)); this.addComponent(form); }
From source file:org.azrul.langkuik.framework.webgui.EditorTableView.java
public void enter(final ViewChangeListener.ViewChangeEvent vcevent) { setCurrentView(vcevent.getViewName()); this.removeAllComponents(); //get user roles UserDetails userDetails = null;/*from w w w . ja v a2 s.co m*/ Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (!(auth instanceof AnonymousAuthenticationToken)) { userDetails = (UserDetails) auth.getPrincipal(); } else { return; } Set<String> currentUserRoles = new HashSet<>(); for (GrantedAuthority grantedAuth : userDetails.getAuthorities()) { currentUserRoles.add(grantedAuth.getAuthority()); } //determine entity rights EntityRight entityRight = null; EntityUserMap[] entityUserMaps = classOfBean.getAnnotation(WebEntity.class).userMap(); for (EntityUserMap e : entityUserMaps) { if (currentUserRoles.contains(e.role()) || ("*").equals(e.role())) { entityRight = e.right(); break; } } if (entityRight == null) { //if entityRight=EntityRight.NONE, still allow to go through because field level might be accessible //Not accessible return; } //create bean utils BeanUtils beanUtils = new BeanUtils(); //creat bread crumb BreadCrumbBuilder.buildBreadCrumb(vcevent.getNavigator(), pageParameter.getBreadcrumb(), pageParameter.getHistory()); //create form FormLayout form = new FormLayout(); FindAnyEntityParameter<C> searchQuery = new FindAnyEntityParameter<>(classOfBean); FindEntityCollectionParameter<P, C> entityCollectionQuery = new FindEntityCollectionParameter<>(parentBean, parentToBeanField, pageParameter.getRelationManagerFactory().create((Class<P>) parentBean.getClass(), classOfBean)); final SearchDataTableLayout<C> allDataTableLayout = new SearchDataTableLayout<>(searchQuery, classOfBean, dao, noBeansPerPage, pageParameter.getCustomTypeDaos(), pageParameter.getConfig(), currentUserRoles, entityRight); final CollectionDataTableLayout<P, C> beanTableLayout = new CollectionDataTableLayout<>( entityCollectionQuery, classOfBean, dao, noBeansPerPage, pageParameter.getCustomTypeDaos(), pageParameter.getConfig(), currentUserRoles, entityRight); //handle associate existing data final Window window = new Window("Associate"); window.setId(window.getCaption()); window.setContent(allDataTableLayout); window.setModal(true); HorizontalLayout popupButtonLayout = new HorizontalLayout(); Button associateToCurrentBtn = new Button("Associate to current", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<C> allDataList = allDataTableLayout.getTableValues(); beanTableLayout.associateEntities(allDataList, choiceType); window.close(); } }); associateToCurrentBtn.setId(associateToCurrentBtn.getCaption()); popupButtonLayout.addComponent(associateToCurrentBtn); Button closeBtn = new Button("Close", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { window.close(); } }); popupButtonLayout.addComponent(closeBtn); closeBtn.setId(closeBtn.getCaption()); popupButtonLayout.setSpacing(true); MarginInfo marginInfo = new MarginInfo(true); allDataTableLayout.setMargin(marginInfo); allDataTableLayout.addComponent(popupButtonLayout); if (parentToBeanFieldState.equals(ComponentState.EDITABLE)) { Button associateExistingBtn = new Button("Associate existing", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { EditorTableView.this.getUI().addWindow(window); } }); form.addComponent(associateExistingBtn); associateExistingBtn.setId(associateExistingBtn.getCaption()); } form.addComponent(beanTableLayout); //Navigation and actions HorizontalLayout buttonLayout = new HorizontalLayout(); if (beanUtils.isCreatable(classOfBean, currentUserRoles) && parentToBeanFieldState.equals(ComponentState.EDITABLE)) { Button addNewBtn = new Button("Add new", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { C currentBean = dao.createNew(true);//dao.createAndSave(parentBean, parentToBeanField, pageParameter.getRelationManagerFactory().create((Class<P>) parentBean.getClass(), classOfBean)); BeanView<P, C> beanView = new BeanView<P, C>(currentBean, parentBean, parentToBeanField, pageParameter); String targetView = "CHOOSE_ONE_TABLE_VIEW_" + UUID.randomUUID().toString(); WebEntity myObject = (WebEntity) currentBean.getClass().getAnnotation(WebEntity.class); History his = new History(targetView, "Add new " + myObject.name()); pageParameter.getHistory().push(his); vcevent.getNavigator().addView(targetView, beanView); vcevent.getNavigator().navigateTo(targetView); } }); buttonLayout.addComponent(addNewBtn); addNewBtn.setId(addNewBtn.getCaption()); } if (beanUtils.isEditable(classOfBean, currentUserRoles) || beanUtils.isViewable(classOfBean, currentUserRoles)) { Button manageBtn = new Button("Manage", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { C currentBean = beanTableLayout.getTableValues().iterator().next(); if (currentBean != null) { BeanView<P, C> beanView = new BeanView<P, C>(currentBean, parentBean, parentToBeanField, pageParameter); String targetView = "CHOOSE_ONE_TABLE_VIEW_" + UUID.randomUUID().toString(); WebEntity myObject = (WebEntity) currentBean.getClass().getAnnotation(WebEntity.class); History his = new History(targetView, "Manage " + myObject.name()); pageParameter.getHistory().push(his); vcevent.getNavigator().addView(targetView, beanView); vcevent.getNavigator().navigateTo(targetView); } } }); buttonLayout.addComponent(manageBtn); manageBtn.setId(manageBtn.getCaption()); } if (parentToBeanFieldState.equals(ComponentState.EDITABLE)) { if (beanUtils.isCreatable(classOfBean, currentUserRoles) && parentToBeanFieldState.equals(ComponentState.EDITABLE)) { Button deleteBtn = new Button("Delete", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { final Collection<C> currentBeans = (Collection<C>) beanTableLayout.getTableValues(); if (!currentBeans.isEmpty()) { ConfirmDialog.show(EditorTableView.this.getUI(), "Please Confirm:", "Are you really sure you want to delete these entries?", "I am", "Not quite", new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { EditorTableView.this.parentBean = beanTableLayout .deleteData(currentBeans); } } }); } } }); buttonLayout.addComponent(deleteBtn); deleteBtn.setId(deleteBtn.getCaption()); } } Button saveAndBackBtn = new Button("Save and back", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //parentDao.save(parentBean); if (!pageParameter.getHistory().isEmpty()) { String currentView = pageParameter.getHistory().pop().getViewHandle(); String lastView = pageParameter.getHistory().peek().getViewHandle(); vcevent.getNavigator().removeView(currentView); vcevent.getNavigator().navigateTo(lastView); } } }); buttonLayout.addComponent(saveAndBackBtn); saveAndBackBtn.setId(saveAndBackBtn.getCaption()); buttonLayout.setSpacing(true); form.addComponent(buttonLayout); this.addComponent(form); }
From source file:org.azrul.langkuik.framework.webgui.PlainTableView.java
@Override public void enter(final ViewChangeListener.ViewChangeEvent vcevent) { setCurrentView(vcevent.getViewName()); this.removeAllComponents(); //determine user details UserDetails userDetails = null;/* ww w .j ava 2 s . c o m*/ Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (!(auth instanceof AnonymousAuthenticationToken)) { userDetails = (UserDetails) auth.getPrincipal(); } else { return; } final Set<String> currentUserRoles = new HashSet<>(); for (GrantedAuthority grantedAuth : userDetails.getAuthorities()) { currentUserRoles.add(grantedAuth.getAuthority()); } //determine entity rights EntityRight entityRight = null; EntityUserMap[] entityUserMaps = classOfBean.getAnnotation(WebEntity.class).userMap(); for (EntityUserMap e : entityUserMaps) { if (currentUserRoles.contains(e.role()) || ("*").equals(e.role())) { entityRight = e.right(); break; } } if (entityRight == null) { //if entityRight=EntityRight.NONE, still allow to go through because field level might be accessible //Not accessible return; } //Build bread crumb BreadCrumbBuilder.buildBreadCrumb(vcevent.getNavigator(), pageParameter.getBreadcrumb(), pageParameter.getHistory()); FindAnyEntityParameter<C> searchQuery = new FindAnyEntityParameter<>(classOfBean); //set form FormLayout form = new FormLayout(); final SearchDataTableLayout<C> dataTable = new SearchDataTableLayout<>(searchQuery, classOfBean, dao, noBeansPerPage, pageParameter.getCustomTypeDaos(), pageParameter.getConfig(), currentUserRoles, entityRight); form.addComponent(dataTable); //Handle navigations and actions HorizontalLayout buttonLayout = new HorizontalLayout(); // Button addNewBtn = new Button("Add new", // new Button.ClickListener() { // @Override // public void buttonClick(Button.ClickEvent event // ) { // C currentBean = dao.createAndSave(); // BeanView<Object, C> beanView = new BeanView<Object, C>(currentBean,null, pageParameter.getRelationManagerFactory(), pageParameter.getEntityManagerFactory(), pageParameter.getHistory(), pageParameter.getBreadcrumb(), pageParameter.getConfig(), pageParameter.getCustomTypeDaos()); // String targetView = "CHOOSE_ONE_TABLE_VIEW_" + UUID.randomUUID().toString(); // WebEntity myObject = (WebEntity) currentBean.getClass().getAnnotation(WebEntity.class); // History his = new History(targetView, "Add new " + myObject.name()); // pageParameter.getHistory().push(his); // vcevent.getNavigator().addView(targetView, beanView); // vcevent.getNavigator().navigateTo(targetView); // // } // }); // buttonLayout.addComponent(addNewBtn); // addNewBtn.setId(addNewBtn.getCaption()); Button manageBtn = new Button("Manage", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Collection<C> currentBeans = (Collection<C>) dataTable.getTableValues(); if (!currentBeans.isEmpty()) { C currentBean = currentBeans.iterator().next(); if (currentBean != null) { BeanView<Object, C> beanView = new BeanView<>(currentBean, null, null, pageParameter); String targetView = "CHOOSE_ONE_TABLE_VIEW_" + UUID.randomUUID().toString(); WebEntity myObject = (WebEntity) currentBean.getClass().getAnnotation(WebEntity.class); History his = new History(targetView, "Manage " + myObject.name()); pageParameter.getHistory().push(his); vcevent.getNavigator().addView(targetView, beanView); vcevent.getNavigator().navigateTo(targetView); } } } }); buttonLayout.addComponent(manageBtn); manageBtn.setId(manageBtn.getCaption()); Button deleteBtn = new Button("Delete", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { final Collection<C> currentBeans = (Collection<C>) dataTable.getTableValues(); if (!currentBeans.isEmpty()) { ConfirmDialog.show(PlainTableView.this.getUI(), "Please Confirm:", "Are you really sure you want to delete these entries?", "I am", "Not quite", new ConfirmDialog.Listener() { public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { // dao.delete(currentBeans); // Collection<C> data = dao.search(searchTerms, classOfBean, currentTableDataIndex, noBeansPerPage); // if (data.isEmpty()) { // data = new ArrayList<C>(); // data.add(dao.createNew()); // } // tableDataIT.setBeans(data); // tableDataIT.refreshItems(); // totalTableData = dao.countSearch(searchTerms, classOfBean); // final Label pageLabel = new Label(); // int lastPage = (int) Math.floor(totalTableData / noBeansPerPage); // if (totalTableData % noBeansPerPage == 0) { // lastPage--; // } // int currentUpdatedPage = currentTableDataIndex / noBeansPerPage; // pageLabel.setCaption(" " + (currentUpdatedPage + 1) + " of " + (lastPage + 1) + " "); } } }); } } }); buttonLayout.addComponent(deleteBtn); deleteBtn.setId(deleteBtn.getCaption()); buttonLayout.setSpacing(true); form.addComponent(buttonLayout); Button backBtn = new Button("Back", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (!pageParameter.getHistory().isEmpty()) { String currentView = pageParameter.getHistory().pop().getViewHandle(); String lastView = pageParameter.getHistory().peek().getViewHandle(); vcevent.getNavigator().removeView(currentView); vcevent.getNavigator().navigateTo(lastView); } } }); form.addComponent(backBtn); backBtn.setId(backBtn.getCaption()); this.addComponent(form); }
From source file:org.bitpimp.VaadinCurrencyConverter.MyVaadinApplication.java
License:Apache License
@Override protected void init(VaadinRequest request) { // Set the window or tab title getPage().setTitle("Yahoo Currency Converter"); // Create the content root layout for the UI final FormLayout content = new FormLayout(); content.setMargin(true);/*from w w w . j a v a2s.c om*/ final Panel panel = new Panel(content); panel.setWidth("500"); panel.setHeight("400"); final VerticalLayout root = new VerticalLayout(); root.addComponent(panel); root.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); root.setSizeFull(); root.setMargin(true); setContent(root); content.addComponent(new Embedded("", new ExternalResource("https://vaadin.com/vaadin-theme/images/vaadin/vaadin-logo-color.png"))); content.addComponent(new Embedded("", new ExternalResource("http://images.wikia.com/logopedia/images/e/e4/YahooFinanceLogo.png"))); // Display the greeting final Label heading = new Label("<b>Simple Currency Converter " + "Using YQL/Yahoo Finance Service</b>", ContentMode.HTML); heading.setWidth(null); content.addComponent(heading); // Build the set of fields for the converter form final TextField fromField = new TextField("From Currency", "AUD"); fromField.setRequired(true); fromField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false)); content.addComponent(fromField); final TextField toField = new TextField("To Currency", "USD"); toField.setRequired(true); toField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false)); content.addComponent(toField); final TextField resultField = new TextField("Result"); resultField.setEnabled(false); content.addComponent(resultField); final TextField timeField = new TextField("Time"); timeField.setEnabled(false); content.addComponent(timeField); final Button submitButton = new Button("Submit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { // Do the conversion final String result = converter.convert(fromField.getValue().toUpperCase(), toField.getValue().toUpperCase()); if (result != null) { resultField.setValue(result); timeField.setValue(new Date().toString()); } } }); content.addComponent(submitButton); // Configure the error handler for the UI UI.getCurrent().setErrorHandler(new DefaultErrorHandler() { @Override public void error(com.vaadin.server.ErrorEvent event) { // Find the final cause String cause = "<b>The operation failed :</b><br/>"; Throwable th = Throwables.getRootCause(event.getThrowable()); if (th != null) cause += th.getClass().getName() + "<br/>"; // Display the error message in a custom fashion content.addComponent(new Label(cause, ContentMode.HTML)); // Do the default error handling (optional) doDefault(event); } }); }
From source file:org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow.java
License:Open Source License
private CommonDialogWindow createWindow() { final Label madatoryStarLabel = new Label("*"); madatoryStarLabel.setStyleName("v-caption v-required-field-indicator"); madatoryStarLabel.setWidth(null);//from ww w . jav a 2 s . c o m addStyleName("lay-color"); setSizeUndefined(); formLayout = new FormLayout(); formLayout.setCaption(null); if (editSwModule) { formLayout.addComponent(softwareModuleType); } else { formLayout.addComponent(typeComboBox); typeComboBox.focus(); } formLayout.addComponent(nameTextField); formLayout.addComponent(versionTextField); formLayout.addComponent(vendorTextField); formLayout.addComponent(descTextArea); setCompositionRoot(formLayout); final CommonDialogWindow window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW) .caption(i18n.getMessage("caption.create.new", i18n.getMessage("caption.software.module"))) .id(UIComponentIdProvider.SW_MODULE_CREATE_DIALOG).content(this).layout(formLayout).i18n(i18n) .saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow(); nameTextField.setEnabled(!editSwModule); versionTextField.setEnabled(!editSwModule); return window; }
From source file:org.eclipse.hawkbit.ui.management.dstable.DistributionAddUpdateWindowLayout.java
License:Open Source License
private void buildLayout() { addStyleName("lay-color"); setSizeUndefined();/*from www . j a v a 2s .c o m*/ formLayout = new FormLayout(); formLayout.addComponent(distsetTypeNameComboBox); formLayout.addComponent(distNameTextField); formLayout.addComponent(distVersionTextField); formLayout.addComponent(descTextArea); formLayout.addComponent(reqMigStepCheckbox); setCompositionRoot(formLayout); distNameTextField.focus(); }