]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/text/WikiPage.java
1 package org
.argeo
.cms
.text
;
4 import javax
.jcr
.NodeIterator
;
5 import javax
.jcr
.RepositoryException
;
6 import javax
.jcr
.nodetype
.NodeType
;
8 import org
.argeo
.cms
.CmsEditable
;
9 import org
.argeo
.cms
.CmsLink
;
10 import org
.argeo
.cms
.CmsNames
;
11 import org
.argeo
.cms
.CmsTypes
;
12 import org
.argeo
.cms
.CmsUiProvider
;
13 import org
.argeo
.cms
.CmsUtils
;
14 import org
.argeo
.cms
.viewers
.JcrVersionCmsEditable
;
15 import org
.argeo
.cms
.widgets
.ScrolledPage
;
16 import org
.argeo
.jcr
.JcrUtils
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.layout
.GridData
;
19 import org
.eclipse
.swt
.widgets
.Composite
;
20 import org
.eclipse
.swt
.widgets
.Control
;
22 /** Display the text of the context, and provide an editor if the user can edit. */
23 public class WikiPage
implements CmsUiProvider
, CmsNames
{
25 public Control
createUi(Composite parent
, Node context
)
26 throws RepositoryException
{
27 CmsEditable cmsEditable
= new JcrVersionCmsEditable(context
);
28 if (cmsEditable
.canEdit())
29 new TextEditorHeader(cmsEditable
, parent
, SWT
.NONE
)
30 .setLayoutData(CmsUtils
.fillWidth());
32 ScrolledPage page
= new ScrolledPage(parent
, SWT
.NONE
);
33 page
.setLayout(CmsUtils
.noSpaceGridLayout());
34 GridData textGd
= CmsUtils
.fillAll();
35 page
.setLayoutData(textGd
);
37 if (context
.isNodeType(CmsTypes
.CMS_TEXT
)) {
38 new StandardTextEditor(page
, SWT
.NONE
, context
, cmsEditable
);
39 } else if (context
.isNodeType(NodeType
.NT_FOLDER
)
40 || context
.getPath().equals("/")) {
41 parent
.setBackgroundMode(SWT
.INHERIT_NONE
);
42 Node indexNode
= JcrUtils
.getOrAdd(context
, CMS_INDEX
,
44 new StandardTextEditor(page
, SWT
.NONE
, indexNode
, cmsEditable
);
45 textGd
.heightHint
= 400;
47 for (NodeIterator ni
= context
.getNodes(); ni
.hasNext();) {
48 Node textNode
= ni
.nextNode();
49 if (textNode
.isNodeType(NodeType
.NT_FOLDER
))
50 new CmsLink(textNode
.getName() + "/", textNode
.getPath())
51 .createUi(parent
, textNode
);
53 for (NodeIterator ni
= context
.getNodes(); ni
.hasNext();) {
54 Node textNode
= ni
.nextNode();
55 if (textNode
.isNodeType(CmsTypes
.CMS_TEXT
)
56 && !textNode
.getName().equals(CMS_INDEX
))
57 new CmsLink(textNode
.getName(), textNode
.getPath())
58 .createUi(parent
, textNode
);