Initial Code Layering (#3788)

* working on formatting

* fixed basic lint errors; starting moving things to their appropriate location

* formatting

* update tslint to match the version of vscode we have

* remove unused code

* work in progress fixing layering

* formatting

* moved connection management service to platform

* formatting

* add missing file

* moving more servies

* formatting

* moving more services

* formatting

* wip

* moving more services

* formatting

* revert back tslint rules

* move css file

* add missing svgs
This commit is contained in:
Anthony Dresser
2019-01-25 14:52:35 -08:00
committed by GitHub
parent c8986464ec
commit ea67859de7
338 changed files with 2036 additions and 7386 deletions

View File

@@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import Severity from 'vs/base/common/severity';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { SERVER_GROUP_CONFIG, SERVER_GROUP_COLORS_CONFIG } from 'sql/parts/objectExplorer/serverGroupDialog/serverGroup.contribution';
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
import { IServerGroupController, IServerGroupDialogCallbacks } from 'sql/platform/serverGroup/common/serverGroupController';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { ServerGroupDialog } from 'sql/parts/objectExplorer/serverGroupDialog/serverGroupDialog';
import { ServerGroupViewModel } from 'sql/parts/objectExplorer/serverGroupDialog/serverGroupViewModel';
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
export class ServerGroupController implements IServerGroupController {
_serviceBrand: any;
private _serverGroupDialog: ServerGroupDialog;
private _connectionManagementService: IConnectionManagementService;
private _callbacks: IServerGroupDialogCallbacks;
private _group: ConnectionProfileGroup;
private _viewModel: ServerGroupViewModel;
constructor(
@IErrorMessageService private _errorMessageService: IErrorMessageService,
@IInstantiationService private _instantiationService: IInstantiationService,
@IConfigurationService private _configurationService: IConfigurationService
) {
}
private handleOnAddServerGroup(): void {
if (this._group) {
let tempGroup: ConnectionProfileGroup = this.copyConnectionProfileGroup(this._group);
this._group.name = this._viewModel.groupName;
this._group.color = this._viewModel.groupColor;
this._group.description = this._viewModel.groupDescription;
this._connectionManagementService.editGroup(this._group).then(() => {
this._serverGroupDialog.close();
}).catch(err => {
// rollback changes made
this._group = tempGroup;
this._errorMessageService.showDialog(Severity.Error, '', err);
});
} else {
let newGroup: IConnectionProfileGroup = {
name: this._viewModel.groupName,
id: undefined,
parentId: undefined,
color: this._viewModel.groupColor,
description: this._viewModel.groupDescription
};
this._connectionManagementService.saveProfileGroup(newGroup).then(groupId => {
if (this._callbacks) {
this._callbacks.onAddGroup(this._serverGroupDialog.groupName);
}
this._serverGroupDialog.close();
}).catch(err => {
this._errorMessageService.showDialog(Severity.Error, '', err);
});
}
}
private copyConnectionProfileGroup(group: ConnectionProfileGroup): ConnectionProfileGroup {
return new ConnectionProfileGroup(group.name, group.parent, group.id, group.color, group.description);
}
private handleOnClose(): void {
if (this._callbacks) {
this._callbacks.onClose();
}
}
public showCreateGroupDialog(connectionManagementService: IConnectionManagementService, callbacks?: IServerGroupDialogCallbacks): TPromise<void> {
this._connectionManagementService = connectionManagementService;
this._group = null;
this._viewModel = new ServerGroupViewModel(undefined, this._configurationService.getValue(SERVER_GROUP_CONFIG)[SERVER_GROUP_COLORS_CONFIG]);
this._callbacks = callbacks ? callbacks : undefined;
return this.openServerGroupDialog();
}
public showEditGroupDialog(connectionManagementService: IConnectionManagementService, group: ConnectionProfileGroup): TPromise<void> {
this._connectionManagementService = connectionManagementService;
this._group = group;
this._viewModel = new ServerGroupViewModel(group, this._configurationService.getValue(SERVER_GROUP_CONFIG)[SERVER_GROUP_COLORS_CONFIG]);
return this.openServerGroupDialog();
}
private openServerGroupDialog(): TPromise<void> {
if (!this._serverGroupDialog) {
this._serverGroupDialog = this._instantiationService.createInstance(ServerGroupDialog);
this._serverGroupDialog.viewModel = this._viewModel;
this._serverGroupDialog.onCancel(() => { });
this._serverGroupDialog.onAddServerGroup(() => this.handleOnAddServerGroup());
this._serverGroupDialog.onCloseEvent(() => this.handleOnClose());
this._serverGroupDialog.render();
} else {
// reset the view model in the view
this._serverGroupDialog.viewModel = this._viewModel;
}
return new TPromise<void>(() => {
this._serverGroupDialog.open();
});
}
}