1 package org
.argeo
.suite
.workbench
.parts
;
4 import javax
.jcr
.Repository
;
5 import javax
.jcr
.Session
;
7 import org
.argeo
.cms
.util
.CmsUtils
;
8 import org
.argeo
.connect
.SystemAppService
;
9 import org
.argeo
.connect
.resources
.ResourcesService
;
10 import org
.argeo
.connect
.ui
.AppWorkbenchService
;
11 import org
.argeo
.connect
.ui
.ConnectUiStyles
;
12 import org
.argeo
.connect
.ui
.SystemWorkbenchService
;
13 import org
.argeo
.connect
.util
.ConnectJcrUtils
;
14 import org
.argeo
.connect
.workbench
.util
.EntityEditorInput
;
15 import org
.argeo
.eclipse
.ui
.EclipseUiUtils
;
16 import org
.argeo
.jcr
.JcrUtils
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.events
.SelectionAdapter
;
20 import org
.eclipse
.swt
.events
.SelectionEvent
;
21 import org
.eclipse
.swt
.layout
.GridData
;
22 import org
.eclipse
.swt
.layout
.GridLayout
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.swt
.widgets
.Label
;
25 import org
.eclipse
.swt
.widgets
.Link
;
26 import org
.eclipse
.ui
.IEditorInput
;
27 import org
.eclipse
.ui
.IEditorSite
;
28 import org
.eclipse
.ui
.PartInitException
;
29 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
30 import org
.eclipse
.ui
.part
.EditorPart
;
32 /** Generic dashboard for Argeo Suite applications */
33 public abstract class AbstractSuiteDashboard
extends EditorPart
{
35 // DEPENDENCY INJECTION
36 private Repository repository
;
37 private ResourcesService resourcesService
;
38 private SystemAppService systemAppService
;
39 private SystemWorkbenchService systemWorkbenchService
;
41 private Session session
;
44 private FormToolkit toolkit
;
47 public void init(IEditorSite site
, IEditorInput input
) throws PartInitException
{
51 session
= ConnectJcrUtils
.login(repository
);
55 private void updateTooltip(IEditorInput input
) {
56 if (input
instanceof EntityEditorInput
) {
57 EntityEditorInput sei
= (EntityEditorInput
) input
;
58 sei
.setTooltipText("My Dashboard");
63 * Implementing classes must call super in order to create the correct form
67 public void createPartControl(Composite parent
) {
68 toolkit
= new FormToolkit(getSite().getShell().getDisplay());
72 protected Composite
createGadgetCmp(Composite parent
, int widthHint
, int heightHint
) {
73 Composite gadgetCmp
= toolkit
.createComposite(parent
, SWT
.BORDER
);
74 GridData gd
= new GridData(SWT
.CENTER
, SWT
.CENTER
, false, false);
75 gd
.widthHint
= widthHint
;
76 gd
.heightHint
= heightHint
;
77 gadgetCmp
.setLayoutData(gd
);
78 CmsUtils
.style(gadgetCmp
, ConnectUiStyles
.GADGET_BOX
);
82 protected Composite
createGadgetTitleCmp(Composite parent
, String title
) {
83 Composite titleCmp
= toolkit
.createComposite(parent
, SWT
.BACKGROUND
| SWT
.INHERIT_NONE
);
84 CmsUtils
.style(titleCmp
, ConnectUiStyles
.GADGET_HEADER
);
85 titleCmp
.setBackground(null);
86 GridData gd
= new GridData(SWT
.FILL
, SWT
.TOP
, true, false);
87 titleCmp
.setLayoutData(gd
);
88 titleCmp
.setLayout(new GridLayout());
90 Label titleLbl
= toolkit
.createLabel(titleCmp
, title
+ " ", SWT
.BOLD
);
91 CmsUtils
.style(titleLbl
, ConnectUiStyles
.GADGET_HEADER
);
92 titleLbl
.setBackground(null);
96 protected Composite
createGadgetBodyCmp(Composite parent
) {
97 Composite bodyCmp
= toolkit
.createComposite(parent
, SWT
.BACKGROUND
| SWT
.INHERIT_NONE
);
98 bodyCmp
.setLayoutData(EclipseUiUtils
.fillAll());
99 bodyCmp
.setLayout(new GridLayout());
103 protected Link
createOpenEntityEditorLink(final AppWorkbenchService peopleUiService
, Composite parent
,
104 final String label
, final Node entity
) {
105 Link link
= new Link(parent
, SWT
.NONE
);
106 link
.setText("<a>" + label
+ "</a>");
107 link
.setLayoutData(EclipseUiUtils
.fillWidth());
108 link
.addSelectionListener(new SelectionAdapter() {
109 private static final long serialVersionUID
= 1L;
112 public void widgetSelected(final SelectionEvent event
) {
113 // Map<String, String> params = new HashMap<String, String>();
114 // params.put(ConnectEditor.PARAM_JCR_ID,
115 // ConnectJcrUtils.getIdentifier(entity));
116 // CommandUtils.callCommand(peopleUiService.getOpenEntityEditorCmdId(), params);
117 peopleUiService
.openEntityEditor(entity
);
125 public void dispose() {
126 JcrUtils
.logoutQuietly(session
);
131 public void doSave(IProgressMonitor monitor
) {
135 public void doSaveAs() {
139 public boolean isDirty() {
144 public boolean isSaveAsAllowed() {
149 public void setFocus() {
153 // Expose to implementing classes
154 protected Session
getSession() {
158 public ResourcesService
getResourcesService() {
159 return resourcesService
;
162 protected SystemAppService
getSystemAppService() {
163 return systemAppService
;
166 protected SystemWorkbenchService
getSystemWorkbenchService() {
167 return systemWorkbenchService
;
170 protected FormToolkit
getFormToolkit() {
174 /* DEPENDENCY INJECTION */
175 public void setRepository(Repository repository
) {
176 this.repository
= repository
;
179 public void setResourcesService(ResourcesService resourcesService
) {
180 this.resourcesService
= resourcesService
;
183 public void setSystemAppService(SystemAppService systemAppService
) {
184 this.systemAppService
= systemAppService
;
187 public void setSystemWorkbenchService(SystemWorkbenchService systemWorkbenchService
) {
188 this.systemWorkbenchService
= systemWorkbenchService
;