mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
toggle focus between query and results (#13928)
* toggle focus between query and results * focus on tab * comments
This commit is contained in:
@@ -311,7 +311,7 @@ export class TabbedPanel extends Disposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private focusCurrentTab(): void {
|
public focusCurrentTab(): void {
|
||||||
if (this._shownTabId) {
|
if (this._shownTabId) {
|
||||||
const tab = this._tabMap.get(this._shownTabId);
|
const tab = this._tabMap.get(this._shownTabId);
|
||||||
if (tab) {
|
if (tab) {
|
||||||
|
|||||||
@@ -306,6 +306,32 @@ export class ToggleQueryResultsKeyboardAction extends Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the focus between query editor and results pane
|
||||||
|
*/
|
||||||
|
export class ToggleFocusBetweenQueryEditorAndResultsAction extends Action {
|
||||||
|
public static ID = 'ToggleFocusBetweenQueryEditorAndResultsAction';
|
||||||
|
public static LABEL = nls.localize('ToggleFocusBetweenQueryEditorAndResultsAction', "Toggle Focus Between Query And Results");
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
id: string,
|
||||||
|
label: string,
|
||||||
|
@IEditorService private _editorService: IEditorService
|
||||||
|
) {
|
||||||
|
super(id, label);
|
||||||
|
this.enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async run(): Promise<void> {
|
||||||
|
const editor = this._editorService.activeEditorPane;
|
||||||
|
if (editor instanceof QueryEditor) {
|
||||||
|
editor.toggleFocusBetweenQueryEditorAndResults();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action class that runs a query in the active SQL text document.
|
* Action class that runs a query in the active SQL text document.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { QueryResultsInput } from 'sql/workbench/common/editor/query/queryResult
|
|||||||
import * as queryContext from 'sql/workbench/contrib/query/common/queryContext';
|
import * as queryContext from 'sql/workbench/contrib/query/common/queryContext';
|
||||||
import {
|
import {
|
||||||
RunQueryKeyboardAction, RunCurrentQueryKeyboardAction, CancelQueryKeyboardAction, RefreshIntellisenseKeyboardAction, ToggleQueryResultsKeyboardAction,
|
RunQueryKeyboardAction, RunCurrentQueryKeyboardAction, CancelQueryKeyboardAction, RefreshIntellisenseKeyboardAction, ToggleQueryResultsKeyboardAction,
|
||||||
RunQueryShortcutAction, RunCurrentQueryWithActualPlanKeyboardAction, CopyQueryWithResultsKeyboardAction, FocusOnCurrentQueryKeyboardAction, ParseSyntaxAction
|
RunQueryShortcutAction, RunCurrentQueryWithActualPlanKeyboardAction, CopyQueryWithResultsKeyboardAction, FocusOnCurrentQueryKeyboardAction, ParseSyntaxAction, ToggleFocusBetweenQueryEditorAndResultsAction
|
||||||
} from 'sql/workbench/contrib/query/browser/keyboardQueryActions';
|
} from 'sql/workbench/contrib/query/browser/keyboardQueryActions';
|
||||||
import * as gridActions from 'sql/workbench/contrib/editData/browser/gridActions';
|
import * as gridActions from 'sql/workbench/contrib/editData/browser/gridActions';
|
||||||
import * as gridCommands from 'sql/workbench/contrib/editData/browser/gridCommands';
|
import * as gridCommands from 'sql/workbench/contrib/editData/browser/gridCommands';
|
||||||
@@ -200,6 +200,17 @@ actionRegistry.registerWorkbenchAction(
|
|||||||
ToggleQueryResultsKeyboardAction.LABEL
|
ToggleQueryResultsKeyboardAction.LABEL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
actionRegistry.registerWorkbenchAction(
|
||||||
|
SyncActionDescriptor.create(
|
||||||
|
ToggleFocusBetweenQueryEditorAndResultsAction,
|
||||||
|
ToggleFocusBetweenQueryEditorAndResultsAction.ID,
|
||||||
|
ToggleFocusBetweenQueryEditorAndResultsAction.LABEL,
|
||||||
|
{ primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_F },
|
||||||
|
QueryEditorVisibleCondition
|
||||||
|
),
|
||||||
|
ToggleFocusBetweenQueryEditorAndResultsAction.LABEL
|
||||||
|
);
|
||||||
|
|
||||||
// Register Flavor Action
|
// Register Flavor Action
|
||||||
actionRegistry.registerWorkbenchAction(
|
actionRegistry.registerWorkbenchAction(
|
||||||
SyncActionDescriptor.create(
|
SyncActionDescriptor.create(
|
||||||
|
|||||||
@@ -470,6 +470,14 @@ export class QueryEditor extends EditorPane {
|
|||||||
this.currentTextEditor.focus();
|
this.currentTextEditor.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public toggleFocusBetweenQueryEditorAndResults(): void {
|
||||||
|
if (!this.resultsVisible || this.resultsEditorContainer.contains(document.activeElement)) {
|
||||||
|
this.focus();
|
||||||
|
} else {
|
||||||
|
this.resultsEditor.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the internal variable keeping track of the editor's size, and re-calculates the sash position.
|
* Updates the internal variable keeping track of the editor's size, and re-calculates the sash position.
|
||||||
* To be called when the container of this editor changes size.
|
* To be called when the container of this editor changes size.
|
||||||
|
|||||||
@@ -153,4 +153,8 @@ export class QueryResultsEditor extends EditorPane {
|
|||||||
public registerQueryModelViewTab(title: string, componentId: string): void {
|
public registerQueryModelViewTab(title: string, componentId: string): void {
|
||||||
this.resultsView.registerQueryModelViewTab(title, componentId);
|
this.resultsView.registerQueryModelViewTab(title, componentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public focus(): void {
|
||||||
|
this.resultsView.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -430,4 +430,8 @@ export class QueryResultsView extends Disposable {
|
|||||||
tab.putState(this.input.state.dynamicModelViewTabsState);
|
tab.putState(this.input.state.dynamicModelViewTabsState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public focus(): void {
|
||||||
|
this._panelView.focusCurrentTab();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user