Class DesignerPalette

java.lang.Object
com.iizigo.color.DesignerPalette

public final class DesignerPalette extends Object
The Designer's palette service: installs the platform base palette from the theme sheet the internal web server serves, so that a role reference resolves in iiziGo as it does on a server; reads the base palette of every shipped family for the previews; lists the module roots whose style folders hold the palette colors; and tells the design views when a palette changed, so that the palette block they show (AppPaletteCSS) is regenerated.

The saved theme choice - the family and the mode the Panel Editor's "Theme and Client" menu stores in the preference store - is read here for the previews of the color editor and the chooser.

Author:
Christopher Mindus
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The preference store key of the saved theme family, as the Panel Editor stores it.
    static final String
    The preference store key of the saved theme mode, as the Panel Editor stores it.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Adds a listener told, in the SWT thread and once per burst of changes, when a palette color changed.
    static PropCnr
    Gets the base palette of a shipped family: the light and dark values the theme sheet defines for it.
    static List<PropCnr>
    Gets the root containers of the loaded module projects: the ones whose style folders hold the palette colors the design views can show.
    static String
    Gets the saved theme family, the one the Panel Editor's "Theme and Client" menu stores.
    static String
    Gets the saved theme mode as a scheme name: light or dark, never auto (the Designer has no OS preference to follow, so auto previews as light).
    static boolean
    Installs the platform base palette in the color resolver from the theme sheet, once.
    static void
    Called when a palette color changed: the listeners are told once, asynchronously in the SWT thread, however many changes arrive before it runs.
    static boolean
    push(PropCnr clientRoot)
    Installs or refreshes the palette block on a design view's client root: the loaded modules' palette colors as CSS custom properties, the base palette installed first.
    static void
    Removes a listener.
    resolve(GProp<?> holder, GColor color, String scheme)
    Resolves a color reference from a holder for a scheme against the saved family's base palette.
    Resolves a palette color for a scheme against the saved family's base palette.
  • Field Details

    • PREF_FAMILY

      public static final String PREF_FAMILY
      The preference store key of the saved theme family, as the Panel Editor stores it.
      See Also:
    • PREF_MODE

      public static final String PREF_MODE
      The preference store key of the saved theme mode, as the Panel Editor stores it.
      See Also:
  • Method Details

    • install

      public static boolean install()
      Installs the platform base palette in the color resolver from the theme sheet, once.
      Returns:
      true when a base palette is installed.
    • getBasePalette

      public static PropCnr getBasePalette(String family)
      Gets the base palette of a shipped family: the light and dark values the theme sheet defines for it. The default family's palette is the installed one.
      Parameters:
      family - The family name, e.g. "graphite", or null for the default family.
      Returns:
      The base palette, or null when the sheet cannot be read.
    • getSavedFamily

      public static String getSavedFamily()
      Gets the saved theme family, the one the Panel Editor's "Theme and Client" menu stores.
      Returns:
      The family name, the default family when none is stored.
    • getSavedScheme

      public static String getSavedScheme()
      Gets the saved theme mode as a scheme name: light or dark, never auto (the Designer has no OS preference to follow, so auto previews as light).
      Returns:
      The scheme name, PaletteColor.SCHEME_LIGHT or PaletteColor.SCHEME_DARK.
    • resolveEntry

      public static ColorResolver.Result resolveEntry(PaletteColor color, String scheme)
      Resolves a palette color for a scheme against the saved family's base palette.
      Parameters:
      color - The palette color.
      scheme - The scheme, light or dark.
      Returns:
      The result, never null.
    • resolve

      public static ColorResolver.Result resolve(GProp<?> holder, GColor color, String scheme)
      Resolves a color reference from a holder for a scheme against the saved family's base palette.
      Parameters:
      holder - Any property in the tree the reference is written in.
      color - The referenced color.
      scheme - The scheme, light or dark.
      Returns:
      The result, never null.
    • getModuleRoots

      public static List<PropCnr> getModuleRoots()
      Gets the root containers of the loaded module projects: the ones whose style folders hold the palette colors the design views can show.
      Returns:
      The roots, possibly empty, never null.
    • push

      public static boolean push(PropCnr clientRoot)
      Installs or refreshes the palette block on a design view's client root: the loaded modules' palette colors as CSS custom properties, the base palette installed first.
      Parameters:
      clientRoot - The client root of the design view.
      Returns:
      true when the block changed.
    • addListener

      public static void addListener(Runnable listener)
      Adds a listener told, in the SWT thread and once per burst of changes, when a palette color changed.
      Parameters:
      listener - The listener.
    • removeListener

      public static void removeListener(Runnable listener)
      Removes a listener.
      Parameters:
      listener - The listener.
    • paletteChanged

      public static void paletteChanged()
      Called when a palette color changed: the listeners are told once, asynchronously in the SWT thread, however many changes arrive before it runs.