it('should create a reverse iterator over the nodes', () => { let list = LinkedList.from([0, 1, 2, 3, 4]); let n = find(list.nodes(), n => n.value === 2)!; let it1 = new LinkedList.RetroNodeIterator(n); let it2 = it1.clone(); let v1 = map(it1, n => n.value); let v2 = map(it2, n => n.value); expect(it1.iter()).to.equal(it1); expect(it2.iter()).to.equal(it2); expect(toArray(v1)).to.deep.equal([2, 1, 0]); expect(toArray(v2)).to.deep.equal([2, 1, 0]); });
it('should return an iterator over the list nodes', () => { let data = [0, 1, 2, 3, 4, 5]; let list = LinkedList.from(data); let it1 = list.nodes(); let it2 = it1.clone(); let v1 = map(it1, n => n.value); let v2 = map(it2, n => n.value); expect(it1.iter()).to.equal(it1); expect(it2.iter()).to.equal(it2); expect(toArray(v1)).to.deep.equal(data); expect(toArray(v2)).to.deep.equal(data); });
/** * Create a dialog panel instance. * * @param options - The dialog setup options. */ constructor(options: Dialog.IOptions={}) { super(); this.addClass('jp-Dialog'); options = Private.handleOptions(options); let renderer = options.renderer; this._host = options.host; this._defaultButton = options.defaultButton; this._buttons = options.buttons; this._buttonNodes = toArray(map(this._buttons, button => { return renderer.createButtonNode(button); })); this._primary = ( options.primaryElement || this._buttonNodes[this._defaultButton] ); let layout = this.layout = new PanelLayout(); let content = new Panel(); content.addClass('jp-Dialog-content'); layout.addWidget(content); let header = renderer.createHeader(options.title); let body = renderer.createBody(options.body); let footer = renderer.createFooter(this._buttonNodes); content.addWidget(header); content.addWidget(body); content.addWidget(footer); }
node.addEventListener('contextmenu', (event: MouseEvent) => { event.preventDefault(); let path = fbWidget.pathForClick(event) || ''; let ext = DocumentRegistry.extname(path); let factories = registry.preferredWidgetFactories(ext); let widgetNames = toArray(map(factories, factory => factory.name)); let prefix = `${namespace}-contextmenu-${++Private.id}`; let openWith: Menu = null; if (path && widgetNames.length > 1) { let disposables = new DisposableSet(); let command: string; openWith = new Menu({ commands }); openWith.title.label = 'Open With...'; openWith.disposed.connect(() => { disposables.dispose(); }); for (let widgetName of widgetNames) { command = `${prefix}:${widgetName}`; disposables.add(commands.addCommand(command, { execute: () => fbWidget.openPath(path, widgetName), label: widgetName })); openWith.addItem({ command }); } } let menu = createContextMenu(fbWidget, openWith); menu.open(event.clientX, event.clientY); });
execute: () => { const widget = tracker.currentWidget; if (!widget) { return; } return Promise.all(toArray(map(widget.selectedItems(), item => { return commands.execute('docmanager:open-browser-tab', { path: item.path }); }))); },
execute: () => { const widget = tracker.currentWidget; if (!widget) { return; } return Promise.all(toArray(map(widget.selectedItems(), item => { if (item.type === 'directory') { return widget.model.cd(item.path); } return commands.execute('docmanager:open', { path: item.path }); }))); },
execute: args => { const factory = (args['factory'] as string) || void 0; const widget = tracker.currentWidget; if (!widget) { return; } return Promise.all( toArray( map(widget.selectedItems(), item => { if (item.type === 'directory') { return widget.model.cd(item.name); } return commands.execute('docmanager:open', { factory: factory, path: item.path }); }) ) ); },
protected onBeforeAttach(msg: Message): void { // clear the current menu items this.clearItems(); // get the widget factories that could be used to open all of the items // in the current filebrowser selection let factories = OpenWithMenu._intersection( map(tracker.currentWidget.selectedItems(), i => { return OpenWithMenu._getFactories(i); }) ); if (factories) { // make new menu items from the widget factories factories.forEach(factory => { this.addItem({ args: { factory: factory }, command: CommandIDs.open }); }); } super.onBeforeAttach(msg); }
/** * Create a dialog panel instance. * * @param options - The dialog setup options. */ constructor(options: Partial<Dialog.IOptions<T>>={}) { super(); this.addClass('jp-Dialog'); let normalized = Private.handleOptions(options); let renderer = normalized.renderer; this._host = normalized.host; this._defaultButton = normalized.defaultButton; this._buttons = normalized.buttons; this._buttonNodes = toArray(map(this._buttons, button => { return renderer.createButtonNode(button); })); let layout = this.layout = new PanelLayout(); let content = new Panel(); content.addClass('jp-Dialog-content'); layout.addWidget(content); this._body = normalized.body; let header = renderer.createHeader(normalized.title); let body = renderer.createBody(normalized.body); let footer = renderer.createFooter(this._buttonNodes); content.addWidget(header); content.addWidget(body); content.addWidget(footer); this._primary = this._buttonNodes[this._defaultButton]; if (options.focusNodeSelector) { let el = body.node.querySelector(options.focusNodeSelector); if (el) { this._primary = el as HTMLElement; } } }
/** * Get an iterator over the ordered toolbar item names. * * @returns An iterator over the toolbar item names. */ names(): IIterator<string> { let layout = this.layout as PanelLayout; return map(layout.widgets, widget => { return Private.nameProperty.get(widget); }); }