Class RuntimeResolver

java.lang.Object
com.iizix.prop.RuntimeResolver
All Implemented Interfaces:
IRuntimeResolver

public class RuntimeResolver extends Object implements IRuntimeResolver
The runtime resolver of the Styles references in a client property tree, shared by the Designer and the Server.

A component's style and dstyle properties are StylesReferences. A predefined name (*name) is its own class name on the client; any other name references a module .iiziStyle and becomes a class name only once IGProp.resolveRuntimeReferences(IRuntimeResolver) has asked this resolver for it, which the owner of the client tree does before every transaction is prepared for sending. The first time a Styles is asked for, it is looked up from the resolver container and a StylesCnr, named by a counter, is added to the client root's $styles container (created on demand), holding a communicating ProxyPropCnr of the Styles and the reference name in the string ref. The client builds the CSS class .iz_<name> from that container, and the component's reference is sent as <name>.

The Designer subclass adds what only the Designer needs: the proxy's root parent when a module model is present, and a listener on the style file so that a move, rename or disposal drops the client Styles for the next resolve to re-create. The Server uses this class as is: a loaded application's styles never change, and the proxy's own source-removed callback covers the removal of a Styles.

Author:
Christopher Mindus
  • Field Details

    • resolver

      protected final PropCnr resolver
      The resolver property: the root of the tree the references are looked up from, or any property in a tree whose root resolves them.
    • root

      protected final PropCnr root
      The root property container of the client.
  • Constructor Details

    • RuntimeResolver

      public RuntimeResolver(PropCnr resolver, PropCnr root)
      Constructs the runtime resolver.
      Parameters:
      resolver - The resolver property: the root of the tree the references are looked up from, or any property in a tree whose root resolves them.
      root - The root property container of the client.
  • Method Details

    • dispose

      public void dispose()
      Disposes of the resolver: every client Styles is removed.
    • remove

      protected final void remove(Styles styles)
      Removes the client Styles of a source Styles, if present. The next resolve of a reference to it creates a new one.
      Parameters:
      styles - The source Styles.
    • resolveStylesReference

      public String resolveStylesReference(String stylesName)
      Resolves references for the Style name.
      Specified by:
      resolveStylesReference in interface IRuntimeResolver
      Parameters:
      stylesName - The Styles referenced.
      Returns:
      The Runtime name to use for the Style as Class Name, null means not found.
    • isStylesSource

      protected boolean isStylesSource(Styles styles)
      Checks that the property a reference resolved to is a Styles a reference may use: a module style, whose parent is a file container in the Designer or the module's style directory container in the Server, directly or through its folders, and never a component's own styles - the rule StylesReferences validates a reference by, StylesReferences.isStylesParent(PropCnr).
      Parameters:
      styles - The Styles found.
      Returns:
      true if it may be used, false otherwise.
    • createStylesContainer

      protected PropCnr createStylesContainer()
      Creates the client root's Styles container, named Atom.STYLES, the first time a Styles is resolved and the root has none.
      Returns:
      The container, a plain PropCnr.
    • onClientStylesAdded

      protected void onClientStylesAdded(RuntimeResolver.ClientStyles cs)
      Called when a Styles has been resolved for the first time and its client counterpart created, before the counterpart is added to the client root.
      Parameters:
      cs - The client Styles.
    • onClientStylesRemoved

      protected void onClientStylesRemoved(RuntimeResolver.ClientStyles cs)
      Called when a client Styles is removed, before its container leaves the client root.
      Parameters:
      cs - The client Styles.