Add navigation notification to CMS View.
[lgpl/argeo-commons.git] / org.argeo.cms.ui / src / org / argeo / cms / ui / CmsView.java
index 0e7e7268042a64650a9979acb5e03dba53dd5553..d57f20bed897a626da6e4d584180b7a7f6471f9e 100644 (file)
@@ -1,10 +1,12 @@
 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.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 
 /** Provides interaction with the CMS system. */
@@ -41,7 +43,28 @@ public interface CmsView {
 
        }
 
-       static CmsView getCmsView(Composite parent) {
+       /**
+        * Convenience methods for when {@link #sendEvent(String, Map)} only requires
+        * one single parameter.
+        */
+       default void sendEvent(String topic, String param, Object value) {
+               Map<String, Object> properties = new HashMap<>();
+               properties.put(param, value);
+               sendEvent(topic, properties);
+       }
+
+       default void applyStyles(Object widget) {
+
+       }
+
+       default <T> T doAs(PrivilegedAction<T> action) {
+               throw new UnsupportedOperationException();
+       }
+       
+       default void stateChanged(String state, String title) {
+       }
+
+       static CmsView getCmsView(Control parent) {
                // find parent shell
                Shell topShell = parent.getShell();
                while (topShell.getParent() != null)