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 // FIXME manage authentication if needed
29 // if (!CurrentUser.roles().contains(AuthConstants.ROLE_ADMIN))
32 // parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
34 parent
.setLayout(new GridLayout(2, true));
37 parent
.setLayout(new GridLayout(1, true));
40 initHighLevelSummary(parent
);
42 Group securityGroup
= createHighLevelGroup(parent
, "Security");
43 securityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
44 new SecurityDeploymentUi(securityGroup
, SWT
.NONE
);
46 Group dataGroup
= createHighLevelGroup(parent
, "Data");
47 dataGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
48 new DataDeploymentUi(dataGroup
, SWT
.NONE
);
50 Group logGroup
= createHighLevelGroup(parent
, "Notifications");
51 logGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
52 new LogDeploymentUi(logGroup
, SWT
.NONE
);
54 Group connectivityGroup
= createHighLevelGroup(parent
, "Connectivity");
55 new ConnectivityDeploymentUi(connectivityGroup
, SWT
.NONE
);
56 connectivityGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, true));
60 private void initHighLevelSummary(Composite parent
) {
61 Composite composite
= new Composite(parent
, SWT
.NONE
);
62 GridData gridData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
64 gridData
.horizontalSpan
= 3;
65 composite
.setLayoutData(gridData
);
66 composite
.setLayout(new FillLayout());
68 ServiceReference
<NodeState
> nodeStateRef
= bc
.getServiceReference(NodeState
.class);
69 if (nodeStateRef
== null)
70 throw new IllegalStateException("No CMS state available");
71 NodeState nodeState
= bc
.getService(nodeStateRef
);
72 ServiceReference
<NodeDeployment
> nodeDeploymentRef
= bc
.getServiceReference(NodeDeployment
.class);
73 Label label
= new Label(composite
, SWT
.WRAP
);
74 CmsUtils
.markup(label
);
75 if (nodeDeploymentRef
== null) {
76 label
.setText("Not yet deployed on <br>" + nodeState
.getHostname() + "</br>, please configure below.");
78 Object stateUuid
= nodeStateRef
.getProperty(NodeConstants
.CN
);
79 NodeDeployment nodeDeployment
= bc
.getService(nodeDeploymentRef
);
80 GregorianCalendar calendar
= new GregorianCalendar();
81 calendar
.setTimeInMillis(nodeDeployment
.getAvailableSince());
82 calendar
.setTimeZone(TimeZone
.getDefault());
83 label
.setText("[" + "<b>" + nodeState
.getHostname() + "</b>]# " + "Deployment state " + stateUuid
84 + ", available since <b>" + calendar
.getTime() + "</b>");
88 private static Group
createHighLevelGroup(Composite parent
, String text
) {
89 Group group
= new Group(parent
, SWT
.NONE
);
91 CmsUtils
.markup(group
);
95 private boolean isDesktop() {