1 package org.argeo.people.web.parts;
2
3 import javax.jcr.Node;
4 import javax.jcr.NodeIterator;
5 import javax.jcr.RepositoryException;
6
7 import org.argeo.cms.ui.CmsUiProvider;
8 import org.argeo.eclipse.ui.EclipseUiUtils;
9 import org.argeo.people.PeopleNames;
10 import org.eclipse.swt.SWT;
11 import org.eclipse.swt.widgets.Composite;
12 import org.eclipse.swt.widgets.Control;
13
14
15 public class ContactsPart implements CmsUiProvider {
16
17
18 private SingleContactPart singleContactPart;
19
20 public ContactsPart() {
21 }
22
23 public ContactsPart(SingleContactPart singleContactPart) {
24 this.singleContactPart= singleContactPart;
25 }
26
27 @Override
28 public Control createUi(Composite parent, Node context) throws RepositoryException {
29 createContactPanel(parent, context);
30 return parent;
31 }
32
33 protected void createContactPanel(Composite parent, Node context) throws RepositoryException {
34 parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
35
36 if (context.hasNode(PeopleNames.PEOPLE_CONTACTS)) {
37 NodeIterator nit = context.getNode(PeopleNames.PEOPLE_CONTACTS).getNodes();
38 while (nit.hasNext()) {
39 Composite contactCmp = new Composite(parent, SWT.NO_FOCUS);
40 contactCmp.setLayoutData(EclipseUiUtils.fillWidth());
41 singleContactPart.createUi(contactCmp, nit.nextNode());
42 }
43 }
44
45 }
46
47
48 public void setSingleContactPart(SingleContactPart singleButtonPart) {
49 this.singleContactPart = singleButtonPart;
50 }
51 }