Class ThemeLiveUpdater

java.lang.Object
com.vaadin.base.devserver.ThemeLiveUpdater
All Implemented Interfaces:
Closeable, AutoCloseable

public class ThemeLiveUpdater extends Object implements Closeable
Watches the given theme folder for changes, combines the theme on changes and pushes the new version to the browser.
Since:
24.1
  • Constructor Summary

    Constructors
    Constructor
    Description
    ThemeLiveUpdater(File themeFolder, VaadinContext context)
    Starts watching the given theme folder (containing styles.css).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Stops watching the folder and cleans up resources.
    static boolean
    push(File themeFolder, VaadinContext context)
    Combines the theme and pushes the new stylesheet to the browser, which is what the watcher does when a theme CSS file is saved.
    static void
    Stops this watcher from pushing on save, without stopping it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ThemeLiveUpdater

      public ThemeLiveUpdater(File themeFolder, VaadinContext context)
      Starts watching the given theme folder (containing styles.css).
      Parameters:
      themeFolder - the folder to watch
      context - the current context
  • Method Details

    • push

      public static boolean push(File themeFolder, VaadinContext context)
      Combines the theme and pushes the new stylesheet to the browser, which is what the watcher does when a theme CSS file is saved.

      Separate from the watcher so a tool that owns the apply loop can perform exactly the same update at the moment it decides a change goes live, rather than reimplementing the combining and the URL. See suspend(VaadinContext).

      For internal use only. May be renamed or removed in a future release.

      Parameters:
      themeFolder - the theme folder, whose name is the theme name
      context - the current context
      Returns:
      true if the new stylesheet reached the browser
      Since:
      25.3
    • suspend

      public static void suspend(VaadinContext context)
      Stops this watcher from pushing on save, without stopping it.

      A tool that owns the edit-to-running-app loop decides when a change goes live, and a second watcher pushing on its own makes "what is the state of my last change?" unanswerable. Such a tool suspends this and performs the theme update itself, through push(File, VaadinContext).

      A context attribute rather than a field, so it can be set before or after the watcher is created - the check happens when a file changes.

      Parameters:
      context - the current Vaadin context
      Since:
      25.3
    • close

      public void close() throws IOException
      Stops watching the folder and cleans up resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException