1 package org
.argeo
.cms
.e4
.maintenance
;
3 import java
.util
.GregorianCalendar
;
4 import java
.util
.TimeZone
;
6 import org
.argeo
.api
.cms
.CmsConstants
;
7 import org
.argeo
.api
.cms
.CmsContext
;
8 import org
.argeo
.api
.cms
.CmsDeployment
;
9 import org
.argeo
.api
.cms
.CmsState
;
10 import org
.argeo
.cms
.swt
.CmsSwtUtils
;
11 import org
.eclipse
.swt
.SWT
;
12 import org
.eclipse
.swt
.layout
.FillLayout
;
13 import org
.eclipse
.swt
.layout
.GridData
;
14 import org
.eclipse
.swt
.layout
.GridLayout
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
16 import org
.eclipse
.swt
.widgets
.Group
;
17 import org
.eclipse
.swt
.widgets
.Label
;
18 import org
.osgi
.framework
.BundleContext
;
19 import org
.osgi
.framework
.FrameworkUtil
;
20 import org
.osgi
.framework
.ServiceReference
;
22 class DeploymentEntryPoint
{
23 private final BundleContext bc
= FrameworkUtil
.getBundle(getClass()).getBundleContext();
25 protected void createContents(Composite parent
) {
26 // FIXME manage authentication if needed
27 // if (!CurrentUser.roles().contains(AuthConstants.ROLE_ADMIN))
30 // parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
32 parent
.setLayout(new GridLayout(2, true));
35 parent
.setLayout(new GridLayout(1, true));
38 initHighLevelSummary(parent
);
40 Group securityGroup
= createHighLevelGroup(parent
, "Security");
41 securityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
42 new SecurityDeploymentUi(securityGroup
, SWT
.NONE
);
44 Group dataGroup
= createHighLevelGroup(parent
, "Data");
45 dataGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
46 new DataDeploymentUi(dataGroup
, SWT
.NONE
);
48 Group logGroup
= createHighLevelGroup(parent
, "Notifications");
49 logGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
50 new LogDeploymentUi(logGroup
, SWT
.NONE
);
52 Group connectivityGroup
= createHighLevelGroup(parent
, "Connectivity");
53 new ConnectivityDeploymentUi(connectivityGroup
, SWT
.NONE
);
54 connectivityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
58 private void initHighLevelSummary(Composite parent
) {
59 Composite composite
= new Composite(parent
, SWT
.NONE
);
60 GridData gridData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
62 gridData
.horizontalSpan
= 3;
63 composite
.setLayoutData(gridData
);
64 composite
.setLayout(new FillLayout());
66 ServiceReference
<CmsState
> nodeStateRef
= bc
.getServiceReference(CmsState
.class);
67 if (nodeStateRef
== null)
68 throw new IllegalStateException("No CMS state available");
69 CmsState nodeState
= bc
.getService(nodeStateRef
);
70 ServiceReference
<CmsContext
> nodeDeploymentRef
= bc
.getServiceReference(CmsContext
.class);
71 Label label
= new Label(composite
, SWT
.WRAP
);
72 CmsSwtUtils
.markup(label
);
73 if (nodeDeploymentRef
== null) {
74 label
.setText("Not yet deployed on, please configure below.");
76 Object stateUuid
= nodeStateRef
.getProperty(CmsConstants
.CN
);
77 CmsContext nodeDeployment
= bc
.getService(nodeDeploymentRef
);
78 GregorianCalendar calendar
= new GregorianCalendar();
79 calendar
.setTimeInMillis(nodeDeployment
.getAvailableSince());
80 calendar
.setTimeZone(TimeZone
.getDefault());
81 label
.setText("Deployment state " + stateUuid
+ ", available since <b>" + calendar
.getTime() + "</b>");
85 private static Group
createHighLevelGroup(Composite parent
, String text
) {
86 Group group
= new Group(parent
, SWT
.NONE
);
88 CmsSwtUtils
.markup(group
);
92 private boolean isDesktop() {