mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Add keyboard shortcuts for focus on current query and go to next output query tab (#1153)
* add go to next output query tab shotcut * add a new keyboard shortcut for focus on current query * minor change
This commit is contained in:
@@ -182,7 +182,7 @@ export class PanelComponent extends Disposable implements AfterContentInit, OnIn
|
|||||||
if (input instanceof TabComponent) {
|
if (input instanceof TabComponent) {
|
||||||
tab = input;
|
tab = input;
|
||||||
} else if (types.isNumber(input)) {
|
} else if (types.isNumber(input)) {
|
||||||
tab = this._tabs[input];
|
tab = this._tabs.toArray()[input];
|
||||||
} else if (types.isString(input)) {
|
} else if (types.isString(input)) {
|
||||||
tab = this._tabs.find(i => i.identifier === input);
|
tab = this._tabs.find(i => i.identifier === input);
|
||||||
}
|
}
|
||||||
@@ -226,6 +226,18 @@ export class PanelComponent extends Disposable implements AfterContentInit, OnIn
|
|||||||
return this._activeTab.identifier;
|
return this._activeTab.identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select on the next tab
|
||||||
|
*/
|
||||||
|
public selectOnNextTab(): void {
|
||||||
|
let activeIndex = this._tabs.toArray().findIndex(i => i === this._activeTab);
|
||||||
|
let nextTabIndex = activeIndex + 1;
|
||||||
|
if (nextTabIndex === this._tabs.length) {
|
||||||
|
nextTabIndex = 0;
|
||||||
|
}
|
||||||
|
this.selectTab(nextTabIndex);
|
||||||
|
}
|
||||||
|
|
||||||
private findAndRemoveTabFromMRU(tab: TabComponent): void {
|
private findAndRemoveTabFromMRU(tab: TabComponent): void {
|
||||||
let mruIndex = this._mru.findIndex(i => i === tab);
|
let mruIndex = this._mru.findIndex(i => i === tab);
|
||||||
|
|
||||||
|
|||||||
@@ -17,3 +17,4 @@ export let SelectAllMessages = 'SelectAllMessages';
|
|||||||
export let SaveAsCsv = 'SaveAsCSV';
|
export let SaveAsCsv = 'SaveAsCSV';
|
||||||
export let SaveAsJSON = 'SaveAsJSON';
|
export let SaveAsJSON = 'SaveAsJSON';
|
||||||
export let SaveAsExcel = 'SaveAsExcel';
|
export let SaveAsExcel = 'SaveAsExcel';
|
||||||
|
export let GoToNextQueryOutputTab = 'GoToNextQueryOutputTab';
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export const MESSAGES_SELECTALL_ID = 'grid.messages.selectAll';
|
|||||||
export const MESSAGES_COPY_ID = 'grid.messages.copy';
|
export const MESSAGES_COPY_ID = 'grid.messages.copy';
|
||||||
export const TOGGLERESULTS_ID = 'grid.toggleResultPane';
|
export const TOGGLERESULTS_ID = 'grid.toggleResultPane';
|
||||||
export const TOGGLEMESSAGES_ID = 'grid.toggleMessagePane';
|
export const TOGGLEMESSAGES_ID = 'grid.toggleMessagePane';
|
||||||
|
export const GOTONEXTQUERYOUTPUTTAB_ID = 'query.goToNextQueryOutputTab';
|
||||||
|
|
||||||
|
|
||||||
export class GridActionProvider {
|
export class GridActionProvider {
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ export const toggleResultsPane = (accessor: ServicesAccessor) => {
|
|||||||
runActionOnActiveResultsEditor(accessor, GridContentEvents.ToggleResultPane);
|
runActionOnActiveResultsEditor(accessor, GridContentEvents.ToggleResultPane);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const goToNextQueryOutputTab = (accessor: ServicesAccessor) => {
|
||||||
|
runActionOnActiveResultsEditor(accessor, GridContentEvents.GoToNextQueryOutputTab);
|
||||||
|
};
|
||||||
|
|
||||||
export const saveAsCsv = (accessor: ServicesAccessor) => {
|
export const saveAsCsv = (accessor: ServicesAccessor) => {
|
||||||
runActionOnActiveResultsEditor(accessor, GridContentEvents.SaveAsCsv);
|
runActionOnActiveResultsEditor(accessor, GridContentEvents.SaveAsCsv);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -165,6 +165,9 @@ export abstract class GridParentComponent {
|
|||||||
case GridContentEvents.SaveAsExcel:
|
case GridContentEvents.SaveAsExcel:
|
||||||
self.sendSaveRequest(SaveFormat.EXCEL);
|
self.sendSaveRequest(SaveFormat.EXCEL);
|
||||||
break;
|
break;
|
||||||
|
case GridContentEvents.GoToNextQueryOutputTab:
|
||||||
|
self.goToNextQueryOutputTab();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
error('Unexpected grid content event type "' + type + '" sent');
|
error('Unexpected grid content event type "' + type + '" sent');
|
||||||
break;
|
break;
|
||||||
@@ -272,6 +275,9 @@ export abstract class GridParentComponent {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected goToNextQueryOutputTab(): void {
|
||||||
|
}
|
||||||
|
|
||||||
private initShortcutsBase(): void {
|
private initShortcutsBase(): void {
|
||||||
let shortcuts = {
|
let shortcuts = {
|
||||||
'ToggleResultPane': () => {
|
'ToggleResultPane': () => {
|
||||||
@@ -297,6 +303,9 @@ export abstract class GridParentComponent {
|
|||||||
},
|
},
|
||||||
'SaveAsExcel': () => {
|
'SaveAsExcel': () => {
|
||||||
this.sendSaveRequest(SaveFormat.EXCEL);
|
this.sendSaveRequest(SaveFormat.EXCEL);
|
||||||
|
},
|
||||||
|
'GoToNextQueryOutputTab': () => {
|
||||||
|
this.goToNextQueryOutputTab();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
|||||||
public queryExecutionStatus: EventEmitter<string> = new EventEmitter<string>();
|
public queryExecutionStatus: EventEmitter<string> = new EventEmitter<string>();
|
||||||
public queryPlanAvailable: EventEmitter<string> = new EventEmitter<string>();
|
public queryPlanAvailable: EventEmitter<string> = new EventEmitter<string>();
|
||||||
public showChartRequested: EventEmitter<IGridDataSet> = new EventEmitter<IGridDataSet>();
|
public showChartRequested: EventEmitter<IGridDataSet> = new EventEmitter<IGridDataSet>();
|
||||||
|
public goToNextQueryOutputTabRequested: EventEmitter<void> = new EventEmitter<void>();
|
||||||
|
|
||||||
@Input() public queryParameters: QueryComponentParams;
|
@Input() public queryParameters: QueryComponentParams;
|
||||||
|
|
||||||
@@ -578,6 +579,10 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected goToNextQueryOutputTab(): void {
|
||||||
|
this.goToNextQueryOutputTabRequested.emit();
|
||||||
|
}
|
||||||
|
|
||||||
protected toggleResultPane(): void {
|
protected toggleResultPane(): void {
|
||||||
this.resultActive = !this.resultActive;
|
this.resultActive = !this.resultActive;
|
||||||
this._cd.detectChanges();
|
this._cd.detectChanges();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import { EditDataEditor } from 'sql/parts/editData/editor/editDataEditor';
|
|||||||
import { EditDataInput } from 'sql/parts/editData/common/editDataInput';
|
import { EditDataInput } from 'sql/parts/editData/common/editDataInput';
|
||||||
import {
|
import {
|
||||||
RunQueryKeyboardAction, RunCurrentQueryKeyboardAction, CancelQueryKeyboardAction, RefreshIntellisenseKeyboardAction, ToggleQueryResultsKeyboardAction,
|
RunQueryKeyboardAction, RunCurrentQueryKeyboardAction, CancelQueryKeyboardAction, RefreshIntellisenseKeyboardAction, ToggleQueryResultsKeyboardAction,
|
||||||
RunQueryShortcutAction, RunCurrentQueryWithActualPlanKeyboardAction
|
RunQueryShortcutAction, RunCurrentQueryWithActualPlanKeyboardAction, FocusOnCurrentQueryKeyboardAction
|
||||||
} from 'sql/parts/query/execution/keyboardQueryActions';
|
} from 'sql/parts/query/execution/keyboardQueryActions';
|
||||||
import * as gridActions from 'sql/parts/grid/views/gridActions';
|
import * as gridActions from 'sql/parts/grid/views/gridActions';
|
||||||
import * as gridCommands from 'sql/parts/grid/views/gridCommands';
|
import * as gridCommands from 'sql/parts/grid/views/gridCommands';
|
||||||
@@ -132,6 +132,16 @@ actionRegistry.registerWorkbenchAction(
|
|||||||
RefreshIntellisenseKeyboardAction.LABEL
|
RefreshIntellisenseKeyboardAction.LABEL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
actionRegistry.registerWorkbenchAction(
|
||||||
|
new SyncActionDescriptor(
|
||||||
|
FocusOnCurrentQueryKeyboardAction,
|
||||||
|
FocusOnCurrentQueryKeyboardAction.ID,
|
||||||
|
FocusOnCurrentQueryKeyboardAction.LABEL,
|
||||||
|
{ primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_Q }
|
||||||
|
),
|
||||||
|
FocusOnCurrentQueryKeyboardAction.LABEL
|
||||||
|
);
|
||||||
|
|
||||||
// Grid actions
|
// Grid actions
|
||||||
|
|
||||||
actionRegistry.registerWorkbenchAction(
|
actionRegistry.registerWorkbenchAction(
|
||||||
@@ -217,6 +227,14 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
|||||||
handler: gridCommands.toggleMessagePane
|
handler: gridCommands.toggleMessagePane
|
||||||
});
|
});
|
||||||
|
|
||||||
|
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||||
|
id: gridActions.GOTONEXTQUERYOUTPUTTAB_ID,
|
||||||
|
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(gridCommandsWeightBonus),
|
||||||
|
when: QueryEditorVisibleCondition,
|
||||||
|
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_P,
|
||||||
|
handler: gridCommands.goToNextQueryOutputTab
|
||||||
|
});
|
||||||
|
|
||||||
// Intellisense and other configuration options
|
// Intellisense and other configuration options
|
||||||
let registryProperties = {
|
let registryProperties = {
|
||||||
'sql.messagesDefaultOpen': {
|
'sql.messagesDefaultOpen': {
|
||||||
|
|||||||
@@ -51,6 +51,34 @@ function escapeSqlString(input: string, escapeChar: string) {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locates the active editor and call focus() on the editor if it is a QueryEditor.
|
||||||
|
*/
|
||||||
|
export class FocusOnCurrentQueryKeyboardAction extends Action {
|
||||||
|
|
||||||
|
public static ID = 'focusOnCurrentQueryKeyboardAction';
|
||||||
|
public static LABEL = nls.localize('focusOnCurrentQueryKeyboardAction', 'Focus on Current Query');
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
id: string,
|
||||||
|
label: string,
|
||||||
|
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService
|
||||||
|
) {
|
||||||
|
super(id, label);
|
||||||
|
this.enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public run(): TPromise<void> {
|
||||||
|
let editor = this._editorService.getActiveEditor();
|
||||||
|
if (editor && editor instanceof QueryEditor) {
|
||||||
|
let queryEditor: QueryEditor = editor;
|
||||||
|
queryEditor.focus();
|
||||||
|
}
|
||||||
|
return TPromise.as(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locates the active editor and calls runQuery() on the editor if it is a QueryEditor.
|
* Locates the active editor and calls runQuery() on the editor if it is a QueryEditor.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -102,6 +102,11 @@ export class QueryOutputComponent implements OnInit, OnDestroy {
|
|||||||
this._cd.detectChanges();
|
this._cd.detectChanges();
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
this._disposables.push(toDisposableSubscription(this.queryComponent.goToNextQueryOutputTabRequested.subscribe(() => {
|
||||||
|
let activeTab = this._panel.getActiveTab;
|
||||||
|
this._panel.selectOnNextTab();
|
||||||
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnDestroy(): void {
|
public ngOnDestroy(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user