mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
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:
@@ -40,57 +40,6 @@ export interface IGridIcon {
|
||||
functionality: (batchId: number, resultId: number, index: number) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simplified interface for a Range object returned by the Rangy javascript plugin
|
||||
*
|
||||
* @export
|
||||
* @interface IRange
|
||||
*/
|
||||
export interface IRange {
|
||||
selectNodeContents(el): void;
|
||||
/**
|
||||
* Returns any user-visible text covered under the range, using standard HTML Range API calls
|
||||
*
|
||||
* @returns {string}
|
||||
*
|
||||
* @memberOf IRange
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* Replaces the current selection with this range. Equivalent to rangy.getSelection().setSingleRange(range).
|
||||
*
|
||||
*
|
||||
* @memberOf IRange
|
||||
*/
|
||||
select(): void;
|
||||
|
||||
/**
|
||||
* Returns the `Document` element containing the range
|
||||
*
|
||||
* @returns {Document}
|
||||
*
|
||||
* @memberOf IRange
|
||||
*/
|
||||
getDocument(): Document;
|
||||
|
||||
/**
|
||||
* Detaches the range so it's no longer tracked by Rangy using DOM manipulation
|
||||
*
|
||||
*
|
||||
* @memberOf IRange
|
||||
*/
|
||||
detach(): void;
|
||||
|
||||
/**
|
||||
* Gets formatted text under a range. This is an improvement over toString() which contains unnecessary whitespac
|
||||
*
|
||||
* @returns {string}
|
||||
*
|
||||
* @memberOf IRange
|
||||
*/
|
||||
text(): string;
|
||||
}
|
||||
|
||||
export interface IGridDataSet {
|
||||
dataRows: IObservableCollection<IGridDataRow>;
|
||||
columnDefinitions: IColumnDefinition[];
|
||||
|
||||
@@ -51,6 +51,11 @@
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
#messageTable {
|
||||
-webkit-user-select: text;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
.resultsMessageValue {
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
@@ -48,9 +48,10 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
private complete = false;
|
||||
private idMapping: { [row: number]: number } = {};
|
||||
|
||||
private currentCell: { row: number, column: number } = null;
|
||||
private rowEditInProgress: boolean = false;
|
||||
private removingNewRow: boolean = false;
|
||||
// Current selected cell state
|
||||
private currentCell: { row: number, column: number, isEditable: boolean };
|
||||
private currentEditCellValue: string;
|
||||
private removingNewRow: boolean;
|
||||
|
||||
// Edit Data functions
|
||||
public onCellEditEnd: (event: { row: number, column: number, newValue: any }) => void;
|
||||
@@ -71,7 +72,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
this._el.nativeElement.className = 'slickgridContainer';
|
||||
let editDataParameters: EditDataComponentParams = this._bootstrapService.getBootstrapParams(this._el.nativeElement.tagName);
|
||||
this.dataService = editDataParameters.dataService;
|
||||
this.actionProvider = new EditDataGridActionProvider(this.dataService, this.onGridSelectAll(), this.onDeleteRow(), this.onRevertRow());
|
||||
this.actionProvider = this._bootstrapService.instantiationService.createInstance(EditDataGridActionProvider, this.dataService, this.onGridSelectAll(), this.onDeleteRow(), this.onRevertRow());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,20 +134,8 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
};
|
||||
|
||||
this.onCellEditEnd = (event: { row: number, column: number, newValue: any }): void => {
|
||||
self.rowEditInProgress = true;
|
||||
|
||||
// Update the cell accordingly
|
||||
self.dataService.updateCell(this.idMapping[event.row], event.column, event.newValue)
|
||||
.then(
|
||||
result => {
|
||||
self.setCellDirtyState(event.row, event.column + 1, result.cell.isDirty);
|
||||
self.setRowDirtyState(event.row, result.isRowDirty);
|
||||
},
|
||||
error => {
|
||||
// On error updating cell, jump back to the cell that was being edited
|
||||
self.focusCell(event.row, event.column + 1);
|
||||
}
|
||||
);
|
||||
// Store the value that was set
|
||||
self.currentEditCellValue = event.newValue;
|
||||
};
|
||||
|
||||
this.onCellEditBegin = (event: { row: number, column: number }): void => { };
|
||||
@@ -199,11 +188,9 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
onDeleteRow(): (index: number) => void {
|
||||
const self = this;
|
||||
return (index: number): void => {
|
||||
self.dataService.deleteRow(index).then(() => {
|
||||
self.dataService.commitEdit().then(() => {
|
||||
self.removeRow(index, 0);
|
||||
});
|
||||
});
|
||||
self.dataService.deleteRow(index)
|
||||
.then(() => self.dataService.commitEdit())
|
||||
.then(() => self.removeRow(index, 0));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -215,44 +202,87 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
|
||||
// Perform a revert row operation
|
||||
self.dataService.revertRow(index)
|
||||
.then(() => { self.dataService.commitEdit(); })
|
||||
.then(() => { self.refreshResultsets(); });
|
||||
.then(() => self.dataService.commitEdit())
|
||||
.then(() => self.refreshResultsets());
|
||||
};
|
||||
}
|
||||
|
||||
onCellSelect(row: number, column: number): void {
|
||||
let self = this;
|
||||
|
||||
// TODO: We can skip this step if we're allowing multiple commits
|
||||
if (this.rowEditInProgress) {
|
||||
// We're in the middle of a row edit, so we need to commit if we move to a different row
|
||||
if (row !== this.currentCell.row) {
|
||||
this.dataService.commitEdit()
|
||||
.then(
|
||||
result => {
|
||||
// Committing was successful. Clean the grid, turn off the row edit flag, then select again
|
||||
self.setGridClean();
|
||||
self.rowEditInProgress = false;
|
||||
self.onCellSelect(row, column);
|
||||
}, error => {
|
||||
// Committing failed, so jump back to the last selected cell
|
||||
self.focusCell(self.currentCell.row, self.currentCell.column);
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// We're not in the middle of a row edit, so we can move anywhere
|
||||
// Checking for removing new row makes sure we don't re-add the new row after we've
|
||||
// jumped to the first cell of the "new row"
|
||||
if (this.isNullRow(row) && !this.removingNewRow) {
|
||||
// We moved into the "new row", add another new row
|
||||
this.addRow(row, column);
|
||||
}
|
||||
// Skip processing if the newly selected cell is undefined or we don't have column
|
||||
// definition for the column (ie, the selection was reset)
|
||||
if (row === undefined || column === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the cell we moved to as the current cell
|
||||
this.currentCell = { row: row, column: column };
|
||||
// Skip processing if the cell hasn't moved (eg, we reset focus to the previous cell after a failed update)
|
||||
if (this.currentCell.row === row && this.currentCell.column === column) {
|
||||
return;
|
||||
}
|
||||
|
||||
let cellSelectTasks: Promise<void> = Promise.resolve();
|
||||
|
||||
if (this.currentCell.isEditable && this.currentEditCellValue !== null && !this.removingNewRow) {
|
||||
// We're exiting a read/write cell after having changed the value, update the cell value in the service
|
||||
cellSelectTasks = cellSelectTasks.then(() => {
|
||||
return self.dataService.updateCell(self.currentCell.row, self.currentCell.column - 1, self.currentEditCellValue)
|
||||
.then(
|
||||
result => {
|
||||
// Cell update was successful, update the flags
|
||||
self.currentEditCellValue = null;
|
||||
self.setCellDirtyState(row, self.currentCell.column, result.cell.isDirty);
|
||||
self.setRowDirtyState(row, result.isRowDirty);
|
||||
return Promise.resolve();
|
||||
},
|
||||
error => {
|
||||
// Cell update failed, jump back to the last cell we were on
|
||||
self.focusCell(self.currentCell.row, self.currentCell.column, true);
|
||||
return Promise.reject(null);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.currentCell.row !== row) {
|
||||
// We're changing row, commit the changes
|
||||
cellSelectTasks = cellSelectTasks.then(() => {
|
||||
return self.dataService.commitEdit()
|
||||
.then(
|
||||
result => {
|
||||
// Committing was successful, clean the grid
|
||||
self.setGridClean();
|
||||
return Promise.resolve();
|
||||
},
|
||||
error => {
|
||||
// Committing failed, jump back to the last selected cell
|
||||
self.focusCell(self.currentCell.row, self.currentCell.column);
|
||||
return Promise.reject(null);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.isNullRow(row) && !this.removingNewRow) {
|
||||
// We've entered the "new row", so we need to add a row and jump to it
|
||||
cellSelectTasks = cellSelectTasks.then(() => {
|
||||
self.addRow(row, column);
|
||||
});
|
||||
}
|
||||
|
||||
// At the end of a successful cell select, update the currently selected cell
|
||||
cellSelectTasks = cellSelectTasks.then(() => {
|
||||
self.currentCell = {
|
||||
row: row,
|
||||
column: column,
|
||||
isEditable: self.dataSet.columnDefinitions[column - 1]
|
||||
? self.dataSet.columnDefinitions[column - 1].isEditable
|
||||
: false
|
||||
};
|
||||
});
|
||||
|
||||
// Cap off any failed promises, since they'll be handled
|
||||
cellSelectTasks.catch(() => {});
|
||||
}
|
||||
|
||||
handleComplete(self: EditDataComponent, event: any): void {
|
||||
@@ -319,9 +349,9 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
self.messagesAdded = true;
|
||||
self.onScroll(0);
|
||||
|
||||
// Reset selected cell state
|
||||
this.currentCell = null;
|
||||
this.rowEditInProgress = false;
|
||||
// Setup the state of the selected cell
|
||||
this.currentCell = { row: null, column: null, isEditable: null };
|
||||
this.currentEditCellValue = null;
|
||||
this.removingNewRow = false;
|
||||
|
||||
// HACK: unsafe reference to the slickgrid object
|
||||
@@ -350,7 +380,6 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
self.placeHolderDataSets[i].resized.emit();
|
||||
}
|
||||
|
||||
|
||||
self._cd.detectChanges();
|
||||
|
||||
if (self.firstRender) {
|
||||
@@ -380,7 +409,6 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
this.dataService.revertRow(this.idMapping[currentNewRowIndex])
|
||||
.then(() => {
|
||||
this.removeRow(currentNewRowIndex, 0);
|
||||
this.rowEditInProgress = false;
|
||||
});
|
||||
handled = true;
|
||||
}
|
||||
@@ -434,7 +462,6 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
this.dataService.createRow();
|
||||
|
||||
// Adding an extra row for 'new row' functionality
|
||||
this.rowEditInProgress = true;
|
||||
this.dataSet.totalRows++;
|
||||
this.dataSet.maxHeight = this.getMaxHeight(this.dataSet.totalRows);
|
||||
this.dataSet.minHeight = this.getMinHeight(this.dataSet.totalRows);
|
||||
|
||||
@@ -11,13 +11,18 @@ import { GridActionProvider } from 'sql/parts/grid/views/gridActions';
|
||||
import { localize } from 'vs/nls';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IAction, Action } from 'vs/base/common/actions';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export class EditDataGridActionProvider extends GridActionProvider {
|
||||
|
||||
constructor(dataService: DataService, selectAllCallback: (index: number) => void,
|
||||
constructor(
|
||||
dataService: DataService,
|
||||
selectAllCallback: (index: number) => void,
|
||||
private _deleteRowCallback: (index: number) => void,
|
||||
private _revertRowCallback: (index: number) => void) {
|
||||
super(dataService, selectAllCallback);
|
||||
private _revertRowCallback: (index: number) => void,
|
||||
@IInstantiationService instantiationService: IInstantiationService
|
||||
) {
|
||||
super(dataService, selectAllCallback, instantiationService);
|
||||
}
|
||||
/**
|
||||
* Return actions given a click on an edit data grid
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { IGridInfo, IRange, SaveFormat } from 'sql/parts/grid/common/interfaces';
|
||||
import { IGridInfo, SaveFormat } from 'sql/parts/grid/common/interfaces';
|
||||
import { DataService } from 'sql/parts/grid/services/dataService';
|
||||
import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IAction, Action } from 'vs/base/common/actions';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const GRID_SAVECSV_ID = 'grid.saveAsCsv';
|
||||
export const GRID_SAVEJSON_ID = 'grid.saveAsJson';
|
||||
@@ -26,7 +27,11 @@ export const TOGGLEMESSAGES_ID = 'grid.toggleMessagePane';
|
||||
|
||||
export class GridActionProvider {
|
||||
|
||||
constructor(protected _dataService: DataService, protected _selectAllCallback: (index: number) => void) {
|
||||
constructor(
|
||||
protected _dataService: DataService,
|
||||
protected _selectAllCallback: (index: number) => void,
|
||||
@IInstantiationService private _instantiationService: IInstantiationService
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +55,7 @@ export class GridActionProvider {
|
||||
*/
|
||||
public getMessagesActions(dataService: DataService, selectAllCallback: () => void): TPromise<IAction[]> {
|
||||
let actions: IAction[] = [];
|
||||
actions.push(new CopyMessagesAction(CopyMessagesAction.ID, CopyMessagesAction.LABEL));
|
||||
actions.push(this._instantiationService.createInstance(CopyMessagesAction, CopyMessagesAction.ID, CopyMessagesAction.LABEL));
|
||||
actions.push(new SelectAllMessagesAction(SelectAllMessagesAction.ID, SelectAllMessagesAction.LABEL, selectAllCallback));
|
||||
return TPromise.as(actions);
|
||||
}
|
||||
@@ -150,14 +155,14 @@ export class CopyMessagesAction extends Action {
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string
|
||||
label: string,
|
||||
@IClipboardService private clipboardService: IClipboardService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
public run(selectedRange: IRange): TPromise<boolean> {
|
||||
let selectedText = selectedRange.text();
|
||||
WorkbenchUtils.executeCopy(selectedText);
|
||||
public run(selectedRange: Selection): TPromise<boolean> {
|
||||
this.clipboardService.writeText(selectedRange.toString());
|
||||
return TPromise.as(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import { IGridDataRow, ISlickRange, SlickGrid, FieldType } from 'angular2-slickg
|
||||
import { toDisposableSubscription } from 'sql/parts/common/rxjsUtils';
|
||||
import * as Constants from 'sql/parts/query/common/constants';
|
||||
import * as LocalizedConstants from 'sql/parts/query/common/localizedConstants';
|
||||
import { IGridInfo, IRange, IGridDataSet, SaveFormat } from 'sql/parts/grid/common/interfaces';
|
||||
import { IGridInfo, IGridDataSet, SaveFormat } from 'sql/parts/grid/common/interfaces';
|
||||
import * as Utils from 'sql/parts/connection/common/utils';
|
||||
import { DataService } from 'sql/parts/grid/services/dataService';
|
||||
import * as actions from 'sql/parts/grid/views/gridActions';
|
||||
@@ -25,8 +25,6 @@ import * as Services from 'sql/parts/grid/services/sharedServices';
|
||||
import * as GridContentEvents from 'sql/parts/grid/common/gridContentEvents';
|
||||
import { ResultsVisibleContext, ResultsGridFocussedContext, ResultsMessagesFocussedContext } from 'sql/parts/query/common/queryContext';
|
||||
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
|
||||
import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
|
||||
import * as rangy from 'sql/base/node/rangy';
|
||||
import { error } from 'sql/base/common/log';
|
||||
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
@@ -228,7 +226,7 @@ export abstract class GridParentComponent {
|
||||
private copySelection(): void {
|
||||
let messageText = this.getMessageText();
|
||||
if (messageText.length > 0) {
|
||||
WorkbenchUtils.executeCopy(messageText);
|
||||
this._bootstrapService.clipboardService.writeText(messageText);
|
||||
} else {
|
||||
let activeGrid = this.activeGrid;
|
||||
let selection = this.slickgrids.toArray()[activeGrid].getSelectedRanges();
|
||||
@@ -251,13 +249,17 @@ export abstract class GridParentComponent {
|
||||
messageText = this.getMessageText();
|
||||
}
|
||||
if (messageText.length > 0) {
|
||||
WorkbenchUtils.executeCopy(messageText);
|
||||
this._bootstrapService.clipboardService.writeText(messageText);
|
||||
}
|
||||
}
|
||||
|
||||
private getMessageText(): string {
|
||||
let range: IRange = this.getSelectedRangeUnderMessages();
|
||||
return range ? range.text() : '';
|
||||
if (document.activeElement === this.getMessagesElement()) {
|
||||
if (window.getSelection()) {
|
||||
return window.getSelection().toString();
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
private initShortcutsBase(): void {
|
||||
@@ -337,10 +339,16 @@ export abstract class GridParentComponent {
|
||||
}
|
||||
|
||||
openContextMenu(event, batchId, resultId, index): void {
|
||||
let selection = this.slickgrids.toArray()[index].getSelectedRanges();
|
||||
|
||||
let slick: any = this.slickgrids.toArray()[index];
|
||||
let grid = slick._grid;
|
||||
|
||||
let selection = this.slickgrids.toArray()[index].getSelectedRanges();
|
||||
|
||||
if (selection && selection.length === 0) {
|
||||
let cell = (grid as Slick.Grid<any>).getCellFromEvent(event);
|
||||
selection = [new Slick.Range(cell.row, cell.cell - 1)];
|
||||
}
|
||||
|
||||
let rowIndex = grid.getCellFromEvent(event).row;
|
||||
|
||||
let actionContext: IGridInfo = {
|
||||
@@ -356,8 +364,6 @@ export abstract class GridParentComponent {
|
||||
getAnchor: () => anchor,
|
||||
getActions: () => this.actionProvider.getGridActions(),
|
||||
getKeyBinding: (action) => this._keybindingFor(action),
|
||||
onHide: (wasCancelled?: boolean) => {
|
||||
},
|
||||
getActionsContext: () => (actionContext)
|
||||
});
|
||||
}
|
||||
@@ -439,25 +445,12 @@ export abstract class GridParentComponent {
|
||||
this._cd.detectChanges();
|
||||
}
|
||||
|
||||
getSelectedRangeUnderMessages(): IRange {
|
||||
let selectedRange: IRange = undefined;
|
||||
let msgEl = this.getMessagesElement();
|
||||
if (msgEl) {
|
||||
selectedRange = this.getSelectedRangeWithin(msgEl);
|
||||
getSelectedRangeUnderMessages(): Selection {
|
||||
if (document.activeElement === this.getMessagesElement()) {
|
||||
return window.getSelection();
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
return selectedRange;
|
||||
}
|
||||
|
||||
getSelectedRangeWithin(el): IRange {
|
||||
let selectedRange = undefined;
|
||||
let sel = rangy.getSelection();
|
||||
let elRange = <IRange>rangy.createRange();
|
||||
elRange.selectNodeContents(el);
|
||||
if (sel.rangeCount) {
|
||||
selectedRange = sel.getRangeAt(0).intersection(elRange);
|
||||
}
|
||||
elRange.detach();
|
||||
return selectedRange;
|
||||
}
|
||||
|
||||
selectAllMessages(): void {
|
||||
@@ -465,11 +458,12 @@ export abstract class GridParentComponent {
|
||||
this.selectElementContents(msgEl);
|
||||
}
|
||||
|
||||
selectElementContents(el): void {
|
||||
let range = rangy.createRange();
|
||||
selectElementContents(el: HTMLElement): void {
|
||||
let range = document.createRange();
|
||||
range.selectNodeContents(el);
|
||||
let sel = rangy.getSelection();
|
||||
sel.setSingleRange(range);
|
||||
let sel = window.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,6 @@ import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
|
||||
import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost.directive';
|
||||
import { IGridDataSet } from 'sql/parts/grid/common/interfaces';
|
||||
import * as DialogHelper from 'sql/base/browser/ui/modal/dialogHelper';
|
||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { IInsightData, IInsightsView, IInsightsConfig } from 'sql/parts/dashboard/widgets/insights/interfaces';
|
||||
@@ -30,8 +29,7 @@ import {
|
||||
} from 'sql/parts/dashboard/widgets/insights/views/charts/chartInsight.component';
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Builder } from 'vs/base/browser/builder';
|
||||
import { attachSelectBoxStyler, attachCheckboxStyler } from 'vs/platform/theme/common/styler';
|
||||
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import * as nls from 'vs/nls';
|
||||
@@ -116,15 +114,17 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
|
||||
|
||||
// Init label first column checkbox
|
||||
// Note: must use 'self' for callback
|
||||
this.labelFirstColumnCheckBox = DialogHelper.createCheckBox(new Builder(this.labelFirstColumnElement.nativeElement),
|
||||
this.labelFirstColumnLabel, 'chartView-checkbox', false, () => this.onLabelFirstColumnChanged());
|
||||
this._disposables.push(attachCheckboxStyler(this.labelFirstColumnCheckBox, this._bootstrapService.themeService));
|
||||
this.labelFirstColumnCheckBox = new Checkbox(this.labelFirstColumnElement.nativeElement, {
|
||||
label: this.labelFirstColumnLabel,
|
||||
onChange: () => this.onLabelFirstColumnChanged()
|
||||
});
|
||||
|
||||
// Init label first column checkbox
|
||||
// Note: must use 'self' for callback
|
||||
this.columnsAsLabelsCheckBox = DialogHelper.createCheckBox(new Builder(this.columnsAsLabelsElement.nativeElement),
|
||||
this.columnsAsLabelsLabel, 'chartView-checkbox', false, () => this.columnsAsLabelsChanged());
|
||||
this._disposables.push(attachCheckboxStyler(this.columnsAsLabelsCheckBox, this._bootstrapService.themeService));
|
||||
this.columnsAsLabelsCheckBox = new Checkbox(this.columnsAsLabelsElement.nativeElement, {
|
||||
label: this.columnsAsLabelsLabel,
|
||||
onChange: () => this.columnsAsLabelsChanged()
|
||||
});
|
||||
|
||||
// Init legend dropdown
|
||||
this.legendSelectBox = new SelectBox(this.legendOptions, this._chartConfig.legendPosition);
|
||||
@@ -332,7 +332,7 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
|
||||
this.componentHost.viewContainerRef.clear();
|
||||
let componentRef = this.componentHost.viewContainerRef.createComponent(componentFactory);
|
||||
this._chartComponent = <ChartInsight>componentRef.instance;
|
||||
this._chartComponent.config = this._chartConfig;
|
||||
this._chartComponent.setConfig(this._chartConfig);
|
||||
this._chartComponent.data = this._executeResult;
|
||||
this._chartComponent.options = mixin(this._chartComponent.options, { animation: { duration: 0 } });
|
||||
if (this._chartComponent.init) {
|
||||
|
||||
@@ -16,20 +16,17 @@ import {
|
||||
ViewChildren, forwardRef, EventEmitter, Input, ViewChild
|
||||
} from '@angular/core';
|
||||
import { IGridDataRow, SlickGrid, VirtualizedCollection } from 'angular2-slickgrid';
|
||||
import * as rangy from 'sql/base/node/rangy';
|
||||
|
||||
import * as LocalizedConstants from 'sql/parts/query/common/localizedConstants';
|
||||
import * as Services from 'sql/parts/grid/services/sharedServices';
|
||||
import { IGridIcon, IMessage, IRange, IGridDataSet } from 'sql/parts/grid/common/interfaces';
|
||||
import { IGridIcon, IMessage, IGridDataSet } from 'sql/parts/grid/common/interfaces';
|
||||
import { GridParentComponent } from 'sql/parts/grid/views/gridParentComponent';
|
||||
import { GridActionProvider } from 'sql/parts/grid/views/gridActions';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { QueryComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
|
||||
import { error } from 'sql/base/common/log';
|
||||
import { TabChild } from 'sql/base/browser/ui/panel/tab.component';
|
||||
|
||||
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { clone } from 'vs/base/common/objects';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
@@ -142,6 +139,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
||||
private complete = false;
|
||||
private sentPlans: Map<number, string> = new Map<number, string>();
|
||||
private hasQueryPlan: boolean = false;
|
||||
private queryPlanResultSetId: number = 0;
|
||||
public queryExecutionStatus: EventEmitter<string> = new EventEmitter<string>();
|
||||
public queryPlanAvailable: EventEmitter<string> = new EventEmitter<string>();
|
||||
public showChartRequested: EventEmitter<IGridDataSet> = new EventEmitter<IGridDataSet>();
|
||||
@@ -168,7 +166,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
||||
const self = this;
|
||||
|
||||
this.dataService = this.queryParameters.dataService;
|
||||
this.actionProvider = new GridActionProvider(this.dataService, this.onGridSelectAll());
|
||||
this.actionProvider = this._bootstrapService.instantiationService.createInstance(GridActionProvider, this.dataService, this.onGridSelectAll());
|
||||
|
||||
this.baseInit();
|
||||
this.setupResizeBind();
|
||||
@@ -265,8 +263,8 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
||||
}
|
||||
|
||||
// if this is a query plan resultset we haven't processed yet then forward to subscribers
|
||||
if (self.hasQueryPlan && !self.sentPlans[resultSet.batchId]) {
|
||||
self.sentPlans[resultSet.batchId] = rows.rows[0][0].displayValue;
|
||||
if (self.hasQueryPlan && resultSet.id === self.queryPlanResultSetId && !self.sentPlans[resultSet.id]) {
|
||||
self.sentPlans[resultSet.id] = rows.rows[0][0].displayValue;
|
||||
self.queryPlanAvailable.emit(rows.rows[0][0].displayValue);
|
||||
}
|
||||
resolve(gridData);
|
||||
@@ -322,6 +320,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
||||
let column = resultSet.columnInfo[i];
|
||||
if (column.columnName === 'Microsoft SQL Server 2005 XML Showplan') {
|
||||
this.hasQueryPlan = true;
|
||||
this.queryPlanResultSetId = resultSet.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -335,27 +334,10 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
||||
self.onScroll(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform copy and do other actions for context menu on the messages component
|
||||
*/
|
||||
handleMessagesContextClick(event: { type: string, selectedRange: IRange }): void {
|
||||
switch (event.type) {
|
||||
case 'copySelection':
|
||||
let selectedText = event.selectedRange.text();
|
||||
WorkbenchUtils.executeCopy(selectedText);
|
||||
break;
|
||||
case 'selectall':
|
||||
document.execCommand('selectAll');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
openMessagesContextMenu(event: any): void {
|
||||
let self = this;
|
||||
event.preventDefault();
|
||||
let selectedRange: IRange = this.getSelectedRangeUnderMessages();
|
||||
let selectedRange = this.getSelectedRangeUnderMessages();
|
||||
let selectAllFunc = () => self.selectAllMessages();
|
||||
let anchor = { x: event.x + 1, y: event.y };
|
||||
this.contextMenuService.showContextMenu({
|
||||
@@ -404,19 +386,6 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
||||
}
|
||||
|
||||
self._cd.detectChanges();
|
||||
|
||||
if (self.firstRender) {
|
||||
let setActive = () => {
|
||||
if (self.firstRender && self.slickgrids.toArray().length > 0) {
|
||||
self.slickgrids.toArray()[0].setActive();
|
||||
self.firstRender = false;
|
||||
}
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
setActive();
|
||||
});
|
||||
}
|
||||
}, self.scrollTimeOutTime);
|
||||
}
|
||||
|
||||
@@ -538,7 +507,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
||||
|
||||
// Deselect any text since we are navigating to a new grid
|
||||
// Do this even if not switching grids, since this covers clicking on the grid after message selection
|
||||
rangy.getSelection().removeAllRanges();
|
||||
window.getSelection().removeAllRanges();
|
||||
|
||||
// check if you are actually trying to change navigation
|
||||
if (this.activeGrid === targetIndex) {
|
||||
@@ -600,4 +569,4 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
||||
layout() {
|
||||
this.resizeGrids();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user