1 package org
.argeo
.api
.cms
.ux
;
3 import java
.util
.HashMap
;
5 import java
.util
.concurrent
.Callable
;
6 import java
.util
.concurrent
.Executors
;
8 import javax
.security
.auth
.login
.LoginContext
;
10 import org
.argeo
.api
.cms
.CmsSession
;
12 /** Provides interaction with the CMS system. */
13 public interface CmsView
{
14 final static String CMS_VIEW_UID_PROPERTY
= "argeo.cms.view.uid";
15 // String KEY = "org.argeo.cms.ui.view";
19 UxContext
getUxContext();
22 void navigateTo(String state
);
25 void authChange(LoginContext loginContext
);
29 // void registerCallbackHandler(CallbackHandler callbackHandler);
32 void exception(Throwable e
);
34 <V
,M
> CmsImageManager
<V
, M
> getImageManager();
36 boolean isAnonymous();
39 * Send an event to this topic. Does nothing by default., but if implemented it
40 * MUST set the {@link #CMS_VIEW_UID_PROPERTY} in the properties.
42 default void sendEvent(String topic
, Map
<String
, Object
> properties
) {
47 * Convenience methods for when {@link #sendEvent(String, Map)} only requires
48 * one single parameter.
50 default void sendEvent(String topic
, String param
, Object value
) {
51 Map
<String
, Object
> properties
= new HashMap
<>();
52 properties
.put(param
, value
);
53 sendEvent(topic
, properties
);
56 default void applyStyles(Object widget
) {
61 * Make sure that this action is executed with the proper subject and in a
64 <T
> T
doAs(Callable
<T
> action
);
66 default void runAs(Runnable runnable
) {
67 doAs(Executors
.callable(runnable
));
70 default void stateChanged(String state
, String title
) {
73 default CmsSession
getCmsSession() {
74 throw new UnsupportedOperationException();
77 default Object
getData(String key
) {
78 throw new UnsupportedOperationException();
81 @SuppressWarnings("unchecked")
82 default <T
> T
getUiContext(Class
<T
> clss
) {
83 return (T
) getData(clss
.getName());
86 default <T
> void setUiContext(Class
<T
> clss
, T instance
) {
87 setData(clss
.getName(), instance
);
90 default void setData(String key
, Object value
) {
91 throw new UnsupportedOperationException();