|
@@ -1,10 +1,18 @@
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
|
|
|
|
|
+import {
|
|
|
|
+ each
|
|
|
|
+} from 'phosphor/lib/algorithm/iteration';
|
|
|
|
+
|
|
import {
|
|
import {
|
|
DisposableSet
|
|
DisposableSet
|
|
} from 'phosphor/lib/core/disposable';
|
|
} from 'phosphor/lib/core/disposable';
|
|
|
|
|
|
|
|
+import {
|
|
|
|
+ FocusTracker
|
|
|
|
+} from 'phosphor/lib/ui/focustracker';
|
|
|
|
+
|
|
import {
|
|
import {
|
|
Menu
|
|
Menu
|
|
} from 'phosphor/lib/ui/menu';
|
|
} from 'phosphor/lib/ui/menu';
|
|
@@ -37,10 +45,6 @@ import {
|
|
IServiceManager
|
|
IServiceManager
|
|
} from '../services';
|
|
} from '../services';
|
|
|
|
|
|
-import {
|
|
|
|
- WidgetTracker
|
|
|
|
-} from '../widgettracker';
|
|
|
|
-
|
|
|
|
import {
|
|
import {
|
|
FileBrowserModel, FileBrowserWidget, IPathTracker, IWidgetOpener
|
|
FileBrowserModel, FileBrowserWidget, IPathTracker, IWidgetOpener
|
|
} from './';
|
|
} from './';
|
|
@@ -82,7 +86,7 @@ const cmdIds = {
|
|
*/
|
|
*/
|
|
function activateFileBrowser(app: JupyterLab, manager: IServiceManager, registry: IDocumentRegistry, mainMenu: IMainMenu, palette: ICommandPalette): IPathTracker {
|
|
function activateFileBrowser(app: JupyterLab, manager: IServiceManager, registry: IDocumentRegistry, mainMenu: IMainMenu, palette: ICommandPalette): IPathTracker {
|
|
let id = 0;
|
|
let id = 0;
|
|
- let tracker = new WidgetTracker<Widget>();
|
|
|
|
|
|
+ let tracker = new FocusTracker<Widget>();
|
|
|
|
|
|
let opener: IWidgetOpener = {
|
|
let opener: IWidgetOpener = {
|
|
open: widget => {
|
|
open: widget => {
|
|
@@ -91,7 +95,7 @@ function activateFileBrowser(app: JupyterLab, manager: IServiceManager, registry
|
|
}
|
|
}
|
|
if (!widget.isAttached) {
|
|
if (!widget.isAttached) {
|
|
app.shell.addToMainArea(widget);
|
|
app.shell.addToMainArea(widget);
|
|
- tracker.addWidget(widget);
|
|
|
|
|
|
+ tracker.add(widget);
|
|
}
|
|
}
|
|
app.shell.activateMain(widget.id);
|
|
app.shell.activateMain(widget.id);
|
|
}
|
|
}
|
|
@@ -165,7 +169,7 @@ function activateFileBrowser(app: JupyterLab, manager: IServiceManager, registry
|
|
/**
|
|
/**
|
|
* Add the filebrowser commands to the application's command registry.
|
|
* Add the filebrowser commands to the application's command registry.
|
|
*/
|
|
*/
|
|
-function addCommands(app: JupyterLab, tracker: WidgetTracker<Widget>, fbWidget: FileBrowserWidget, docManager: DocumentManager): void {
|
|
|
|
|
|
+function addCommands(app: JupyterLab, tracker: FocusTracker<Widget>, fbWidget: FileBrowserWidget, docManager: DocumentManager): void {
|
|
let commands = app.commands;
|
|
let commands = app.commands;
|
|
let fbModel = fbWidget.model;
|
|
let fbModel = fbWidget.model;
|
|
|
|
|
|
@@ -181,8 +185,8 @@ function addCommands(app: JupyterLab, tracker: WidgetTracker<Widget>, fbWidget:
|
|
label: 'Save',
|
|
label: 'Save',
|
|
caption: 'Save and create checkpoint',
|
|
caption: 'Save and create checkpoint',
|
|
execute: () => {
|
|
execute: () => {
|
|
- if (tracker.activeWidget) {
|
|
|
|
- let context = docManager.contextForWidget(tracker.activeWidget);
|
|
|
|
|
|
+ if (tracker.currentWidget) {
|
|
|
|
+ let context = docManager.contextForWidget(tracker.currentWidget);
|
|
return context.save().then(() => {
|
|
return context.save().then(() => {
|
|
return context.createCheckpoint();
|
|
return context.createCheckpoint();
|
|
});
|
|
});
|
|
@@ -193,8 +197,8 @@ function addCommands(app: JupyterLab, tracker: WidgetTracker<Widget>, fbWidget:
|
|
label: 'Revert to Checkpoint',
|
|
label: 'Revert to Checkpoint',
|
|
caption: 'Revert contents to previous checkpoint',
|
|
caption: 'Revert contents to previous checkpoint',
|
|
execute: () => {
|
|
execute: () => {
|
|
- if (tracker.activeWidget) {
|
|
|
|
- let context = docManager.contextForWidget(tracker.activeWidget);
|
|
|
|
|
|
+ if (tracker.currentWidget) {
|
|
|
|
+ let context = docManager.contextForWidget(tracker.currentWidget);
|
|
context.restoreCheckpoint().then(() => {
|
|
context.restoreCheckpoint().then(() => {
|
|
context.revert();
|
|
context.revert();
|
|
});
|
|
});
|
|
@@ -205,8 +209,8 @@ function addCommands(app: JupyterLab, tracker: WidgetTracker<Widget>, fbWidget:
|
|
label: 'Save As...',
|
|
label: 'Save As...',
|
|
caption: 'Save with new path and create checkpoint',
|
|
caption: 'Save with new path and create checkpoint',
|
|
execute: () => {
|
|
execute: () => {
|
|
- if (tracker.activeWidget) {
|
|
|
|
- let context = docManager.contextForWidget(tracker.activeWidget);
|
|
|
|
|
|
+ if (tracker.currentWidget) {
|
|
|
|
+ let context = docManager.contextForWidget(tracker.currentWidget);
|
|
return context.saveAs().then(() => {
|
|
return context.saveAs().then(() => {
|
|
return context.createCheckpoint();
|
|
return context.createCheckpoint();
|
|
}).then(() => {
|
|
}).then(() => {
|
|
@@ -224,17 +228,15 @@ function addCommands(app: JupyterLab, tracker: WidgetTracker<Widget>, fbWidget:
|
|
commands.addCommand(cmdIds.close, {
|
|
commands.addCommand(cmdIds.close, {
|
|
label: 'Close',
|
|
label: 'Close',
|
|
execute: () => {
|
|
execute: () => {
|
|
- if (tracker.activeWidget) {
|
|
|
|
- tracker.activeWidget.close();
|
|
|
|
|
|
+ if (tracker.currentWidget) {
|
|
|
|
+ tracker.currentWidget.close();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
commands.addCommand(cmdIds.closeAll, {
|
|
commands.addCommand(cmdIds.closeAll, {
|
|
label: 'Close All',
|
|
label: 'Close All',
|
|
execute: () => {
|
|
execute: () => {
|
|
- for (let widget of tracker.widgets) {
|
|
|
|
- widget.close();
|
|
|
|
- }
|
|
|
|
|
|
+ each(tracker.widgets, widget => widget.close());
|
|
}
|
|
}
|
|
});
|
|
});
|
|
commands.addCommand(cmdIds.showBrowser, {
|
|
commands.addCommand(cmdIds.showBrowser, {
|