Author: hlship
Date: Fri May 21 20:05:34 2010
New Revision: 947149
URL: http://svn.apache.org/viewvc?rev=947149&view=rev
Log:
TAP5-56: Rework the JavascriptSupport interface to use a StylesheetOptions
object rather than just a string for media
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StylesheetLink.java
(with props)
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StylesheetOptions.java
(with props)
Removed:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/IncludedStylesheet.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavascriptSupport.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinkerTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImplTest.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinker.java
Fri May 21 20:05:34 2010
@@ -31,13 +31,8 @@ public interface DocumentLinker
/**
* Adds a link to load a CSS stylesheet.
- *
- * @param styleURL
- * URL of stylesheet to load
- * @param media
- * media value (or null to omit the media attribute)
*/
- void addStylesheetLink(String styleURL, String media);
+ void addStylesheetLink(StylesheetLink stylesheet);
/**
* Adds JavaScript code. The code is collected into a single block that is
injected just before the close body tag
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
Fri May 21 20:05:34 2010
@@ -16,7 +16,6 @@ package org.apache.tapestry5.internal.se
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.apache.tapestry5.dom.Document;
import org.apache.tapestry5.dom.Element;
@@ -35,7 +34,7 @@ public class DocumentLinkerImpl implemen
private final Map<InitializationPriority, JSONObject> priorityToInit =
CollectionFactory.newMap();
- private final List<IncludedStylesheet> includedStylesheets =
CollectionFactory.newList();
+ private final List<StylesheetLink> includedStylesheets =
CollectionFactory.newList();
private final boolean compactJSON;
@@ -62,9 +61,9 @@ public class DocumentLinkerImpl implemen
this.compactJSON = compactJSON;
}
- public void addStylesheetLink(String styleURL, String media)
+ public void addStylesheetLink(StylesheetLink sheet)
{
- includedStylesheets.add(new IncludedStylesheet(styleURL, media));
+ includedStylesheets.add(sheet);
}
public void addScriptLink(String scriptURL)
@@ -261,7 +260,7 @@ public class DocumentLinkerImpl implemen
* @param stylesheets
* to add to the document
*/
- protected void addStylesheetsToHead(Element root, List<IncludedStylesheet>
stylesheets)
+ protected void addStylesheetsToHead(Element root, List<StylesheetLink>
stylesheets)
{
int count = stylesheets.size();
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinker.java
Fri May 21 20:05:34 2010
@@ -36,13 +36,13 @@ public class PartialMarkupDocumentLinker
scripts.put(scriptURL);
}
- public void addStylesheetLink(String styleURL, String media)
+ public void addStylesheetLink(StylesheetLink stylesheet)
{
- JSONObject object = new JSONObject();
- object.put("href", styleURL);
+ JSONObject object = new JSONObject(
- if (media != null)
- object.put("media", media);
+ "href", stylesheet.getUrl(),
+
+ "media", stylesheet.getOptions().getMedia());
stylesheets.put(object);
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RenderSupportImpl.java
Fri May 21 20:05:34 2010
@@ -24,6 +24,7 @@ import org.apache.tapestry5.json.JSONArr
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.AssetSource;
import org.apache.tapestry5.services.javascript.JavascriptSupport;
+import org.apache.tapestry5.services.javascript.StylesheetOptions;
public class RenderSupportImpl implements RenderSupport
{
@@ -167,11 +168,11 @@ public class RenderSupportImpl implement
public void addStylesheetLink(Asset stylesheet, String media)
{
- javascriptSupport.importStylesheet(stylesheet, media);
+ javascriptSupport.importStylesheet(stylesheet, new
StylesheetOptions(media));
}
public void addStylesheetLink(String stylesheetURL, String media)
{
- javascriptSupport.importStylesheet(stylesheetURL, media);
+ javascriptSupport.importStylesheet(stylesheetURL, new
StylesheetOptions(media));
}
}
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StylesheetLink.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StylesheetLink.java?rev=947149&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StylesheetLink.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StylesheetLink.java
Fri May 21 20:05:34 2010
@@ -0,0 +1,91 @@
+// Copyright 2008, 2009, 2010 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.services;
+
+import org.apache.tapestry5.dom.Element;
+import org.apache.tapestry5.internal.TapestryInternalUtils;
+import org.apache.tapestry5.services.javascript.StylesheetOptions;
+
+/**
+ * Captures the information needed to create a stylesheet link in the final
{...@link Document}.
+ *
+ * @see DocumentLinker
+ * @since 5.2.0
+ */
+public final class StylesheetLink
+{
+ private final String url;
+
+ private final StylesheetOptions options;
+
+ private static final StylesheetOptions BLANK_OPTIONS = new
StylesheetOptions(null);
+
+ public StylesheetLink(String url)
+ {
+ this(url, null);
+ }
+
+ public StylesheetLink(String url, StylesheetOptions options)
+ {
+ this.url = url;
+ this.options = options != null ? options : BLANK_OPTIONS;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ /**
+ * Returns an instance of {...@link StylesheetOptions}. Never returns null
(a blank options
+ * object is returned if null is passed to the constructor).
+ */
+ public StylesheetOptions getOptions()
+ {
+ return options;
+ }
+
+ /**
+ * Invoked to add the stylesheet link to a container element.
+ *
+ * @param container
+ * to add the new element to
+ */
+ void add(Element container)
+ {
+ container.element("link", "href", url, "rel", "stylesheet", "type",
"text/css", "media", options.getMedia());
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format("StylesheetLink[%s %s]", url, options);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+
+ if (obj == null || !(obj instanceof StylesheetLink))
+ return false;
+
+ StylesheetLink ssl = (StylesheetLink) obj;
+
+ return TapestryInternalUtils.isEqual(url, ssl.url) &&
TapestryInternalUtils.isEqual(options, ssl.options);
+ }
+
+}
Propchange:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/StylesheetLink.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImpl.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImpl.java
Fri May 21 20:05:34 2010
@@ -22,6 +22,7 @@ import org.apache.tapestry5.Asset;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.internal.InternalConstants;
import org.apache.tapestry5.internal.services.DocumentLinker;
+import org.apache.tapestry5.internal.services.StylesheetLink;
import
org.apache.tapestry5.internal.services.javascript.JavascriptStackPathConstructor;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.apache.tapestry5.ioc.internal.util.Defense;
@@ -35,22 +36,10 @@ import org.apache.tapestry5.services.jav
import org.apache.tapestry5.services.javascript.JavascriptStack;
import org.apache.tapestry5.services.javascript.JavascriptStackSource;
import org.apache.tapestry5.services.javascript.JavascriptSupport;
+import org.apache.tapestry5.services.javascript.StylesheetOptions;
public class JavascriptSupportImpl implements JavascriptSupport
{
- private class Stylesheet
- {
- final String path;
-
- final String media;
-
- public Stylesheet(String path, String media)
- {
- this.path = path;
- this.media = media;
- }
- }
-
private final IdAllocator idAllocator;
private final DocumentLinker linker;
@@ -67,7 +56,7 @@ public class JavascriptSupportImpl imple
private final Set<String> importedStylesheets = CollectionFactory.newSet();
- private final List<Stylesheet> otherStylesheets =
CollectionFactory.newList();
+ private final List<StylesheetLink> otherStylesheets =
CollectionFactory.newList();
private final Map<InitializationPriority, JSONObject> inits =
CollectionFactory.newMap();
@@ -110,15 +99,15 @@ public class JavascriptSupportImpl imple
{
public void op(String value)
{
- linker.addStylesheetLink(value, null);
+ linker.addStylesheetLink(new StylesheetLink(value, null));
}
}, stackStylesheets);
- Func.each(new Operation<Stylesheet>()
+ Func.each(new Operation<StylesheetLink>()
{
- public void op(Stylesheet value)
+ public void op(StylesheetLink value)
{
- linker.addStylesheetLink(value.path, value.media);
+ linker.addStylesheetLink(value);
}
}, otherStylesheets);
@@ -259,14 +248,14 @@ public class JavascriptSupportImpl imple
addedStacks.put(stackName, true);
}
- public void importStylesheet(Asset stylesheet, String media)
+ public void importStylesheet(Asset stylesheet, StylesheetOptions options)
{
Defense.notNull(stylesheet, "stylesheet");
- importStylesheet(stylesheet.toClientURL(), media);
+ importStylesheet(stylesheet.toClientURL(), options);
}
- public void importStylesheet(String stylesheetURL, String media)
+ public void importStylesheet(String stylesheetURL, StylesheetOptions
options)
{
Defense.notBlank(stylesheetURL, "stylesheetURL");
@@ -277,7 +266,7 @@ public class JavascriptSupportImpl imple
importedStylesheets.add(stylesheetURL);
- otherStylesheets.add(new Stylesheet(stylesheetURL, media));
+ otherStylesheets.add(new StylesheetLink(stylesheetURL, options));
}
public void importStack(String stackName)
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
Fri May 21 20:05:34 2010
@@ -2006,7 +2006,7 @@ public final class TapestryModule
{
DocumentLinker linker =
environment.peekRequired(DocumentLinker.class);
- linker.addStylesheetLink(defaultStylesheet.toClientURL(),
null);
+ linker.addStylesheetLink(new
StylesheetLink(defaultStylesheet.toClientURL()));
renderer.renderMarkup(writer);
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavascriptSupport.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavascriptSupport.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavascriptSupport.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavascriptSupport.java
Fri May 21 20:05:34 2010
@@ -151,20 +151,20 @@ public interface JavascriptSupport
*
* @param stylesheet
* asset for the stylesheet
- * @param media
- * media value for the stylesheet, or null to not specify a
specific media type
+ * @param options
+ * describes options for importing the stylesheet (may be null)
*/
- void importStylesheet(Asset stylesheet, String media);
+ void importStylesheet(Asset stylesheet, StylesheetOptions options);
/**
- * As with {...@link #importStylesheet(Asset, String)}, but the stylesheet
is represented as a URL string.
+ * As with {...@link #importStylesheet(Asset, StylesheetOptions)}, but the
stylesheet is represented as a URL string.
*
* @param stylesheet
* URL for the stylesheet
- * @param media
- * media value for the stylesheet, or null to not specify a
specific media type
+ * @param options
+ * describes options for importing the stylesheet (may be null)
*/
- void importStylesheet(String stylesheetURL, String media);
+ void importStylesheet(String stylesheetURL, StylesheetOptions options);
/**
* Imports a {...@link JavascriptStack} by name, a related set of
JavaScript libraries and stylesheets.
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StylesheetOptions.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StylesheetOptions.java?rev=947149&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StylesheetOptions.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StylesheetOptions.java
Fri May 21 20:05:34 2010
@@ -0,0 +1,58 @@
+// Copyright 2010 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.services.javascript;
+
+import org.apache.tapestry5.internal.TapestryInternalUtils;
+
+/**
+ * Provides options to describe options associated with importing a stylesheet
onto a page.
+ *
+ * @since 5.2.0
+ */
+public class StylesheetOptions
+{
+ private final String media;
+
+ public StylesheetOptions(String media)
+ {
+ this.media = media;
+ }
+
+ /**
+ * The media associated with this stylesheet, i.e., "print". Becomes the
media attribute
+ * of the <link> tag. May be null.
+ */
+ public String getMedia()
+ {
+ return media;
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format("StylesheetOptions[media=%s]", media);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null || !(obj instanceof StylesheetOptions))
+ return false;
+
+ StylesheetOptions sso = (StylesheetOptions) obj;
+
+ return TapestryInternalUtils.isEqual(media, sso.media);
+ }
+}
Propchange:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/StylesheetOptions.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.java
Fri May 21 20:05:34 2010
@@ -21,6 +21,7 @@ import org.apache.tapestry5.internal.tes
import org.apache.tapestry5.json.JSONArray;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.javascript.InitializationPriority;
+import org.apache.tapestry5.services.javascript.StylesheetOptions;
import org.testng.annotations.Test;
public class DocumentLinkerImplTest extends InternalBaseTestCase
@@ -68,7 +69,7 @@ public class DocumentLinkerImplTest exte
// Only checked if there's something to link.
- linker.addStylesheetLink("style.css", null);
+ linker.addStylesheetLink(new StylesheetLink("style.css"));
replay();
@@ -157,7 +158,7 @@ public class DocumentLinkerImplTest exte
DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3",
true);
- linker.addStylesheetLink("style.css", "print");
+ linker.addStylesheetLink(new StylesheetLink("style.css", new
StylesheetOptions("print")));
linker.addScriptLink("foo.js");
linker.addScriptLink("bar/baz.js");
linker.addScript(InitializationPriority.IMMEDIATE,
"pageInitialization();");
@@ -194,8 +195,8 @@ public class DocumentLinkerImplTest exte
DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3",
true);
- linker.addStylesheetLink("foo.css", null);
- linker.addStylesheetLink("bar/baz.css", "print");
+ linker.addStylesheetLink(new StylesheetLink("foo.css"));
+ linker.addStylesheetLink(new StylesheetLink("bar/baz.css", new
StylesheetOptions("print")));
linker.updateDocument(document);
@@ -212,7 +213,7 @@ public class DocumentLinkerImplTest exte
DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3",
true);
- linker.addStylesheetLink("foo.css", null);
+ linker.addStylesheetLink(new StylesheetLink("foo.css"));
linker.updateDocument(document);
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinkerTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinkerTest.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinkerTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/PartialMarkupDocumentLinkerTest.java
Fri May 21 20:05:34 2010
@@ -17,6 +17,7 @@ package org.apache.tapestry5.internal.se
import org.apache.tapestry5.json.JSONArray;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.javascript.InitializationPriority;
+import org.apache.tapestry5.services.javascript.StylesheetOptions;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -75,8 +76,8 @@ public class PartialMarkupDocumentLinker
{
PartialMarkupDocumentLinker linker = new PartialMarkupDocumentLinker();
- linker.addStylesheetLink("foo.css", "print");
- linker.addStylesheetLink("bar.css", null);
+ linker.addStylesheetLink(new StylesheetLink("foo.css", new
StylesheetOptions("print")));
+ linker.addStylesheetLink(new StylesheetLink("bar.css"));
JSONObject reply = new JSONObject();
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/RenderSupportImplTest.java
Fri May 21 20:05:34 2010
@@ -23,6 +23,7 @@ import org.apache.tapestry5.json.JSONArr
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.AssetSource;
import org.apache.tapestry5.services.javascript.JavascriptSupport;
+import org.apache.tapestry5.services.javascript.StylesheetOptions;
import org.testng.annotations.Test;
public class RenderSupportImplTest extends InternalBaseTestCase
@@ -111,7 +112,7 @@ public class RenderSupportImplTest exten
JavascriptSupport javascriptSupport = mockJavascriptSupport();
Asset asset = mockAsset();
- javascriptSupport.importStylesheet(asset, media);
+ javascriptSupport.importStylesheet(asset, new
StylesheetOptions(media));
replay();
@@ -128,7 +129,7 @@ public class RenderSupportImplTest exten
String media = "print";
JavascriptSupport javascriptSupport = mockJavascriptSupport();
- javascriptSupport.importStylesheet(ASSET_URL, media);
+ javascriptSupport.importStylesheet(ASSET_URL, new
StylesheetOptions(media));
replay();
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImplTest.java?rev=947149&r1=947148&r2=947149&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImplTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ajax/JavascriptSupportImplTest.java
Fri May 21 20:05:34 2010
@@ -21,6 +21,7 @@ import org.apache.tapestry5.Asset;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.internal.InternalConstants;
import org.apache.tapestry5.internal.services.DocumentLinker;
+import org.apache.tapestry5.internal.services.StylesheetLink;
import
org.apache.tapestry5.internal.services.javascript.JavascriptStackPathConstructor;
import org.apache.tapestry5.internal.test.InternalBaseTestCase;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
@@ -31,6 +32,7 @@ import org.apache.tapestry5.services.jav
import org.apache.tapestry5.services.javascript.JavascriptStack;
import org.apache.tapestry5.services.javascript.JavascriptStackSource;
import org.apache.tapestry5.services.javascript.JavascriptSupport;
+import org.apache.tapestry5.services.javascript.StylesheetOptions;
import org.testng.annotations.Test;
public class JavascriptSupportImplTest extends InternalBaseTestCase
@@ -133,7 +135,7 @@ public class JavascriptSupportImplTest e
linker.addScriptLink("stack1.js");
linker.addScriptLink("stack2.js");
- linker.addStylesheetLink("style.css", null);
+ linker.addStylesheetLink(new StylesheetLink("style.css"));
}
protected final JavascriptStack mockJavascriptStack()
@@ -214,7 +216,7 @@ public class JavascriptSupportImplTest e
expect(stack.getInitialization()).andReturn("customInit();");
linker.addScriptLink("stack.js");
- linker.addStylesheetLink("stack.css", null);
+ linker.addStylesheetLink(new StylesheetLink("stack.css"));
linker.addScript(InitializationPriority.IMMEDIATE, "stackInit();");
linker.addScript(InitializationPriority.IMMEDIATE, "customInit();");
@@ -340,14 +342,15 @@ public class JavascriptSupportImplTest e
{
DocumentLinker linker = mockDocumentLinker();
Asset stylesheet = mockAsset("style.css");
+ StylesheetOptions options = new StylesheetOptions("print");
- linker.addStylesheetLink("style.css", "print");
+ linker.addStylesheetLink(new StylesheetLink("style.css", options));
replay();
JavascriptSupportImpl jss = new JavascriptSupportImpl(linker, null,
null);
- jss.importStylesheet(stylesheet, "print");
+ jss.importStylesheet(stylesheet, options);
jss.commit();
@@ -358,15 +361,16 @@ public class JavascriptSupportImplTest e
public void duplicate_stylesheet_ignored_first_media_wins()
{
DocumentLinker linker = mockDocumentLinker();
+ StylesheetOptions options = new StylesheetOptions("print");
- linker.addStylesheetLink("style.css", "print");
+ linker.addStylesheetLink(new StylesheetLink("style.css", options));
replay();
JavascriptSupportImpl jss = new JavascriptSupportImpl(linker, null,
null);
- jss.importStylesheet("style.css", "print");
- jss.importStylesheet("style.css", "screen");
+ jss.importStylesheet("style.css", options);
+ jss.importStylesheet("style.css", new StylesheetOptions("hologram"));
jss.commit();