Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -6,25 +6,37 @@
'use strict';
import 'vs/css!sql/media/icons/common-icons';
import 'vs/css!./media/errorMessageDialog';
import { Button } from 'sql/base/browser/ui/button/button';
import { Modal } from 'sql/base/browser/ui/modal/modal';
import * as TelemetryKeys from 'sql/common/telemetryKeys';
import { attachModalDialogStyler } from 'sql/common/theme/styler';
import { attachButtonStyler, attachModalDialogStyler } from 'sql/common/theme/styler';
import { Builder } from 'vs/base/browser/builder';
import Severity from 'vs/base/common/severity';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachButtonStyler } from 'vs/platform/theme/common/styler';
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import Event, { Emitter } from 'vs/base/common/event';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { localize } from 'vs/nls';
import { IAction } from 'vs/base/common/actions';
const maxActions = 1;
export class ErrorMessageDialog extends Modal {
private _body: HTMLElement;
private _okButton: Button;
private _copyButton: Button;
private _actionButtons: Button[];
private _actions: IAction[];
private _severity: Severity;
private _message: string;
private _messageDetails: string;
private _okLabel: string;
private _closeLabel: string;
private _onOk = new Emitter<void>();
public onOk: Event<void> = this._onOk.event;
@@ -37,6 +49,8 @@ export class ErrorMessageDialog extends Modal {
@IContextKeyService contextKeyService: IContextKeyService
) {
super('', TelemetryKeys.ErrorMessage, partService, telemetryService, contextKeyService, { isFlyout: false, hasTitleIcon: true });
this._okLabel = localize('OK', 'OK');
this._closeLabel = localize('close', 'Close');
}
protected renderBody(container: HTMLElement) {
@@ -47,12 +61,37 @@ export class ErrorMessageDialog extends Modal {
public render() {
super.render();
attachModalDialogStyler(this, this._themeService);
let copyButton = this.addFooterButton('Copy to Clipboard', () => this._clipboardService.writeText(this._message), 'left');
copyButton.icon = 'icon scriptToClipboard';
attachButtonStyler(copyButton, this._themeService, { buttonBackground: SIDE_BAR_BACKGROUND, buttonHoverBackground: SIDE_BAR_BACKGROUND });
let okButton = this.addFooterButton('OK', () => this.ok());
attachButtonStyler(okButton, this._themeService);
this._register(attachModalDialogStyler(this, this._themeService));
this.createCopyButton();
this._actionButtons = [];
for (let i = 0; i < maxActions; i++) {
this._actionButtons.unshift(this.createStandardButton('Action', () => this.onActionSelected(i)));
}
this._okButton = this.addFooterButton(this._okLabel, () => this.ok());
this._register(attachButtonStyler(this._okButton, this._themeService));
}
private createCopyButton() {
let copyButtonLabel = localize('copyDetails', 'Copy details');
this._copyButton = this.addFooterButton(copyButtonLabel, () => this._clipboardService.writeText(this._messageDetails), 'left');
this._copyButton.icon = 'icon scriptToClipboard';
this._copyButton.getElement().title = copyButtonLabel;
this._register(attachButtonStyler(this._copyButton, this._themeService, { buttonBackground: SIDE_BAR_BACKGROUND, buttonHoverBackground: SIDE_BAR_BACKGROUND }));
}
private createStandardButton(label: string, onSelect: () => void): Button {
let button = this.addFooterButton(label, onSelect, 'right');
this._register(attachButtonStyler(button, this._themeService));
return button;
}
private onActionSelected(index: number): void {
// Call OK so it always closes
this.ok();
// Run the action if possible
if (this._actions && index < this._actions.length) {
this._actions[index].run();
}
}
protected layout(height?: number): void {
@@ -99,13 +138,39 @@ export class ErrorMessageDialog extends Modal {
this.hide();
}
public open(severity: Severity, headerTitle: string, message: string) {
public open(severity: Severity, headerTitle: string, message: string, messageDetails: string, actions: IAction[]) {
this._severity = severity;
this._message = message;
this.title = headerTitle;
this._messageDetails = messageDetails;
if (this._messageDetails) {
this._copyButton.getElement().style.visibility = 'visible';
} else {
this._copyButton.getElement().style.visibility = 'hidden';
}
this.resetActions();
if (actions && actions.length > 0) {
for (let i = 0; i < maxActions && i < actions.length; i++) {
this._actions.push(actions[i]);
let button = this._actionButtons[i];
button.label = actions[i].label;
button.getElement().style.visibility = 'visible';
}
this._okButton.label = this._closeLabel;
} else {
this._okButton.label = this._okLabel;
}
this.updateIconTitle();
this.updateDialogBody();
this.show();
this._okButton.focus();
}
private resetActions(): void {
this._actions = [];
for(let actionButton of this._actionButtons) {
actionButton.getElement().style.visibility = 'hidden';
}
}
public dispose(): void {

View File

@@ -11,6 +11,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IErrorMessageService } from 'sql/parts/connection/common/connectionManagement';
import { ErrorMessageDialog } from 'sql/workbench/errorMessageDialog/errorMessageDialog';
import { IAction } from 'vs/base/common/actions';
export class ErrorMessageService implements IErrorMessageService {
@@ -25,11 +26,11 @@ export class ErrorMessageService implements IErrorMessageService {
@IInstantiationService private _instantiationService: IInstantiationService
) { }
public showDialog(severity: Severity, headerTitle: string, message: string): void {
this.doShowDialog(severity, headerTitle, message);
public showDialog(severity: Severity, headerTitle: string, message: string, messageDetails?: string, actions?: IAction[]): void {
this.doShowDialog(severity, headerTitle, message, messageDetails, actions);
}
private doShowDialog(severity: Severity, headerTitle: string, message: string): void {
private doShowDialog(severity: Severity, headerTitle: string, message: string, messageDetails: string, actions?: IAction[]): void {
if (!this._errorDialog) {
this._errorDialog = this._instantiationService.createInstance(ErrorMessageDialog);
this._errorDialog.onOk(() => this.handleOnOk());
@@ -37,7 +38,7 @@ export class ErrorMessageService implements IErrorMessageService {
}
let title = headerTitle ? headerTitle : this.getDefaultTitle(severity);
return this._errorDialog.open(severity, title, message);
return this._errorDialog.open(severity, title, message, messageDetails, actions);
}
private getDefaultTitle(severity: Severity) {

View File

@@ -13,4 +13,14 @@
height: 20px;
float: left;
margin-right: 10px;
}
/* Make the test selectable*/
.error-dialog .error-message {
-webkit-user-select: text;
user-select: text;
}
.modal .footer-button a.monaco-button.monaco-text-button.icon.scriptToClipboard {
width: 120px;
}