Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function realizeTabAreaConfig(config: DockLayout.ITabAreaConfig, renderer: DockLayout.IRenderer): TabLayoutNode {
// Create the tab bar for the layout node.
let tabBar = renderer.createTabBar();
// Hide each widget and add it to the tab bar.
each(config.widgets, widget => {
widget.hide();
tabBar.addTab(widget.title);
});
// Set the current index of the tab bar.
tabBar.currentIndex = config.currentIndex;
// Return the new tab layout node.
return new TabLayoutNode(tabBar);
}
// Bail early if there are no items to match.
if (this._items.length === 0) {
return false;
}
// Find the matching items for the event.
let items = Private.matchItems(this._items, event);
// Bail if there are no matching items.
if (!items || items.length === 0) {
return false;
}
// Add the filtered items to the menu.
each(items, item => { this.menu.addItem(item); });
// Open the context menu at the current mouse position.
this.menu.open(event.clientX, event.clientY);
// Indicate success.
return true;
}
function normalizeTabAreaConfig(config: DockLayout.ITabAreaConfig, widgetSet: Set): DockLayout.ITabAreaConfig | null {
// Bail early if there is no content.
if (config.widgets.length === 0) {
return null;
}
// Setup the filtered widgets array.
let widgets: Widget[] = [];
// Filter the config for unique widgets.
each(config.widgets, widget => {
if (!widgetSet.has(widget)) {
widgetSet.add(widget);
widgets.push(widget);
}
});
// Bail if there are no effective widgets.
if (widgets.length === 0) {
return null;
}
// Normalize the current index.
let index = config.currentIndex;
if (index !== -1 && (index < 0 || index >= widgets.length)) {
index = 0;
}
dispose(): void {
// Dispose of the widgets and layout items.
each(this._items, item => {
let widget = item.widget;
item.dispose();
widget.dispose();
});
// Clear the layout state.
this._box = null;
this._items.length = 0;
this._rowStarts.length = 0;
this._rowSizers.length = 0;
this._columnStarts.length = 0;
this._columnSizers.length = 0;
// Dispose of the rest of the layout.
super.dispose();
}
function disconnectAll(object: any): void {
// Clear and cleanup any receiver connections.
let receivers = receiversForSender.get(object);
if (receivers && receivers.length > 0) {
each(receivers, connection => { connection.signal = null; });
scheduleCleanup(receivers);
}
// Clear and cleanup any sender connections.
let senders = sendersForReceiver.get(object);
if (senders && senders.length > 0) {
each(senders, connection => { connection.signal = null; });
scheduleCleanup(senders);
}
}
function disconnectAll(object: any): void {
// Clear and cleanup any receiver connections.
let receivers = receiversForSender.get(object);
if (receivers && receivers.length > 0) {
each(receivers, connection => { connection.signal = null; });
scheduleCleanup(receivers);
}
// Clear and cleanup any sender connections.
let senders = sendersForReceiver.get(object);
if (senders && senders.length > 0) {
each(senders, connection => { connection.signal = null; });
scheduleCleanup(senders);
}
}
function killSessions(id: string, baseUrl: string): void {
let running = runningSessions.get(baseUrl) || [];
each(running.slice(), session => {
if (session.id === id) {
session.dispose();
}
});
}
holdSizes(): void {
each(this.sizers, sizer => { sizer.sizeHint = sizer.size; });
}
function clear(node: Node): void {
if (node.type === NodeType.Branch) {
each(node.children, clear);
node.children.length = 0;
node.sizes.length = 0;
node.items.length = 0;
} else {
node.items.length = 0;
node.next = null;
node.prev = null;
}
}
fts.forEach(ft => {
if (ft.name in this._widgetFactoriesForFileType) {
each(this._widgetFactoriesForFileType[ft.name], n => {
factories.add(n);
});
}
});