當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript notification.INotificationHandle類代碼示例

本文整理匯總了TypeScript中vs/platform/notification/common/notification.INotificationHandle的典型用法代碼示例。如果您正苦於以下問題:TypeScript INotificationHandle類的具體用法?TypeScript INotificationHandle怎麽用?TypeScript INotificationHandle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了INotificationHandle類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: prompt

    public prompt(severity: Severity, message: string, choices: PromptOption[]): TPromise<number> {
        let handle: INotificationHandle;

        const promise = new TPromise<number>(c => {

            // Complete promise with index of action that was picked
            const callback = (index: number, closeNotification: boolean) => () => {
                c(index);

                if (closeNotification) {
                    handle.dispose();
                }

                return TPromise.as(void 0);
            };

            // Convert choices into primary/secondary actions
            const actions: INotificationActions = {
                primary: [],
                secondary: []
            };

            choices.forEach((choice, index) => {
                let isPrimary = true;
                let label: string;
                let closeNotification = false;

                if (typeof choice === 'string') {
                    label = choice;
                } else {
                    isPrimary = false;
                    label = choice.label;
                    closeNotification = !choice.keepOpen;
                }

                const action = new Action(`workbench.dialog.choice.${index}`, label, null, true, callback(index, closeNotification));
                if (isPrimary) {
                    actions.primary.push(action);
                } else {
                    actions.secondary.push(action);
                }
            });

            // Show notification with actions
            handle = this.notify({ severity, message, actions });

            // Cancel promise when notification gets disposed
            once(handle.onDidDispose)(() => promise.cancel());

        }, () => handle.dispose());

        return promise;
    }
開發者ID:sameer-coder,項目名稱:vscode,代碼行數:53,代碼來源:notificationService.ts

示例2: prompt

    public prompt(severity: Severity, message: string, choices: IPromptChoice[], onCancel?: () => void): INotificationHandle {
        let handle: INotificationHandle;
        let choiceClicked = false;

        // Convert choices into primary/secondary actions
        const actions: INotificationActions = { primary: [], secondary: [] };
        choices.forEach((choice, index) => {
            const action = new Action(`workbench.dialog.choice.${index}`, choice.label, null, true, () => {
                choiceClicked = true;

                // Pass to runner
                choice.run();

                // Close notification unless we are told to keep open
                if (!choice.keepOpen) {
                    handle.close();
                }

                return TPromise.as(void 0);
            });

            if (!choice.isSecondary) {
                actions.primary.push(action);
            } else {
                actions.secondary.push(action);
            }
        });

        // Show notification with actions
        handle = this.notify({ severity, message, actions });

        once(handle.onDidClose)(() => {

            // Cleanup when notification gets disposed
            dispose(...actions.primary, ...actions.secondary);

            // Indicate cancellation to the outside if no action was executed
            if (!choiceClicked && typeof onCancel === 'function') {
                onCancel();
            }
        });

        return handle;
    }
開發者ID:AllureFer,項目名稱:vscode,代碼行數:44,代碼來源:notificationService.ts

示例3:

            const callback = (index: number, closeNotification: boolean) => () => {
                c(index);

                if (closeNotification) {
                    handle.dispose();
                }

                return TPromise.as(void 0);
            };
開發者ID:sameer-coder,項目名稱:vscode,代碼行數:9,代碼來源:notificationService.ts

示例4: Action

            const action = new Action(`workbench.dialog.choice.${index}`, choice.label, null, true, () => {
                choiceClicked = true;

                // Pass to runner
                choice.run();

                // Close notification unless we are told to keep open
                if (!choice.keepOpen) {
                    handle.close();
                }

                return TPromise.as(void 0);
            });
開發者ID:AllureFer,項目名稱:vscode,代碼行數:13,代碼來源:notificationService.ts


注:本文中的vs/platform/notification/common/notification.INotificationHandle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。