]> git.argeo.org Git - lgpl/argeo-commons.git/blob - swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/ContentComposite.java
Start improving single-user login
[lgpl/argeo-commons.git] / swt / org.argeo.cms.swt / src / org / argeo / cms / swt / acr / ContentComposite.java
1 package org.argeo.cms.swt.acr;
2
3 import org.argeo.api.acr.Content;
4 import org.argeo.api.acr.spi.ProvidedContent;
5 import org.eclipse.swt.widgets.Composite;
6
7 /** A composite which can (optionally) manage a content. */
8 public class ContentComposite extends Composite {
9 private static final long serialVersionUID = -1447009015451153367L;
10
11 public ContentComposite(Composite parent, int style, Content item) {
12 super(parent, style);
13 if (item != null)
14 setData(item);
15 }
16
17 public boolean hasContent() {
18 if (getData() == null)
19 return false;
20 return getData() instanceof Content;
21 }
22
23 public Content getContent() {
24 return (Content) getData();
25 }
26
27 @Deprecated
28 public Content getNode() {
29 return getContent();
30 }
31
32 protected ProvidedContent getProvidedContent() {
33 return (ProvidedContent) getContent();
34 }
35
36 public String getSessionLocalId() {
37 return getProvidedContent().getSessionLocalId();
38 }
39
40 protected void itemUpdated() {
41 layout();
42 }
43
44 public void setContent(Content content) {
45 setData(content);
46 itemUpdated();
47 }
48 }