]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/ContentComposite.java
Refactor SWT directory structure.
[lgpl/argeo-commons.git] / swt / org.argeo.cms.swt / src / org / argeo / cms / swt / acr / ContentComposite.java
diff --git a/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/ContentComposite.java b/swt/org.argeo.cms.swt/src/org/argeo/cms/swt/acr/ContentComposite.java
new file mode 100644 (file)
index 0000000..951889e
--- /dev/null
@@ -0,0 +1,41 @@
+package org.argeo.cms.swt.acr;
+
+import org.argeo.api.acr.Content;
+import org.argeo.api.acr.spi.ProvidedContent;
+import org.eclipse.swt.widgets.Composite;
+
+/** A composite which can (optionally) manage a content. */
+public class ContentComposite extends Composite {
+       private static final long serialVersionUID = -1447009015451153367L;
+
+       public ContentComposite(Composite parent, int style, Content item) {
+               super(parent, style);
+               setData(item);
+       }
+
+       public Content getContent() {
+               return (Content) getData();
+       }
+
+       @Deprecated
+       public Content getNode() {
+               return getContent();
+       }
+
+       protected ProvidedContent getProvidedContent() {
+               return (ProvidedContent) getContent();
+       }
+
+       public String getSessionLocalId() {
+               return getProvidedContent().getSessionLocalId();
+       }
+
+       protected void itemUpdated() {
+               layout();
+       }
+
+       public void setContent(Content content) {
+               setData(content);
+               itemUpdated();
+       }
+}