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
) {
61 return NamespaceUtils
.toPrefixedName(model
);
62 } catch (IllegalStateException e
) {
63 return model
.toString();
67 attributesPart
.addColumn(new Column
<QName
>() {
70 public String
getText(QName model
) {
71 return attributesPart
.getInput().get(model
).toString();
75 public int getWidth() {
80 // attributesPart.setInput(selected);
82 SwtTabularPart
<Content
, QName
> attributeTable
= new SwtTabularPart
<>(area
, style
, attributesPart
);
83 attributeTable
.setLayoutData(CmsSwtUtils
.fillAll());
86 DefaultTabularPart
<Content
, QName
> typesPart
= new DefaultTabularPart
<>() {
89 protected List
<QName
> asList(Content input
) {
90 return input
.getContentClasses();
93 typesPart
.addColumn(new Column
<QName
>() {
96 public String
getText(QName model
) {
97 return toPrefixedName(model
);
102 // typesPart.setInput(selected);
104 SwtTabularPart
<Content
, QName
> typesTable
= new SwtTabularPart
<>(area
, style
, typesPart
);
105 typesTable
.setLayoutData(CmsSwtUtils
.fillAll());
108 contentPart
.setInput(rootContent
);
109 contentPart
.onSelected((o
) -> {
110 Content c
= (Content
) o
;
112 attributesPart
.setInput(c
);
113 typesPart
.setInput(c
);
116 attributesPart
.refresh();
120 // protected void refreshTable() {
121 // for (TableItem item : table.getItems()) {
124 // for (QName key : selected.keySet()) {
125 // TableItem item = new TableItem(table, 0);
126 // item.setText(0, key.toString());
127 // Object value = selected.get(key);
128 // item.setText(1, value.toString());
130 // table.getColumn(0).pack();
131 // table.getColumn(1).pack();
134 // public static void main(String[] args) {
136 // if (args.length > 0) {
137 // basePath = Paths.get(args[0]);
139 // basePath = Paths.get(System.getProperty("user.home"));
142 // final Display display = new Display();
143 // final Shell shell = new Shell(display);
144 // shell.setText(basePath.toString());
145 // shell.setLayout(new FillLayout());
147 // FsContentProvider contentSession = new FsContentProvider("/", basePath);
148 //// GcrContentTreeView treeView = new GcrContentTreeView(shell, 0, contentSession.get("/"));
150 // shell.setSize(shell.computeSize(800, 600));
152 // while (!shell.isDisposed()) {
153 // if (!display.readAndDispatch())
156 // display.dispose();