Add grid.viewAsChart and grid.goToNextGrid keyboard shortcuts for editor (#1390)

* adding shortcuts for view as chart and go to next grid

* small fix

* refactor query output functions out of gridParentComponents

* Revert "refactor query output functions out of gridParentComponents"

This reverts commit 51addcac76d2a21df150a8d95f54f061aab6ac7a.
This commit is contained in:
Abbie Petchtes
2018-05-11 09:38:14 -07:00
committed by GitHub
parent 23ec6ac567
commit eae8de0373
7 changed files with 50 additions and 3 deletions

View File

@@ -17,4 +17,6 @@ export let SelectAllMessages = 'SelectAllMessages';
export let SaveAsCsv = 'SaveAsCSV';
export let SaveAsJSON = 'SaveAsJSON';
export let SaveAsExcel = 'SaveAsExcel';
export let ViewAsChart = 'ViewAsChart';
export let GoToNextQueryOutputTab = 'GoToNextQueryOutputTab';
export let GoToNextGrid = 'GoToNextGrid';

View File

@@ -25,7 +25,8 @@ export const MESSAGES_COPY_ID = 'grid.messages.copy';
export const TOGGLERESULTS_ID = 'grid.toggleResultPane';
export const TOGGLEMESSAGES_ID = 'grid.toggleMessagePane';
export const GOTONEXTQUERYOUTPUTTAB_ID = 'query.goToNextQueryOutputTab';
export const GRID_VIEWASCHART_ID = 'grid.viewAsChart';
export const GRID_GOTONEXTGRID_ID = 'grid.goToNextGrid';
export class GridActionProvider {

View File

@@ -77,4 +77,11 @@ export const selectAllMessages = (accessor: ServicesAccessor) => {
runActionOnActiveResultsEditor(accessor, GridContentEvents.SelectAllMessages);
};
export const viewAsChart = (accessor: ServicesAccessor) => {
runActionOnActiveResultsEditor(accessor, GridContentEvents.ViewAsChart);
};
export const goToNextGrid = (accessor: ServicesAccessor) => {
runActionOnActiveResultsEditor(accessor, GridContentEvents.GoToNextGrid);
};

View File

@@ -168,6 +168,12 @@ export abstract class GridParentComponent {
case GridContentEvents.GoToNextQueryOutputTab:
self.goToNextQueryOutputTab();
break;
case GridContentEvents.ViewAsChart:
self.showChartForGrid(self.activeGrid);
break;
case GridContentEvents.GoToNextGrid:
self.goToNextGrid();
break;
default:
error('Unexpected grid content event type "' + type + '" sent');
break;
@@ -278,6 +284,22 @@ export abstract class GridParentComponent {
protected goToNextQueryOutputTab(): void {
}
protected showChartForGrid(index: number) {
}
protected goToNextGrid() {
if (this.renderedDataSets.length > 0) {
let next = this.activeGrid + 1;
if (next >= this.renderedDataSets.length) {
next = 0;
}
this.navigateToGrid(next);
}
}
protected navigateToGrid(index: number) {
}
private initShortcutsBase(): void {
let shortcuts = {
'ToggleResultPane': () => {

View File

@@ -589,7 +589,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
});
}
private showChartForGrid(index: number) {
protected showChartForGrid(index: number) {
if (this.renderedDataSets.length > index) {
this.showChartRequested.emit(this.renderedDataSets[index]);
}

View File

@@ -211,6 +211,22 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
handler: gridCommands.saveAsExcel
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: gridActions.GRID_VIEWASCHART_ID,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(gridCommandsWeightBonus),
when: ResultsGridFocusCondition,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_R, KeyMod.CtrlCmd | KeyCode.KEY_V),
handler: gridCommands.viewAsChart
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: gridActions.GRID_GOTONEXTGRID_ID,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(gridCommandsWeightBonus),
when: ResultsGridFocusCondition,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_R, KeyMod.CtrlCmd | KeyCode.KEY_N),
handler: gridCommands.goToNextGrid
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: gridActions.TOGGLERESULTS_ID,
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(gridCommandsWeightBonus),

View File

@@ -102,7 +102,6 @@ export class QueryOutputComponent implements OnDestroy {
})));
this._disposables.push(toDisposableSubscription(this.queryComponent.goToNextQueryOutputTabRequested.subscribe(() => {
let activeTab = this._panel.getActiveTab;
this._panel.selectOnNextTab();
})));
}