1 package org
.argeo
.cms
.util
;
5 import javax
.jcr
.Repository
;
6 import javax
.jcr
.RepositoryException
;
8 import org
.apache
.commons
.logging
.Log
;
9 import org
.apache
.commons
.logging
.LogFactory
;
10 import org
.argeo
.cms
.CmsException
;
11 import org
.argeo
.cms
.ui
.AbstractCmsEntryPoint
;
12 import org
.argeo
.cms
.ui
.CmsImageManager
;
13 import org
.argeo
.cms
.ui
.CmsStyles
;
14 import org
.argeo
.cms
.ui
.CmsUiProvider
;
15 import org
.argeo
.cms
.ui
.UxContext
;
16 import org
.argeo
.cms
.ui
.internal
.ImageManagerImpl
;
17 import org
.eclipse
.rap
.rwt
.RWT
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.layout
.FillLayout
;
20 import org
.eclipse
.swt
.layout
.GridData
;
21 import org
.eclipse
.swt
.widgets
.Composite
;
22 import org
.eclipse
.swt
.widgets
.Control
;
24 /** Simple header/body ergonomics. */
25 public class SimpleErgonomics
extends AbstractCmsEntryPoint
{
26 private final static Log log
= LogFactory
.getLog(SimpleErgonomics
.class);
28 private boolean uiInitialized
= false;
29 private Composite headerArea
;
30 private Composite bodyArea
;
31 private final CmsUiProvider uiProvider
;
33 private CmsUiProvider header
;
34 private Integer headerHeight
= 40;
36 private CmsImageManager imageManager
= new ImageManagerImpl();
37 private UxContext uxContext
= null;
39 public SimpleErgonomics(Repository repository
, String workspace
,
40 String defaultPath
, CmsUiProvider uiProvider
,
41 Map
<String
, String
> factoryProperties
) {
42 super(repository
, workspace
, defaultPath
, factoryProperties
);
43 this.uiProvider
= uiProvider
;
47 protected void initUi(Composite parent
) {
48 parent
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
49 parent
.setLayout(CmsUtils
.noSpaceGridLayout());
51 // createAdminArea(parent);
52 headerArea
= new Composite(parent
, SWT
.NONE
);
53 headerArea
.setLayout(new FillLayout());
54 GridData headerData
= new GridData(SWT
.FILL
, SWT
.FILL
, false, false);
55 headerData
.heightHint
= headerHeight
;
56 headerArea
.setLayoutData(headerData
);
58 bodyArea
= new Composite(parent
, SWT
.NONE
);
59 bodyArea
.setData(RWT
.CUSTOM_VARIANT
, CmsStyles
.CMS_BODY
);
60 bodyArea
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
61 bodyArea
.setLayout(CmsUtils
.noSpaceGridLayout());
62 uxContext
= new SimpleUxContext();
68 protected void refresh() {
71 if (getState() == null)
75 if (log
.isTraceEnabled())
76 log
.trace("UI refreshed " + getNode());
79 protected void createAdminArea(Composite parent
) {
82 protected void refreshHeader() {
83 for (Control child
: headerArea
.getChildren())
86 header
.createUi(headerArea
, getNode());
87 } catch (RepositoryException e
) {
88 throw new CmsException("Cannot refresh header", e
);
90 headerArea
.layout(true, true);
93 protected void refreshBody() {
95 Throwable exception
= getException();
96 if (exception
!= null) {
97 SystemNotifications systemNotifications
= new SystemNotifications(
99 systemNotifications
.notifyException(exception
);
106 for (Control child
: bodyArea
.getChildren())
108 bodyArea
.setLayout(CmsUtils
.noSpaceGridLayout());
111 uiProvider
.createUi(bodyArea
, getNode());
112 } catch (RepositoryException e
) {
113 throw new CmsException("Cannot refresh body", e
);
116 bodyArea
.layout(true, true);
120 public UxContext
getUxContext() {
125 public CmsImageManager
getImageManager() {
129 public void setHeader(CmsUiProvider header
) {
130 this.header
= header
;
133 public void setHeaderHeight(Integer headerHeight
) {
134 this.headerHeight
= headerHeight
;
137 public void setImageManager(CmsImageManager imageManager
) {
138 this.imageManager
= imageManager
;