private void initComponents() { setSpacing(true); HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); layout.setWidth("100%"); cardNuberField = new TextField(); cardNuberField.setWidth("100%"); cardNuberField.setInputPrompt("Ноомер социальной карты, либо e-mail"); layout.addComponent(cardNuberField); layout.setComponentAlignment(cardNuberField, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(cardNuberField, 1.0f); addComponent(layout); layout = new HorizontalLayout(); layout.setSpacing(true); layout.setWidth("100%"); checkwordField = new TextField(); checkwordField.setWidth("100%"); checkwordField.setInputPrompt("Проверочное слово"); layout.addComponent(checkwordField); layout.setComponentAlignment(checkwordField, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(checkwordField, 1.0f); addComponent(layout); Button btnSearch = new Button("Найти"); btnSearch.addClickListener(getSearchClickListener()); addComponent(btnSearch); }
private Component buildFooter() { HorizontalLayout footer = new HorizontalLayout(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Unit.PERCENTAGE); Button ok = new Button("OK"); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.addClickListener( event -> { try { fieldGroup.commit(); // Updated user should also be persisted to database. But // not in this demo. Notification success = new Notification("Profile updated successfully"); success.setDelayMsec(2000); success.setStyleName("bar success small"); success.setPosition(Position.BOTTOM_CENTER); success.show(Page.getCurrent()); // DashboardEventBus.post(new ProfileUpdatedEvent()); close(); } catch (CommitException e) { Notification.show("Error while updating profile", Type.ERROR_MESSAGE); } }); ok.focus(); footer.addComponent(ok); footer.setComponentAlignment(ok, Alignment.TOP_RIGHT); return footer; }
private Layout createTextFieldMail(String title, Component component) { HorizontalLayout layout = new HorizontalLayout(); Label lbTitle = new Label(title); lbTitle.setWidth("60px"); lbTitle.setStyleName("lbmail"); layout.addComponent(lbTitle); layout.setComponentAlignment(lbTitle, Alignment.MIDDLE_RIGHT); layout.addComponent(component); layout.setComponentAlignment(component, Alignment.MIDDLE_LEFT); layout.setWidth("100%"); layout.setExpandRatio(component, 1.0f); return layout; }
private void init() { VerticalLayout root = new VerticalLayout(); header = new HorizontalLayout(); tituloLbl.setStyleName("titlePanel"); header.addComponent(tituloLbl); headerLayout = new HorizontalLayout(); header.addComponent(headerLayout); header.setComponentAlignment(headerLayout, Alignment.MIDDLE_RIGHT); header.setStyleName("headerPanel"); header.setWidth("100%"); header.setHeight("50px"); body = new VerticalLayout(); body.setStyleName("bodyPanel"); body.setWidth("100%"); footer = new HorizontalLayout(); footer.setStyleName("footerPanel"); footerLayout = new HorizontalLayout(); footer.addComponent(footerLayout); footer.setComponentAlignment(footerLayout, Alignment.MIDDLE_CENTER); footer.setWidth("100%"); footer.setHeight("60px"); root.addComponent(header); root.addComponent(body); root.addComponent(footer); root.setWidth("100%"); setCompositionRoot(root); }
public MainScreen() { Label loginLabel = new Label("Welcome " + VaadinSession.getCurrent().getAttribute(String.class)); HorizontalLayout menuBar = new HorizontalLayout(loginLabel); MessageTable table = new MessageTable(); TextArea messageArea = new TextArea(); messageArea.setWidth(100, PERCENTAGE); Button sendButton = new Button("Send"); sendButton.addClickListener(new SendMessageClickListener(table, messageArea)); HorizontalLayout lowerBar = new HorizontalLayout(messageArea, sendButton); lowerBar.setWidth(100, PERCENTAGE); lowerBar.setSpacing(true); VerticalLayout mainLayout = new VerticalLayout(menuBar, table, lowerBar); mainLayout.setSpacing(true); mainLayout.setMargin(true); mainLayout.setSizeFull(); setCompositionRoot(mainLayout); }
public WindowTimtheobomon() { setCaption("Tìm theo bộ môn "); // Constants.USER_CAPTION) ; HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setImmediate(false); mainLayout.setWidth(Constants.WIDTH_MAX, Sizeable.UNITS_PIXELS); mainLayout.setMargin(false); mainLayout.setSpacing(true); mainLayout.addComponent(new leftSide()); rContent = new VerticalLayout(); rContent.setWidth("100%"); mainLayout.addComponent(rContent); mainLayout.setExpandRatio(rContent, 1.0f); VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setStyleName("bl-mainContent"); v.addComponent(mainLayout); v.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); addComponent(new topLogin()); addComponent(new topPanel()); addComponent(new mainMenu()); addComponent(v); addComponent(new bottom()); // --------------------bl Label title = new Label("<center><h1>Tìm theo bộ môn<h1></center>", Label.CONTENT_XHTML); final BeanItemContainer<ResearchingBean> beans = new BeanItemContainer<ResearchingBean>(ResearchingBean.class); Table table = new Table("Tìm kiếm", beans); table.setWidth("100%"); table.setPageLength(10); rContent.addComponent(title); rContent.addComponent(table); }
private Component createConnectionSelectorLayout() { final ProfileInfoPanelHolder infoPanelHolder = new ProfileInfoPanelHolder(); profileSelector = createProfileSelector(infoPanelHolder); HorizontalLayout content = new HorizontalLayout(profileSelector, infoPanelHolder); content.setSizeFull(); content.setExpandRatio(infoPanelHolder, 1); Component buttons = createConnectionButtons(infoPanelHolder); Component profileManagerToolbar = createProfileManagerToolbar(profileSelector); HorizontalLayout footer = new HorizontalLayout(profileManagerToolbar, buttons); footer.setWidth("100%"); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT); VerticalLayout layout = new VerticalLayout(content, footer); layout.setSizeFull(); layout.setExpandRatio(content, 1); return layout; }
private Layout createBottomPanel() { final HorizontalLayout controlPanel = new HorizontalLayout(); controlPanel.setMargin(true); controlPanel.setStyleName("more-info"); controlPanel.setHeight("40px"); controlPanel.setWidth("100%"); Button moreInfoBtn = new Button( "More information...", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { editUserForm.displayAdvancedForm(user); } }); moreInfoBtn.addStyleName(UIConstants.THEME_LINK); controlPanel.addComponent(moreInfoBtn); controlPanel.setComponentAlignment(moreInfoBtn, Alignment.MIDDLE_LEFT); return controlPanel; }
public WindowManagerTeacher() { setCaption("quan ly bo mon "); // Constants.USER_CAPTION) ; mainLayout = new HorizontalLayout(); mainLayout.setImmediate(false); mainLayout.setWidth(Constants.WIDTH_MAX, Sizeable.UNITS_PIXELS); mainLayout.setMargin(false); mainLayout.setSpacing(true); mainLayout.addComponent(new leftSide()); rContentList = new VerticalLayout(); rContentList.setWidth("100%"); mainLayout.addComponent(rContentList); mainLayout.setExpandRatio(rContentList, 1.0f); rContentModify = new rightContentAddNewTeacher(1); rContentModify.setWidth("100%"); VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setStyleName("bl-mainContent"); v.addComponent(mainLayout); v.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); addComponent(new topLogin()); addComponent(new topPanel()); addComponent(new mainMenu()); addComponent(v); addComponent(new bottom()); // --------------------bl Label title = new Label("<center><h1>Danh sách giang vien<h1></center>", Label.CONTENT_XHTML); table = new Table(); table.setWidth("100%"); table.setPageLength(20); rContentList.addComponent(title); rContentList.addComponent(table); Connection conn = null; Statement stmt = null; try { JDBCConnectionPool pool = new SimpleJDBCConnectionPool( JDBC_DRIVER, DB_URL + QlgiangvienApplication.DB_DBNAME, QlgiangvienApplication.DB_USER, QlgiangvienApplication.DB_PASS); String mysql = "SELECT * from GiangVien"; TableQuery query = new TableQuery("GiangVien", pool); query.setVersionColumn("OPTLOCK"); SQLContainer container = new SQLContainer(query); container.setAutoCommit(true); // container.re table.setContainerDataSource(container); // FreeformQuery query = new FreeformQuery(mysql, pool, "MaGV") ; // container = new SQLContainer(query); // table.setContainerDataSource(container) ; table.addGeneratedColumn( "Chinh Sua", new Table.ColumnGenerator() { public Component generateCell(Table source, Object itemId, Object columnId) { final Item item = table.getItem(itemId); Button btnModify = new Button( "Chinh Sua", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // rContentList.setVisible(false); // rContentModify.setVisible(true); System.out.println(item.toString()); rContentModify.setUpdateData( item.getItemProperty("MaGV").getValue().toString()); mainLayout.removeComponent(rContentList); mainLayout.addComponent(rContentModify); mainLayout.setExpandRatio(rContentModify, 1.0f); } }); return btnModify; } }); confirmDelete(); table.addGeneratedColumn( "Xoa", new Table.ColumnGenerator() { public Component generateCell(Table source, Object itemId, Object columnId) { // Item item = table.getItem(itemId); Button btnModify = new Button( "Xoa", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (subwindow.getParent() == null) { getWindow().addWindow(subwindow); } } }); return btnModify; } }); } catch (Exception e) { System.out.println("in right COntent: " + e.toString()); } } // end of container
private void initUI() { GridLayout mainLayout = new GridLayout(1, 5); mainLayout.setWidth("100%"); mainLayout.setMargin(true); mainLayout.setSpacing(true); CssLayout inputPanel = new CssLayout(); inputPanel.setWidth("100%"); inputPanel.setStyleName("mail-panel"); inputLayout = new GridLayout(3, 4); inputLayout.setSpacing(true); inputLayout.setWidth("100%"); inputLayout.setColumnExpandRatio(0, 1.0f); inputPanel.addComponent(inputLayout); mainLayout.addComponent(inputPanel); tokenFieldMailTo = new EmailTokenField(); inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0); if (lstMail != null) { for (String mail : lstMail) { if (StringUtils.isNotBlank(mail)) { if (mail.indexOf("<") > -1) { String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">")); if (strMail != null && !strMail.equalsIgnoreCase("null")) {} } else { } } } } final TextField subject = new TextField(); subject.setRequired(true); subject.setWidth("100%"); subjectField = createTextFieldMail("Subject:", subject); inputLayout.addComponent(subjectField, 0, 1); initButtonLinkCcBcc(); ccField = createTextFieldMail("Cc:", tokenFieldMailCc); bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc); final RichTextArea noteArea = new RichTextArea(); noteArea.setWidth("100%"); noteArea.setHeight("200px"); mainLayout.addComponent(noteArea, 0, 1); mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("500px"); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.addComponent(uploadExt); controlsLayout.setExpandRatio(uploadExt, 1.0f); controlsLayout.setSpacing(true); Button cancelBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { MailFormWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); controlsLayout.addComponent(cancelBtn); controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT); Button sendBtn = new Button( "Send", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) { NotificationUtil.showErrorNotification( "To Email field and Subject field must be not empty! Please fulfil them before sending email."); return; } if (AppContext.getUser().getEmail() != null && AppContext.getUser().getEmail().length() > 0) { ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class); List<File> listFile = attachments.files(); List<EmailAttachementSource> emailAttachmentSource = null; if (listFile != null && listFile.size() > 0) { emailAttachmentSource = new ArrayList<>(); for (File file : listFile) { emailAttachmentSource.add(new FileEmailAttachmentSource(file)); } } systemMailService.sendHTMLMail( AppContext.getUser().getEmail(), AppContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(), tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(), subject.getValue().toString(), noteArea.getValue().toString(), emailAttachmentSource); MailFormWindow.this.close(); } else { NotificationUtil.showErrorNotification( "Your email is empty value, please fulfil it before sending email!"); } } }); sendBtn.setIcon(FontAwesome.SEND); sendBtn.setStyleName(UIConstants.BUTTON_ACTION); controlsLayout.addComponent(sendBtn); controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT); mainLayout.addComponent(controlsLayout, 0, 2); this.setContent(mainLayout); }
private Component buildProfileTab() { HorizontalLayout root = new HorizontalLayout(); root.setCaption("Profile"); root.setIcon(FontAwesome.USER); root.setWidth(100.0f, Unit.PERCENTAGE); root.setSpacing(true); root.setMargin(true); root.addStyleName("profile-form"); VerticalLayout pic = new VerticalLayout(); pic.setSizeUndefined(); pic.setSpacing(true); Image profilePic = new Image(null, new ThemeResource("img/profile-pic-300px.jpg")); profilePic.setWidth(100.0f, Unit.PIXELS); pic.addComponent(profilePic); Button upload = new Button( "Change…", event -> { Notification.show("Not implemented in this demo"); }); upload.addStyleName(ValoTheme.BUTTON_TINY); pic.addComponent(upload); root.addComponent(pic); FormLayout details = new FormLayout(); details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(details); root.setExpandRatio(details, 1); firstNameField = new TextField("First Name"); details.addComponent(firstNameField); lastNameField = new TextField("Last Name"); details.addComponent(lastNameField); titleField = new ComboBox("Title"); titleField.setInputPrompt("Please specify"); titleField.addItem("Mr."); titleField.addItem("Mrs."); titleField.addItem("Ms."); titleField.setNewItemsAllowed(true); details.addComponent(titleField); sexField = new OptionGroup("Sex"); sexField.addItem(Boolean.FALSE); sexField.setItemCaption(Boolean.FALSE, "Female"); sexField.addItem(Boolean.TRUE); sexField.setItemCaption(Boolean.TRUE, "Male"); sexField.addStyleName("horizontal"); details.addComponent(sexField); Label section = new Label("Contact Info"); section.addStyleName(ValoTheme.LABEL_H4); section.addStyleName(ValoTheme.LABEL_COLORED); details.addComponent(section); emailField = new TextField("Email"); emailField.setWidth("100%"); emailField.setRequired(true); emailField.setNullRepresentation(""); details.addComponent(emailField); locationField = new TextField("Location"); locationField.setWidth("100%"); locationField.setNullRepresentation(""); locationField.setComponentError(new UserError("This address doesn't exist")); details.addComponent(locationField); phoneField = new TextField("Phone"); phoneField.setWidth("100%"); phoneField.setNullRepresentation(""); details.addComponent(phoneField); newsletterField = new OptionalSelect<>(); newsletterField.addOption(0, "Daily"); newsletterField.addOption(1, "Weekly"); newsletterField.addOption(2, "Monthly"); details.addComponent(newsletterField); section = new Label("Additional Info"); section.addStyleName(ValoTheme.LABEL_H4); section.addStyleName(ValoTheme.LABEL_COLORED); details.addComponent(section); websiteField = new TextField("Website"); websiteField.setInputPrompt("http://"); websiteField.setWidth("100%"); websiteField.setNullRepresentation(""); details.addComponent(websiteField); bioField = new TextArea("Bio"); bioField.setWidth("100%"); bioField.setRows(4); bioField.setNullRepresentation(""); details.addComponent(bioField); return root; }