1 33 34 package com.icesoft.icefaces.samples.showcase.components.expandableTable; 35 36 import com.icesoft.icefaces.samples.showcase.util.StyleBean; 37 38 import javax.faces.application.Application; 39 import javax.faces.context.FacesContext; 40 import java.util.ArrayList ; 41 import java.util.GregorianCalendar ; 42 43 58 public class SalesRecordsManager { 59 60 private ArrayList inventoryGroupItemBeans; 61 62 private boolean isInit; 63 64 public static final String GROUP_INDENT_STYLE_CLASS = "groupRowIndentStyle"; 66 public static final String GROUP_ROW_STYLE_CLASS = "groupRowStyle"; 67 public static final String CHILD_INDENT_STYLE_CLASS = "childRowIndentStyle"; 68 public static final String CHILD_ROW_STYLE_CLASS = "childRowStyle"; 69 public static final String CONTRACT_IMAGE = "tree_nav_top_close_no_siblings.gif"; 71 public static final String EXPAND_IMAGE = "tree_nav_top_open_no_siblings.gif"; 72 73 public SalesRecordsManager() { 74 init(); 75 } 76 77 private void init() { 78 79 if (isInit) { 81 return; 82 } 83 isInit = true; 84 85 if (inventoryGroupItemBeans != null) { 87 inventoryGroupItemBeans.clear(); 88 } else { 89 inventoryGroupItemBeans = new ArrayList (10); 90 } 91 92 Application application = 93 FacesContext.getCurrentInstance().getApplication(); 94 StyleBean styleBean = 95 ((StyleBean) application.createValueBinding("#{styleBean}"). 96 getValue(FacesContext.getCurrentInstance())); 97 98 102 103 SalesGroupRecordBean salesRecordGroup = 105 new SalesGroupRecordBean(GROUP_INDENT_STYLE_CLASS, 106 GROUP_ROW_STYLE_CLASS, 107 styleBean, 108 EXPAND_IMAGE, CONTRACT_IMAGE, 109 inventoryGroupItemBeans, false); 110 salesRecordGroup.setDescription("Tuesday's Items"); 111 salesRecordGroup.setDate(new GregorianCalendar (2006, 5, 2)); 112 113 SalesGroupRecordBean childSalesGroup = 115 new SalesGroupRecordBean(CHILD_INDENT_STYLE_CLASS, 116 CHILD_ROW_STYLE_CLASS); 117 childSalesGroup.setDescription("2mm Torx screws"); 118 childSalesGroup.setDate(new GregorianCalendar (2006, 6, 3)); 119 childSalesGroup.setQuantity(6); 120 childSalesGroup.setPrice(0.25); 121 salesRecordGroup.addChildSalesGroupRecord(childSalesGroup); 122 childSalesGroup = 123 new SalesGroupRecordBean(CHILD_INDENT_STYLE_CLASS, 124 CHILD_ROW_STYLE_CLASS); 125 childSalesGroup.setDescription("5mm Torx screws"); 126 childSalesGroup.setDate(new GregorianCalendar (2006, 7, 2)); 127 childSalesGroup.setQuantity(6); 128 childSalesGroup.setPrice(0.25); 129 salesRecordGroup.addChildSalesGroupRecord(childSalesGroup); 130 131 salesRecordGroup = 133 new SalesGroupRecordBean(GROUP_INDENT_STYLE_CLASS, 134 GROUP_ROW_STYLE_CLASS, 135 styleBean, 136 EXPAND_IMAGE, CONTRACT_IMAGE, 137 inventoryGroupItemBeans, true); 138 salesRecordGroup.setDescription("Wednesday's Items"); 139 salesRecordGroup.setDate(new GregorianCalendar (2006, 6, 2)); 140 141 childSalesGroup = 143 new SalesGroupRecordBean(CHILD_INDENT_STYLE_CLASS, 144 CHILD_ROW_STYLE_CLASS); 145 childSalesGroup.setDescription("Steel Hammer"); 146 childSalesGroup.setDate(new GregorianCalendar (2006, 6, 6)); 147 childSalesGroup.setQuantity(1); 148 childSalesGroup.setPrice(35.0); 149 salesRecordGroup.addChildSalesGroupRecord(childSalesGroup); 150 childSalesGroup = 151 new SalesGroupRecordBean(CHILD_INDENT_STYLE_CLASS, 152 CHILD_ROW_STYLE_CLASS); 153 childSalesGroup.setDescription("Bag of 10# nails"); 154 childSalesGroup.setDate(new GregorianCalendar (2006, 6, 6)); 155 childSalesGroup.setQuantity(2); 156 childSalesGroup.setPrice(15.0); 157 salesRecordGroup.addChildSalesGroupRecord(childSalesGroup); 158 childSalesGroup = 159 new SalesGroupRecordBean(CHILD_INDENT_STYLE_CLASS, 160 CHILD_ROW_STYLE_CLASS); 161 childSalesGroup.setDescription("Bag of 15# nails"); 162 childSalesGroup.setDate(new GregorianCalendar (2006, 6, 6)); 163 childSalesGroup.setQuantity(5); 164 childSalesGroup.setPrice(15.0); 165 salesRecordGroup.addChildSalesGroupRecord(childSalesGroup); 166 167 salesRecordGroup = 169 new SalesGroupRecordBean(GROUP_INDENT_STYLE_CLASS, 170 GROUP_ROW_STYLE_CLASS, 171 styleBean, 172 EXPAND_IMAGE, CONTRACT_IMAGE, 173 inventoryGroupItemBeans, false); 174 salesRecordGroup.setDescription("Thursday's Items"); 175 salesRecordGroup.setDate(new GregorianCalendar (2006, 7, 2)); 176 177 childSalesGroup = 179 new SalesGroupRecordBean(CHILD_INDENT_STYLE_CLASS, 180 CHILD_ROW_STYLE_CLASS); 181 childSalesGroup.setDescription("B&D Table Saw"); 182 childSalesGroup.setDate(new GregorianCalendar (2006, 6, 15)); 183 childSalesGroup.setQuantity(1); 184 childSalesGroup.setPrice(310.0); 185 salesRecordGroup.addChildSalesGroupRecord(childSalesGroup); 186 187 } 188 189 193 public void dispose() { 194 isInit = false; 195 if (inventoryGroupItemBeans != null) { 197 SalesGroupRecordBean tmp; 198 ArrayList tmpList; 199 for (int i = 0; i < inventoryGroupItemBeans.size(); i++) { 200 tmp = (SalesGroupRecordBean) inventoryGroupItemBeans.get(i); 201 tmpList = tmp.getChildSalesRecords(); 202 if (tmpList != null) { 203 tmpList.clear(); 204 } 205 } 206 inventoryGroupItemBeans.clear(); 207 } 208 } 209 210 216 public ArrayList getSalesGroupRecordBeans() { 217 return inventoryGroupItemBeans; 218 } 219 } | Popular Tags |