1 package org
.argeo
.cms
.ui
;
3 import java
.util
.HashMap
;
6 import javax
.security
.auth
.login
.LoginContext
;
8 import org
.eclipse
.swt
.widgets
.Control
;
9 import org
.eclipse
.swt
.widgets
.Shell
;
11 /** Provides interaction with the CMS system. */
12 public interface CmsView
{
13 final static String CMS_VIEW_UID_PROPERTY
= "argeo.cms.view.uid";
14 // String KEY = "org.argeo.cms.ui.view";
18 UxContext
getUxContext();
21 void navigateTo(String state
);
24 void authChange(LoginContext loginContext
);
28 // void registerCallbackHandler(CallbackHandler callbackHandler);
31 void exception(Throwable e
);
33 CmsImageManager
getImageManager();
35 boolean isAnonymous();
38 * Send an event to this topic. Does noothing by default., but if implemented it
39 * MUST set the {@link #CMS_VIEW_UID_PROPERTY} in the properties.
41 default void sendEvent(String topic
, Map
<String
, Object
> properties
) {
46 * Convenience methods for when {@link #sendEvent(String, Map)} only requires
47 * one single parameter.
49 default void sendEvent(String topic
, String param
, Object value
) {
50 Map
<String
, Object
> properties
= new HashMap
<>();
51 properties
.put(param
, value
);
52 sendEvent(topic
, properties
);
55 default void applyStyles(Object widget
) {
59 static CmsView
getCmsView(Control parent
) {
61 Shell topShell
= parent
.getShell();
62 while (topShell
.getParent() != null)
63 topShell
= (Shell
) topShell
.getParent();
64 return (CmsView
) topShell
.getData(CmsView
.class.getName());
67 static void registerCmsView(Shell shell
, CmsView view
) {
69 Shell topShell
= shell
;
70 while (topShell
.getParent() != null)
71 topShell
= (Shell
) topShell
.getParent();
72 // check if already set
73 if (topShell
.getData(CmsView
.class.getName()) != null) {
74 CmsView registeredView
= (CmsView
) topShell
.getData(CmsView
.class.getName());
75 throw new IllegalArgumentException("Cms view " + registeredView
+ " already registered in this shell");
77 shell
.setData(CmsView
.class.getName(), view
);