1 package org
.argeo
.cms
.maintenance
;
3 import java
.util
.GregorianCalendar
;
4 import java
.util
.TimeZone
;
6 import org
.argeo
.cms
.util
.CmsUtils
;
7 import org
.argeo
.node
.NodeConstants
;
8 import org
.argeo
.node
.NodeDeployment
;
9 import org
.argeo
.node
.NodeState
;
10 import org
.eclipse
.rap
.rwt
.application
.AbstractEntryPoint
;
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
extends AbstractEntryPoint
{
23 private static final long serialVersionUID
= -881152502968982437L;
24 private final BundleContext bc
= FrameworkUtil
.getBundle(getClass()).getBundleContext();
27 protected void createContents(Composite parent
) {
28 // parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
30 parent
.setLayout(new GridLayout(2, true));
33 parent
.setLayout(new GridLayout(1, true));
36 initHighLevelSummary(parent
);
38 Group securityGroup
= createHighLevelGroup(parent
, "Security");
39 securityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
40 new SecurityDeploymentUi(securityGroup
, SWT
.NONE
);
42 Group dataGroup
= createHighLevelGroup(parent
, "Data");
43 dataGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
44 new DataDeploymentUi(dataGroup
, SWT
.NONE
);
46 Group logGroup
= createHighLevelGroup(parent
, "Notifications");
47 logGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
48 new LogDeploymentUi(logGroup
, SWT
.NONE
);
50 Group connectivityGroup
= createHighLevelGroup(parent
, "Connectivity");
51 new ConnectivityDeploymentUi(connectivityGroup
, SWT
.NONE
);
52 connectivityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
56 private void initHighLevelSummary(Composite parent
) {
57 Composite composite
= new Composite(parent
, SWT
.NONE
);
58 GridData gridData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
60 gridData
.horizontalSpan
= 3;
61 composite
.setLayoutData(gridData
);
62 composite
.setLayout(new FillLayout());
64 ServiceReference
<NodeState
> nodeStateRef
= bc
.getServiceReference(NodeState
.class);
65 if (nodeStateRef
== null)
66 throw new IllegalStateException("No CMS state available");
67 NodeState nodeState
= bc
.getService(nodeStateRef
);
68 ServiceReference
<NodeDeployment
> nodeDeploymentRef
= bc
.getServiceReference(NodeDeployment
.class);
69 Label label
= new Label(composite
, SWT
.WRAP
);
70 CmsUtils
.markup(label
);
71 if (nodeDeploymentRef
== null) {
72 label
.setText("Not yet deployed on <br>" + nodeState
.getHostname() + "</br>, please configure below.");
74 Object stateUuid
= nodeStateRef
.getProperty(NodeConstants
.CN
);
75 NodeDeployment nodeDeployment
= bc
.getService(nodeDeploymentRef
);
76 GregorianCalendar calendar
= new GregorianCalendar();
77 calendar
.setTimeInMillis(nodeDeployment
.getAvailableSince());
78 calendar
.setTimeZone(TimeZone
.getDefault());
79 label
.setText("[" + "<b>" + nodeState
.getHostname() + "</b>]# " + "Deployment state " + stateUuid
80 + ", available since <b>" + calendar
.getTime() + "</b>");
84 private static Group
createHighLevelGroup(Composite parent
, String text
) {
85 Group group
= new Group(parent
, SWT
.NONE
);
87 CmsUtils
.markup(group
);
91 private boolean isDesktop() {