47b8544eefabfc3ef948efb713c17fa865902751
[gpl/argeo-suite.git] / org.argeo.suite.web / src / org / argeo / suite / web / DynamicHeader.java
1 package org.argeo.suite.web;
2
3 import javax.jcr.Node;
4 import javax.jcr.RepositoryException;
5
6 import org.argeo.cms.auth.CurrentUser;
7 import org.argeo.cms.ui.CmsUiProvider;
8 import org.eclipse.swt.widgets.Composite;
9 import org.eclipse.swt.widgets.Control;
10
11 /**
12 * Choose between possible headers depending on the client logged-in status and
13 * display type.
14 */
15 public class DynamicHeader implements CmsUiProvider {
16
17 private CmsUiProvider publicHeaderProvider;
18 private CmsUiProvider privateHeaderProvider;
19
20 @Override
21 public Control createUi(Composite parent, Node context) throws RepositoryException {
22 if (CurrentUser.isRegistered())
23 return privateHeaderProvider.createUi(parent, context);
24 else
25 return publicHeaderProvider.createUi(parent, context);
26 }
27
28 public void setPrivateHeaderProvider(CmsUiProvider privateHeaderProvider) {
29 this.privateHeaderProvider = privateHeaderProvider;
30 }
31
32 public void setPublicHeaderProvider(CmsUiProvider publicHeaderProvider) {
33 this.publicHeaderProvider = publicHeaderProvider;
34 }
35 }