-
-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
91 additions
and
1 deletion.
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
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
54 changes: 54 additions & 0 deletions
54
arduino-ide-extension/src/browser/dialogs/temp-sketch-dialog.ts
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,54 @@ | ||
import { nls } from "@theia/core"; | ||
import { AbstractDialog, Dialog, DialogProps, Message } from "@theia/core/lib/browser"; | ||
import { inject } from "@theia/core/shared/inversify"; | ||
|
||
export class TempSketchDialog extends AbstractDialog<TempSketchDialog.Options> { | ||
protected readonly dontSaveButton: HTMLButtonElement; | ||
protected _value: TempSketchDialog.Options = 'Cancel'; | ||
|
||
get value(): TempSketchDialog.Options { | ||
return this._value; | ||
} | ||
|
||
constructor( | ||
@inject(DialogProps) props: DialogProps | ||
) { | ||
super(props); | ||
const messageNode = document.createElement('div'); | ||
messageNode.textContent = nls.localize('arduino/sketch/saveTempSketch', 'Save your sketch to open it again later.'); | ||
this.contentNode.appendChild(messageNode); | ||
this.dontSaveButton = this.createButton(nls.localizeByDefault(TempSketchDialog.Values["Don't Save"])); | ||
this.dontSaveButton.classList.add('secondary'); | ||
this.controlPanel.appendChild(this.dontSaveButton); | ||
this.appendCloseButton(Dialog.CANCEL); | ||
this.appendAcceptButton(nls.localizeByDefault(TempSketchDialog.Values['Save As...'])); | ||
} | ||
|
||
protected onAfterAttach(msg: Message): void { | ||
super.onAfterAttach(msg); | ||
this.addAction(this.dontSaveButton, () => this.dontSave(), 'click'); | ||
} | ||
|
||
protected addAcceptAction<K extends keyof HTMLElementEventMap>(element: HTMLElement, ...additionalEventTypes: K[]): void { | ||
this.addAction(element, () => this.doSave(), 'click'); | ||
} | ||
|
||
protected dontSave(): void { | ||
this._value = TempSketchDialog.Values["Don't Save"]; | ||
this.accept(); | ||
} | ||
|
||
protected doSave(): void { | ||
this._value = TempSketchDialog.Values['Save As...']; | ||
this.accept(); | ||
} | ||
} | ||
|
||
export namespace TempSketchDialog { | ||
export const enum Values { | ||
"Don't Save" = "Don't Save", | ||
Cancel = 'Cancel', | ||
'Save As...' = 'Save As...', | ||
}; | ||
export type Options = keyof typeof Values; | ||
} |
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