The identity of the browser window.
Underlying OpenFin window Controller.
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();
the attach page to a browser window.
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');
the id of the page to get.
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();
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');
the id of the attached page to remove from the browser window.
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']);
the reorder pages request.
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();
the reparent page request.
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()
new toolbar options.
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()
new window state options.
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');
the id of the attached page to set as active.
Updates the browser window title based on the provided title object.
The new title object for the browser window.
import * as WorkspacePlatform from '@openfin/workspace-platform';
const workspacePlatform = WorkspacePlatform.getCurrentSync();
workspacePlatform.Browser.wrapSync(identity).updateBrowserWindowTitle({type: 'view-title'});
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);
the update request.
Controller for interacting with a browser window.