BrightSide Workbench Full Report + Source Code
SaleActionCreator.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2013 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.crm.zul.sale;
20 
21 import java.util.Date;
22 import org.turro.command.Command;
23 import org.turro.command.Context;
24 import org.turro.crm.entity.SaleProspect;
25 import org.turro.crm.zul.menu.CrmMenu;
26 import org.turro.elephant.util.Components;
27 import org.turro.i18n.I_;
28 import org.turro.zkoss.filter.GenericFilterListbox;
29 import org.zkoss.zk.ui.event.Event;
30 import org.zkoss.zk.ui.event.EventListener;
31 import org.zkoss.zk.ui.event.Events;
32 import org.zkoss.zk.ui.ext.AfterCompose;
33 import org.zkoss.zul.Button;
34 import org.zkoss.zul.Vlayout;
35 import org.zkoss.zul.Window;
36 
41 public class SaleActionCreator extends Vlayout implements AfterCompose {
42 
43  private Date from, to;
44 
45  public SaleActionCreator(Date from, Date to) {
46  this.from = from;
47  this.to = to;
48  setHflex("1");
49  }
50 
51  @Override
52  public void afterCompose() {
53  createComponents();
54  }
55 
56  public void proceed() {
57  // Close calendar process
58  Events.postEvent(new Event(Events.ON_CLOSE, Components.from(SaleActionCreator.this).parent(Window.class)));
61  splb.setMultiple(false);
62  splb.setCheckmark(false);
63  splb.setSelectFirst(true);
64  splb.show(I_.get("Select") +": " + I_.get("Sale prospect"), "800px", "600px", new Command() {
65  @Override
66  public Object execute(Context context) {
67  if(splb != null) {
68  SaleProspect sp = splb.getObjectValue();
69  if(sp != null) {
70  CrmMenu.showSaleActions(null, sp, from, to);
71  }
72  }
73  return null;
74  }
75  });
76  }
77 
78  private void createComponents() {
79  Button create = new Button();
80  create.setLabel(I_.get("Sale action"));
81  create.setHflex("1");
82  appendChild(create);
83  create.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
84  @Override
85  public void onEvent(Event event) throws Exception {
86  proceed();
87  }
88  });
89 
90  }
91 
92 }
static void showSaleActions(Vendor vendor, SaleProspect saleProspect)
Definition: CrmMenu.java:69
static Components from(Object component)
Definition: Components.java:46
static String get(String msg)
Definition: I_.java:41
void show(String title, String width, String height, Command command)