1 package org
.argeo
.suite
.workbench
.parts
;
3 import java
.util
.HashMap
;
7 import javax
.jcr
.Repository
;
8 import javax
.jcr
.Session
;
10 import org
.argeo
.activities
.ActivitiesService
;
11 import org
.argeo
.cms
.ui
.workbench
.util
.CommandUtils
;
12 import org
.argeo
.cms
.util
.CmsUtils
;
13 import org
.argeo
.connect
.resources
.ResourcesService
;
14 import org
.argeo
.connect
.ui
.ConnectUiStyles
;
15 import org
.argeo
.connect
.util
.ConnectJcrUtils
;
16 import org
.argeo
.connect
.workbench
.AppWorkbenchService
;
17 import org
.argeo
.connect
.workbench
.SystemWorkbenchService
;
18 import org
.argeo
.connect
.workbench
.util
.EntityEditorInput
;
19 import org
.argeo
.documents
.DocumentsService
;
20 import org
.argeo
.eclipse
.ui
.EclipseUiUtils
;
21 import org
.argeo
.jcr
.JcrUtils
;
22 import org
.argeo
.people
.PeopleService
;
23 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
24 import org
.eclipse
.swt
.SWT
;
25 import org
.eclipse
.swt
.events
.SelectionAdapter
;
26 import org
.eclipse
.swt
.events
.SelectionEvent
;
27 import org
.eclipse
.swt
.graphics
.Image
;
28 import org
.eclipse
.swt
.layout
.GridData
;
29 import org
.eclipse
.swt
.layout
.GridLayout
;
30 import org
.eclipse
.swt
.widgets
.Composite
;
31 import org
.eclipse
.swt
.widgets
.Label
;
32 import org
.eclipse
.swt
.widgets
.Link
;
33 import org
.eclipse
.ui
.IEditorInput
;
34 import org
.eclipse
.ui
.IEditorSite
;
35 import org
.eclipse
.ui
.PartInitException
;
36 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
37 import org
.eclipse
.ui
.part
.EditorPart
;
39 /** Generic dashboard for Argeo Suite applications */
40 public abstract class AbstractSuiteDashboard
extends EditorPart
{
42 // DEPENDENCY INJECTION
43 private Repository repository
;
44 private ResourcesService resourcesService
;
45 private ActivitiesService activitiesService
;
46 private PeopleService peopleService
;
47 private DocumentsService documentsService
;
48 private SystemWorkbenchService systemWorkbenchService
;
50 private Session session
;
53 private Image logoImg
;
54 private FormToolkit toolkit
;
57 public void init(IEditorSite site
, IEditorInput input
) throws PartInitException
{
61 session
= ConnectJcrUtils
.login(repository
);
66 private void updateTooltip(IEditorInput input
) {
67 if (input
instanceof EntityEditorInput
) {
68 EntityEditorInput sei
= (EntityEditorInput
) input
;
69 sei
.setTooltipText("My Dashboard");
73 // private void initialiseImg() {
74 // InputStream is = null;
76 // String imgPath = peopleService.getInstanceConfPath() + "/"
77 // + AoNames.AO_DEFAULT_LOGO;
78 // if (session.nodeExists(imgPath)) {
79 // Node imageNode = session.getNode(imgPath).getNode(
81 // is = imageNode.getProperty(Property.JCR_DATA).getBinary()
83 // logoImg = new Image(this.getSite().getShell().getDisplay(), is);
85 // } catch (RepositoryException re) {
86 // throw new AoException(
87 // "Unable to initialise specific logo for demo app", re);
89 // IOUtils.closeQuietly(is);
94 * Implementing classes must call super in order to create the correct form
98 public void createPartControl(Composite parent
) {
99 toolkit
= new FormToolkit(getSite().getShell().getDisplay());
103 protected Composite
createGadgetCmp(Composite parent
, int widthHint
, int heightHint
) {
104 Composite gadgetCmp
= toolkit
.createComposite(parent
, SWT
.BORDER
);
105 GridData gd
= new GridData(SWT
.CENTER
, SWT
.CENTER
, false, false);
106 gd
.widthHint
= widthHint
;
107 gd
.heightHint
= heightHint
;
108 gadgetCmp
.setLayoutData(gd
);
109 CmsUtils
.style(gadgetCmp
, ConnectUiStyles
.GADGET_BOX
);
113 protected Composite
createGadgetTitleCmp(Composite parent
, String title
) {
114 Composite titleCmp
= toolkit
.createComposite(parent
, SWT
.BACKGROUND
| SWT
.INHERIT_NONE
);
115 CmsUtils
.style(titleCmp
, ConnectUiStyles
.GADGET_HEADER
);
116 titleCmp
.setBackground(null);
117 GridData gd
= new GridData(SWT
.FILL
, SWT
.TOP
, true, false);
118 titleCmp
.setLayoutData(gd
);
119 titleCmp
.setLayout(new GridLayout());
121 Label titleLbl
= toolkit
.createLabel(titleCmp
, title
+ " ", SWT
.BOLD
);
122 CmsUtils
.style(titleLbl
, ConnectUiStyles
.GADGET_HEADER
);
123 titleLbl
.setBackground(null);
127 protected Composite
createGadgetBodyCmp(Composite parent
) {
128 Composite bodyCmp
= toolkit
.createComposite(parent
, SWT
.BACKGROUND
| SWT
.INHERIT_NONE
);
129 bodyCmp
.setLayoutData(EclipseUiUtils
.fillAll());
130 bodyCmp
.setLayout(new GridLayout());
134 protected Link
createOpenEntityEditorLink(final AppWorkbenchService peopleUiService
, Composite parent
,
135 final String label
, final Node entity
) {
136 Link link
= new Link(parent
, SWT
.NONE
);
137 link
.setText("<a>" + label
+ "</a>");
138 link
.setLayoutData(EclipseUiUtils
.fillWidth());
139 link
.addSelectionListener(new SelectionAdapter() {
140 private static final long serialVersionUID
= 1L;
143 public void widgetSelected(final SelectionEvent event
) {
144 Map
<String
, String
> params
= new HashMap
<String
, String
>();
146 params
.put("param.jcrId", ConnectJcrUtils
.getIdentifier(entity
));
147 CommandUtils
.callCommand(peopleUiService
.getOpenEntityEditorCmdId(), params
);
155 public void dispose() {
156 JcrUtils
.logoutQuietly(session
);
163 public void doSave(IProgressMonitor monitor
) {
167 public void doSaveAs() {
171 public boolean isDirty() {
176 public boolean isSaveAsAllowed() {
181 public void setFocus() {
185 // Expose to implementing classes
186 protected Session
getSession() {
190 public ResourcesService
getResourceService() {
191 return resourcesService
;
194 protected ActivitiesService
getActivityService() {
195 return activitiesService
;
198 protected PeopleService
getPeopleService() {
199 return peopleService
;
202 protected DocumentsService
getDocumentsService() {
203 return documentsService
;
206 protected SystemWorkbenchService
getSystemWorkbenchService() {
207 return systemWorkbenchService
;
210 protected Image
getLogoImg() {
214 protected FormToolkit
getFormToolkit() {
218 /* DEPENDENCY INJECTION */
219 public void setRepository(Repository repository
) {
220 this.repository
= repository
;
223 public void setResourcesService(ResourcesService resourcesService
) {
224 this.resourcesService
= resourcesService
;
227 public void setActivitiesService(ActivitiesService activitiesService
) {
228 this.activitiesService
= activitiesService
;
231 public void setDocumentsService(DocumentsService documentsService
) {
232 this.documentsService
= documentsService
;
235 public void setPeopleService(PeopleService peopleService
) {
236 this.peopleService
= peopleService
;
239 public void setSystemWorkbenchService(SystemWorkbenchService systemWorkbenchService
) {
240 this.systemWorkbenchService
= systemWorkbenchService
;