You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StyleSheet.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.annotations;
  17. import java.lang.annotation.ElementType;
  18. import java.lang.annotation.Retention;
  19. import java.lang.annotation.RetentionPolicy;
  20. import java.lang.annotation.Target;
  21. import com.vaadin.server.ClientConnector;
  22. /**
  23. * If this annotation is present on a {@link ClientConnector} class, the
  24. * framework ensures the referenced style sheets are loaded before the init
  25. * method for the corresponding client-side connector is invoked.
  26. * <p>
  27. * Absolute URLs including protocol and host are used as is on the client-side.
  28. * Relative URLs are mapped to APP/PUBLISHED/[url] which are by default served
  29. * from the classpath relative to the class where the annotation is defined.
  30. * <p>
  31. * The file is only loaded if it has not already been loaded, determined as
  32. * follows:
  33. * <ul>
  34. * <li>For absolute URLs, the URL is considered loaded if the same URL has
  35. * previously been loaded using {@code StyleSheet} or if a
  36. * {@code <link rel="stylesheet">} tag using the same URL was present in the DOM
  37. * when the Vaadin client-side was initialized.
  38. * <li>For relative URLs, the URL is considered loaded if another file with the
  39. * same name has already been loaded using {@code StyleSheet}, even if that file
  40. * was loaded from a different folder.
  41. * </ul>
  42. * <p>
  43. * Special Vaadin urls are also supported. The most useful is vaadin:// which
  44. * maps to the location of the automatically published VAADIN folder. Using the
  45. * VAADIN folder and vaadin:// you can publish stylesheets which use images or
  46. * other files with relative paths.
  47. * <p>
  48. * Example: <code>@StyleSheet({"http://host.com/file1.css", "file2.css"})</code>
  49. * on the class com.example.MyConnector would load the file
  50. * http://host.com/file1.css as is and file2.css from /com/example/file2.css on
  51. * the server's classpath using the ClassLoader that was used to load
  52. * com.example.MyConnector.
  53. *
  54. * @author Vaadin Ltd
  55. * @since 7.0.0
  56. */
  57. @Retention(RetentionPolicy.RUNTIME)
  58. @Target(ElementType.TYPE)
  59. public @interface StyleSheet {
  60. /**
  61. * Style sheets to load before initializing the client-side connector.
  62. *
  63. * @return an array of style sheet urls
  64. */
  65. public String[] value();
  66. }