1 package org
.argeo
.cms
.util
;
5 import javax
.jcr
.Repository
;
6 import javax
.jcr
.RepositoryException
;
8 import org
.argeo
.cms
.AbstractCmsEntryPoint
;
9 import org
.argeo
.cms
.CmsException
;
10 import org
.argeo
.cms
.CmsImageManager
;
11 import org
.argeo
.cms
.CmsStyles
;
12 import org
.argeo
.cms
.CmsUiProvider
;
13 import org
.argeo
.cms
.internal
.ImageManagerImpl
;
14 import org
.eclipse
.rap
.rwt
.RWT
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.layout
.FillLayout
;
17 import org
.eclipse
.swt
.layout
.GridData
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.swt
.widgets
.Control
;
21 /** Simple header/body ergonomics. */
22 public class SimpleErgonomics
extends AbstractCmsEntryPoint
{
23 private Composite headerArea
;
24 private Composite bodyArea
;
25 private final CmsUiProvider uiProvider
;
27 private CmsUiProvider header
;
28 private Integer headerHeight
= 40;
30 private CmsImageManager imageManager
= new ImageManagerImpl();
32 public SimpleErgonomics(Repository repository
, String workspace
,
33 String defaultPath
, CmsUiProvider uiProvider
,
34 Map
<String
, String
> factoryProperties
) {
35 super(repository
, workspace
, defaultPath
, factoryProperties
);
36 this.uiProvider
= uiProvider
;
40 protected void createUi(Composite parent
) {
41 parent
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
42 parent
.setLayout(CmsUtils
.noSpaceGridLayout());
44 headerArea
= new Composite(parent
, SWT
.NONE
);
45 headerArea
.setLayout(new FillLayout());
46 GridData headerData
= new GridData(SWT
.FILL
, SWT
.FILL
, false, false);
47 headerData
.heightHint
= headerHeight
;
48 headerArea
.setLayoutData(headerData
);
50 bodyArea
= new Composite(parent
, SWT
.NONE
);
51 bodyArea
.setData(RWT
.CUSTOM_VARIANT
, CmsStyles
.CMS_BODY
);
52 bodyArea
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
53 bodyArea
.setLayout(CmsUtils
.noSpaceGridLayout());
59 protected void refresh() {
64 protected void refreshHeader() {
65 if (headerArea
== null)
67 for (Control child
: headerArea
.getChildren())
70 header
.createUi(headerArea
, getNode());
71 } catch (RepositoryException e
) {
72 throw new CmsException("Cannot refresh header", e
);
74 headerArea
.layout(true, true);
77 protected void refreshBody() {
81 Throwable exception
= getException();
82 if (exception
!= null) {
83 SystemNotifications systemNotifications
= new SystemNotifications(
85 systemNotifications
.notifyException(exception
);
92 for (Control child
: bodyArea
.getChildren())
94 bodyArea
.setLayout(CmsUtils
.noSpaceGridLayout());
96 String state
= getState();
100 // throw new CmsException("State cannot be null");
101 uiProvider
.createUi(bodyArea
, getNode());
102 } catch (RepositoryException e
) {
103 throw new CmsException("Cannot refresh body", e
);
106 bodyArea
.layout(true, true);
110 public CmsImageManager
getImageManager() {
114 public void setHeader(CmsUiProvider header
) {
115 this.header
= header
;
118 public void setHeaderHeight(Integer headerHeight
) {
119 this.headerHeight
= headerHeight
;
122 public void setImageManager(CmsImageManager imageManager
) {
123 this.imageManager
= imageManager
;