@Test public void testOnMonacoLoaded() { final MonacoPropertiesFactory properties = mock(MonacoPropertiesFactory.class); final JavaScriptObject constructionOptions = mock(JavaScriptObject.class); final Monaco monaco = mock(Monaco.class); final MonacoEditor editor = mock(MonacoEditor.class); final MonacoStandaloneCodeEditor standaloneCodeEditor = mock(MonacoStandaloneCodeEditor.class); final com.google.gwt.user.client.Element element = mock(com.google.gwt.user.client.Element.class); final elemental2.dom.Element elemental2Element = mock(elemental2.dom.Element.class); final CallbackFunction onKeyDown = mock(CallbackFunction.class); final CallbackFunction widgetTrigger = mock(CallbackFunction.class); final NativeEvent blurEvent = mock(NativeEvent.class); monaco.editor = editor; when(widget.getElement()).thenReturn(element); when(properties.getConstructionOptions()).thenReturn(constructionOptions); doReturn(onKeyDown).when(domElement).getOnKeyDown(standaloneCodeEditor); doReturn(widgetTrigger).when(domElement).getWidgetTrigger(blurEvent); doReturn(blurEvent).when(domElement).getBlurEvent(); doReturn(properties).when(domElement).makeMonacoPropertiesFactory(); doReturn(elemental2Element).when(domElement).uncheckedCast(element); doReturn(standaloneCodeEditor).when(editor).create(elemental2Element, constructionOptions); domElement.onMonacoLoaded().accept(monaco); verify(standaloneCodeEditor).onKeyDown(onKeyDown); verify(standaloneCodeEditor).onDidBlurEditorWidget(widgetTrigger); verify(widget).setCodeEditor(standaloneCodeEditor); verify(widget).setFocus(true); }
Consumer<Monaco> onMonacoLoaded() { final MonacoPropertiesFactory properties = makeMonacoPropertiesFactory(); return monaco -> { final MonacoStandaloneCodeEditor codeEditor = monaco.editor.create(uncheckedCast(widget.getElement()), properties.getConstructionOptions()); codeEditor.onKeyDown(getOnKeyDown(codeEditor)); codeEditor.onDidBlurEditorWidget(getWidgetTrigger(getBlurEvent())); widget.setCodeEditor(codeEditor); widget.setFocus(true); }; }
MonacoEditorDOMElement extends BaseDOMElement<String, MonacoEditorWidget> implements TakesValue<String>,
                                                                                                  Focusable { Consumer<Monaco> onMonacoLoaded() { final MonacoPropertiesFactory properties = makeMonacoPropertiesFactory(); return monaco -> { final MonacoStandaloneCodeEditor codeEditor = monaco.editor.create(uncheckedCast(widget.getElement()), properties.getConstructionOptions()); codeEditor.onKeyDown(getOnKeyDown(codeEditor)); codeEditor.onDidBlurEditorWidget(getWidgetTrigger(getBlurEvent())); widget.setCodeEditor(codeEditor); widget.setFocus(true); }; } }
MonacoEditorDOMElement extends BaseDOMElement<String, MonacoEditorWidget> implements TakesValue<String>,
                                                                                                  Focusable { Consumer<Monaco> onMonacoLoaded() { final MonacoPropertiesFactory properties = makeMonacoPropertiesFactory(); return monaco -> { final MonacoStandaloneCodeEditor codeEditor = monaco.editor.create(uncheckedCast(widget.getElement()), properties.getConstructionOptions()); codeEditor.onKeyDown(getOnKeyDown(codeEditor)); codeEditor.onDidBlurEditorWidget(getWidgetTrigger(getBlurEvent())); widget.setCodeEditor(codeEditor); widget.setFocus(true); }; } MonacoEditorDOMElement(final MonacoEditorWidget widget,
                                  final GridLayer gridLayer,
                                  final GridWidget gridWidget,
                                  final SessionManager sessionManager,
                                  final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                  final Function<GridCellTuple, Command> hasNoValueCommand,
                                  final Function<GridCellValueTuple, Command> hasValueCommand); }
MonacoEditorDOMElement extends BaseDOMElement<String, MonacoEditorWidget> implements TakesValue<String>,
                                                                                                  Focusable { Consumer<Monaco> onMonacoLoaded() { final MonacoPropertiesFactory properties = makeMonacoPropertiesFactory(); return monaco -> { final MonacoStandaloneCodeEditor codeEditor = monaco.editor.create(uncheckedCast(widget.getElement()), properties.getConstructionOptions()); codeEditor.onKeyDown(getOnKeyDown(codeEditor)); codeEditor.onDidBlurEditorWidget(getWidgetTrigger(getBlurEvent())); widget.setCodeEditor(codeEditor); widget.setFocus(true); }; } MonacoEditorDOMElement(final MonacoEditorWidget widget,
                                  final GridLayer gridLayer,
                                  final GridWidget gridWidget,
                                  final SessionManager sessionManager,
                                  final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                  final Function<GridCellTuple, Command> hasNoValueCommand,
                                  final Function<GridCellValueTuple, Command> hasValueCommand); void setupElements(); @Override void initialise(final GridBodyCellRenderContext context); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override @SuppressWarnings("unchecked") void flush(final String value); }
MonacoEditorDOMElement extends BaseDOMElement<String, MonacoEditorWidget> implements TakesValue<String>,
                                                                                                  Focusable { Consumer<Monaco> onMonacoLoaded() { final MonacoPropertiesFactory properties = makeMonacoPropertiesFactory(); return monaco -> { final MonacoStandaloneCodeEditor codeEditor = monaco.editor.create(uncheckedCast(widget.getElement()), properties.getConstructionOptions()); codeEditor.onKeyDown(getOnKeyDown(codeEditor)); codeEditor.onDidBlurEditorWidget(getWidgetTrigger(getBlurEvent())); widget.setCodeEditor(codeEditor); widget.setFocus(true); }; } MonacoEditorDOMElement(final MonacoEditorWidget widget,
                                  final GridLayer gridLayer,
                                  final GridWidget gridWidget,
                                  final SessionManager sessionManager,
                                  final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                                  final Function<GridCellTuple, Command> hasNoValueCommand,
                                  final Function<GridCellValueTuple, Command> hasValueCommand); void setupElements(); @Override void initialise(final GridBodyCellRenderContext context); @Override void setValue(final String value); @Override String getValue(); @Override int getTabIndex(); @Override void setAccessKey(final char key); @Override void setFocus(final boolean focused); @Override void setTabIndex(final int index); @Override @SuppressWarnings("unchecked") void flush(final String value);  }