UNPKG

2.42 kBTypeScriptView Raw
1import { SelectionService } from '../common/selection-service';
2import { CommandHandler } from './command';
3import URI from './uri';
4import { MaybeArray } from './types';
5export interface UriCommandHandler<T extends MaybeArray<URI>> extends CommandHandler {
6 execute(uri: T, ...args: any[]): any;
7 isEnabled?(uri: T, ...args: any[]): boolean;
8 isVisible?(uri: T, ...args: any[]): boolean;
9}
10/**
11 * Handler for a single URI-based selection.
12 */
13export interface SingleUriCommandHandler extends UriCommandHandler<URI> {
14}
15/**
16 * Handler for multiple URIs.
17 */
18export interface MultiUriCommandHandler extends UriCommandHandler<URI[]> {
19}
20export declare class UriAwareCommandHandler<T extends MaybeArray<URI>> implements UriCommandHandler<T> {
21 protected readonly selectionService: SelectionService;
22 protected readonly handler: UriCommandHandler<T>;
23 protected readonly options?: UriAwareCommandHandler.Options | undefined;
24 /**
25 * @deprecated since 1.6.0. Please use `UriAwareCommandHandler.MonoSelect` or `UriAwareCommandHandler.MultiSelect`.
26 */
27 constructor(selectionService: SelectionService, handler: UriCommandHandler<T>, options?: UriAwareCommandHandler.Options | undefined);
28 protected getUri(...args: any[]): T | undefined;
29 protected getArgsWithUri(...args: any[]): [T | undefined, ...any[]];
30 execute(...args: any[]): object | undefined;
31 isVisible(...args: any[]): boolean;
32 isEnabled(...args: any[]): boolean;
33 protected isMulti(): boolean | undefined;
34}
35export declare namespace UriAwareCommandHandler {
36 /**
37 * Further options for the URI aware command handler instantiation.
38 */
39 interface Options {
40 /**
41 * `true` if the handler supports multiple selection. Otherwise, `false`. Defaults to `false`.
42 */
43 readonly multi?: boolean;
44 }
45 /**
46 * @returns a command handler for mono-select contexts that expects a `URI` as the first parameter of its methods.
47 */
48 function MonoSelect(selectionService: SelectionService, handler: UriCommandHandler<URI>): UriAwareCommandHandler<URI>;
49 /**
50 * @returns a command handler for multi-select contexts that expects a `URI[]` as the first parameter of its methods.
51 */
52 function MultiSelect(selectionService: SelectionService, handler: UriCommandHandler<URI[]>): UriAwareCommandHandler<URI[]>;
53}
54//# sourceMappingURL=uri-command-handler.d.ts.map
\No newline at end of file