]> git.argeo.org Git - gpl/argeo-suite.git/blob - src/org/argeo/suite/workbench/SuiteWorkbenchService.java
Prepare next development cycle
[gpl/argeo-suite.git] / src / org / argeo / suite / workbench / SuiteWorkbenchService.java
1 package org.argeo.suite.workbench;
2
3 import java.util.List;
4
5 import javax.jcr.Node;
6
7 import org.argeo.connect.workbench.AppWorkbenchService;
8 import org.argeo.eclipse.ui.EclipseUiUtils;
9 import org.argeo.suite.workbench.parts.DefaultDashboardEditor;
10 import org.eclipse.jface.wizard.Wizard;
11 import org.eclipse.swt.graphics.Image;
12
13 /** Centralize workbench services from the various base apps */
14 public class SuiteWorkbenchService implements AppWorkbenchService {
15
16 // Injected known AppWorkbenchServices: order is important, first found
17 // result will be returned by the various methods.
18 private List<AppWorkbenchService> knownAppWbServices;
19 private String defaultEditorId = DefaultDashboardEditor.ID;
20
21 @Override
22 public String getDefaultEditorId() {
23 return defaultEditorId;
24 }
25
26 @Override
27 public String getEntityEditorId(Node entity) {
28 String result = null;
29 for (AppWorkbenchService appWbService : knownAppWbServices) {
30 result = appWbService.getEntityEditorId(entity);
31 if (EclipseUiUtils.notEmpty(result))
32 return result;
33 }
34 return null;
35 }
36
37 @Override
38 public String getSearchEntityEditorId(String nodeType) {
39 String result = null;
40 for (AppWorkbenchService appWbService : knownAppWbServices) {
41 result = appWbService.getSearchEntityEditorId(nodeType);
42 if (EclipseUiUtils.notEmpty(result))
43 return result;
44 }
45 return null;
46 }
47
48 @Override
49 public Image getIconForType(Node entity) {
50 Image result = null;
51 for (AppWorkbenchService appWbService : knownAppWbServices) {
52 result = appWbService.getIconForType(entity);
53 if (result != null)
54 return result;
55 }
56 return null;
57 }
58
59 @Override
60 public Wizard getCreationWizard(Node node) {
61 Wizard result = null;
62 for (AppWorkbenchService appWbService : knownAppWbServices) {
63 result = appWbService.getCreationWizard(node);
64 if (result != null)
65 return result;
66 }
67 return null;
68 }
69
70 /* DEPENDENCY INJECTION */
71 public void setKnownAppWbServices(List<AppWorkbenchService> knownAppWbServices) {
72 this.knownAppWbServices = knownAppWbServices;
73 }
74
75 public void setDefaultEditorId(String defaultEditorId) {
76 this.defaultEditorId = defaultEditorId;
77 }
78 }