Index: src/com/servoy/plugins/BehaviorProvider.java =================================================================== --- src/com/servoy/plugins/BehaviorProvider.java (revision 58) +++ src/com/servoy/plugins/BehaviorProvider.java (working copy) @@ -9,6 +9,7 @@ package com.servoy.plugins; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -28,6 +29,7 @@ import com.servoy.j2db.scripting.FunctionDefinition; import com.servoy.j2db.server.headlessclient.IWebClientPluginAccess; import com.servoy.j2db.server.headlessclient.dataui.WebEventExecutor; +import com.servoy.j2db.util.Debug; import com.servoy.j2db.util.Utils; /** @@ -48,7 +50,7 @@ private final List jsReferences = new ArrayList(2); private final List cssReferences = new ArrayList(2); - + public BehaviorProvider(IWebClientPluginAccess app) { this.app = app; } @@ -217,6 +219,40 @@ public void removeJsReference(String url) { jsReferences.remove(url); } + + public void addGlobalCssReference(Object url) + { + try + { + Method method = app.getPageContributor().getClass().getMethod("addGlobalCSSResourceReference", url.getClass()); + method.invoke(app.getPageContributor(), url); + } + catch (NoSuchMethodException ex) + { + throw new UnsupportedOperationException("Cannot add global css reference. This operation is not supported for Servoy versions lower than 7.3"); + } + catch (Exception e) + { + Debug.error(e); + } + } + + public void removeGlobalCssReference(Object url) + { + try + { + Method method = app.getPageContributor().getClass().getMethod("removeGlobalResourceReference", url.getClass()); + method.invoke(app.getPageContributor(), url); + } + catch (NoSuchMethodException ex) + { + throw new UnsupportedOperationException("Cannot remove global css reference. This operation is not supported for Servoy versions lower than 7.3"); + } + catch (Exception e) + { + Debug.error(e); + } + } /* public interface ILatestPageBehaviorListener extends IBehaviorListener Index: src/com/servoy/plugins/WebClientProvider.java =================================================================== --- src/com/servoy/plugins/WebClientProvider.java (revision 58) +++ src/com/servoy/plugins/WebClientProvider.java (working copy) @@ -480,7 +480,43 @@ public void js_removeCssReference(ResourceReference url) { removeCssReference(url); } + + public void js_addGlobalCssReference(String url) { + addGlobalCssReference(url); + } + public void js_addGlobalCssReference(ResourceReference url) { + addGlobalCssReference(url); + } + + public void js_removeGlobalCssReference(String url) { + removeGlobalCssReference(url); + } + + public void js_removeGlobalCssReference(ResourceReference url) { + removeGlobalCssReference(url); + } + + public void removeGlobalCssReference(ResourceReference url) { + BehaviorProvider bp = getBehavior(); + if (bp != null) bp.removeGlobalCssReference(url); + } + + public void removeGlobalCssReference(String url) { + BehaviorProvider bp = getBehavior(); + if (bp != null) bp.removeGlobalCssReference(url); + } + + private void addGlobalCssReference(String url) { + BehaviorProvider bp = getBehavior(); + if (bp != null) bp.addGlobalCssReference(url); + } + + private void addGlobalCssReference(ResourceReference url) { + BehaviorProvider bp = getBehavior(); + if (bp != null) bp.addGlobalCssReference(url); + } + public void js_addJsReference(String url) { addJsReference(url); }