Class AddConletType

All Implemented Interfaces:
Future<Void>, Associator, Eligible

public class AddConletType extends ConsoleCommand
Adds a web console component type with its global resources (JavaScript and/or CSS) to the console page.

Specifying global resources result in the respective <link .../> or <script ...></script> nodes being added to the page’s <head> node.

This in turn causes the browser to issue GET requests that (usually) refer to the web console component’s resources. These requests are converted to ConletResourceRequests by the web console and sent to the web console components, which must respond to the requests.

The sequence of events is shown in the diagram.

WebConsole Ready Event Sequence

See ResourceRequest for details about the processing of the ConletResourceRequest.

A conlet’s JavaScript may (and probably must) make use of the functions provided by the web console page. See the JavaScript documentation of these functions for details.

  • Constructor Details

    • AddConletType

      public AddConletType(String conletType)
      Create a new event for the given web console component type.
      Parameters:
      conletType - a unique id for the web console component type (usually the class name)
  • Method Details

    • conletType

      public String conletType()
      Return the web console component type.
      Returns:
      the web console component type
    • setDisplayNames

      public AddConletType setDisplayNames(Map<Locale,String> displayNames)
      Sets the names (by locale) used to display the type in the user interface.
      Parameters:
      displayNames - the display names
      Returns:
      the event for easy chaining
    • displayNames

      Return the display names.
      Returns:
      the displayNames
    • addRenderMode

      Add a render mode to be offered to the user for creating new conlet instances.

      Several modes may be added. Usually only the modes Conlet.RenderMode.Preview and Conlet.RenderMode.View make sense and are the only ones supported by webconsoles. They commonly cause the conlet type to be added to a menu which is made available to the user.

      Parameters:
      mode - the mode
      Returns:
      the event for easy chaining
    • renderModes

      Return the render modes.
      Returns:
      the result
    • addScript

      Add a script resource to be requested by the browser.
      Parameters:
      scriptResource - the script resource
      Returns:
      the event for easy chaining
    • addCss

      public AddConletType addCss(RenderSupport renderSupport, URI uri)
      Add the URI of a CSS resource that is to be added to the header section of the web console page.
      Parameters:
      renderSupport - the render support for mapping the uri
      uri - the URI
      Returns:
      the event for easy chaining
    • scriptResources

      Return all script resources.
      Returns:
      the result
    • cssUris

      public URI[] cssUris()
      Return all CSS URIs.
      Returns:
      the result
    • addPageContent

      public AddConletType addPageContent(String area, Map<String,String> properties)
      Causes a container with this conlet’s type as attribute “data-conlet-type” and classes “conlet conlet-content” to be added to the specified page area.

      The properties are added to the container as additional “data-conlet-…” attributes and will be passed to the AddConletRequest issued by the console when requesting the conlet’s representation.

      Currently, the only defined page area is “headerIcons”. When adding conlets in this area, the numeric property “priority” may be used to determine the order. The default value is 0. Conlets with the same priority are ordered by their type name.

      Parameters:
      area - the area into which the component is to be added
      properties - the properties
      Returns:
      the event for easy chaining
      See Also:
    • pageContent

      Return the list of page components.
      Returns:
      the list
    • emitJson

      public void emitJson(Writer writer) throws IOException
      Description copied from class: ConsoleCommand
      Emits the JSON notification using the given writer.

      Derived classes usually simply call ConsoleCommand.emitJson(Writer, String, Object...) with the method name and parameters.

      Specified by:
      emitJson in class ConsoleCommand
      Parameters:
      writer - the writer
      Throws:
      IOException