forked from eclipsesource/theia-tree-editor-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display error message, dirty indicator and title icon
- Loading branch information
1 parent
eaf4478
commit a16ef93
Showing
4 changed files
with
53 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ResourceSaveable } from './ResourceSaveable'; | ||
import { unmanaged } from 'inversify'; | ||
import { WidgetManager} from "@theia/core/lib/browser"; | ||
import { MessageService, Resource } from '@theia/core/lib/common'; | ||
import { DIRTY_CLASS, TreeEditorWidget } from './theia-tree-editor-widget'; | ||
import * as _ from 'lodash'; | ||
|
||
export class DirtyResourceSavable extends ResourceSaveable { | ||
private _widgetManager: WidgetManager; | ||
private _messageService: MessageService; | ||
|
||
constructor( | ||
resource: Resource, | ||
getData: () => any, | ||
@unmanaged() widgetManager: WidgetManager, | ||
@unmanaged() messageService: MessageService | ||
) { | ||
super(resource, getData); | ||
|
||
this._widgetManager = widgetManager; | ||
this._messageService = messageService; | ||
} | ||
|
||
onSaveSuccess = () => { | ||
const widget = _.head(this._widgetManager.getWidgets('theia-tree-editor')) as TreeEditorWidget; | ||
const dirtyClass = ` ${DIRTY_CLASS}`; | ||
widget.title.className = widget.title.className.replace(dirtyClass, ''); | ||
|
||
} | ||
|
||
onSaveFailure = () => { | ||
this._messageService.error('Cannot Save: Undefined Resource'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters