Class PageResourceManager<N extends NodeWrapper>

java.lang.Object
org.knime.core.webui.node.PageResourceManager<N>
Type Parameters:
N - the node wrapper this manager operates on

public final class PageResourceManager<N extends NodeWrapper> extends Object
Gives access to the pages and page resources for nodes (i.e. pages that represent, e.g., node dialogs and views) and node-related ui elements (e.g. port view).
Author:
Martin Horn, KNIME GmbH, Konstanz, Germany
  • Constructor Details

  • Method Details

    • getPagePathPrefix

      public static String getPagePathPrefix(PageResourceManager.PageType type)
      Returns a page path prefix for the path returned by getPagePath(NodeWrapper). The page path prefix helps to separate pages of different page types (e.g. view or dialog) - such that page-ids (see getPageId(NodeWrapper)) only need to be unique within a page type.
      Parameters:
      type - the page type to get the prefix for. Can be null in case of a re-usable page (see Page.getPageIdForReusablePage()) - in that case the same page-path is supposed to be valid for all the different page-types
      Returns:
      the path prefix
    • getDomainName

      public String getDomainName()
      Returns:
      a unique domain name used to identify page resources of this kind
    • getPage

      public Page getPage(N nodeWrapper)
      Parameters:
      nodeWrapper - the node to get the page for
      Returns:
      the page for the given node
      Throws:
      IllegalArgumentException - if there is no page given for the node
    • getPage

      public Page getPage(String pageId)
      Parameters:
      pageId -
      Returns:
      the page for the given page-id or null if there is none
    • getPageId

      public String getPageId(N nodeWrapper)
      Parameters:
      nodeWrapper - the node to get the id for
      Returns:
      the page type
    • getBaseUrl

      public String getBaseUrl()
      The base url for the page and associated resources. It is only required if the AP is run as a desktop application or the page resource used for image/report generation. It's not required if run within an 'executor' as part of the server infrastructure - in this case the base url needs to be determined by the frontend.
      Returns:
      the base url
    • getDebugUrl

      public Optional<String> getDebugUrl(N nodeWrapper)
      Optionally returns a debug url for a view (dialog etc.) which is controlled by a system property.
      Parameters:
      nodeWrapper - the node to get the debug url for
      Returns:
      a debug url or an empty optional if none is set
    • getPagePath

      public String getPagePath(N nodeWrapper)
      Provides the relative path for a page. A page path is assembled of various path-segments, see PagePathSegments. Here are examples of page paths as a function of, e.g., PageResourceManager.PageType and PageCache.PageIdType:
      • a static node view: uiext-view/org.knime...NodeFactory/index.html
      • a static node dialog: uiext-dialog/org.knime...NodeFactory/index.html
      • a static-reusable view (i.e. to be re-used between ui-extension types and node instances; e.g. node or port view): uiext/tableview/TableView.umd.js
      • a non-static node view: uiext-view/5_4_3/342342/index.html (where 5_4_3 is the node id of the the view belongs to, and 342342 the 'page-content-id' - see NodeViewManager#getPagePathSegments(NodeWrapper))
      • a non-static port view: uiext-port/5_4_3_1_0
      • where 5_4_3... is the node id of the node the port belongs to and ..._1_0 the port-index and port-view-index (a port can have multiple views).
      Parameters:
      nodeWrapper - the node which provides the page
      Returns:
      the relative page path
    • getPageResource

      public Optional<Resource> getPageResource(String resourceId)
      Gives access to page resources. NOTE: Only those resources are available that belong to a page whose path has been requested via getPagePath(NodeWrapper).
      Parameters:
      resourceId - the id of the resource
      Returns:
      the resource or an empty optional if there is no resource for the given id available
    • getPageResourceFromUrl

      public Optional<Resource> getPageResourceFromUrl(String url)
      Gives access to page resources via a full URL. NOTE: Only those resources are available that belong to a page whose URL has been requested via getPage(NodeWrapper).
      Parameters:
      url - the resource url
      Returns:
      the resource or an empty optional if there is no resource available at the given URL
    • clearPageCache

      public void clearPageCache()
      Clears the page cache.
    • getPageCacheSize

      public int getPageCacheSize()
      For testing purposes only.
      Returns:
      the page cache size