X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Fui%2FCmsView.java;h=f8ab3a6821cf09860bdb052e6b118c377d3053ed;hb=c5d120d226b31b3d930fc3006c56ac9e4d29ed2a;hp=d57f20bed897a626da6e4d584180b7a7f6471f9e;hpb=904a1973a06955a1af45d27b74e563f391bd4eb3;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java index d57f20bed..f8ab3a682 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java @@ -6,6 +6,7 @@ import java.util.Map; import javax.security.auth.login.LoginContext; +import org.argeo.cms.auth.CmsSession; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; @@ -36,7 +37,7 @@ public interface CmsView { boolean isAnonymous(); /** - * Send an event to this topic. Does noothing by default., but if implemented it + * Send an event to this topic. Does nothing by default., but if implemented it * MUST set the {@link #CMS_VIEW_UID_PROPERTY} in the properties. */ default void sendEvent(String topic, Map properties) { @@ -60,10 +61,43 @@ public interface CmsView { default T doAs(PrivilegedAction action) { throw new UnsupportedOperationException(); } - + + default Void runAs(Runnable runnable) { + return doAs(new PrivilegedAction() { + + @Override + public Void run() { + if (runnable != null) + runnable.run(); + return null; + } + }); + } + default void stateChanged(String state, String title) { } + default CmsSession getCmsSession() { + throw new UnsupportedOperationException(); + } + + default Object getData(String key) { + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + default T getUiContext(Class clss) { + return (T) getData(clss.getName()); + } + + default void setUiContext(Class clss, T instance) { + setData(clss.getName(), instance); + } + + default void setData(String key, Object value) { + throw new UnsupportedOperationException(); + } + static CmsView getCmsView(Control parent) { // find parent shell Shell topShell = parent.getShell();