List of usage examples for com.vaadin.ui Button setIcon
@Override public void setIcon(Resource icon)
From source file:com.anphat.customer.controller.CustomerContactController.java
private void addEditButtonForTableCareCust() { panelTblHistory.getMainTable().addGeneratedColumn("btnEdit", new CustomTable.ColumnGenerator() { @Override/*from w w w. java2 s.c o m*/ public Object generateCell(CustomTable source, Object itemId, Object columnId) { final CustomerCareHistoryDTO editDTO = (CustomerCareHistoryDTO) itemId; Button btnEdit = new Button(); btnEdit.addStyleName("v-button-link"); btnEdit.setIcon(FontAwesome.EDIT); // btnEdit.setCaption("Sa"); btnEdit.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { CustomerContactDialog contactDialog = new CustomerContactDialog( BundleUtils.getString("customerCareHistoryForm"), lstCustomerServiceStatus, lstCustContact); contactDialog.fillData2Dialog(editDTO); contactDialog.setIsEdit(Boolean.TRUE); UI.getCurrent().addWindow(contactDialog); addListenerBtnSaveContactWhenEditCare(contactDialog, editDTO); event.getButton().setEnabled(true); } }); return btnEdit; } }); }
From source file:com.anphat.list.controller.ListStaffController.java
private void initTable() { itemContainer = new BeanItemContainer<>(StaffDTO.class); //add detail link into tblstaff tblStaffs.addGeneratedColumn("resetPassword", new CustomTable.ColumnGenerator() { @Override/*from w w w .j a v a2s. com*/ public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final Button linkDetails = new Button(); linkDetails.setIcon(FontAwesome.KEY); linkDetails.setStyleName(Runo.BUTTON_LINK); linkDetails.addStyleName("v-button-link-left"); linkDetails.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { final StaffDTO staffDTO = (StaffDTO) itemId; ConfirmDialog.show(UI.getCurrent(), "Reset mt khu", "?t li mt khu mc nh cho ti khon " + staffDTO.getName(), "?ng ", "Hu b?", new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { staffDTO.setPassword( DataUtil.md5(BundleUtils.getStringCas("password_default"))); // Confirmed to continue String result = WSStaff.updateStaff(staffDTO); if (Constants.SUCCESS.equalsIgnoreCase(result)) { CommonMessages.showMessageUpdateSuccess("pass"); } } } }); } }); linkDetails.setDescription(BundleUtils.getString("resetPassword")); return linkDetails; } }); tblStaffs.addGeneratedColumn("detailRole", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final Button btnAddRole = new Button(BundleUtils.getString("detail.roles")); btnAddRole.setStyleName(Runo.BUTTON_LINK); btnAddRole.addStyleName("v-button-link-left"); btnAddRole.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { StaffDTO staffDTO = (StaffDTO) itemId; MapStaffRolesDiaglog diaglog = new MapStaffRolesDiaglog( BundleUtils.getString("map.staff.roles.view")); diaglog.setTblRolesVisiableOnly(); MapStaffRolesController controller = new MapStaffRolesController(diaglog); controller.initOnlyView(staffDTO); UI.getCurrent().addWindow(diaglog); } }); btnAddRole.setDescription(BundleUtils.getString("lb.header.staff.addCustomer.decr")); return btnAddRole; } }); //160316 NgocND6 them chuc nang hang hoa quan ly cua tung nhan vien tblStaffs.addGeneratedColumn("goodsManage", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final Button linkDetails = new Button(BundleUtils.getString("lb.header.staff.goodsManage")); linkDetails.setStyleName(Runo.BUTTON_LINK); linkDetails.addStyleName("v-button-link-left"); linkDetails.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // StaffDTO staffDTO = (StaffDTO) itemId; // if (staffDTO.getStatus().equalsIgnoreCase("1")) { // getListMapStaffCustomer(staffDTO); // if (listMapStaffCustomer != null) { // DialogGoodsManagement dialogGoodsManagement = new DialogGoodsManagement(BundleUtils.getString("transfer.goods.manage.managoodsassignstaff")); // dialogGoodsManagement.initDialog(); // DialogGoodsManagementController dgmc = new DialogGoodsManagementController(staffDTO, dialogGoodsManagement); // UI.getCurrent().addWindow(dialogGoodsManagement); // }else{ // Notification.show(BundleUtils.getString("transfer.goods.manage.staffdontassigncust"), Notification.Type.WARNING_MESSAGE); // } // } else { // Notification.show(BundleUtils.getString("dept.staff.alert.message.notActive")); // } } }); linkDetails.setDescription(BundleUtils.getString("lb.header.staff.addCustomer.decr")); return linkDetails; } }); tableUtils = new TableUtils(); tableUtils.generateColumn(tblStaffs); CommonFunctionTableFilter.initTable(staffTablePanel, headerData, itemContainer, captionfieldsetListStaff, 5, "lb.header.staff"); CommonUtils.convertFieldAppParamTable(tblStaffs, Constants.STAFF.STATUS, Constants.APP_PARAMS.COMMON_STATUS); CommonUtils.convertFieldAppParamTable(tblStaffs, Constants.STAFF.STAFF_TYPE, Constants.APP_PARAMS.STAFF_TYPE); // tblStaffs.setColumnHeader("addStock", BundleUtils.getString("add.staff.for.stock")); }
From source file:com.cavisson.gui.dashboard.components.controls.ButtonsAndLinks.java
License:Apache License
/** * *//*from ww w. j a v a 2s . c o m*/ public ButtonsAndLinks() { setMargin(true); Label h1 = new Label("Buttons"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Button button = new Button("Normal"); row.addComponent(button); button = new Button("Disabled"); button.setEnabled(false); row.addComponent(button); button = new Button("Primary"); button.addStyleName("primary"); row.addComponent(button); button = new Button("Friendly"); button.addStyleName("friendly"); row.addComponent(button); button = new Button("Danger"); button.addStyleName("danger"); row.addComponent(button); TestIcon testIcon = new TestIcon(10); button = new Button("Small"); button.addStyleName("small"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button("Large"); button.addStyleName("large"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button("Top"); button.addStyleName("icon-align-top"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button("Image icon"); button.setIcon(testIcon.get(true, 16)); row.addComponent(button); button = new Button("Image icon"); button.addStyleName("icon-align-right"); button.setIcon(testIcon.get(true)); row.addComponent(button); button = new Button("Photos"); button.setIcon(testIcon.get()); row.addComponent(button); button = new Button(); button.setIcon(testIcon.get()); button.addStyleName("icon-only"); row.addComponent(button); button = new Button("Borderless"); button.setIcon(testIcon.get()); button.addStyleName("borderless"); row.addComponent(button); button = new Button("Borderless, colored"); button.setIcon(testIcon.get()); button.addStyleName("borderless-colored"); row.addComponent(button); button = new Button("Quiet"); button.setIcon(testIcon.get()); button.addStyleName("quiet"); row.addComponent(button); button = new Button("Link style"); button.setIcon(testIcon.get()); button.addStyleName("link"); row.addComponent(button); button = new Button("Icon on right"); button.setIcon(testIcon.get()); button.addStyleName("icon-align-right"); row.addComponent(button); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); row.addComponent(group); button = new Button("One"); group.addComponent(button); button = new Button("Two"); group.addComponent(button); button = new Button("Three"); group.addComponent(button); button = new Button("Tiny"); button.addStyleName("tiny"); row.addComponent(button); button = new Button("Huge"); button.addStyleName("huge"); row.addComponent(button); NativeButton nbutton = new NativeButton("Native"); row.addComponent(nbutton); h1 = new Label("Links"); h1.addStyleName("h1"); addComponent(h1); row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Link link = new Link("vaadin.com", new ExternalResource("https://vaadin.com")); row.addComponent(link); link = new Link("Link with icon", new ExternalResource("https://vaadin.com")); link.addStyleName("color3"); link.setIcon(testIcon.get()); row.addComponent(link); link = new Link("Small", new ExternalResource("https://vaadin.com")); link.addStyleName("small"); row.addComponent(link); link = new Link("Large", new ExternalResource("https://vaadin.com")); link.addStyleName("large"); row.addComponent(link); link = new Link(null, new ExternalResource("https://vaadin.com")); link.setIcon(testIcon.get()); link.addStyleName("large"); row.addComponent(link); }
From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java
License:Apache License
Panel notifications() { Panel p = new Panel("Notifications"); VerticalLayout content = new VerticalLayout() { Notification notification = new Notification(""); TextField title = new TextField("Title"); TextArea description = new TextArea("Description"); MenuBar style = new MenuBar(); MenuBar type = new MenuBar(); String typeString = ""; String styleString = ""; TextField delay = new TextField(); {//from w w w .ja v a 2 s .c o m setSpacing(true); setMargin(true); title.setInputPrompt("Title for the notification"); title.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { if (title.getValue() == null || title.getValue().length() == 0) { notification.setCaption(null); } else { notification.setCaption(title.getValue()); } } }); title.setValue("Notification Title"); title.setWidth("100%"); addComponent(title); description.setInputPrompt("Description for the notification"); description.addStyleName("small"); description.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { if (description.getValue() == null || description.getValue().length() == 0) { notification.setDescription(null); } else { notification.setDescription(description.getValue()); } } }); description.setValue( "A more informative message about what has happened. Nihil hic munitissimus habendi senatus locus, nihil horum? Inmensae subtilitatis, obscuris et malesuada fames. Hi omnes lingua, institutis, legibus inter se differunt."); description.setWidth("100%"); addComponent(description); Command typeCommand = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { if (selectedItem.getText().equals("Humanized")) { typeString = ""; notification.setStyleName(styleString.trim()); } else { typeString = selectedItem.getText().toLowerCase(); notification.setStyleName((typeString + " " + styleString.trim()).trim()); } for (MenuItem item : type.getItems()) { item.setChecked(false); } selectedItem.setChecked(true); } }; type.setCaption("Type"); MenuItem humanized = type.addItem("Humanized", typeCommand); humanized.setCheckable(true); humanized.setChecked(true); type.addItem("Tray", typeCommand).setCheckable(true); type.addItem("Warning", typeCommand).setCheckable(true); type.addItem("Error", typeCommand).setCheckable(true); type.addItem("System", typeCommand).setCheckable(true); addComponent(type); type.addStyleName("small"); Command styleCommand = new Command() { @Override public void menuSelected(final MenuItem selectedItem) { styleString = ""; for (MenuItem item : style.getItems()) { if (item.isChecked()) { styleString += " " + item.getText().toLowerCase(); } } if (styleString.trim().length() > 0) { notification.setStyleName((typeString + " " + styleString.trim()).trim()); } else if (typeString.length() > 0) { notification.setStyleName(typeString.trim()); } else { notification.setStyleName(null); } } }; style.setCaption("Additional style"); style.addItem("Dark", styleCommand).setCheckable(true); style.addItem("Success", styleCommand).setCheckable(true); style.addItem("Failure", styleCommand).setCheckable(true); style.addItem("Bar", styleCommand).setCheckable(true); style.addItem("Small", styleCommand).setCheckable(true); style.addItem("Closable", styleCommand).setCheckable(true); addComponent(style); style.addStyleName("small"); CssLayout group = new CssLayout(); group.setCaption("Fade delay"); group.addStyleName("v-component-group"); addComponent(group); delay.setInputPrompt("Infinite"); delay.addStyleName("align-right"); delay.addStyleName("small"); delay.setWidth("7em"); delay.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { try { notification.setDelayMsec(Integer.parseInt(delay.getValue())); } catch (Exception e) { notification.setDelayMsec(-1); delay.setValue(""); } } }); delay.setValue("1000"); group.addComponent(delay); Button clear = new Button(null, new ClickListener() { @Override public void buttonClick(final ClickEvent event) { delay.setValue(""); } }); clear.setIcon(FontAwesome.TIMES_CIRCLE); clear.addStyleName("last"); clear.addStyleName("small"); clear.addStyleName("icon-only"); group.addComponent(clear); group.addComponent(new Label(" msec", ContentMode.HTML)); GridLayout grid = new GridLayout(3, 3); grid.setCaption("Show in position"); addComponent(grid); grid.setSpacing(true); Button pos = new Button("", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { notification.setPosition(Position.TOP_LEFT); notification.show(Page.getCurrent()); } }); pos.addStyleName("small"); grid.addComponent(pos); pos = new Button("", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { notification.setPosition(Position.TOP_CENTER); notification.show(Page.getCurrent()); } }); pos.addStyleName("small"); grid.addComponent(pos); pos = new Button("", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { notification.setPosition(Position.TOP_RIGHT); notification.show(Page.getCurrent()); } }); pos.addStyleName("small"); grid.addComponent(pos); pos = new Button("", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { notification.setPosition(Position.MIDDLE_LEFT); notification.show(Page.getCurrent()); } }); pos.addStyleName("small"); grid.addComponent(pos); pos = new Button("", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { notification.setPosition(Position.MIDDLE_CENTER); notification.show(Page.getCurrent()); } }); pos.addStyleName("small"); grid.addComponent(pos); pos = new Button("", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { notification.setPosition(Position.MIDDLE_RIGHT); notification.show(Page.getCurrent()); } }); pos.addStyleName("small"); grid.addComponent(pos); pos = new Button("", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { notification.setPosition(Position.BOTTOM_LEFT); notification.show(Page.getCurrent()); } }); pos.addStyleName("small"); grid.addComponent(pos); pos = new Button("", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { notification.setPosition(Position.BOTTOM_CENTER); notification.show(Page.getCurrent()); } }); pos.addStyleName("small"); grid.addComponent(pos); pos = new Button("", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { notification.setPosition(Position.BOTTOM_RIGHT); notification.show(Page.getCurrent()); } }); pos.addStyleName("small"); grid.addComponent(pos); } }; p.setContent(content); return p; }
From source file:com.cavisson.gui.dashboard.components.controls.Panels.java
License:Apache License
public Panels() { setMargin(true);/*from w w w. j a va 2 s .c o m*/ Label h1 = new Label("Panels & Layout panels"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); TestIcon testIcon = new TestIcon(60); Panel panel = new Panel("Normal"); panel.setIcon(testIcon.get()); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Sized"); panel.setIcon(testIcon.get()); panel.setWidth("10em"); panel.setHeight("250px"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Custom Caption"); panel.setIcon(testIcon.get()); panel.addStyleName("color1"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Custom Caption"); panel.setIcon(testIcon.get()); panel.addStyleName("color2"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Custom Caption"); panel.setIcon(testIcon.get()); panel.addStyleName("color3"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Borderless style"); panel.setIcon(testIcon.get()); panel.addStyleName("borderless"); panel.setContent(panelContent()); row.addComponent(panel); panel = new Panel("Borderless + scroll divider"); panel.setIcon(testIcon.get()); panel.addStyleName("borderless"); panel.addStyleName("scroll-divider"); panel.setContent(panelContentScroll()); panel.setHeight("17em"); row.addComponent(panel); panel = new Panel("Well style"); panel.setIcon(testIcon.get()); panel.addStyleName("well"); panel.setContent(panelContent()); row.addComponent(panel); CssLayout layout = new CssLayout(); layout.setIcon(testIcon.get()); layout.setCaption("Panel style layout"); layout.addStyleName("card"); layout.addComponent(panelContent()); row.addComponent(layout); layout = new CssLayout(); layout.addStyleName("card"); row.addComponent(layout); HorizontalLayout panelCaption = new HorizontalLayout(); panelCaption.addStyleName("v-panel-caption"); panelCaption.setWidth("100%"); // panelCaption.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Label label = new Label("Panel style layout"); panelCaption.addComponent(label); panelCaption.setExpandRatio(label, 1); Button action = new Button(); action.setIcon(FontAwesome.PENCIL); action.addStyleName("borderless-colored"); action.addStyleName("small"); action.addStyleName("icon-only"); panelCaption.addComponent(action); MenuBar dropdown = new MenuBar(); dropdown.addStyleName("borderless"); dropdown.addStyleName("small"); MenuItem addItem = dropdown.addItem("", FontAwesome.CHEVRON_DOWN, null); addItem.setStyleName("icon-only"); addItem.addItem("Settings", null); addItem.addItem("Preferences", null); addItem.addSeparator(); addItem.addItem("Sign Out", null); panelCaption.addComponent(dropdown); layout.addComponent(panelCaption); layout.addComponent(panelContent()); layout.setWidth("14em"); layout = new CssLayout(); layout.setIcon(testIcon.get()); layout.setCaption("Well style layout"); layout.addStyleName("well"); layout.addComponent(panelContent()); row.addComponent(layout); }
From source file:com.cavisson.gui.dashboard.components.controls.ValoThemeUI.java
License:Apache License
Component buildTestMenu() { final CssLayout menu = new CssLayout(); menu.addStyleName("large-icons"); final Label logo = new Label("Va"); logo.setSizeUndefined();/*from w ww. j av a2 s . c o m*/ logo.setPrimaryStyleName("valo-menu-logo"); menu.addComponent(logo); Button b = new Button("Reference <span class=\"valo-menu-badge\">3</span>"); b.setIcon(FontAwesome.TH_LIST); b.setPrimaryStyleName("valo-menu-item"); b.addStyleName("selected"); b.setHtmlContentAllowed(true); menu.addComponent(b); b = new Button("API"); b.setIcon(FontAwesome.BOOK); b.setPrimaryStyleName("valo-menu-item"); menu.addComponent(b); b = new Button("Examples <span class=\"valo-menu-badge\">12</span>"); b.setIcon(FontAwesome.TABLE); b.setPrimaryStyleName("valo-menu-item"); b.setHtmlContentAllowed(true); menu.addComponent(b); return menu; }
From source file:com.cavisson.gui.dashboard.components.controls.ValoThemeUI.java
License:Apache License
CssLayout buildMenu() { // Add items/*from w w w . j a v a 2 s . com*/ menuItems.put("common", "Common UI Elements"); menuItems.put("labels", "Labels"); menuItems.put("buttons-and-links", "Buttons & Links"); menuItems.put("textfields", "Text Fields"); menuItems.put("datefields", "Date Fields"); menuItems.put("comboboxes", "Combo Boxes"); menuItems.put("selects", "Selects"); menuItems.put("checkboxes", "Check Boxes & Option Groups"); menuItems.put("sliders", "Sliders & Progress Bars"); menuItems.put("colorpickers", "Color Pickers"); menuItems.put("menubars", "Menu Bars"); menuItems.put("trees", "Trees"); menuItems.put("tables", "Tables"); menuItems.put("dragging", "Drag and Drop"); menuItems.put("panels", "Panels"); menuItems.put("splitpanels", "Split Panels"); menuItems.put("tabs", "Tabs"); menuItems.put("accordions", "Accordions"); menuItems.put("popupviews", "Popup Views"); // menuItems.put("calendar", "Calendar"); menuItems.put("forms", "Forms"); final HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName("valo-menu-title"); menu.addComponent(top); menu.addComponent(createThemeSelect()); final Button showMenu = new Button("Menu", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (menu.getStyleName().contains("valo-menu-visible")) { menu.removeStyleName("valo-menu-visible"); } else { menu.addStyleName("valo-menu-visible"); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName("valo-menu-toggle"); showMenu.setIcon(FontAwesome.LIST); menu.addComponent(showMenu); final Label title = new Label("<h3>Vaadin <strong>Valo Theme</strong></h3>", ContentMode.HTML); title.setSizeUndefined(); top.addComponent(title); top.setExpandRatio(title, 1); final MenuBar settings = new MenuBar(); settings.addStyleName("user-menu"); final StringGenerator sg = new StringGenerator(); final MenuItem settingsItem = settings.addItem( sg.nextString(true) + " " + sg.nextString(true) + sg.nextString(false), new ThemeResource("../tests-valo/img/profile-pic-300px.jpg"), null); settingsItem.addItem("Edit Profile", null); settingsItem.addItem("Preferences", null); settingsItem.addSeparator(); settingsItem.addItem("Sign Out", null); menu.addComponent(settings); menuItemsLayout.setPrimaryStyleName("valo-menuitems"); menu.addComponent(menuItemsLayout); Label label = null; int count = -1; for (final Entry<String, String> item : menuItems.entrySet()) { if (item.getKey().equals("labels")) { label = new Label("Components", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); } if (item.getKey().equals("panels")) { label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>"); count = 0; label = new Label("Containers", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); } if (item.getKey().equals("forms")) { label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>"); count = 0; label = new Label("Other", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); } final Button b = new Button(item.getValue(), new ClickListener() { @Override public void buttonClick(final ClickEvent event) { navigator.navigateTo(item.getKey()); } }); if (count == 2) { b.setCaption(b.getCaption() + " <span class=\"valo-menu-badge\">123</span>"); } b.setHtmlContentAllowed(true); b.setPrimaryStyleName("valo-menu-item"); b.setIcon(testIcon.get()); menuItemsLayout.addComponent(b); count++; } label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>"); return menu; }
From source file:com.constellio.app.ui.pages.base.MainLayoutImpl.java
private ConstellioMenuButton buildButton(final NavigationItem item) { ComponentState state = presenter.getStateFor(item); Button button = new Button($("MainLayout." + item.getCode())); button.setVisible(state.isVisible()); button.setEnabled(state.isEnabled()); button.addStyleName(item.getCode()); if (item.getFontAwesome() != null) { button.setIcon(item.getFontAwesome()); }//from ww w . j av a2 s. c o m button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { item.activate(navigate()); } }); return new ConstellioMenuButton(item.getViewGroup(), button); }
From source file:com.esofthead.mycollab.common.ui.components.CommentRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout().withSpacing(true).withMargin(false) .withWidth("100%").withStyleName("message"); MVerticalLayout userBlock = new MVerticalLayout().withSpacing(true).withMargin(false).withWidth("80px"); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); ClickListener gotoUser = new ClickListener() { private static final long serialVersionUID = 1L; @Override/*w w w . j a va 2s .co m*/ public void buttonClick(ClickEvent event) { EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoRead(this, comment.getCreateduser())); } }; Button userAvatarBtn = UserAvatarControlFactory.createUserAvatarButtonLink(comment.getOwnerAvatarId(), comment.getOwnerFullName()); userAvatarBtn.addClickListener(gotoUser); userBlock.addComponent(userAvatarBtn); Button userName = new Button(comment.getOwnerFullName()); userName.setStyleName("user-name"); userName.addStyleName("link"); userName.addStyleName(UIConstants.WORD_WRAP); userName.addClickListener(gotoUser); userBlock.addComponent(userName); layout.addComponent(userBlock); CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(true, true, false, true)).withWidth("100%") .withStyleName("message-header"); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Label timePostLbl = new Label( AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), DateTimeUtils.getPrettyDateValue(comment.getCreatedtime(), AppContext.getUserLocale())), ContentMode.HTML); timePostLbl.setDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); messageHeader.addComponent(timePostLbl); messageHeader.setExpandRatio(timePostLbl, 1.0f); // Message delete button Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); if (hasDeletePermission(comment)) { msgDeleteBtn.setVisible(true); msgDeleteBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { CommentService commentService = ApplicationContextUtil .getSpringBean(CommentService.class); commentService.removeWithSession(comment.getId(), AppContext.getUsername(), AppContext.getAccountId()); CommentRowDisplayHandler.this.owner.removeRow(layout); } } }); } }); } else { msgDeleteBtn.setVisible(false); } rowLayout.addComponent(messageHeader); Label messageContent = new UrlDetectableLabel(comment.getComment()); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withMargin(true) .withWidth("100%").withStyleName("message-footer"); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.addComponent(attachmentDisplay); messageFooter.setComponentAlignment(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.addComponent(rowLayout); layout.setExpandRatio(rowLayout, 1.0f); return layout; }
From source file:com.esofthead.mycollab.mobile.module.crm.ui.RelatedReadItemField.java
License:Open Source License
@Override protected Component initContent() { try {//from w w w. j av a2s . c o m final String type = (String) PropertyUtils.getProperty(RelatedReadItemField.this.bean, "type"); if (type == null || type.equals("")) { return new Label(""); } final Integer typeid = (Integer) PropertyUtils.getProperty(bean, "typeid"); if (typeid == null) { return new Label(""); } Resource relatedLink = null; String relateItemName = null; if ("Account".equals(type)) { AccountService accountService = ApplicationContextUtil.getSpringBean(AccountService.class); final SimpleAccount account = accountService.findById(typeid, AppContext.getAccountId()); if (account != null) { relateItemName = account.getAccountname(); relatedLink = MyCollabResource.newResource("icons/16/crm/account.png"); } } else if ("Campaign".equals(type)) { CampaignService campaignService = ApplicationContextUtil.getSpringBean(CampaignService.class); final SimpleCampaign campaign = campaignService.findById(typeid, AppContext.getAccountId()); if (campaign != null) { relateItemName = campaign.getCampaignname(); relatedLink = MyCollabResource.newResource("icons/16/crm/campaign.png"); } } else if ("Contact".equals(type)) { ContactService contactService = ApplicationContextUtil.getSpringBean(ContactService.class); final SimpleContact contact = contactService.findById(typeid, AppContext.getAccountId()); if (contact != null) { relateItemName = contact.getContactName(); relatedLink = MyCollabResource.newResource("icons/16/crm/contact.png"); } } else if ("Lead".equals(type)) { LeadService leadService = ApplicationContextUtil.getSpringBean(LeadService.class); final SimpleLead lead = leadService.findById(typeid, AppContext.getAccountId()); if (lead != null) { relateItemName = lead.getLeadName(); relatedLink = MyCollabResource.newResource("icons/16/crm/lead.png"); } } else if ("Opportunity".equals(type)) { OpportunityService opportunityService = ApplicationContextUtil .getSpringBean(OpportunityService.class); final SimpleOpportunity opportunity = opportunityService.findById(typeid, AppContext.getAccountId()); if (opportunity != null) { relateItemName = opportunity.getOpportunityname(); relatedLink = MyCollabResource.newResource("icons/16/crm/opportunity.png"); } } else if ("Case".equals(type)) { CaseService caseService = ApplicationContextUtil.getSpringBean(CaseService.class); final SimpleCase cases = caseService.findById(typeid, AppContext.getAccountId()); if (cases != null) { relateItemName = cases.getSubject(); relatedLink = MyCollabResource.newResource("icons/16/crm/case.png"); } } Button related = new Button(relateItemName); if (relatedLink != null) related.setIcon(relatedLink); if (relatedLink != null) { return related; } else { return new Label(""); } } catch (Exception e) { return new Label(""); } }