Package org.knime.core.webui.node
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
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
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionPageResourceManager(PageResourceManager.PageType pageType, Function<N, Page> createPage) PageResourceManager(PageResourceManager.PageType pageType, Function<N, Page> createPage, BiFunction<N, PagePathSegments, PagePathSegments> modifyPagePathSegments, BiFunction<String, PagePathSegments, PagePathSegments> decomposePagePath, boolean shouldCleanUpPageOnNodeStateChange) -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the page cache.The base url for the page and associated resources.getDebugUrl(N nodeWrapper) Optionally returns a debug url for a view (dialog etc.) which is controlled by a system property.intFor testing purposes only.getPagePath(N nodeWrapper) Provides the relative path for a page.static StringReturns a page path prefix for the path returned bygetPagePath(NodeWrapper).getPageResource(String resourceId) Gives access to page resources.Gives access to page resources via a full URL.
-
Constructor Details
-
PageResourceManager
- Parameters:
pageType-createPage- function that creates a new page for a given node wrapper
-
PageResourceManager
public PageResourceManager(PageResourceManager.PageType pageType, Function<N, Page> createPage, BiFunction<N, PagePathSegments, PagePathSegments> modifyPagePathSegments, BiFunction<String, PagePathSegments, PagePathSegments> decomposePagePath, boolean shouldCleanUpPageOnNodeStateChange) - Parameters:
pageType-createPage-modifyPagePathSegments- optional function to modify thePagePathSegments; can benulldecomposePagePath- an optional function to decompose thePagePathSegments; can benullshouldCleanUpPageOnNodeStateChange- whether to remove the page from the cache on node state change
-
-
Method Details
-
getPagePathPrefix
Returns a page path prefix for the path returned bygetPagePath(NodeWrapper). The page path prefix helps to separate pages of different page types (e.g. view or dialog) - such that page-ids (seegetPageId(NodeWrapper)) only need to be unique within a page type.- Parameters:
type- the page type to get the prefix for. Can benullin case of a re-usable page (seePage.getPageIdForReusablePage()) - in that case the same page-path is supposed to be valid for all the different page-types- Returns:
- the path prefix
-
getDomainName
- Returns:
- a unique domain name used to identify page resources of this kind
-
getPage
- 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
- Parameters:
pageId-- Returns:
- the page for the given page-id or
nullif there is none
-
getPageId
- Parameters:
nodeWrapper- the node to get the id for- Returns:
- the page type
-
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
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
Provides the relative path for a page. A page path is assembled of various path-segments, seePagePathSegments. Here are examples of page paths as a function of, e.g.,PageResourceManager.PageTypeandPageCache.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(where5_4_3is the node id of the the view belongs to, and342342the 'page-content-id' - seeNodeViewManager#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_0the 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
- a static node view:
-
getPageResource
Gives access to page resources. NOTE: Only those resources are available that belong to a page whose path has been requested viagetPagePath(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
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 viagetPage(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
-