AboutSupportDeveloper GuideVersion 20.1.5

Controller for interacting with a browser window.

Hierarchy

  • BrowserWindowModule

Properties

_bookmarks: BrowserBookmarks
identity: Identity_4

The identity of the browser window.

openfinWindow: _Window

Underlying OpenFin window Controller.

Methods

  • Attach a page to a browser window. If multiplePagesDisabled is true or a page with same id or title is attached to an existing browser window, an error will be thrown.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    const layout = {
    content: [
    {
    type: 'stack',
    content: [
    {
    type: 'component',
    componentName: 'view',
    componentState: {
    name: 'myViewName',
    url: 'http://google.com'
    }
    }
    ]
    }
    ]
    };
    const page = {
    title: 'myPageTitle',
    pageId: 'myPageId',
    layout
    };
    // assume a browser window already exists
    const windows = await workspacePlatform.Browser.getAllWindows();
    await windows[0].addPage(page);
    // focus window
    await windows[0].openfinWindow.focus();
    // restore window if minimized
    await windows[0].openfinWindow.restore();

    Parameters

    Returns Promise<void>

  • Get a page that is attached to the browser window.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    // assume a browser window already exists
    const windows = await workspacePlatform.Browser.getAllWindows();
    const page = await windows[0].getPage('MyPageId');

    Parameters

    • id: string

      the id of the page to get.

    Returns Promise<AttachedPage>

  • Return all the pages that are attached to a browser window.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    // assume a browser window already exists
    const windows = await workspacePlatform.Browser.getAllWindows();
    const pages = await windows[0].getPages();

    Returns Promise<AttachedPage[]>

  • Remove an attached page from the browser window.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    // assume a browser window already exists
    const windows = await workspacePlatform.Browser.getAllWindows();
    await windows[0].removePage('myPageId');

    Parameters

    • id: string

      the id of the attached page to remove from the browser window.

    Returns Promise<void>

  • Reorder pages attached to the browser window. If multiplePagesDisabled is true an error will be thrown.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    // assume a browser window already exists and has three pages in it
    const windows = await workspacePlatform.Browser.getAllWindows();
    await windows[0].reorderPages(['myPageId2', 'myPageId1', 'myPageId3']);

    Parameters

    Returns Promise<void>

  • Remove an existing page from an existing browser window and reparent it to another existing browser window. If multiplePagesDisabled is true an error will be thrown.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    const workspacePlatform = WorkspacePlatform.getCurrentSync();

    // assume a page and multiple browser windows already exists
    const wrappedTargetWindow = workspacePlatform.Browser.wrapSync(identity)
    const reparentPageRequest = { pageId: 'my-target-page' }
    // wrap the window to which you wish to move the page and call reparentPage
    await wrappedTargetWindow.reparentPage(reparentPageRequest);
    // focus window
    await wrappedTargetWindow.openfinWindow.focus();
    // restore window if minimized
    await wrappedTargetWindow.openfinWindow.restore();

    Parameters

    Returns Promise<void>

  • Replace toolbar options with custom toolbar options

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    // to set the array to our default buttons, pass in null

    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    workspacePlatform.Browser.wrapSync(identity).replaceToolbarOptions({buttons:[{
    type: 'Custom',
    tooltip: 'Custom Tooltip',
    disabled: false,
    iconUrl: 'https://www.openfin.co/favicon.ico',
    action: {
    id: 'sample-custom-action-name',
    customData: {
    message: 'Clicked on custom Toolbar button'
    }
    }
    }]})

    const openFinWindow = fin.Window.wrapSync(identity);
    // call getOptions() to view updated toolbarOptions under workspacePlatform
    await openFinWindow.getOptions()

    Parameters

    Returns Promise<void>

  • Replace window state button options with custom window state button options

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    // to set the array to our default buttons, pass in null

    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    workspacePlatform.Browser.wrapSync(identity).replaceWindowStateButtonOptions({buttons:[{
    type: 'Custom',
    tooltip: 'Custom tooltip',
    disabled: false,
    iconUrl: 'https://www.openfin.co/favicon.ico',
    action: {
    id: 'sample-custom-action-name',
    customData: {
    message: 'Clicked on custom window state button'
    }
    }
    }]})

    const openFinWindow = fin.Window.wrapSync(identity);
    // call getOptions() to view updated windowStateButtonOptions under workspacePlatform
    await openFinWindow.getOptions()

    Parameters

    Returns Promise<void>

  • Set the active page for the browser window. If multiplePagesDisabled is true an error will be thrown.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    // assume a browser window already exists
    const windows = await workspacePlatform.Browser.getAllWindows();
    await windows[0].setActivePage('MyPageId');

    Parameters

    • id: string

      the id of the attached page to set as active.

    Returns Promise<void>

  • Updates the browser window title based on the provided title object.

    Parameters

    • title: WindowTitle

      The new title object for the browser window.

    Returns Promise<void>

    Example

    import * as WorkspacePlatform from '@openfin/workspace-platform';
    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    workspacePlatform.Browser.wrapSync(identity).updateBrowserWindowTitle({type: 'view-title'});

    Example

    import * as WorkspacePlatform from '@openfin/workspace-platform';
    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    workspacePlatform.Browser.wrapSync(identity).updateBrowserWindowTitle({type: 'custom', value: 'My Custom Title'});
  • Update a page in which is attached to the browser window.

    import * as WorkspacePlatform from '@openfin/workspace-platform';

    const workspacePlatform = WorkspacePlatform.getCurrentSync();
    const layout = {
    content: [
    {
    type: 'stack',
    content: [
    {
    type: 'component',
    componentName: 'view',
    componentState: {
    name: 'myViewName',
    url: 'http://google.com'
    }
    }
    ]
    }
    ]
    };
    const page = {
    title: 'myPageTitle',
    pageId: 'myPageId',
    layout
    };
    // assume a browser window already exists
    const windows = await workspacePlatform.Browser.getAllWindows();
    const req = {
    pageId: 'myPageId',
    page
    };
    await windows[0].updatePage(req);

    Parameters

    Returns Promise<void>