List of usage examples for com.vaadin.ui Label setContentMode
public void setContentMode(ContentMode contentMode)
From source file:com.mycompany.project.views.ContactsView.java
public ContactsView() { VerticalLayout mainVLayout = new VerticalLayout(); mainVLayout.setMargin(true);//from w w w . j a va2s. c om mainVLayout.setSpacing(true); setContent(mainVLayout); // view header Label header = new Label("<div align=\"center\" style=\"font-size:12pt;\">Contactos</div>"); header.setContentMode(ContentMode.HTML); mainVLayout.addComponent(header); // set window properties window.setWidth("400px"); window.setCaption("Nuevo Contacto"); window.setModal(true); window.setContent(newContactForm); // add new cotact button Button btnNew = new Button("Agregar Nuevo Contacto"); mainVLayout.addComponent(btnNew); // clicking the button should display the NewContactForm btnNew.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (window.getParent() == null) { getUI().addWindow(window); } } }); //add a horozontal layout - left has a table, right has a ContactDetail component HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSizeFull(); hLayout.setSpacing(true); mainVLayout.addComponent(hLayout); //add a table table.setWidth("600px"); table.setImmediate(true); hLayout.addComponent(table); // how does table get its data beanContainer.setBeanIdProperty("id"); table.setContainerDataSource(beanContainer); //set columns final Object[] NATURAL_COL_ORDER = new Object[] { "name", "phone", "email" }; final String[] COL_HEADERS_ENGLISH = new String[] { "Name", "Phone", "Email" }; table.setSelectable(true); table.setColumnCollapsingAllowed(true); table.setRowHeaderMode(RowHeaderMode.INDEX); table.setVisibleColumns(NATURAL_COL_ORDER); table.setColumnHeaders(COL_HEADERS_ENGLISH); // selecting a table row should enable/disale the ContactDetails component table.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { String contactId = (String) table.getValue(); contactDetails.setContactId(contactId); } }); //add a ContactDetails component // contactDetails.setWidth("500px"); hLayout.addComponent(contactDetails); // let the table fill the entire remaining width hLayout.setExpandRatio(contactDetails, 1); }
From source file:com.mycompany.project.views.GroupsView.java
public GroupsView() { VerticalLayout mainVLayout = new VerticalLayout(); mainVLayout.setMargin(true);//from ww w. jav a 2 s . c om mainVLayout.setSpacing(true); setContent(mainVLayout); // view header Label header = new Label("<div align=\"center\" style=\"font-size:12pt;\">Grupos</div>"); header.setContentMode(ContentMode.HTML); mainVLayout.addComponent(header); // set window properties window.setWidth("400px"); window.setCaption("New Group"); window.setModal(true); window.setContent(newGroupForm); // add new cotact button Button btnNew = new Button("Add New Group"); mainVLayout.addComponent(btnNew); // clicking the button should display the NewContactForm btnNew.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (window.getParent() == null) { getUI().addWindow(window); } } }); //add a horozontal layout - left has a table, right has a ContactDetail component HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSizeFull(); hLayout.setSpacing(true); mainVLayout.addComponent(hLayout); //add a table table.setWidth("600px"); table.setImmediate(true); hLayout.addComponent(table); // how does table get its data beanContainer.setBeanIdProperty("id"); table.setContainerDataSource(beanContainer); //set columns final Object[] NATURAL_COL_ORDER = new Object[] { "name" }; final String[] COL_HEADERS_ENGLISH = new String[] { "Name" }; table.setSelectable(true); table.setColumnCollapsingAllowed(true); table.setRowHeaderMode(RowHeaderMode.INDEX); table.setVisibleColumns(NATURAL_COL_ORDER); table.setColumnHeaders(COL_HEADERS_ENGLISH); // selecting a table row should enable/disale the ContactDetails component table.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { String groupId = (String) table.getValue(); groupDetails.setGroupId(groupId); } }); //add a ContactDetails component // contactDetails.setWidth("500px"); hLayout.addComponent(groupDetails); // let the table fill the entire remaining width hLayout.setExpandRatio(groupDetails, 1); }
From source file:com.openhris.commons.AboutHris.java
public Window aboutHris() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSpacing(true);/*from w w w . ja v a2 s . co m*/ vlayout.setMargin(true); final Window subWindow = new Window("About HRMS", vlayout); subWindow.setWidth("300px"); Label version = new Label("Version: <b>1.0</b>"); version.setContentMode(Label.CONTENT_XHTML); subWindow.addComponent(version); Label title = new Label("Title: <b>Human Resource Information System</b>"); title.setContentMode(Label.CONTENT_XHTML); subWindow.addComponent(title); Label developer = new Label("Developed By: <b>Engr. Godfrey D. Beray</b>"); developer.setContentMode(Label.CONTENT_XHTML); subWindow.addComponent(developer); Label framework = new Label("Framework: <b>VAADIN - Sept2012</b>"); framework.setContentMode(Label.CONTENT_XHTML); subWindow.addComponent(framework); return subWindow; }
From source file:com.peergreen.webconsole.scope.home.extensions.PeergreenNewsFeedFrame.java
License:Open Source License
/** * News popup/* w w w . j a v a 2 s .c om*/ * * @param feedMessage * @return */ private Window getNewsDescription(FeedMessage feedMessage) { FormLayout fields = new FormLayout(); fields.setWidth("35em"); fields.setSpacing(true); fields.setMargin(true); Label label = new Label("<a href=\"" + feedMessage.getLink() + "\">" + feedMessage.getLink().substring(0, 50) + "..." + "</a>"); label.setContentMode(ContentMode.HTML); label.setSizeUndefined(); label.setCaption("URL"); fields.addComponent(label); String description = feedMessage.getDescription(); if (description.length() > 1000) { description = description.substring(0, 999) + "..."; } Label desc = new Label(description); desc.setContentMode(ContentMode.HTML); desc.setCaption("Description"); fields.addComponent(desc); Button ok = new Button("Close"); ok.addStyleName("wide"); ok.addStyleName("default"); final Window w = new DefaultWindow(feedMessage.getTitle(), fields, ok); w.center(); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { w.close(); } }); return w; }
From source file:com.peergreen.webconsole.scope.logs.stream.TextColumnGenerator.java
License:Open Source License
/** * Generates the cell containing the Date value. The column is * irrelevant in this use case./* ww w . ja v a2s . com*/ */ @Override public Component generateCell(Table source, Object itemId, Object columnId) { BeanItem<TableEntry> item = (BeanItem<TableEntry>) source.getItem(itemId); TableEntry tableEntry = item.getBean(); Property<?> prop = item.getItemProperty(columnId); Label label = new Label(); String text = item.getBean().getText().replaceAll(" ", " "); if (StreamType.OUT.name().equals(item.getBean().getType()) || "INFO".equals(item.getBean().getType())) { label.setValue("<font color='black'>".concat(text).concat("</font>")); } else if (StreamType.ERR.name().equals(item.getBean().getType()) || "ERROR".equals(item.getBean().getType())) { label.setValue("<font color='red'>".concat(text).concat("</font>")); } else if ("DEBUG".equals(item.getBean().getType())) { label.setValue("<font color='grey'>".concat(text).concat("</font>")); } else if ("WARNING".equals(item.getBean().getType())) { label.setValue("<font color='orange'>".concat(text).concat("</font>")); } else if ("SEVERE".equals(item.getBean().getType())) { label.setValue("<font color='red'>".concat(text).concat("</font>")); } else { label.setValue("<font color='black'>".concat(text).concat("</font>")); } label.setValue("<div style='font-family:Monaco, Menlo, Consolas, monospace;font-size:small;'>" .concat(label.getValue().concat("</div>"))); label.setContentMode(ContentMode.HTML); return label; }
From source file:com.purebred.core.MainApplication.java
License:Open Source License
/** * Open separate error Window, useful for showing stacktraces. * * @param message//w ww . j a va2 s .c o m */ public void openErrorWindow(String message) { Window errorWindow = new Window("Error"); errorWindow.addStyleName("opaque"); VerticalLayout layout = (VerticalLayout) errorWindow.getContent(); layout.setSpacing(true); layout.setWidth("100%"); errorWindow.setWidth("100%"); errorWindow.setModal(true); Label label = new Label(message); label.setContentMode(Label.CONTENT_PREFORMATTED); layout.addComponent(label); errorWindow.setClosable(true); errorWindow.setScrollable(true); MainApplication.getInstance().getMainWindow().addWindow(errorWindow); }
From source file:com.save.reports.maintenance.MaintenanceReportUI.java
Window exportLargeData() { Window sub = new Window("EXPORT LARGE DATA"); sub.setWidth("300px"); sub.setModal(true);/*from w ww . ja v a 2 s. c om*/ sub.center(); VerticalLayout v = new VerticalLayout(); v.setSizeFull(); v.setMargin(true); v.setSpacing(true); Label status = new Label("Exporting large amount of data will take longer and will eat a lot of memory.", ContentMode.HTML); status.setContentMode(ContentMode.HTML); v.addComponent(status); Button b = new CommonButton("PROCEED TO EXPORT?"); b.addClickListener((Button.ClickEvent e) -> { sub.close(); processExportDataToExcel(); }); v.addComponent(b); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private VerticalLayout getUDContainer(String strUID) { if (bee == null) bee = new UserDetailsBackEnd(); hm = bee.getUD(strUID);// w w w. ja va2s .c o m String strProf = hm.get("Profile Type"); VerticalLayout cAgentInfo = new VerticalLayout(); cAgentInfo.setMargin(new MarginInfo(true, false, true, false)); cAgentInfo.setStyleName("c_details_test"); cAgentInfo.setSizeUndefined(); FormLayout cBasic = new FormLayout(); // cBasic.setSpacing(true); Label lbB = new Label(); lbB.setCaption("General"); lbB.setStyleName("label_search_user u_d_t"); cBasic.addComponent(lbB); String cap = "First Name"; TextField tF = new TextField(cap); tFFN = tF; tFFN.setRequired(true); tF.setValue(hm.get(cap)); addDatum("Username", hm.get("Username"), cBasic); addDatum("Profile", strProf, cBasic); addDatum("Account Status", hm.get("Status"), cBasic); addDatum("First Name", hm.get("First Name"), cBasic); tF = new TextField("Middle Name"); addDatum("Middle Name", hm.get("Middle Name"), cBasic); addDatum("Last Name", hm.get("Last Name"), cBasic); addDatum("Gender", hm.get("Gender"), cBasic); addDatum("Occupation", hm.get("Occupation"), cBasic); addDatum("Date of Birth", hm.get("Date of Birth"), cBasic); addDatum("Country", hm.get("Country"), cBasic); addDatum("State", hm.get("State"), cBasic); addDatum("Local Government", hm.get("Local Government"), cBasic); VerticalLayout cC = new VerticalLayout(); HorizontalLayout cBAndCAndAcc = new HorizontalLayout(); cBAndCAndAcc.addComponent(cBasic); cBAndCAndAcc.addComponent(cC); FormLayout cCompany = new FormLayout(); // Label lbC = new Label("Company"); Label lbC = new Label(); lbC.setCaption("Identification"); lbC.setStyleName("label_search_user lb_frm_add_user u_d_t"); combo = new ComboBox("ID Type"); combo.addItem("Passport Number"); combo.addItem("National Registration Identification Number"); combo.addItem("Drivers License Number"); combo.addItem("Identification Card"); combo.addItem("Employer Identification Number"); combo.select("Passport Number"); comboIDType = combo; comboIDType.setRequired(true); cCompany.addComponent(lbC); addDatum("ID Type", hm.get("ID Type"), cCompany); addDatum("ID No.", hm.get("ID No."), cCompany); addDatum("Issuer", hm.get("Issuer"), cCompany); addDatum("Issue Date", hm.get("Issue Date"), cCompany); addDatum("Expiry Date", hm.get("Expiry Date"), cCompany); cC.addComponent(cCompany); FormLayout pC = new FormLayout(); lbC = new Label(); lbC.setCaption("Primary Contacts"); lbC.setStyleName("label_search_user u_d_t"); pC.addComponent(lbC); addDatum("Mobile Phone No.", hm.get("P-Mobile Phone No."), pC); addDatum("Alt. Phone No.", hm.get("P-Alt. Phone No."), pC); addDatum("Email Address", hm.get("Email"), pC); cC.addComponent(pC); FormLayout sC = new FormLayout(); lbC = new Label(); lbC.setCaption("Secondary Contacts"); lbC.setStyleName("label_search_user lb_frm_add_user u_d_t"); sC.addComponent(lbC); addDatum("Mobile Phone No.", hm.get("S-Mobile Phone No."), sC); addDatum("Alt. Phone No.", hm.get("S-Alt. Phone No."), sC); addDatum("Email Address", hm.get("Email"), sC); cC.addComponent(sC); FormLayout physicalC = new FormLayout(); lbC = new Label(); lbC.setCaption("Physical Address"); lbC.setStyleName("label_search_user lb_frm_add_user u_d_t"); physicalC.addComponent(lbC); StringBuilder sbAddr = new StringBuilder(); String strp = hm.get("Postal Code"); sbAddr.append((strp == null || strp.trim().isEmpty()) ? "" : "P.O.Box " + strp + ", "); strp = hm.get("Street"); sbAddr.append((strp == null || strp.trim().isEmpty()) ? "" : strp + ", "); strp = hm.get("Province"); sbAddr.append((strp == null || strp.trim().isEmpty()) ? "" : strp + ", "); strp = hm.get("State"); sbAddr.append((strp == null || strp.trim().isEmpty()) ? "" : strp + ", "); strp = hm.get("Country"); sbAddr.append((strp == null || strp.trim().isEmpty()) ? "." : strp); Label lb = new Label(); lbC.setContentMode(ContentMode.HTML); lb.setStyleName("label_ud"); lb.setCaption(sbAddr.toString()); physicalC.addComponent(lb); cC.addComponent(physicalC); cC.addComponent(cBtnEditCancel); cC.setMargin(new MarginInfo(false, true, false, true)); cAgentInfo.addComponent(cBAndCAndAcc); return cAgentInfo; }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private void addLinkUserContainer() { VerticalLayout cDeletePrompt = new VerticalLayout(); cPlaceholder.addComponent(cDeletePrompt); cPlaceholder.setComponentAlignment(cDeletePrompt, Alignment.MIDDLE_CENTER); // cDeletePrompt.setWidth("100%"); cDeletePrompt.setStyleName("c_link"); cDeletePrompt.setSpacing(true);/* w ww .j a v a2s. c o m*/ String username = curUser; Label lbActivationPrompt = new Label( "<span style='text-align: center;'>Please enter Child Username to link to " + username + "'s Account</span>"); lbActivationPrompt.setContentMode(ContentMode.HTML); lbActivationPrompt.setWidth("300px"); lbActivationPrompt.setStyleName("lb_link_user"); cDeletePrompt.addComponent(lbActivationPrompt); cDeletePrompt.setComponentAlignment(lbActivationPrompt, Alignment.TOP_LEFT); VerticalLayout frmDeleteReason = new VerticalLayout(); frmDeleteReason.setSizeUndefined(); frmDeleteReason.setSpacing(true); frmDeleteReason.setMargin(true); cDeletePrompt.addComponent(frmDeleteReason); cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.TOP_CENTER); tFU = new TextField("Child Username"); tFU.setRequired(true); final ComboBox comboUProf = new ComboBox("Select Profile"); comboUProf.setNullSelectionAllowed(false); comboUProf.setRequired(true); comboUProf.addItem(8); comboUProf.setItemCaption(8, "DEPOSIT_ONLY"); comboUProf.addItem(9); comboUProf.setItemCaption(9, "DEPOSIT_AND_WITHDRAWAL"); comboUProf.select(8); final TextField tFP = new TextField("Parent Account ID"); tFP.setValue(username); tFP.setEnabled(false); final TextField tFInitUser = new TextField("Initiating User"); tFInitUser.setValue(UI.getCurrent().getSession().getAttribute("user").toString()); tFInitUser.focus(); tFInitUser.setEnabled(false); frmDeleteReason.addComponent(tFU); frmDeleteReason.addComponent(comboUProf); frmDeleteReason.addComponent(tFP); frmDeleteReason.addComponent(tFInitUser); HorizontalLayout cPopupBtns = new HorizontalLayout(); cPopupBtns.setSizeUndefined(); cPopupBtns.setSpacing(true); final Button btnCancel = new Button(); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName("btn_link"); btnCancel.setDescription("Cancel"); final Button btnSet = new Button("Link"); btnSet.setDescription("Link specified account."); btnSet.setIcon(FontAwesome.LINK); cPopupBtns.addComponent(btnSet); cPopupBtns.addComponent(btnCancel); frmDeleteReason.addComponent(cPopupBtns); cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.MIDDLE_CENTER); btnSet.setClickShortcut(KeyCode.ENTER, null); btnSet.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -6318666715385643538L; @Override public void buttonClick(ClickEvent event) { tFU.validate(); btnSet.setEnabled(false); btnCancel.setEnabled(false); Button btn = event.getButton(); if (ums == null) ums = new UserManagementService(); btn.setEnabled(false); String strResponse = null; try { strResponse = UserManagementService.linkUser(tFP.getValue(), new Integer(comboUProf.getValue().toString()), tFInitUser.getValue(), tFU.getValue()); if (strResponse.equals("The operation was successful and completed")) { updateLinksTable(tFU.getValue()); cPlaceholder.setVisible(false); tFU.setValue(""); btnLink.setVisible(true); NotifCustom.show("Link", strResponse); } else { NotifCustom.show("Link", strResponse); } } catch (RemoteException e) { e.printStackTrace(); } btnSet.setEnabled(true); btnCancel.setEnabled(true); } }); btnCancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 7161821652386306043L; @Override public void buttonClick(ClickEvent event) { btnLink.setVisible(true); cPlaceholder.setVisible(false); } }); }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.ErrorView.java
public void displayErrorMessage(Exception ex, String title, String message) { VerticalLayout info = new VerticalLayout(); errorInfo.addComponent(info);/*from w w w.j av a2s .c o m*/ errorInfo.setComponentAlignment(info, Alignment.TOP_LEFT); info.setStyleName("error-page-information"); if (title != null) { } if (message != null) { } if (ex != null) { Label label = new Label(); label.setContentMode(Label.CONTENT_XHTML); label.setCaption(ex.getLocalizedMessage()); info.addComponent(label); Label stacktraceLabel = new Label("Stacktrace"); info.addComponent(stacktraceLabel); Label stacktrace = new Label(); stacktrace.setWidth("50%"); stacktrace.setStyleName("error-page-stacktrace"); stacktrace.setCaptionAsHtml(true); StringWriter errors = new StringWriter(); ex.printStackTrace(new PrintWriter(errors)); stacktrace.setCaption(errors.toString()); info.addComponent(stacktrace); } }