X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Fui%2FCmsView.java;h=ce0acb89fd2b68c0c2c249b6f9df362310d0483c;hb=a6c43627c0687dae14095c505be60e709ac8d823;hp=51f6acc8cb770e37be2c353123b2368fb701c8d1;hpb=b45e59192a4bb34a6b38a9bfa416b3dc3f6b7892;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 51f6acc8c..ce0acb89f 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 @@ -2,10 +2,13 @@ package org.argeo.cms.ui; import javax.security.auth.login.LoginContext; -import org.argeo.cms.auth.CmsAuthenticated; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +/** Provides interaction with the CMS system. */ +public interface CmsView { + //String KEY = "org.argeo.cms.ui.view"; -/** Provides interaction with the CMS system. UNSTABLE API at this stage. */ -public interface CmsView extends CmsAuthenticated { UxContext getUxContext(); // NAVIGATION @@ -15,11 +18,36 @@ public interface CmsView extends CmsAuthenticated { void authChange(LoginContext loginContext); void logout(); - -// void registerCallbackHandler(CallbackHandler callbackHandler); + + // void registerCallbackHandler(CallbackHandler callbackHandler); // SERVICES void exception(Throwable e); CmsImageManager getImageManager(); + + boolean isAnonymous(); + + 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); + } + }