Java tutorial
/** * This file is part of mycollab-web. * * mycollab-web is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * mycollab-web is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with mycollab-web. If not, see <http://www.gnu.org/licenses/>. */ package com.esofthead.mycollab.module.crm.view.account; import java.util.Arrays; import com.esofthead.mycollab.core.arguments.NumberSearchField; import com.esofthead.mycollab.core.arguments.StringSearchField; import com.esofthead.mycollab.eventmanager.EventBusFactory; import com.esofthead.mycollab.module.crm.domain.SimpleAccount; import com.esofthead.mycollab.module.crm.domain.criteria.AccountSearchCriteria; import com.esofthead.mycollab.module.crm.events.AccountEvent; import com.esofthead.mycollab.vaadin.AppContext; import com.esofthead.mycollab.vaadin.ui.Depot; import com.esofthead.mycollab.vaadin.ui.MyCollabResource; import com.esofthead.mycollab.vaadin.ui.UIConstants; import com.esofthead.mycollab.vaadin.ui.WebResourceIds; import com.esofthead.mycollab.vaadin.ui.table.IPagedBeanTable.TableClickEvent; import com.esofthead.mycollab.vaadin.ui.table.IPagedBeanTable.TableClickListener; import com.vaadin.server.FontAwesome; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; /** * * @author MyCollab Ltd. * @since 1.0 */ public class AccountListDashlet extends Depot { private static final long serialVersionUID = 1L; private AccountTableDisplay tableItem; public static final String VIEW_DEF_ID = "crm-account-dashlet"; public AccountListDashlet() { super("My Accounts", new VerticalLayout()); tableItem = new AccountTableDisplay(Arrays.asList(AccountTableFieldDef.accountname, AccountTableFieldDef.phoneoffice, AccountTableFieldDef.email)); tableItem.addTableListener(new TableClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(final TableClickEvent event) { final SimpleAccount account = (SimpleAccount) event.getData(); if ("accountname".equals(event.getFieldName())) { EventBusFactory.getInstance() .post(new AccountEvent.GotoRead(AccountListDashlet.this, account.getId())); } } }); bodyContent.addComponent(tableItem); Button customizeViewBtn = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { UI.getCurrent() .addWindow(new AccountListCustomizeWindow(AccountListDashlet.VIEW_DEF_ID, tableItem)); } }); customizeViewBtn.setIcon(FontAwesome.ADJUST); customizeViewBtn.setDescription("Layout Options"); customizeViewBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); this.addHeaderElement(customizeViewBtn); } public void display() { final AccountSearchCriteria criteria = new AccountSearchCriteria(); criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId())); criteria.setAssignUser(new StringSearchField(AppContext.getUsername())); tableItem.setSearchCriteria(criteria); } }