Merge pull request #29 from bcmi-labs/PROEDITOR-20

PROEDITOR-20: Restored the dirt flag in editor tab
This commit is contained in:
Luca Cipriani 2019-07-25 16:52:50 +02:00 committed by GitHub
commit df7225c32b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 28 deletions

View File

@ -46,8 +46,6 @@ import { SilentMonacoStatusBarContribution } from './customization/silent-monaco
import { ApplicationShell } from '@theia/core/lib/browser';
import { CustomApplicationShell } from './customization/custom-application-shell';
import { CustomFrontendApplication } from './customization/custom-frontend-application';
import { EditorWidgetFactory } from '@theia/editor/lib/browser/editor-widget-factory';
import { CustomEditorWidgetFactory } from './customization/custom-editor-widget-factory';
import { SelectBoardDialog, SelectBoardDialogProps } from './boards/select-board-dialog';
import { SelectBoardDialogWidget } from './boards/select-board-dialog-widget';
const ElementQueries = require('css-element-queries/src/ElementQueries');
@ -156,6 +154,4 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
bind(ApplicationShell).to(CustomApplicationShell).inSingletonScope();
unbind(FrontendApplication);
bind(FrontendApplication).to(CustomFrontendApplication).inSingletonScope();
unbind(EditorWidgetFactory);
bind(EditorWidgetFactory).to(CustomEditorWidgetFactory).inSingletonScope();
});

View File

@ -1,7 +1,33 @@
import { ApplicationShell } from "@theia/core/lib/browser";
import { ApplicationShell, Widget, Saveable, FocusTracker, Message } from '@theia/core/lib/browser';
import { EditorWidget } from '@theia/editor/lib/browser';
export class CustomApplicationShell extends ApplicationShell {
protected refreshBottomPanelToggleButton() {
}
protected async track(widget: Widget): Promise<void> {
const tracker = (this as any).tracker as FocusTracker<Widget>;
tracker.add(widget);
this.disableClose(Saveable.apply(widget));
if (ApplicationShell.TrackableWidgetProvider.is(widget)) {
for (const toTrack of await widget.getTrackableWidgets()) {
tracker.add(toTrack);
this.disableClose(Saveable.apply(toTrack));
}
if (widget.onDidChangeTrackableWidgets) {
widget.onDidChangeTrackableWidgets(widgets => widgets.forEach(w => this.track(w)));
}
}
}
private disableClose(widget: Widget | undefined): void {
if (widget instanceof EditorWidget) {
const onCloseRequest = (_: Message) => {
// NOOP
};
(widget as any).onCloseRequest = onCloseRequest.bind(widget);
}
}
}

View File

@ -1,22 +0,0 @@
import { injectable } from "inversify";
import { EditorWidgetFactory } from "@theia/editor/lib/browser/editor-widget-factory";
import URI from "@theia/core/lib/common/uri";
import { EditorWidget } from "@theia/editor/lib/browser";
@injectable()
export class CustomEditorWidgetFactory extends EditorWidgetFactory {
protected async createEditor(uri: URI): Promise<EditorWidget> {
const icon = await this.labelProvider.getIcon(uri);
return this.editorProvider(uri).then(textEditor => {
const newEditor = new EditorWidget(textEditor, this.selectionService);
newEditor.id = this.id + ':' + uri.toString();
newEditor.title.closable = false;
newEditor.title.label = this.labelProvider.getName(uri);
newEditor.title.iconClass = icon + ' file-icon';
newEditor.title.caption = this.labelProvider.getLongName(uri);
return newEditor;
});
}
}

View File

@ -0,0 +1,13 @@
/* Do not show the `close` icon for editor, but show the dirty state. */
.p-TabBar.theia-app-centers .p-TabBar-tab.p-mod-closable:hover > .p-TabBar-tabCloseIcon,
.p-TabBar.theia-app-centers .p-TabBar-tab.p-mod-current > .p-TabBar-tabCloseIcon {
background-image: none;
cursor: pointer;
}
.p-TabBar.theia-app-centers .p-TabBar-tab.p-mod-closable.theia-mod-dirty:hover > .p-TabBar-tabCloseIcon,
.p-TabBar.theia-app-centers .p-TabBar-tab.p-mod-closable.theia-mod-dirty > .p-TabBar-tabCloseIcon:hover {
background-size: 10px;
background-image: var(--theia-icon-circle);
cursor: pointer;
}

View File

@ -1,3 +1,4 @@
@import './list-widget.css';
@import './board-select-dialog.css';
@import './main.css';
@import './editor.css';