mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-28 07:40:30 -04:00
Merge from master
This commit is contained in:
@@ -3,23 +3,19 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
export const ID = 'urlService';
|
||||
export const IURLService = createDecorator<IURLService>(ID);
|
||||
export const IURLService = createDecorator<IURLService>('urlService');
|
||||
|
||||
export interface IURLHandler {
|
||||
handleURL(uri: URI): TPromise<boolean>;
|
||||
handleURL(uri: URI): Thenable<boolean>;
|
||||
}
|
||||
|
||||
export interface IURLService {
|
||||
_serviceBrand: any;
|
||||
|
||||
open(url: URI): TPromise<boolean>;
|
||||
open(url: URI): Thenable<boolean>;
|
||||
registerHandler(handler: IURLHandler): IDisposable;
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { IURLHandler, IURLService } from './url';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
|
||||
export interface IURLServiceChannel extends IChannel {
|
||||
call(command: 'open', url: string): TPromise<boolean>;
|
||||
call(command: string, arg?: any): TPromise<any>;
|
||||
}
|
||||
|
||||
export class URLServiceChannel implements IURLServiceChannel {
|
||||
|
||||
constructor(private service: IURLService) { }
|
||||
|
||||
listen<T>(event: string, arg?: any): Event<T> {
|
||||
throw new Error('No events');
|
||||
}
|
||||
|
||||
call(command: string, arg?: any): TPromise<any> {
|
||||
switch (command) {
|
||||
case 'open': return this.service.open(URI.revive(arg));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class URLServiceChannelClient implements IURLService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
open(url: URI): TPromise<boolean, any> {
|
||||
return this.channel.call('open', url.toJSON());
|
||||
}
|
||||
|
||||
registerHandler(handler: IURLHandler): IDisposable {
|
||||
throw new Error('Not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
export interface IURLHandlerChannel extends IChannel {
|
||||
call(command: 'handleURL', arg: any): TPromise<boolean>;
|
||||
call(command: string, arg?: any): TPromise<any>;
|
||||
}
|
||||
|
||||
export class URLHandlerChannel implements IURLHandlerChannel {
|
||||
|
||||
constructor(private handler: IURLHandler) { }
|
||||
|
||||
listen<T>(event: string, arg?: any): Event<T> {
|
||||
throw new Error('No events');
|
||||
}
|
||||
|
||||
call(command: string, arg?: any): TPromise<any> {
|
||||
switch (command) {
|
||||
case 'handleURL': return this.handler.handleURL(URI.revive(arg));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class URLHandlerChannelClient implements IURLHandler {
|
||||
|
||||
constructor(private channel: IChannel) { }
|
||||
|
||||
handleURL(uri: URI): TPromise<boolean> {
|
||||
return this.channel.call('handleURL', uri.toJSON());
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,9 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { first } from 'vs/base/common/async';
|
||||
|
||||
declare module Array {
|
||||
@@ -21,7 +18,7 @@ export class URLService implements IURLService {
|
||||
|
||||
private handlers = new Set<IURLHandler>();
|
||||
|
||||
open(uri: URI): TPromise<boolean> {
|
||||
open(uri: URI): Thenable<boolean> {
|
||||
const handlers = Array.from(this.handlers);
|
||||
return first(handlers.map(h => () => h.handleURL(uri)), undefined, false);
|
||||
}
|
||||
@@ -38,11 +35,11 @@ export class RelayURLService extends URLService implements IURLHandler {
|
||||
super();
|
||||
}
|
||||
|
||||
open(uri: URI): TPromise<boolean> {
|
||||
open(uri: URI): Thenable<boolean> {
|
||||
return this.urlService.open(uri);
|
||||
}
|
||||
|
||||
handleURL(uri: URI): TPromise<boolean> {
|
||||
handleURL(uri: URI): Thenable<boolean> {
|
||||
return super.open(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user