Made the editors closeable in pro mode.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2019-11-26 10:33:59 +01:00
parent a2a9cbb02e
commit 4e683b237d

View File

@ -1,22 +1,35 @@
import { ApplicationShell, Widget, Saveable, FocusTracker, Message } from '@theia/core/lib/browser'; import { ApplicationShell, Widget, Saveable, FocusTracker, Message } from '@theia/core/lib/browser';
import { EditorWidget } from '@theia/editor/lib/browser'; import { EditorWidget } from '@theia/editor/lib/browser';
import { injectable, inject } from 'inversify';
import { EditorMode } from '../editor-mode';
@injectable()
export class ArduinoApplicationShell extends ApplicationShell { export class ArduinoApplicationShell extends ApplicationShell {
@inject(EditorMode)
protected readonly editorMode: EditorMode;
protected refreshBottomPanelToggleButton() { protected refreshBottomPanelToggleButton() {
if (this.editorMode.proMode) {
super.refreshBottomPanelToggleButton();
}
} }
protected async track(widget: Widget): Promise<void> { protected async track(widget: Widget): Promise<void> {
const tracker = (this as any).tracker as FocusTracker<Widget>; if (this.editorMode.proMode) {
tracker.add(widget); super.track(widget);
this.disableClose(Saveable.apply(widget)); } else {
if (ApplicationShell.TrackableWidgetProvider.is(widget)) { const tracker = (this as any).tracker as FocusTracker<Widget>;
for (const toTrack of await widget.getTrackableWidgets()) { tracker.add(widget);
tracker.add(toTrack); this.disableClose(Saveable.apply(widget));
this.disableClose(Saveable.apply(toTrack)); if (ApplicationShell.TrackableWidgetProvider.is(widget)) {
} for (const toTrack of await widget.getTrackableWidgets()) {
if (widget.onDidChangeTrackableWidgets) { tracker.add(toTrack);
widget.onDidChangeTrackableWidgets(widgets => widgets.forEach(w => this.track(w))); this.disableClose(Saveable.apply(toTrack));
}
if (widget.onDidChangeTrackableWidgets) {
widget.onDidChangeTrackableWidgets(widgets => widgets.forEach(w => this.track(w)));
}
} }
} }
} }