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
.util
.EntityEditorInput
;
18 import org
.argeo
.documents
.DocumentsService
;
19 import org
.argeo
.eclipse
.ui
.EclipseUiUtils
;
20 import org
.argeo
.jcr
.JcrUtils
;
21 import org
.argeo
.people
.PeopleService
;
22 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
23 import org
.eclipse
.swt
.SWT
;
24 import org
.eclipse
.swt
.events
.SelectionAdapter
;
25 import org
.eclipse
.swt
.events
.SelectionEvent
;
26 import org
.eclipse
.swt
.graphics
.Image
;
27 import org
.eclipse
.swt
.layout
.GridData
;
28 import org
.eclipse
.swt
.layout
.GridLayout
;
29 import org
.eclipse
.swt
.widgets
.Composite
;
30 import org
.eclipse
.swt
.widgets
.Label
;
31 import org
.eclipse
.swt
.widgets
.Link
;
32 import org
.eclipse
.ui
.IEditorInput
;
33 import org
.eclipse
.ui
.IEditorSite
;
34 import org
.eclipse
.ui
.PartInitException
;
35 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
36 import org
.eclipse
.ui
.part
.EditorPart
;
38 /** Generic dashboard for Argeo Suite applications */
39 public abstract class AbstractSuiteDashboard
extends EditorPart
{
41 // DEPENDENCY INJECTION
42 private Repository repository
;
43 private ResourcesService resourcesService
;
44 private ActivitiesService activitiesService
;
45 private PeopleService peopleService
;
46 private DocumentsService documentsService
;
47 private AppWorkbenchService appWorkbenchService
;
49 private Session session
;
52 private Image logoImg
;
53 private FormToolkit toolkit
;
56 public void init(IEditorSite site
, IEditorInput input
) throws PartInitException
{
60 session
= ConnectJcrUtils
.login(repository
);
65 private void updateTooltip(IEditorInput input
) {
66 if (input
instanceof EntityEditorInput
) {
67 EntityEditorInput sei
= (EntityEditorInput
) input
;
68 sei
.setTooltipText("My Dashboard");
72 // private void initialiseImg() {
73 // InputStream is = null;
75 // String imgPath = peopleService.getInstanceConfPath() + "/"
76 // + AoNames.AO_DEFAULT_LOGO;
77 // if (session.nodeExists(imgPath)) {
78 // Node imageNode = session.getNode(imgPath).getNode(
80 // is = imageNode.getProperty(Property.JCR_DATA).getBinary()
82 // logoImg = new Image(this.getSite().getShell().getDisplay(), is);
84 // } catch (RepositoryException re) {
85 // throw new AoException(
86 // "Unable to initialise specific logo for demo app", re);
88 // IOUtils.closeQuietly(is);
93 * Implementing classes must call super in order to create the correct form
97 public void createPartControl(Composite parent
) {
98 toolkit
= new FormToolkit(getSite().getShell().getDisplay());
102 protected Composite
createGadgetCmp(Composite parent
, int widthHint
, int heightHint
) {
103 Composite gadgetCmp
= toolkit
.createComposite(parent
, SWT
.BORDER
);
104 GridData gd
= new GridData(SWT
.CENTER
, SWT
.CENTER
, false, false);
105 gd
.widthHint
= widthHint
;
106 gd
.heightHint
= heightHint
;
107 gadgetCmp
.setLayoutData(gd
);
108 CmsUtils
.style(gadgetCmp
, ConnectUiStyles
.GADGET_BOX
);
112 protected Composite
createGadgetTitleCmp(Composite parent
, String title
) {
113 Composite titleCmp
= toolkit
.createComposite(parent
, SWT
.BACKGROUND
| SWT
.INHERIT_NONE
);
114 CmsUtils
.style(titleCmp
, ConnectUiStyles
.GADGET_HEADER
);
115 titleCmp
.setBackground(null);
116 GridData gd
= new GridData(SWT
.FILL
, SWT
.TOP
, true, false);
117 titleCmp
.setLayoutData(gd
);
118 titleCmp
.setLayout(new GridLayout());
120 Label titleLbl
= toolkit
.createLabel(titleCmp
, title
+ " ", SWT
.BOLD
);
121 CmsUtils
.style(titleLbl
, ConnectUiStyles
.GADGET_HEADER
);
122 titleLbl
.setBackground(null);
126 protected Composite
createGadgetBodyCmp(Composite parent
) {
127 Composite bodyCmp
= toolkit
.createComposite(parent
, SWT
.BACKGROUND
| SWT
.INHERIT_NONE
);
128 bodyCmp
.setLayoutData(EclipseUiUtils
.fillAll());
129 bodyCmp
.setLayout(new GridLayout());
133 protected Link
createOpenEntityEditorLink(final AppWorkbenchService peopleUiService
, Composite parent
,
134 final String label
, final Node entity
) {
135 Link link
= new Link(parent
, SWT
.NONE
);
136 link
.setText("<a>" + label
+ "</a>");
137 link
.setLayoutData(EclipseUiUtils
.fillWidth());
138 link
.addSelectionListener(new SelectionAdapter() {
139 private static final long serialVersionUID
= 1L;
142 public void widgetSelected(final SelectionEvent event
) {
143 Map
<String
, String
> params
= new HashMap
<String
, String
>();
145 params
.put("param.jcrId", ConnectJcrUtils
.getIdentifier(entity
));
146 CommandUtils
.callCommand(peopleUiService
.getOpenEntityEditorCmdId(), params
);
154 public void dispose() {
155 JcrUtils
.logoutQuietly(session
);
162 public void doSave(IProgressMonitor monitor
) {
166 public void doSaveAs() {
170 public boolean isDirty() {
175 public boolean isSaveAsAllowed() {
180 public void setFocus() {
184 // Expose to implementing classes
185 protected Session
getSession() {
189 public ResourcesService
getResourceService() {
190 return resourcesService
;
193 protected ActivitiesService
getActivityService() {
194 return activitiesService
;
197 protected PeopleService
getPeopleService() {
198 return peopleService
;
201 protected DocumentsService
getDocumentsService() {
202 return documentsService
;
205 protected AppWorkbenchService
getAppWorkbenchService() {
206 return appWorkbenchService
;
209 protected Image
getLogoImg() {
213 protected FormToolkit
getFormToolkit() {
217 /* DEPENDENCY INJECTION */
218 public void setRepository(Repository repository
) {
219 this.repository
= repository
;
222 public void setResourcesService(ResourcesService resourcesService
) {
223 this.resourcesService
= resourcesService
;
226 public void setActivitiesService(ActivitiesService activitiesService
) {
227 this.activitiesService
= activitiesService
;
230 public void setDocumentsService(DocumentsService documentsService
) {
231 this.documentsService
= documentsService
;
234 public void setPeopleService(PeopleService peopleService
) {
235 this.peopleService
= peopleService
;
238 public void setAppWorkbenchService(AppWorkbenchService appWorkbenchService
) {
239 this.appWorkbenchService
= appWorkbenchService
;