1
2
3
4
5
6
7
8 package com.buckosoft.PicMan.web;
9
10 import java.util.Iterator;
11 import java.util.List;
12
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15
16 import com.buckosoft.PicMan.db.DatabaseFacade;
17 import com.buckosoft.PicMan.domain.Set;
18 import com.buckosoft.PicMan.domain.SetSize;
19
20
21
22
23
24 @Deprecated
25 public class SetSizeWebTable {
26 private static final boolean DEBUG = true;
27 protected final Log logger = LogFactory.getLog(getClass());
28
29 static private final String eol = "\r\n";
30
31 private DatabaseFacade dbf;
32
33 public void setDatabase(DatabaseFacade dbf) { this.dbf = dbf; }
34 public DatabaseFacade getDatabase() { return(dbf); }
35
36
37
38
39
40 @Deprecated
41 public String getSetSizeWebTable(List<SetSize> l, boolean showUsed) {
42 List<Integer> sizes = dbf.getSizes();
43 List<Set> sets = dbf.getSets();
44
45 StringBuilder sb = new StringBuilder();
46
47 sb.append("<input type=\"checkbox\" name=\"showUnused\" id=\"showUnused\" onclick=\"onClickShowUnused();\"");
48 if (showUsed)
49 sb.append(" checked=\"checked\"");
50 sb.append(" />Show Unused Sets" + eol);
51 sb.append("<table name=\"settable\" id=\"settable\" align=\"center\">" + eol);
52 for (int iSet=0; iSet<sets.size(); iSet++) {
53 Set set = (Set)sets.get(iSet);
54 sb.append("<tr name=\"x_");
55 sb.append(set.getName());
56 sb.append("\">" + eol);
57 for (int iSize=0; iSize<sizes.size(); iSize++) {
58 int size = ((Integer)sizes.get(iSize)).intValue();
59 String checkName = dbf.getUuid(set.getName(), size);
60 String checked = "";
61 if (isOnList(l, set.getName(), size))
62 checked = " CHECKED";
63 sb.append("<td>" + eol);
64 sb.append("<input type=\"checkbox\" id=\"x_");
65 sb.append(checkName);
66 sb.append("\" name=\"x_");
67 sb.append(checkName);
68 sb.append("\"" + checked + ">");
69 sb.append(checkName);
70 sb.append("</td>" + eol);
71 }
72 sb.append("</tr>" + eol);
73 }
74
75 sb.append("</table>" + eol);
76 return(sb.toString());
77 }
78
79 private boolean isOnList(List<SetSize> l, String setName, int size) {
80 if (DEBUG && false)
81 logger.info("isOnList: lsize=" + l.size() + " set=\"" + setName+ "\" size=" + size);
82 Iterator<SetSize> iter = l.iterator();
83 while (iter.hasNext()) {
84 SetSize ss = iter.next();
85 if (DEBUG && false)
86 logger.info("isOnList: compare to: " + ss.getSetName() + "_" + ss.getSize());
87 if (ss.getSetName().equals(setName) && ss.getSize() == size)
88 return(true);
89 }
90 return(false);
91 }
92 }