1 package org
.argeo
.cms
.swt
.app
;
3 import static org
.argeo
.api
.acr
.NamespaceUtils
.toPrefixedName
;
5 import java
.util
.ArrayList
;
8 import javax
.xml
.namespace
.QName
;
10 import org
.argeo
.api
.acr
.Content
;
11 import org
.argeo
.api
.acr
.NamespaceUtils
;
12 import org
.argeo
.cms
.swt
.CmsSwtUtils
;
13 import org
.argeo
.cms
.swt
.widgets
.SwtHierarchicalPart
;
14 import org
.argeo
.cms
.swt
.widgets
.SwtTabularPart
;
15 import org
.argeo
.cms
.ux
.acr
.ContentHierarchicalPart
;
16 import org
.argeo
.cms
.ux
.widgets
.Column
;
17 import org
.argeo
.cms
.ux
.widgets
.DefaultTabularPart
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.custom
.SashForm
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
22 public class AcrContentTreeView
extends Composite
{
23 private static final long serialVersionUID
= -3707881216246077323L;
25 private Content rootContent
;
27 // private Content selected;
29 public AcrContentTreeView(Composite parent
, int style
, Content content
) {
31 this.rootContent
= content
;
32 // this.selected = rootContent;
33 setLayout(CmsSwtUtils
.noSpaceGridLayout());
35 SashForm split
= new SashForm(this, SWT
.HORIZONTAL
);
36 split
.setLayoutData(CmsSwtUtils
.fillAll());
38 ContentHierarchicalPart contentPart
= new ContentHierarchicalPart();
39 contentPart
.setInput(rootContent
);
41 SwtHierarchicalPart
<Content
> hPart
= new SwtHierarchicalPart
<>(split
, getStyle(), contentPart
);
43 Composite area
= new Composite(split
, SWT
.BORDER
);
44 area
.setLayout(CmsSwtUtils
.noSpaceGridLayout(2));
45 split
.setWeights(new int[] { 30, 70 });
48 DefaultTabularPart
<Content
, QName
> attributesPart
= new DefaultTabularPart
<>() {
51 protected List
<QName
> asList(Content input
) {
52 return new ArrayList
<>(input
.keySet());
56 attributesPart
.addColumn(new Column
<QName
>() {
59 public String
getText(QName model
) {
60 return toPrefixedName(model
);
63 attributesPart
.addColumn(new Column
<QName
>() {
66 public String
getText(QName model
) {
67 return attributesPart
.getInput().get(model
).toString();
71 public int getWidth() {
76 // attributesPart.setInput(selected);
78 SwtTabularPart
<Content
, QName
> attributeTable
= new SwtTabularPart
<>(area
, style
, attributesPart
);
79 attributeTable
.setLayoutData(CmsSwtUtils
.fillAll());
82 DefaultTabularPart
<Content
, QName
> typesPart
= new DefaultTabularPart
<>() {
85 protected List
<QName
> asList(Content input
) {
86 return input
.getContentClasses();
89 typesPart
.addColumn(new Column
<QName
>() {
92 public String
getText(QName model
) {
93 return toPrefixedName(model
);
98 // typesPart.setInput(selected);
100 SwtTabularPart
<Content
, QName
> typesTable
= new SwtTabularPart
<>(area
, style
, typesPart
);
101 typesTable
.setLayoutData(CmsSwtUtils
.fillAll());
104 contentPart
.setInput(rootContent
);
105 contentPart
.onSelected((o
) -> {
106 Content c
= (Content
) o
;
108 attributesPart
.setInput(c
);
109 typesPart
.setInput(c
);
112 attributesPart
.refresh();
116 // protected void refreshTable() {
117 // for (TableItem item : table.getItems()) {
120 // for (QName key : selected.keySet()) {
121 // TableItem item = new TableItem(table, 0);
122 // item.setText(0, key.toString());
123 // Object value = selected.get(key);
124 // item.setText(1, value.toString());
126 // table.getColumn(0).pack();
127 // table.getColumn(1).pack();
130 // public static void main(String[] args) {
132 // if (args.length > 0) {
133 // basePath = Paths.get(args[0]);
135 // basePath = Paths.get(System.getProperty("user.home"));
138 // final Display display = new Display();
139 // final Shell shell = new Shell(display);
140 // shell.setText(basePath.toString());
141 // shell.setLayout(new FillLayout());
143 // FsContentProvider contentSession = new FsContentProvider("/", basePath);
144 //// GcrContentTreeView treeView = new GcrContentTreeView(shell, 0, contentSession.get("/"));
146 // shell.setSize(shell.computeSize(800, 600));
148 // while (!shell.isDisposed()) {
149 // if (!display.readAndDispatch())
152 // display.dispose();