40726cd0d83fb87b81e5cd53ff35369fcb0b01ae
[gpl/argeo-suite.git] / org.argeo.suite.workbench.rap / src / org / argeo / suite / workbench / parts / DefaultDashboardEditor.java
1 package org.argeo.suite.workbench.parts;
2
3 import javax.jcr.Node;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7 import org.argeo.connect.people.PeopleConstants;
8 import org.argeo.connect.people.PeopleTypes;
9 import org.argeo.connect.people.workbench.rap.PeopleRapUtils;
10 import org.argeo.connect.util.ConnectJcrUtils;
11 import org.argeo.eclipse.ui.EclipseUiUtils;
12 import org.argeo.suite.workbench.AsUiPlugin;
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.layout.GridData;
15 import org.eclipse.swt.layout.GridLayout;
16 import org.eclipse.swt.widgets.Composite;
17
18 /** Argeo Suite Default Dashboard */
19 public class DefaultDashboardEditor extends AbstractSuiteDashboard {
20         final static Log log = LogFactory.getLog(DefaultDashboardEditor.class);
21         public final static String ID = AsUiPlugin.PLUGIN_ID + ".defaultDashboardEditor";
22
23         // Default gadget dimensions
24         private int wh = 300;
25         private int hh = 350;
26
27         @Override
28         public void createPartControl(Composite parent) {
29                 super.createPartControl(parent);
30
31                 parent.setLayout(new GridLayout());
32                 // Main Layout
33                 Composite body = getFormToolkit().createComposite(parent);
34                 body.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
35
36                 GridLayout bodyLayout = new GridLayout(2, true);
37                 bodyLayout.horizontalSpacing = 20;
38                 bodyLayout.verticalSpacing = 20;
39                 body.setLayout(bodyLayout);
40
41                 // Project List
42                 Composite projectsGadget = createGadgetCmp(body, wh, hh);
43                 populateProjectsGadget(projectsGadget);
44
45                 // Contacts
46                 Composite contactGadget = createGadgetCmp(body, wh, hh);
47                 populateContactsGadget(contactGadget);
48
49         }
50
51         /** Links to the various projects */
52         private void populateProjectsGadget(Composite parent) {
53                 parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
54                 createGadgetTitleCmp(parent, "Projects");
55                 Composite bodyCmp = createGadgetBodyCmp(parent);
56
57                 // // TODO enhance this
58                 // NodeIterator nit = AoUtils.listNodesOfType(getSession(),
59                 // AoTypes.OFFICE_ACCOUNT,
60                 // getAoService().getBasePath(AoTypes.OFFICE_ACCOUNT));
61                 // while (nit.hasNext()) {
62                 // Node account = nit.nextNode();
63                 // PeopleRapUtils.createOpenEntityEditorLink(getAoWbService(), bodyCmp,
64                 // ConnectJcrUtils.get(account, Property.JCR_TITLE), account);
65                 // }
66                 //
67                 // PeopleWorkbenchService aoWbSrv = getAoWbService();
68                 // // Opens a lits of all projects
69                 //
70                 // PeopleRapUtils.createOpenSearchEditorLink(aoWbSrv, bodyCmp, "All
71                 // projects", TrackerTypes.TRACKER_PROJECT,
72                 // AoConstants.ACCOUNTS_BASE_PATH);
73         }
74
75         /** Links to the various contact search pages */
76         private void populateContactsGadget(Composite parent) {
77                 parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
78                 createGadgetTitleCmp(parent, "Contacts");
79                 Composite bodyCmp = createGadgetBodyCmp(parent);
80                 
81                 PeopleRapUtils.createOpenSearchEditorLink(getAppWorkbenchService(), bodyCmp, "Persons",
82                                 PeopleTypes.PEOPLE_PERSON, getPeopleService().getBasePath(PeopleTypes.PEOPLE_PERSON));
83
84                 PeopleRapUtils.createOpenSearchEditorLink(getAppWorkbenchService(), bodyCmp, "Organisations",
85                                 PeopleTypes.PEOPLE_ORG, getPeopleService().getBasePath(PeopleTypes.PEOPLE_ORG));
86
87                 Node tagParent = getPeopleService().getResourceService().getTagLikeResourceParent(getSession(),
88                                 PeopleTypes.PEOPLE_MAILING_LIST);
89                 PeopleRapUtils.createOpenSearchEditorLink(getAppWorkbenchService(), bodyCmp, "Mailing lists",
90                                 PeopleTypes.PEOPLE_MAILING_LIST, ConnectJcrUtils.getPath(tagParent));
91                 
92                 PeopleRapUtils.createOpenSearchEditorLink(getAppWorkbenchService(), bodyCmp, "Tasks",
93                                 PeopleTypes.PEOPLE_TASK, getPeopleService().getBasePath(null));
94                 
95                 tagParent = getPeopleService().getResourceService().getTagLikeResourceParent(getSession(),
96                                 PeopleConstants.RESOURCE_TAG);
97                 
98                 PeopleRapUtils.createOpenSearchEditorLink(getAppWorkbenchService(), bodyCmp, "Tags",
99                                 PeopleTypes.PEOPLE_TAG_INSTANCE, ConnectJcrUtils.getPath(tagParent));
100
101         }
102 }