|
@@ -45,13 +45,16 @@ class MainAreaWidget<T extends Widget = Widget> extends Widget {
|
|
|
|
|
|
const content = this.content = options.content;
|
|
const content = this.content = options.content;
|
|
const toolbar = this.toolbar = options.toolbar || new Toolbar();
|
|
const toolbar = this.toolbar = options.toolbar || new Toolbar();
|
|
|
|
+ const spinner = this._spinner;
|
|
|
|
|
|
const layout = this.layout = new BoxLayout({spacing: 0});
|
|
const layout = this.layout = new BoxLayout({spacing: 0});
|
|
layout.direction = 'top-to-bottom';
|
|
layout.direction = 'top-to-bottom';
|
|
- layout.addWidget(toolbar);
|
|
|
|
- layout.addWidget(content);
|
|
|
|
|
|
+
|
|
BoxLayout.setStretch(toolbar, 0);
|
|
BoxLayout.setStretch(toolbar, 0);
|
|
BoxLayout.setStretch(content, 1);
|
|
BoxLayout.setStretch(content, 1);
|
|
|
|
+ BoxLayout.setStretch(spinner, 1);
|
|
|
|
+
|
|
|
|
+ layout.addWidget(toolbar);
|
|
|
|
|
|
if (!content.id) {
|
|
if (!content.id) {
|
|
content.id = uuid();
|
|
content.id = uuid();
|
|
@@ -65,29 +68,32 @@ class MainAreaWidget<T extends Widget = Widget> extends Widget {
|
|
content.disposed.connect(() => this.dispose());
|
|
content.disposed.connect(() => this.dispose());
|
|
|
|
|
|
if (options.populated) {
|
|
if (options.populated) {
|
|
- this.node.appendChild(this._spinner.node);
|
|
|
|
|
|
+ layout.addWidget(spinner);
|
|
this.populated = options.populated;
|
|
this.populated = options.populated;
|
|
this.populated.then(() => {
|
|
this.populated.then(() => {
|
|
this._isPopulated = true;
|
|
this._isPopulated = true;
|
|
- const active = document.activeElement;
|
|
|
|
- this.node.removeChild(this._spinner.node);
|
|
|
|
- if (active === this._spinner.node) {
|
|
|
|
|
|
+ const active = document.activeElement === spinner.node;
|
|
|
|
+ spinner.dispose();
|
|
|
|
+ layout.addWidget(content);
|
|
|
|
+ if (active) {
|
|
this._focusContent();
|
|
this._focusContent();
|
|
}
|
|
}
|
|
- this._spinner.dispose();
|
|
|
|
- // Catch a population error.
|
|
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
- this.node.removeChild(this._spinner.node);
|
|
|
|
- this._spinner.dispose();
|
|
|
|
|
|
+ // Catch a population error.
|
|
|
|
+ const error = new Widget();
|
|
// Show the error to the user.
|
|
// Show the error to the user.
|
|
const pre = document.createElement('pre');
|
|
const pre = document.createElement('pre');
|
|
pre.textContent = String(e);
|
|
pre.textContent = String(e);
|
|
- this.node.appendChild(pre);
|
|
|
|
|
|
+ error.node.appendChild(pre);
|
|
|
|
+ BoxLayout.setStretch(error, 1);
|
|
|
|
+ spinner.dispose();
|
|
|
|
+ layout.addWidget(error);
|
|
});
|
|
});
|
|
// Handle no populated promise.
|
|
// Handle no populated promise.
|
|
} else {
|
|
} else {
|
|
|
|
+ spinner.dispose();
|
|
|
|
+ layout.addWidget(content);
|
|
this._isPopulated = true;
|
|
this._isPopulated = true;
|
|
- this._spinner.dispose();
|
|
|
|
this.populated = Promise.resolve(void 0);
|
|
this.populated = Promise.resolve(void 0);
|
|
}
|
|
}
|
|
}
|
|
}
|