From 24b5f410650ae58c6ba912071ff47d1fa171da5c Mon Sep 17 00:00:00 2001 From: Anthony Dresser Date: Thu, 21 Mar 2019 16:10:54 -0700 Subject: [PATCH] add data explorer default (#4653) --- extensions/azurecore/package.json | 17 --- .../common/dataExplorer.contribution.ts | 91 ---------------- .../common/registeredServer.contribution.ts | 100 ------------------ .../viewlet/connectionTreeAction.ts | 2 +- .../browser}/connectionViewletPanel.ts | 1 + .../browser/dataExplorer.contribution.ts | 90 ++++++++++++++++ .../browser}/dataExplorerExtensionPoint.ts | 0 .../browser}/dataExplorerViewlet.ts | 4 +- .../browser/media}/dataExplorerViewlet.css | 0 .../contrib/watermark/browser/watermark.ts | 9 +- src/vs/workbench/workbench.main.ts | 7 +- 11 files changed, 101 insertions(+), 220 deletions(-) delete mode 100644 src/sql/parts/dataExplorer/common/dataExplorer.contribution.ts delete mode 100644 src/sql/parts/objectExplorer/common/registeredServer.contribution.ts rename src/sql/{parts/dataExplorer/objectExplorer/connectionViewlet => workbench/parts/dataExplorer/browser}/connectionViewletPanel.ts (99%) create mode 100644 src/sql/workbench/parts/dataExplorer/browser/dataExplorer.contribution.ts rename src/sql/{parts/dataExplorer/common => workbench/parts/dataExplorer/browser}/dataExplorerExtensionPoint.ts (100%) rename src/sql/{parts/dataExplorer/viewlet => workbench/parts/dataExplorer/browser}/dataExplorerViewlet.ts (95%) rename src/sql/{parts/dataExplorer/viewlet => workbench/parts/dataExplorer/browser/media}/dataExplorerViewlet.css (100%) diff --git a/extensions/azurecore/package.json b/extensions/azurecore/package.json index 9a7c71fbe2..fce48c4e21 100644 --- a/extensions/azurecore/package.json +++ b/extensions/azurecore/package.json @@ -105,23 +105,6 @@ } } ], - "viewsContainers": { - "activitybar": [ - { - "id": "azureResource", - "title": "%azure.title%", - "icon": "resources/azure.svg" - } - ] - }, - "views": { - "azureResource": [ - { - "id": "azureResourceExplorer", - "name": "%azure.resource.explorer.title%" - } - ] - }, "dataExplorer": { "azureResource": [ { diff --git a/src/sql/parts/dataExplorer/common/dataExplorer.contribution.ts b/src/sql/parts/dataExplorer/common/dataExplorer.contribution.ts deleted file mode 100644 index f744b09bf9..0000000000 --- a/src/sql/parts/dataExplorer/common/dataExplorer.contribution.ts +++ /dev/null @@ -1,91 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import 'vs/css!sql/media/actionBarLabel'; -import { localize } from 'vs/nls'; -import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet'; -import { Registry } from 'vs/platform/registry/common/platform'; -import { VIEWLET_ID } from 'sql/parts/dataExplorer/common/dataExplorerExtensionPoint'; -import { DataExplorerViewlet, DataExplorerViewletViewsContribution } from 'sql/parts/dataExplorer/viewlet/dataExplorerViewlet'; -import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; -import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; -import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; -import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; -import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; -import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; -import { ToggleViewletAction } from 'vs/workbench/browser/parts/activitybar/activitybarActions'; -import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; - -// Viewlet Action -export class OpenDataExplorerViewletAction extends ToggleViewletAction { - public static ID = VIEWLET_ID; - public static LABEL = 'Show Data Explorer'; - - constructor( - id: string, - label: string, - @IViewletService viewletService: IViewletService, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService - ) { - super(viewletDescriptor, layoutService, viewletService); - } -} - -// Data Explorer Viewlet -const viewletDescriptor = new ViewletDescriptor( - DataExplorerViewlet, - VIEWLET_ID, - localize('workbench.dataExplorer', 'Data Explorer'), - 'dataExplorer', - 0 -); - -if (process.env.NODE_ENV === 'development') { - Registry.as(ViewletExtensions.Viewlets).registerViewlet(viewletDescriptor); - Registry.as(ViewletExtensions.Viewlets).setDefaultViewletId(VIEWLET_ID); - const workbenchRegistry = Registry.as(WorkbenchExtensions.Workbench); - workbenchRegistry.registerWorkbenchContribution(DataExplorerViewletViewsContribution, LifecyclePhase.Starting); - const registry = Registry.as(ActionExtensions.WorkbenchActions); - registry.registerWorkbenchAction( - new SyncActionDescriptor( - OpenDataExplorerViewletAction, - OpenDataExplorerViewletAction.ID, - OpenDataExplorerViewletAction.LABEL, - { primary: KeyMod.CtrlCmd | KeyCode.Shift | KeyCode.KEY_C }), - 'View: Show Servers', - localize('registeredServers.view', "View") - ); - - let configurationRegistry = Registry.as(Extensions.Configuration); - configurationRegistry.registerConfiguration({ - 'id': 'databaseConnections', - 'order': 0, - 'title': localize('databaseConnections', 'Database Connections'), - 'type': 'object', - 'properties': { - 'datasource.connections': { - 'description': localize('datasource.connections', 'data source connections'), - 'type': 'array' - }, - 'datasource.connectionGroups': { - 'description': localize('datasource.connectionGroups', 'data source groups'), - 'type': 'array' - } - } - }); - configurationRegistry.registerConfiguration({ - 'id': 'startupConfig', - 'title': localize('startupConfig', 'Startup Configuration'), - 'type': 'object', - 'properties': { - 'startup.alwaysShowServersView': { - 'type': 'boolean', - 'description': localize('startup.alwaysShowServersView', 'True for the Servers view to be shown on launch of Azure Data Studio default; false if the last opened view should be shown'), - 'default': true - } - } - }); -} diff --git a/src/sql/parts/objectExplorer/common/registeredServer.contribution.ts b/src/sql/parts/objectExplorer/common/registeredServer.contribution.ts deleted file mode 100644 index 2119139c35..0000000000 --- a/src/sql/parts/objectExplorer/common/registeredServer.contribution.ts +++ /dev/null @@ -1,100 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import 'vs/css!sql/media/actionBarLabel'; -import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; -import { localize } from 'vs/nls'; -import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions'; -import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet'; -import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; -import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; -import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; -import { Registry } from 'vs/platform/registry/common/platform'; -import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; - -import { VIEWLET_ID } from 'sql/platform/connection/common/connectionManagement'; -import { ConnectionViewlet } from 'sql/workbench/parts/connection/electron-browser/connectionViewlet'; -import { ToggleViewletAction } from 'vs/workbench/browser/parts/activitybar/activitybarActions'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; - -// Viewlet Action -export class OpenConnectionsViewletAction extends ToggleViewletAction { - public static ID = VIEWLET_ID; - public static LABEL = 'Show Servers'; - - constructor( - id: string, - label: string, - @IViewletService viewletService: IViewletService, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService - ) { - super(viewletDescriptor, layoutService, viewletService); - } -} - -// Viewlet -const viewletDescriptor = new ViewletDescriptor( - ConnectionViewlet, - VIEWLET_ID, - 'Servers', - 'connectionViewlet', - 0 -); - -if (process.env.NODE_ENV !== 'development') { - Registry.as(ViewletExtensions.Viewlets).registerViewlet(viewletDescriptor); - - Registry.as(ViewletExtensions.Viewlets).setDefaultViewletId(VIEWLET_ID); - - const registry = Registry.as(ActionExtensions.WorkbenchActions); - registry.registerWorkbenchAction( - new SyncActionDescriptor( - OpenConnectionsViewletAction, - OpenConnectionsViewletAction.ID, - OpenConnectionsViewletAction.LABEL, - { primary: KeyMod.CtrlCmd | KeyCode.Shift | KeyCode.KEY_C }), - 'View: Show Servers', - localize('registeredServers.view', "View") - ); - - let configurationRegistry = Registry.as(Extensions.Configuration); - configurationRegistry.registerConfiguration({ - 'id': 'databaseConnections', - 'order': 0, - 'title': localize('databaseConnections', 'Database Connections'), - 'type': 'object', - 'properties': { - 'datasource.connections': { - 'description': localize('datasource.connections', 'data source connections'), - 'type': 'array' - }, - 'datasource.connectionGroups': { - 'description': localize('datasource.connectionGroups', 'data source groups'), - 'type': 'array' - } - } - }); - configurationRegistry.registerConfiguration({ - 'id': 'startupConfig', - 'title': localize('startupConfig', 'Startup Configuration'), - 'type': 'object', - 'properties': { - 'startup.alwaysShowServersView': { - 'type': 'boolean', - 'description': localize('startup.alwaysShowServersView', 'True for the Servers view to be shown on launch of Azure Data Studio default; false if the last opened view should be shown'), - 'default': true - } - } - }); -} - -MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, { - group: '3_views', - command: { - id: VIEWLET_ID, - title: localize({ key: 'miViewRegisteredServers', comment: ['&& denotes a mnemonic'] }, "&&Servers") - }, - order: 1 -}); diff --git a/src/sql/parts/objectExplorer/viewlet/connectionTreeAction.ts b/src/sql/parts/objectExplorer/viewlet/connectionTreeAction.ts index 27a33b1661..4663e0c26b 100644 --- a/src/sql/parts/objectExplorer/viewlet/connectionTreeAction.ts +++ b/src/sql/parts/objectExplorer/viewlet/connectionTreeAction.ts @@ -22,7 +22,7 @@ import Severity from 'vs/base/common/severity'; import { ObjectExplorerActionsContext } from 'sql/parts/objectExplorer/viewlet/objectExplorerActions'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService'; -import { ConnectionViewletPanel } from 'sql/parts/dataExplorer/objectExplorer/connectionViewlet/connectionViewletPanel'; +import { ConnectionViewletPanel } from 'sql/workbench/parts/dataExplorer/browser/connectionViewletPanel'; export class RefreshAction extends Action { diff --git a/src/sql/parts/dataExplorer/objectExplorer/connectionViewlet/connectionViewletPanel.ts b/src/sql/workbench/parts/dataExplorer/browser/connectionViewletPanel.ts similarity index 99% rename from src/sql/parts/dataExplorer/objectExplorer/connectionViewlet/connectionViewletPanel.ts rename to src/sql/workbench/parts/dataExplorer/browser/connectionViewletPanel.ts index ba66d48218..abfb5cfc11 100644 --- a/src/sql/parts/dataExplorer/objectExplorer/connectionViewlet/connectionViewletPanel.ts +++ b/src/sql/workbench/parts/dataExplorer/browser/connectionViewletPanel.ts @@ -169,5 +169,6 @@ export class ConnectionViewletPanel extends ViewletPanel { focus(): void { super.focus(); + this._serverTreeView.tree.domFocus(); } } diff --git a/src/sql/workbench/parts/dataExplorer/browser/dataExplorer.contribution.ts b/src/sql/workbench/parts/dataExplorer/browser/dataExplorer.contribution.ts new file mode 100644 index 0000000000..7cca38bc9e --- /dev/null +++ b/src/sql/workbench/parts/dataExplorer/browser/dataExplorer.contribution.ts @@ -0,0 +1,90 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the Source EULA. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import 'vs/css!sql/media/actionBarLabel'; +import { localize } from 'vs/nls'; +import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor, ShowViewletAction } from 'vs/workbench/browser/viewlet'; +import { Registry } from 'vs/platform/registry/common/platform'; +import { VIEWLET_ID } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint'; +import { DataExplorerViewlet, DataExplorerViewletViewsContribution } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet'; +import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; +import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; +import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; +import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; +import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; +import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; +import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; +import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; +import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; + +// Viewlet Action +export class OpenDataExplorerViewletAction extends ShowViewletAction { + public static ID = VIEWLET_ID; + public static LABEL = localize('showDataExplorer', "Show Data Explorer"); + + constructor( + id: string, + label: string, + @IViewletService viewletService: IViewletService, + @IEditorGroupsService editorGroupService: IEditorGroupsService, + @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService + ) { + super(id, label, VIEWLET_ID, viewletService, editorGroupService, layoutService); + } +} + +// Data Explorer Viewlet +const viewletDescriptor = new ViewletDescriptor( + DataExplorerViewlet, + VIEWLET_ID, + localize('workbench.dataExplorer', "Data Explorer"), + 'dataExplorer', + 0 +); + +Registry.as(ViewletExtensions.Viewlets).registerViewlet(viewletDescriptor); +Registry.as(ViewletExtensions.Viewlets).setDefaultViewletId(VIEWLET_ID); +const workbenchRegistry = Registry.as(WorkbenchExtensions.Workbench); +workbenchRegistry.registerWorkbenchContribution(DataExplorerViewletViewsContribution, LifecyclePhase.Starting); +const registry = Registry.as(ActionExtensions.WorkbenchActions); +registry.registerWorkbenchAction( + new SyncActionDescriptor( + OpenDataExplorerViewletAction, + OpenDataExplorerViewletAction.ID, + OpenDataExplorerViewletAction.LABEL, + { primary: KeyMod.CtrlCmd | KeyCode.Shift | KeyCode.KEY_C }), + 'View: Show Data Explorer', + localize('dataExplorer.view', "View") +); + +let configurationRegistry = Registry.as(Extensions.Configuration); +configurationRegistry.registerConfiguration({ + 'id': 'databaseConnections', + 'order': 0, + 'title': localize('databaseConnections', "Database Connections"), + 'type': 'object', + 'properties': { + 'datasource.connections': { + 'description': localize('datasource.connections', "data source connections"), + 'type': 'array' + }, + 'datasource.connectionGroups': { + 'description': localize('datasource.connectionGroups', "data source groups"), + 'type': 'array' + } + } +}); +configurationRegistry.registerConfiguration({ + 'id': 'startupConfig', + 'title': localize('startupConfig', "Startup Configuration"), + 'type': 'object', + 'properties': { + 'startup.alwaysShowServersView': { + 'type': 'boolean', + 'description': localize('startup.alwaysShowServersView', "True for the Servers view to be shown on launch of Azure Data Studio default; false if the last opened view should be shown"), + 'default': true + } + } +}); diff --git a/src/sql/parts/dataExplorer/common/dataExplorerExtensionPoint.ts b/src/sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint.ts similarity index 100% rename from src/sql/parts/dataExplorer/common/dataExplorerExtensionPoint.ts rename to src/sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint.ts diff --git a/src/sql/parts/dataExplorer/viewlet/dataExplorerViewlet.ts b/src/sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet.ts similarity index 95% rename from src/sql/parts/dataExplorer/viewlet/dataExplorerViewlet.ts rename to src/sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet.ts index 21a4331779..33db3aceee 100644 --- a/src/sql/parts/dataExplorer/viewlet/dataExplorerViewlet.ts +++ b/src/sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet.ts @@ -22,8 +22,8 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IAddedViewDescriptorRef } from 'vs/workbench/browser/parts/views/views'; import { ViewletPanel } from 'vs/workbench/browser/parts/views/panelViewlet'; -import { VIEWLET_ID, VIEW_CONTAINER } from 'sql/parts/dataExplorer/common/dataExplorerExtensionPoint'; -import { ConnectionViewletPanel } from 'sql/parts/dataExplorer/objectExplorer/connectionViewlet/connectionViewletPanel'; +import { VIEWLET_ID, VIEW_CONTAINER } from 'sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint'; +import { ConnectionViewletPanel } from 'sql/workbench/parts/dataExplorer/browser/connectionViewletPanel'; import { Extensions as ViewContainerExtensions, IViewDescriptor, IViewsRegistry } from 'vs/workbench/common/views'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; diff --git a/src/sql/parts/dataExplorer/viewlet/dataExplorerViewlet.css b/src/sql/workbench/parts/dataExplorer/browser/media/dataExplorerViewlet.css similarity index 100% rename from src/sql/parts/dataExplorer/viewlet/dataExplorerViewlet.css rename to src/sql/workbench/parts/dataExplorer/browser/media/dataExplorerViewlet.css diff --git a/src/vs/workbench/contrib/watermark/browser/watermark.ts b/src/vs/workbench/contrib/watermark/browser/watermark.ts index 64a7364923..6d3b96c616 100644 --- a/src/vs/workbench/contrib/watermark/browser/watermark.ts +++ b/src/vs/workbench/contrib/watermark/browser/watermark.ts @@ -29,11 +29,10 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { IDimension } from 'vs/platform/layout/browser/layoutService'; -const $ = dom.$; - // {{SQL CARBON EDIT}} -import { OpenConnectionsViewletAction } from 'sql/parts/objectExplorer/common/registeredServer.contribution'; +import { OpenDataExplorerViewletAction } from 'sql/workbench/parts/dataExplorer/browser/dataExplorer.contribution'; +const $ = dom.$; interface WatermarkEntry { text: string; @@ -44,7 +43,7 @@ interface WatermarkEntry { // {{SQL CARBON EDIT}} const showServers: WatermarkEntry = { text: nls.localize('watermark.showServers', 'Show Servers'), - id: OpenConnectionsViewletAction.ID + id: OpenDataExplorerViewletAction.ID }; const newSqlFile: WatermarkEntry = { @@ -230,4 +229,4 @@ Registry.as(ConfigurationExtensions.Configuration) 'description': nls.localize('tips.enabled', "When enabled, will show the watermark tips when no editor is open.") }, } - }); \ No newline at end of file + }); diff --git a/src/vs/workbench/workbench.main.ts b/src/vs/workbench/workbench.main.ts index 79f8abf83f..a7551bd518 100644 --- a/src/vs/workbench/workbench.main.ts +++ b/src/vs/workbench/workbench.main.ts @@ -441,12 +441,11 @@ import 'sql/parts/taskHistory/viewlet/taskHistoryViewlet'; import 'sql/parts/tasks/common/tasks.contribution'; // data explorer -import 'sql/parts/dataExplorer/common/dataExplorer.contribution'; -import 'sql/parts/dataExplorer/viewlet/dataExplorerViewlet'; -import 'sql/parts/dataExplorer/common/dataExplorerExtensionPoint'; +import 'sql/workbench/parts/dataExplorer/browser/dataExplorer.contribution'; +import 'sql/workbench/parts/dataExplorer/browser/dataExplorerViewlet'; +import 'sql/workbench/parts/dataExplorer/browser/dataExplorerExtensionPoint'; import 'sql/workbench/parts/dataExplorer/electron-browser/nodeActions.contribution'; -import 'sql/parts/objectExplorer/common/registeredServer.contribution'; import 'sql/workbench/parts/connection/electron-browser/connectionViewlet'; import 'sql/workbench/api/node/sqlExtHost.contribution'; import 'sql/parts/connection/common/connection.contribution';