diff --git a/integration/eclipse/src/copy-paste/copy-paste.ts b/integration/eclipse/src/copy-paste/copy-paste.ts deleted file mode 100644 index 00621dc4..00000000 --- a/integration/eclipse/src/copy-paste/copy-paste.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { - Action, - CutOperation, - EditorContextService, - IActionDispatcher, - IActionHandler, - IAsyncClipboardService, - PasteOperation, - RequestClipboardDataAction, - TYPES, - ViewerOptions -} from '@eclipse-glsp/client'; -import { inject, injectable } from 'inversify'; - -// Eclipse-specific integration: in Eclipse, we trigger the Copy/Paste actions from -// the IDE Keybindings. We don't use the browser events. This is fine, because we -// don't need browser clipboard support (We use the Eclipse System Clipboard); so -// we don't need special permission from the Browser. - -@injectable() -export class IvyEclipseCopyPasteActionHandler implements IActionHandler { - @inject(TYPES.IActionDispatcher) protected actionDispatcher: IActionDispatcher; - @inject(TYPES.ViewerOptions) protected viewerOptions: ViewerOptions; - @inject(TYPES.IAsyncClipboardService) protected clipboadService: IAsyncClipboardService; - @inject(EditorContextService) protected editorContext: EditorContextService; - - handle(action: Action): void { - switch (action.kind) { - case 'invoke-copy': - this.handleCopy(); - break; - case 'invoke-paste': - this.handlePaste(); - break; - case 'invoke-cut': - this.handleCut(); - break; - } - } - - handleCopy(): void { - if (this.shouldCopy()) { - this.actionDispatcher.request(RequestClipboardDataAction.create(this.editorContext.get())); - } else { - this.clipboadService.clear(); - } - } - - handleCut(): void { - if (this.shouldCopy()) { - this.handleCopy(); - this.actionDispatcher.dispatch(CutOperation.create(this.editorContext.get())); - } - } - - handlePaste(): void { - // In the Eclipse Integration case, the server manages its own clipboard. - // Just pass an empty clipboard data to remain compliant with the API. - const clipboardData = {}; - this.actionDispatcher.dispatch(PasteOperation.create({ clipboardData: clipboardData, editorContext: this.editorContext.get() })); - } - - protected shouldCopy(): boolean | null { - return ( - this.editorContext.get().selectedElementIds.length > 0 && - (document.activeElement instanceof SVGElement || document.activeElement instanceof HTMLElement) && - document.activeElement.parentElement && - document.activeElement.parentElement.id === this.viewerOptions.baseDiv - ); - } -} diff --git a/integration/eclipse/src/copy-paste/di.config.ts b/integration/eclipse/src/copy-paste/di.config.ts deleted file mode 100644 index 97d65be2..00000000 --- a/integration/eclipse/src/copy-paste/di.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { configureActionHandler } from '@eclipse-glsp/client'; -import { ContainerModule } from 'inversify'; - -import { IvyEclipseCopyPasteActionHandler } from './copy-paste'; - -const ivyEclipseCopyPasteModule = new ContainerModule((bind, _unbind, isBound) => { - configureActionHandler({ bind, isBound }, 'invoke-copy', IvyEclipseCopyPasteActionHandler); - configureActionHandler({ bind, isBound }, 'invoke-cut', IvyEclipseCopyPasteActionHandler); - configureActionHandler({ bind, isBound }, 'invoke-paste', IvyEclipseCopyPasteActionHandler); -}); - -export default ivyEclipseCopyPasteModule; diff --git a/integration/eclipse/src/di.config.ts b/integration/eclipse/src/di.config.ts index 3497a662..348aa9ff 100644 --- a/integration/eclipse/src/di.config.ts +++ b/integration/eclipse/src/di.config.ts @@ -9,9 +9,8 @@ import ivyGoToSourceModule from './edit-source/di.config'; import ivyEditorActionModule from './editor-action/di.config'; import ivyOpenDataClassModule from './open-data-class/di.config'; import ivyToolBarModule from './tool-bar/di.config'; -import ivyEclipseCopyPasteModule from './copy-paste/di.config'; -import ivyEclipseDeleteModule from './invoke-delete/di.config'; import { IvyEclipseGLSPDiagramServer } from './ivy-eclipse-glsp-diagram-server'; +import { eclipseCopyPasteModule, eclipseDeleteModule } from '@eclipse-glsp/ide'; export default function createContainer(widgetId: string): Container { const container = createIvyDiagramContainer(widgetId); @@ -19,10 +18,8 @@ export default function createContainer(widgetId: string): Container { container.rebind(TYPES.ILogger).to(ConsoleLogger).inSingletonScope(); container.rebind(TYPES.LogLevel).toConstantValue(LogLevel.warn); - // Revert after Issue 690 is merged - container.load(ivyEclipseCopyPasteModule); - // Revert after Issue 690 is merged - container.load(ivyEclipseDeleteModule); + container.load(eclipseCopyPasteModule); + container.load(eclipseDeleteModule); container.load(ivyOpenInscriptionModule); container.load(ivyOpenDecoratorBrowserModule); container.load(ivyOpenQuickOutlineModule); diff --git a/integration/eclipse/src/invoke-delete/di.config.ts b/integration/eclipse/src/invoke-delete/di.config.ts deleted file mode 100644 index 7eaf6933..00000000 --- a/integration/eclipse/src/invoke-delete/di.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { configureActionHandler } from '@eclipse-glsp/client'; -import { ContainerModule } from 'inversify'; - -import { IvyInvokeDeleteActionHandler } from './invoke-delete'; - -const ivyEclipseDeleteModule = new ContainerModule((bind, _unbind, isBound) => { - configureActionHandler({ bind, isBound }, 'invoke-delete', IvyInvokeDeleteActionHandler); -}); - -export default ivyEclipseDeleteModule; diff --git a/integration/eclipse/src/invoke-delete/invoke-delete.ts b/integration/eclipse/src/invoke-delete/invoke-delete.ts deleted file mode 100644 index 652abf3c..00000000 --- a/integration/eclipse/src/invoke-delete/invoke-delete.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Action, DeleteElementOperation, EditorContextService, IActionDispatcher, IActionHandler, TYPES } from '@eclipse-glsp/client'; -import { inject, injectable } from 'inversify'; - -export class InvokeDeleteAction implements Action { - static KIND = 'invoke-delete'; - readonly kind = InvokeDeleteAction.KIND; -} - -export function isInvokeDeleteAction(action: Action): action is InvokeDeleteAction { - return action.kind === InvokeDeleteAction.KIND; -} - -@injectable() -export class IvyInvokeDeleteActionHandler implements IActionHandler { - @inject(TYPES.IActionDispatcher) protected actionDispatcher: IActionDispatcher; - @inject(EditorContextService) protected editorContext: EditorContextService; - - handle(action: Action): void { - if (isInvokeDeleteAction(action)) { - this.handleDelete(); - } - } - - handleDelete(): void { - this.actionDispatcher.dispatch(DeleteElementOperation.create(this.editorContext.get().selectedElementIds)); - } -}