Skip to content

Commit

Permalink
GH-22: Committing changes before starting to fix cyclic dependencies.
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
  • Loading branch information
kittaakos committed Apr 5, 2017
1 parent c085ef6 commit 64204ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
13 changes: 3 additions & 10 deletions src/application/browser/menu/context-menu-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,13 @@ export interface ContextMenuRenderer {
@injectable()
export class BrowserContextMenuRenderer implements ContextMenuRenderer {

constructor(
@inject(MainMenuFactory) private menuFactory: MainMenuFactory) { }
constructor( @inject(MainMenuFactory) private menuFactory: MainMenuFactory) {
}

render(path: string, anchor: Anchor): void {
const contextMenu = this.menuFactory.createContextMenu(path);
const {x, y} = this.getAnchor(anchor);
const { x, y } = anchor instanceof MouseEvent ? { x: anchor.clientX, y: anchor.clientY } : anchor;
contextMenu.open(x, y);
}

private getAnchor(event: MouseEvent | { x: number, y: number }): { x: number, y: number } {
if (event instanceof MouseEvent) {
return { x: event.clientX, y: event.clientY };
}
return event;
}

}
10 changes: 5 additions & 5 deletions src/application/electron-browser/menu/context-menu-renderer.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { inject, injectable } from "inversify";
import { MainMenuFactory } from "./menu-plugin";
import { ContextMenuRenderer } from "../../browser/menu/context-menu-renderer";
import { Anchor, ContextMenuRenderer } from "../../browser/menu/context-menu-renderer";

@injectable()
export class ElectronContextMenuRenderer implements ContextMenuRenderer {

constructor(
@inject(MainMenuFactory) private menuFactory: MainMenuFactory) {}
constructor( @inject(MainMenuFactory) private menuFactory: MainMenuFactory) {
}

render(path: string, event: MouseEvent): void {
render(path: string, anchor: Anchor): void {
const menu = this.menuFactory.createContextMenu(path);

menu.popup();
}

}
10 changes: 5 additions & 5 deletions src/editor/browser/editor-contextmenu.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { injectable } from "inversify";
// import { ContextMenuRenderer } from "../../application/browser/menu/context-menu-renderer";
import { injectable, inject } from "inversify";
import { ContextMenuRenderer } from "../../application/browser/menu/context-menu-renderer";
import IContextMenuService = monaco.editor.IContextMenuService;
import IContextMenuDelegate = monaco.editor.IContextMenuDelegate;
import CommandsRegistry = monaco.commands.CommandsRegistry;
Expand All @@ -15,12 +15,12 @@ export interface EditorContextMenuService extends IContextMenuService {
@injectable()
export class BrowserContextMenuService implements EditorContextMenuService {

// constructor(@inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer) {
// }
constructor(@inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer) {
}

showContextMenu(delegate: IContextMenuDelegate): void {
console.log(delegate.getAnchor());
// console.log(this.contextMenuRenderer);
console.log(this.contextMenuRenderer);
const ids = Object.keys(CommandsRegistry.getCommands());
console.log(ids.length);

Expand Down

0 comments on commit 64204ae

Please sign in to comment.