Improve CMS View.
[lgpl/argeo-commons.git] / org.argeo.cms.ui / src / org / argeo / cms / ui / CmsView.java
index 9f5e4f7973f9e35f29b37dca5199ca9b88814e2d..e18d4b4330d3098a6c8178fa71f1cda29382497b 100644 (file)
@@ -1,11 +1,13 @@
 package org.argeo.cms.ui;
 
+import java.security.PrivilegedAction;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.security.auth.login.LoginContext;
 
-import org.eclipse.swt.widgets.Composite;
+import org.argeo.cms.auth.CmsSession;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 
 /** Provides interaction with the CMS system. */
@@ -52,7 +54,34 @@ public interface CmsView {
                sendEvent(topic, properties);
        }
 
-       static CmsView getCmsView(Composite parent) {
+       default void applyStyles(Object widget) {
+
+       }
+
+       default <T> T doAs(PrivilegedAction<T> action) {
+               throw new UnsupportedOperationException();
+       }
+
+       default Void runAs(Runnable runnable) {
+               return doAs(new PrivilegedAction<Void>() {
+
+                       @Override
+                       public Void run() {
+                               if (runnable != null)
+                                       runnable.run();
+                               return null;
+                       }
+               });
+       }
+
+       default void stateChanged(String state, String title) {
+       }
+
+       default CmsSession getCmsSession() {
+               throw new UnsupportedOperationException();
+       }
+
+       static CmsView getCmsView(Control parent) {
                // find parent shell
                Shell topShell = parent.getShell();
                while (topShell.getParent() != null)