1 package org
.argeo
.cms
.ui
;
3 import java
.util
.HashMap
;
6 import javax
.security
.auth
.login
.LoginContext
;
8 import org
.eclipse
.swt
.widgets
.Composite
;
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 static CmsView
getCmsView(Composite parent
) {
57 Shell topShell
= parent
.getShell();
58 while (topShell
.getParent() != null)
59 topShell
= (Shell
) topShell
.getParent();
60 return (CmsView
) topShell
.getData(CmsView
.class.getName());
63 static void registerCmsView(Shell shell
, CmsView view
) {
65 Shell topShell
= shell
;
66 while (topShell
.getParent() != null)
67 topShell
= (Shell
) topShell
.getParent();
68 // check if already set
69 if (topShell
.getData(CmsView
.class.getName()) != null) {
70 CmsView registeredView
= (CmsView
) topShell
.getData(CmsView
.class.getName());
71 throw new IllegalArgumentException("Cms view " + registeredView
+ " already registered in this shell");
73 shell
.setData(CmsView
.class.getName(), view
);