View Javadoc
1   package org.argeo.people.web.pages;
2   
3   import javax.jcr.Node;
4   import javax.jcr.RepositoryException;
5   
6   import org.argeo.cms.ui.CmsUiProvider;
7   import org.argeo.connect.resources.ResourcesService;
8   import org.argeo.eclipse.ui.EclipseUiUtils;
9   import org.argeo.people.PeopleService;
10  import org.argeo.people.web.parts.ActivitiesPart;
11  import org.argeo.people.web.parts.ContactButtonsPart;
12  import org.argeo.people.web.parts.ContactsWithNotePart;
13  import org.argeo.people.web.parts.OrgHeaderPart;
14  import org.argeo.people.web.parts.SingleContactPart;
15  import org.eclipse.swt.SWT;
16  import org.eclipse.swt.layout.GridData;
17  import org.eclipse.swt.widgets.Composite;
18  import org.eclipse.swt.widgets.Control;
19  
20  /**
21   * Shows all information we have about a given organisation. Expects a context
22   * that has the people:org NodeType
23   */
24  public class OrgPage implements CmsUiProvider {
25  
26  	/* We can override defaults parts with dependency injection */
27  	private OrgHeaderPart orgHeaderPart;
28  	private ContactsWithNotePart contactsWithNotePart;
29  	private ActivitiesPart activitiesPart;
30  
31  	/** Inject various subparts */
32  	public OrgPage() {
33  	}
34  
35  	public OrgPage(ResourcesService resourcesService, PeopleService peopleService) {
36  		orgHeaderPart = new OrgHeaderPart(resourcesService, peopleService);
37  
38  		ContactButtonsPart cbp = new ContactButtonsPart();
39  		SingleContactPart scp = new SingleContactPart();
40  		scp.setResourcesService(resourcesService);
41  		scp.setContactButtonsPart(cbp);
42  		contactsWithNotePart = new ContactsWithNotePart(scp);
43  
44  		activitiesPart = new ActivitiesPart(peopleService);
45  	}
46  
47  	@Override
48  	public Control createUi(Composite parent, Node context) throws RepositoryException {
49  
50  		// TODO use a scrollable composite
51  		Composite body = new Composite(parent, SWT.NO_FOCUS);
52  		body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
53  		body.setLayout(EclipseUiUtils.noSpaceGridLayout());
54  
55  		// header
56  		Composite headerCmp = new Composite(body, SWT.NO_FOCUS);
57  		headerCmp.setLayoutData(EclipseUiUtils.fillWidth());
58  		orgHeaderPart.createUi(headerCmp, context);
59  
60  		// contacts
61  		Composite contactCmp = new Composite(body, SWT.NO_FOCUS);
62  		contactCmp.setLayoutData(EclipseUiUtils.fillWidth());
63  		contactsWithNotePart.createUi(contactCmp, context);
64  
65  		// activities
66  		Composite activitiesCmp = new Composite(body, SWT.NO_FOCUS);
67  		activitiesCmp.setLayoutData(EclipseUiUtils.fillWidth());
68  		activitiesPart.createUi(activitiesCmp, context);
69  
70  		parent.layout();
71  		return body;
72  	}
73  
74  	/* DEPENDENCY INJECTION */
75  	public void setOrgHeaderPart(OrgHeaderPart orgHeaderPart) {
76  		this.orgHeaderPart = orgHeaderPart;
77  	}
78  
79  	public void setContactsWithNotePart(ContactsWithNotePart contactsWithNotePart) {
80  		this.contactsWithNotePart = contactsWithNotePart;
81  	}
82  
83  	public void setActivitiesPart(ActivitiesPart activitiesPart) {
84  		this.activitiesPart = activitiesPart;
85  	}
86  }