X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Fui%2FCmsView.java;h=b403a2088d33fbfcb703c49c1bdf11762eca4b6d;hb=b94bc29e6cb5aa29283a380fdc775ecded7f5734;hp=ce0acb89fd2b68c0c2c249b6f9df362310d0483c;hpb=1233dcea2383bfe5c83e5ec33d0c502afff22601;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 ce0acb89f..b403a2088 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,5 +1,8 @@ package org.argeo.cms.ui; +import java.util.HashMap; +import java.util.Map; + import javax.security.auth.login.LoginContext; import org.eclipse.swt.widgets.Composite; @@ -7,7 +10,10 @@ import org.eclipse.swt.widgets.Shell; /** Provides interaction with the CMS system. */ public interface CmsView { - //String KEY = "org.argeo.cms.ui.view"; + final static String CMS_VIEW_UID_PROPERTY = "argeo.cms.view.uid"; + // String KEY = "org.argeo.cms.ui.view"; + + String getUid(); UxContext getUxContext(); @@ -28,6 +34,28 @@ public interface CmsView { 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) { + + } + + /** + * Convenience methods for when {@link #sendEvent(String, Map)} only requires + * one single parameter. + */ + default void sendEvent(String topic, String param, Object value) { + Map properties = new HashMap<>(); + properties.put(param, value); + sendEvent(topic, properties); + } + + default void applyStyles(Object widget) { + + } + static CmsView getCmsView(Composite parent) { // find parent shell Shell topShell = parent.getShell(); @@ -44,8 +72,7 @@ public interface CmsView { // 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"); + throw new IllegalArgumentException("Cms view " + registeredView + " already registered in this shell"); } shell.setData(CmsView.class.getName(), view); }