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