1
2
3
4
5 package org.directdemocracyportal.democracy.web.views;
6
7 import java.util.Set;
8
9 import org.directdemocracyportal.democracy.model.application.Portal;
10 import org.directdemocracyportal.democracy.model.core.GroupAgent;
11 import org.directdemocracyportal.democracy.model.world.Person;
12 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder;
13 import org.directdemocracyportal.democracy.web.ImageConstants;
14 import org.directdemocracyportal.democracy.web.ApplicationMessageHolder.MessageConstans;
15
16 import thinwire.ui.Panel;
17 import thinwire.ui.Tree;
18 import thinwire.ui.layout.TableLayout;
19
20 /***
21 * The Class StartContentPanel.
22 */
23 public class StartContentPanel extends Panel
24 {
25
26 /***
27 * Instantiates a new start content panel.
28 *
29 * @param portal the portal
30 */
31 public StartContentPanel(Portal portal) {
32 setLayout(new TableLayout(new double[][] { { 0 },
33 { 0 } },
34 1,
35 5));
36
37 Tree globalPortalTree = createGlobalPortalTree(portal);
38 globalPortalTree.setLimit("0,0,1,1");
39 getChildren().add(globalPortalTree);
40 }
41
42 /***
43 * Creates the global portal tree.
44 *
45 * @param portal the portal
46 * @return the tree
47 */
48 private Tree createGlobalPortalTree(Portal portal) {
49 Tree tree = new Tree();
50 tree.setRootItemVisible(true);
51
52 Tree.Item root = tree.getRootItem();
53 root.setText(ApplicationMessageHolder.getMessage(MessageConstans.APPLICATION_NAME));
54 root.setExpanded(true);
55
56 Tree.Item orgTree = new Tree.Item(ApplicationMessageHolder.getMessage(MessageConstans.GROUPS), ImageConstants.GROUP_HOME_ICON);
57 root.getChildren().add(orgTree);
58
59 Set<GroupAgent> groups = portal.getChildren();
60
61 for(GroupAgent group : groups) {
62 Tree.Item orgItem = new Tree.Item(group.getName());
63 orgTree.getChildren().add(orgItem);
64 }
65
66 Tree.Item memberTree = new Tree.Item(ApplicationMessageHolder.getMessage(MessageConstans.MEMBERS), ImageConstants.AGENT_ICON);
67 root.getChildren().add(memberTree);
68
69 Set<Person> personsActive = portal.personsActive();
70
71 for(Person person : personsActive) {
72 Tree.Item memberItem = new Tree.Item(person.getName());
73 memberTree.getChildren().add(memberItem);
74 }
75
76 return tree;
77 }
78 }