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