X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Fui%2FCmsView.java;h=0e7e7268042a64650a9979acb5e03dba53dd5553;hb=ed889869ecd572e9699260306c346b64f4439e3b;hp=8ef468a702f928c0155d20a7aa6e69f9c8207335;hpb=c5fa035468228d1f87ab5431a3fad17403eee1c3;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java index 8ef468a70..0e7e72680 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/ui/CmsView.java @@ -1,11 +1,19 @@ package org.argeo.cms.ui; +import java.util.Map; + import javax.security.auth.login.LoginContext; -import org.argeo.node.NodeAuthenticated; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +/** Provides interaction with the CMS system. */ +public interface CmsView { + final static String CMS_VIEW_UID_PROPERTY = "argeo.cms.view.uid"; + // String KEY = "org.argeo.cms.ui.view"; + + String getUid(); -/** Provides interaction with the CMS system. UNSTABLE API at this stage. */ -public interface CmsView extends NodeAuthenticated { UxContext getUxContext(); // NAVIGATION @@ -16,8 +24,42 @@ public interface CmsView extends NodeAuthenticated { void logout(); + // void registerCallbackHandler(CallbackHandler callbackHandler); + // SERVICES void exception(Throwable e); CmsImageManager getImageManager(); + + boolean isAnonymous(); + + /** + * Send an event to this topic. Does noothing by default., but if implemented it + * MUST set the {@link #CMS_VIEW_UID_PROPERTY} in the properties. + */ + default void sendEvent(String topic, Map properties) { + + } + + static CmsView getCmsView(Composite parent) { + // find parent shell + Shell topShell = parent.getShell(); + while (topShell.getParent() != null) + topShell = (Shell) topShell.getParent(); + return (CmsView) topShell.getData(CmsView.class.getName()); + } + + static void registerCmsView(Shell shell, CmsView view) { + // find parent shell + Shell topShell = shell; + while (topShell.getParent() != null) + topShell = (Shell) topShell.getParent(); + // check if already set + if (topShell.getData(CmsView.class.getName()) != null) { + CmsView registeredView = (CmsView) topShell.getData(CmsView.class.getName()); + throw new IllegalArgumentException("Cms view " + registeredView + " already registered in this shell"); + } + shell.setData(CmsView.class.getName(), view); + } + }