]> git.argeo.org Git - gpl/argeo-suite.git/blob - swt/terms/TermsEntryArea.java
Prepare next development cycle
[gpl/argeo-suite.git] / swt / terms / TermsEntryArea.java
1 package org.argeo.app.swt.terms;
2
3 import org.argeo.api.acr.Content;
4 import org.argeo.api.acr.NamespaceUtils;
5 import org.argeo.api.acr.spi.ProvidedContent;
6 import org.argeo.api.cms.ux.CmsView;
7 import org.argeo.app.api.EntityType;
8 import org.argeo.app.api.TermsManager;
9 import org.argeo.app.ux.SuiteUxEvent;
10 import org.argeo.cms.swt.CmsSwtUtils;
11 import org.argeo.cms.swt.acr.SwtUiProvider;
12 import org.argeo.cms.swt.widgets.SwtTreeView;
13 import org.argeo.cms.ux.acr.ContentHierarchicalPart;
14 import org.eclipse.swt.layout.GridLayout;
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Control;
17
18 /** Entry area for managing the typologies. */
19 public class TermsEntryArea implements SwtUiProvider {
20 private TermsManager termsManager;
21
22 @Override
23 public Control createUiPart(Composite parent, Content content) {
24 // parent.setLayout(new GridLayout());
25 // Label lbl = new Label(parent, SWT.NONE);
26 // lbl.setText("Typologies");
27 //
28 // Set<Typology> typologies = termsManager.getTypologies();
29 // for (Typology typology : typologies) {
30 // new Label(parent, 0).setText(typology.getId());
31 // }
32 //
33 //
34 // return lbl;
35 CmsView cmsView = CmsSwtUtils.getCmsView(parent);
36
37 parent.setLayout(new GridLayout());
38 Content rootContent = ((ProvidedContent) content).getSession().getRepository().get().get("/terms");
39
40 ContentHierarchicalPart contentPart = new ContentHierarchicalPart() {
41
42 @Override
43 protected boolean isLeaf(Content content) {
44 if (content.hasContentClass(EntityType.document.qName()))
45 return true;
46 return super.isLeaf(content);
47 }
48
49 };
50 contentPart.addColumn((c) -> NamespaceUtils.toPrefixedName(c.getName()));
51 // contentPart.setInput(rootContent);
52
53 SwtTreeView<Content> view = new SwtTreeView<>(parent, 0, contentPart);
54 view.setLayoutData(CmsSwtUtils.fillAll());
55
56 contentPart.setInput(rootContent);
57 // contentPart.onSelected((o) -> {
58 // Content c = (Content) o;
59 //// log.debug(c.getPath());
60 // cmsView.sendEvent(SuiteUxEvent.refreshPart.topic(), SuiteUxEvent.eventProperties(c));
61 // });
62 return view;
63
64 }
65
66 public void setTermsManager(TermsManager termsManager) {
67 this.termsManager = termsManager;
68 }
69
70 }