@eclipse-glsp/client
Version:
A sprotty-based client for GLSP
81 lines • 4.54 kB
TypeScript
/********************************************************************************
* Copyright (c) 2020-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Action, Disposable, DisposableCollection, IActionDispatcher, IActionHandler, MaybeActions } from '@eclipse-glsp/sprotty';
import { EditorContextService } from '../../base/editor-context-service';
import { IFeedbackActionDispatcher, IFeedbackEmitter } from '../../base/feedback/feedback-action-dispatcher';
import { FeedbackEmitter } from '../../base/feedback/feedback-emitter';
import { Tool } from '../../base/tool-manager/tool';
import { GLSPKeyTool } from '../../base/view/key-tool';
import { GLSPMouseTool } from '../../base/view/mouse-tool';
export interface FeedbackAwareTool extends Tool {
/**
* Creates a new feedback emitter helper object. While anything can serve as a feedback emitter,
* this method ensures that the emitter is stable and does not change between model updates.
*/
createFeedbackEmitter(): FeedbackEmitter;
/**
* Registers `actions` to be sent out as feedback, i.e., changes that are re-established whenever the `GModelRoot`
* has been set or updated.
*
* @param feedbackActions the actions to be sent out.
* @param feedbackEmitter the emitter sending out feedback actions (this tool by default).
* @param cleanupActions the actions to be sent out when the feedback is de-registered through the returned Disposable.
* @returns A 'Disposable' that de-registers the feedback and cleans up any pending feedback with the given `cleanupActions`.
* @deprecated It is recommended to create a {@link createFeedbackEmitter dedicated emitter} per feedback instead of using the tool.
*/
registerFeedback(feedbackActions: Action[], feedbackEmitter?: IFeedbackEmitter, cleanupActions?: MaybeActions): Disposable;
/**
* De-registers all feedback from the given `feedbackEmitter` (this tool by default) and cleans up any pending feedback with the
* given `cleanupActions`.
*
* @param feedbackEmitter the emitter to be deregistered (this tool by default).
* @param cleanupActions the actions to be dispatched right after the deregistration to clean up any pending feedback.
* @deprecated It is recommended to create a {@link createFeedbackEmitter dedicated emitter} per feedback and dispose it like that.
*/
deregisterFeedback(feedbackEmitter?: IFeedbackEmitter, cleanupActions?: MaybeActions): void;
}
/**
* A reusable base implementation for {@link Tool}s.
*/
export declare abstract class BaseTool implements FeedbackAwareTool {
protected feedbackDispatcher: IFeedbackActionDispatcher;
protected actionDispatcher: IActionDispatcher;
protected mouseTool: GLSPMouseTool;
protected keyTool: GLSPKeyTool;
protected readonly editorContext: EditorContextService;
protected readonly toDisposeOnDisable: DisposableCollection;
abstract enable(): void;
disable(): void;
abstract id: string;
dispatchActions(actions: Action[]): Promise<void>;
createFeedbackEmitter(): FeedbackEmitter;
registerFeedback(feedbackActions: Action[], feedbackEmitter?: IFeedbackEmitter, cleanupActions?: MaybeActions): Disposable;
deregisterFeedback(feedbackEmitter?: IFeedbackEmitter, cleanupActions?: MaybeActions): void;
}
/**
* A reusable base implementation for edit {@link Tool}s.
*/
export declare abstract class BaseEditTool extends BaseTool {
get isEditTool(): boolean;
}
export declare abstract class BaseCreationTool<T extends Action> extends BaseEditTool implements IActionHandler {
protected abstract isTriggerAction: (obj: any) => obj is T;
protected triggerAction: T;
handle(action: Action): Action | void;
enable(): void;
protected abstract doEnable(): void;
}
//# sourceMappingURL=base-tools.d.ts.map