1 package org
.argeo
.cms
.swt
.app
;
3 import java
.util
.ArrayList
;
6 import javax
.xml
.namespace
.QName
;
8 import org
.argeo
.api
.acr
.Content
;
9 import org
.argeo
.cms
.swt
.CmsSwtUtils
;
10 import org
.argeo
.cms
.swt
.acr
.SwtContentHierarchicalPart
;
11 import org
.argeo
.cms
.swt
.widgets
.SwtTabularPart
;
12 import org
.argeo
.cms
.ux
.widgets
.Column
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.custom
.SashForm
;
15 import org
.eclipse
.swt
.layout
.GridLayout
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
18 public class AcrContentTreeView
extends Composite
{
19 private static final long serialVersionUID
= -3707881216246077323L;
21 private Content rootContent
;
23 private Content selected
;
25 public AcrContentTreeView(Composite parent
, int style
, Content content
) {
27 this.rootContent
= content
;
28 this.selected
= rootContent
;
29 setLayout(CmsSwtUtils
.noSpaceGridLayout());
31 SashForm split
= new SashForm(this, SWT
.HORIZONTAL
);
32 split
.setLayoutData(CmsSwtUtils
.fillAll());
34 SwtContentHierarchicalPart hPart
= new SwtContentHierarchicalPart(split
, getStyle());
35 Composite area
= new Composite(split
, SWT
.NONE
);
36 area
.setLayout(CmsSwtUtils
.noSpaceGridLayout(2));
37 split
.setWeights(new int[] { 30, 70 });
40 SwtTabularPart attributesPart
= new SwtTabularPart(area
, SWT
.NONE
) {
44 protected Object
getData(int row
) {
49 protected int getItemCount() {
50 data
= new ArrayList
<>(selected
.keySet());
54 attributesPart
.getArea().setLayoutData(CmsSwtUtils
.fillHeight());
56 attributesPart
.addColumn(new Column
<QName
>() {
59 public String
getText(QName model
) {
60 return model
.toString();
63 attributesPart
.addColumn(new Column
<QName
>() {
66 public String
getText(QName model
) {
67 return selected
.get(model
).toString();
71 public int getWidth() {
78 SwtTabularPart typesPart
= new SwtTabularPart(area
, SWT
.NONE
) {
82 protected Object
getData(int row
) {
87 protected int getItemCount() {
88 data
= new ArrayList
<>(selected
.getTypes());
92 typesPart
.addColumn(new Column
<QName
>() {
95 public String
getText(QName model
) {
96 return model
.toString();
99 typesPart
.getArea().setLayoutData(CmsSwtUtils
.fillHeight());
102 hPart
.setInput(rootContent
);
103 hPart
.onSelected((o
) -> {
104 Content c
= (Content
) o
;
106 attributesPart
.refresh();
110 attributesPart
.refresh();
114 // protected void refreshTable() {
115 // for (TableItem item : table.getItems()) {
118 // for (QName key : selected.keySet()) {
119 // TableItem item = new TableItem(table, 0);
120 // item.setText(0, key.toString());
121 // Object value = selected.get(key);
122 // item.setText(1, value.toString());
124 // table.getColumn(0).pack();
125 // table.getColumn(1).pack();
128 // public static void main(String[] args) {
130 // if (args.length > 0) {
131 // basePath = Paths.get(args[0]);
133 // basePath = Paths.get(System.getProperty("user.home"));
136 // final Display display = new Display();
137 // final Shell shell = new Shell(display);
138 // shell.setText(basePath.toString());
139 // shell.setLayout(new FillLayout());
141 // FsContentProvider contentSession = new FsContentProvider("/", basePath);
142 //// GcrContentTreeView treeView = new GcrContentTreeView(shell, 0, contentSession.get("/"));
144 // shell.setSize(shell.computeSize(800, 600));
146 // while (!shell.isDisposed()) {
147 // if (!display.readAndDispatch())
150 // display.dispose();