mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-04-01 01:20:31 -04:00
Merge from vscode ec07311dab2556c9d66a4cb3eecdc21c524202e1 (#6739)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./watermark';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { isMacintosh, OS } from 'vs/base/common/platform';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
@@ -42,65 +42,21 @@ interface WatermarkEntry {
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
const showServers: WatermarkEntry = {
|
||||
text: nls.localize('watermark.showServers', "Show Servers"),
|
||||
id: OpenDataExplorerViewletAction.ID
|
||||
};
|
||||
const showServers: WatermarkEntry = { text: nls.localize('watermark.showServers', "Show Servers"), id: OpenDataExplorerViewletAction.ID };
|
||||
const newSqlFile: WatermarkEntry = { text: nls.localize('watermark.newSqlFile', "New SQL File"), id: GlobalNewUntitledFileAction.ID };
|
||||
const newNotebook: WatermarkEntry = { text: nls.localize('watermark.newNotebook', "New Notebook"), id: NewNotebookAction.ID };
|
||||
|
||||
const newSqlFile: WatermarkEntry = {
|
||||
text: nls.localize('watermark.newSqlFile', "New SQL File"),
|
||||
id: GlobalNewUntitledFileAction.ID
|
||||
};
|
||||
const newNotebook: WatermarkEntry = {
|
||||
text: nls.localize('watermark.newNotebook', "New Notebook"),
|
||||
id: NewNotebookAction.ID
|
||||
};
|
||||
|
||||
const showCommands: WatermarkEntry = {
|
||||
text: nls.localize('watermark.showCommands', "Show All Commands"),
|
||||
id: ShowAllCommandsAction.ID
|
||||
};
|
||||
const quickOpen: WatermarkEntry = {
|
||||
text: nls.localize('watermark.quickOpen', "Go to File"),
|
||||
id: QUICKOPEN_ACTION_ID
|
||||
};
|
||||
const openFileNonMacOnly: WatermarkEntry = {
|
||||
text: nls.localize('watermark.openFile', "Open File"),
|
||||
id: OpenFileAction.ID,
|
||||
mac: false
|
||||
};
|
||||
const openFolderNonMacOnly: WatermarkEntry = {
|
||||
text: nls.localize('watermark.openFolder', "Open Folder"),
|
||||
id: OpenFolderAction.ID,
|
||||
mac: false
|
||||
};
|
||||
const openFileOrFolderMacOnly: WatermarkEntry = {
|
||||
text: nls.localize('watermark.openFileFolder', "Open File or Folder"),
|
||||
id: OpenFileFolderAction.ID,
|
||||
mac: true
|
||||
};
|
||||
const openRecent: WatermarkEntry = {
|
||||
text: nls.localize('watermark.openRecent', "Open Recent"),
|
||||
id: 'workbench.action.openRecent'
|
||||
};
|
||||
const newUntitledFile: WatermarkEntry = {
|
||||
text: nls.localize('watermark.newUntitledFile', "New Untitled File"),
|
||||
id: GlobalNewUntitledFileAction.ID
|
||||
};
|
||||
const showCommands: WatermarkEntry = { text: nls.localize('watermark.showCommands', "Show All Commands"), id: ShowAllCommandsAction.ID };
|
||||
const quickOpen: WatermarkEntry = { text: nls.localize('watermark.quickOpen', "Go to File"), id: QUICKOPEN_ACTION_ID };
|
||||
const openFileNonMacOnly: WatermarkEntry = { text: nls.localize('watermark.openFile', "Open File"), id: OpenFileAction.ID, mac: false };
|
||||
const openFolderNonMacOnly: WatermarkEntry = { text: nls.localize('watermark.openFolder', "Open Folder"), id: OpenFolderAction.ID, mac: false };
|
||||
const openFileOrFolderMacOnly: WatermarkEntry = { text: nls.localize('watermark.openFileFolder', "Open File or Folder"), id: OpenFileFolderAction.ID, mac: true };
|
||||
const openRecent: WatermarkEntry = { text: nls.localize('watermark.openRecent', "Open Recent"), id: 'workbench.action.openRecent' };
|
||||
const newUntitledFile: WatermarkEntry = { text: nls.localize('watermark.newUntitledFile', "New Untitled File"), id: GlobalNewUntitledFileAction.ID };
|
||||
const newUntitledFileMacOnly: WatermarkEntry = assign({ mac: true }, newUntitledFile);
|
||||
const toggleTerminal: WatermarkEntry = {
|
||||
text: nls.localize({ key: 'watermark.toggleTerminal', comment: ['toggle is a verb here'] }, "Toggle Terminal"),
|
||||
id: TERMINAL_COMMAND_ID.TOGGLE
|
||||
};
|
||||
|
||||
const findInFiles: WatermarkEntry = {
|
||||
text: nls.localize('watermark.findInFiles', "Find in Files"),
|
||||
id: FindInFilesActionId
|
||||
};
|
||||
const startDebugging: WatermarkEntry = {
|
||||
text: nls.localize('watermark.startDebugging', "Start Debugging"),
|
||||
id: StartAction.ID
|
||||
};
|
||||
const toggleTerminal: WatermarkEntry = { text: nls.localize({ key: 'watermark.toggleTerminal', comment: ['toggle is a verb here'] }, "Toggle Terminal"), id: TERMINAL_COMMAND_ID.TOGGLE };
|
||||
const findInFiles: WatermarkEntry = { text: nls.localize('watermark.findInFiles', "Find in Files"), id: FindInFilesActionId };
|
||||
const startDebugging: WatermarkEntry = { text: nls.localize('watermark.startDebugging', "Start Debugging"), id: StartAction.ID };
|
||||
|
||||
// {{SQL CARBON EDIT}} - Replace noFolderEntries and folderEntries
|
||||
const noFolderEntries = [
|
||||
@@ -121,13 +77,13 @@ const folderEntries = [
|
||||
const WORKBENCH_TIPS_ENABLED_KEY = 'workbench.tips.enabled';
|
||||
|
||||
export class WatermarkContribution extends Disposable implements IWorkbenchContribution {
|
||||
|
||||
private watermark: HTMLElement;
|
||||
private watermarkDisposable = this._register(new DisposableStore());
|
||||
private enabled: boolean;
|
||||
private workbenchState: WorkbenchState;
|
||||
|
||||
constructor(
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@ILifecycleService private readonly lifecycleService: ILifecycleService,
|
||||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
|
||||
@IKeybindingService private readonly keybindingService: IKeybindingService,
|
||||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
@@ -135,13 +91,20 @@ export class WatermarkContribution extends Disposable implements IWorkbenchContr
|
||||
@IEditorGroupsService private readonly editorGroupsService: IEditorGroupsService
|
||||
) {
|
||||
super();
|
||||
this.workbenchState = contextService.getWorkbenchState();
|
||||
|
||||
lifecycleService.onShutdown(this.dispose, this);
|
||||
this.workbenchState = contextService.getWorkbenchState();
|
||||
this.enabled = this.configurationService.getValue<boolean>(WORKBENCH_TIPS_ENABLED_KEY);
|
||||
|
||||
this.registerListeners();
|
||||
|
||||
if (this.enabled) {
|
||||
this.create();
|
||||
}
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
this.lifecycleService.onShutdown(this.dispose, this);
|
||||
|
||||
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration(WORKBENCH_TIPS_ENABLED_KEY)) {
|
||||
const enabled = this.configurationService.getValue<boolean>(WORKBENCH_TIPS_ENABLED_KEY);
|
||||
@@ -155,6 +118,7 @@ export class WatermarkContribution extends Disposable implements IWorkbenchContr
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this.contextService.onDidChangeWorkbenchState(e => {
|
||||
const previousWorkbenchState = this.workbenchState;
|
||||
this.workbenchState = this.contextService.getWorkbenchState();
|
||||
@@ -175,6 +139,7 @@ export class WatermarkContribution extends Disposable implements IWorkbenchContr
|
||||
const selected = folder ? folderEntries : noFolderEntries
|
||||
.filter(entry => !('mac' in entry) || entry.mac === isMacintosh)
|
||||
.filter(entry => !!CommandsRegistry.getCommand(entry.id));
|
||||
|
||||
const update = () => {
|
||||
dom.clearNode(box);
|
||||
selected.map(entry => {
|
||||
@@ -187,10 +152,14 @@ export class WatermarkContribution extends Disposable implements IWorkbenchContr
|
||||
dd.innerHTML = keybinding.element.outerHTML;
|
||||
});
|
||||
};
|
||||
|
||||
update();
|
||||
|
||||
dom.prepend(container.firstElementChild as HTMLElement, this.watermark);
|
||||
this._register(this.keybindingService.onDidUpdateKeybindings(update));
|
||||
this._register(this.editorGroupsService.onDidLayout(dimension => this.handleEditorPartSize(container, dimension)));
|
||||
|
||||
this.watermarkDisposable.add(this.keybindingService.onDidUpdateKeybindings(update));
|
||||
this.watermarkDisposable.add(this.editorGroupsService.onDidLayout(dimension => this.handleEditorPartSize(container, dimension)));
|
||||
|
||||
this.handleEditorPartSize(container, this.editorGroupsService.contentDimension);
|
||||
}
|
||||
|
||||
@@ -205,9 +174,11 @@ export class WatermarkContribution extends Disposable implements IWorkbenchContr
|
||||
private destroy(): void {
|
||||
if (this.watermark) {
|
||||
this.watermark.remove();
|
||||
|
||||
const container = this.layoutService.getContainer(Parts.EDITOR_PART);
|
||||
container.classList.remove('has-watermark');
|
||||
this.dispose();
|
||||
|
||||
this.watermarkDisposable.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user