]> git.argeo.org Git - lgpl/argeo-commons.git/blob - CmsView.java
0e7e7268042a64650a9979acb5e03dba53dd5553
[lgpl/argeo-commons.git] / CmsView.java
1 package org.argeo.cms.ui;
2
3 import java.util.Map;
4
5 import javax.security.auth.login.LoginContext;
6
7 import org.eclipse.swt.widgets.Composite;
8 import org.eclipse.swt.widgets.Shell;
9
10 /** Provides interaction with the CMS system. */
11 public interface CmsView {
12 final static String CMS_VIEW_UID_PROPERTY = "argeo.cms.view.uid";
13 // String KEY = "org.argeo.cms.ui.view";
14
15 String getUid();
16
17 UxContext getUxContext();
18
19 // NAVIGATION
20 void navigateTo(String state);
21
22 // SECURITY
23 void authChange(LoginContext loginContext);
24
25 void logout();
26
27 // void registerCallbackHandler(CallbackHandler callbackHandler);
28
29 // SERVICES
30 void exception(Throwable e);
31
32 CmsImageManager getImageManager();
33
34 boolean isAnonymous();
35
36 /**
37 * Send an event to this topic. Does noothing by default., but if implemented it
38 * MUST set the {@link #CMS_VIEW_UID_PROPERTY} in the properties.
39 */
40 default void sendEvent(String topic, Map<String, Object> properties) {
41
42 }
43
44 static CmsView getCmsView(Composite parent) {
45 // find parent shell
46 Shell topShell = parent.getShell();
47 while (topShell.getParent() != null)
48 topShell = (Shell) topShell.getParent();
49 return (CmsView) topShell.getData(CmsView.class.getName());
50 }
51
52 static void registerCmsView(Shell shell, CmsView view) {
53 // find parent shell
54 Shell topShell = shell;
55 while (topShell.getParent() != null)
56 topShell = (Shell) topShell.getParent();
57 // check if already set
58 if (topShell.getData(CmsView.class.getName()) != null) {
59 CmsView registeredView = (CmsView) topShell.getData(CmsView.class.getName());
60 throw new IllegalArgumentException("Cms view " + registeredView + " already registered in this shell");
61 }
62 shell.setData(CmsView.class.getName(), view);
63 }
64
65 }