@Test public void shouldFormatOperationWhenDocumentIsNotNullButFormatterIsNull() throws EditorInitException { doReturn(null).when(configuration).getContentFormatter(); initializeAndInitEditor(); embeddedTextEditorPresenter.doOperation(TextEditorOperations.FORMAT); verify(contentFormatter, never()).format(document); }
@Override public void doOperation(final int operation) { switch (operation) { case TextEditorOperations.CODEASSIST_PROPOSALS: if (this.document != null) { this.document.getDocumentHandle().getDocEventBus().fireEvent(new CompletionRequestEvent()); } break; case TextEditorOperations.FORMAT: ContentFormatter formatter = getConfiguration().getContentFormatter(); if (this.document != null && formatter != null) { formatter.format(getDocument()); } break; default: throw new UnsupportedOperationException("Operation code: " + operation + " is not supported!"); } }
EmbeddedTextEditorPresenter extends AbstractEditorPresenter implements EmbeddedTextEditor,
                                                                                    FileEventHandler,
                                                                                    UndoableEditor,
                                                                                    HasBreakpointRenderer,
                                                                                    HasReadOnlyProperty,
                                                                                    HandlesTextOperations,
                                                                                    EditorWithErrors,
                                                                                    Delegate { @Override public void doOperation(final int operation) { switch (operation) { case TextEditorOperations.CODEASSIST_PROPOSALS: if (this.document != null) { this.document.getDocumentHandle().getDocEventBus().fireEvent(new CompletionRequestEvent()); } break; case TextEditorOperations.FORMAT: ContentFormatter formatter = getConfiguration().getContentFormatter(); if (this.document != null && formatter != null) { formatter.format(getDocument()); } break; default: throw new UnsupportedOperationException("Operation code: " + operation + " is not supported!"); } } }
EmbeddedTextEditorPresenter extends AbstractEditorPresenter implements EmbeddedTextEditor,
                                                                                    FileEventHandler,
                                                                                    UndoableEditor,
                                                                                    HasBreakpointRenderer,
                                                                                    HasReadOnlyProperty,
                                                                                    HandlesTextOperations,
                                                                                    EditorWithErrors,
                                                                                    Delegate { @Override public void doOperation(final int operation) { switch (operation) { case TextEditorOperations.CODEASSIST_PROPOSALS: if (this.document != null) { this.document.getDocumentHandle().getDocEventBus().fireEvent(new CompletionRequestEvent()); } break; case TextEditorOperations.FORMAT: ContentFormatter formatter = getConfiguration().getContentFormatter(); if (this.document != null && formatter != null) { formatter.format(getDocument()); } break; default: throw new UnsupportedOperationException("Operation code: " + operation + " is not supported!"); } } @AssistedInject  EmbeddedTextEditorPresenter(final CodeAssistantFactory codeAssistantFactory,
                                       final BreakpointManager breakpointManager,
                                       final BreakpointRendererFactory breakpointRendererFactory,
                                       final DialogFactory dialogFactory,
                                       final DocumentStorage documentStorage,
                                       final JsEditorConstants constant,
                                       @Assisted final EditorWidgetFactory<T> editorWidgetFactory,
                                       final EditorModule<T> editorModule,
                                       final EmbeddedTextEditorPartView editorView,
                                       final EventBus eventBus,
                                       final FileTypeIdentifier fileTypeIdentifier,
                                       final QuickAssistantFactory quickAssistantFactory,
                                       final Resources resources,
                                       final WorkspaceAgent workspaceAgent); }
EmbeddedTextEditorPresenter extends AbstractEditorPresenter implements EmbeddedTextEditor,
                                                                                    FileEventHandler,
                                                                                    UndoableEditor,
                                                                                    HasBreakpointRenderer,
                                                                                    HasReadOnlyProperty,
                                                                                    HandlesTextOperations,
                                                                                    EditorWithErrors,
                                                                                    Delegate { @Override public void doOperation(final int operation) { switch (operation) { case TextEditorOperations.CODEASSIST_PROPOSALS: if (this.document != null) { this.document.getDocumentHandle().getDocEventBus().fireEvent(new CompletionRequestEvent()); } break; case TextEditorOperations.FORMAT: ContentFormatter formatter = getConfiguration().getContentFormatter(); if (this.document != null && formatter != null) { formatter.format(getDocument()); } break; default: throw new UnsupportedOperationException("Operation code: " + operation + " is not supported!"); } } @AssistedInject  EmbeddedTextEditorPresenter(final CodeAssistantFactory codeAssistantFactory,
                                       final BreakpointManager breakpointManager,
                                       final BreakpointRendererFactory breakpointRendererFactory,
                                       final DialogFactory dialogFactory,
                                       final DocumentStorage documentStorage,
                                       final JsEditorConstants constant,
                                       @Assisted final EditorWidgetFactory<T> editorWidgetFactory,
                                       final EditorModule<T> editorModule,
                                       final EmbeddedTextEditorPartView editorView,
                                       final EventBus eventBus,
                                       final FileTypeIdentifier fileTypeIdentifier,
                                       final QuickAssistantFactory quickAssistantFactory,
                                       final Resources resources,
                                       final WorkspaceAgent workspaceAgent); @Override void close(final boolean save); @Inject void injectAsyncLoader(final AsyncRequestLoader loader); @Override boolean isEditable(); @Override void doRevertToSaved(); @Override OutlineImpl getOutline(); @Override void go(final AcceptsOneWidget container); @Override String getTitleToolTip(); @Override void onClose(@Nonnull final AsyncCallback<Void> callback); @Override EmbeddedTextEditorPartView getView(); @Override void activate(); @Override void onFileOperation(final FileEvent event); @Override void initialize(@Nonnull final TextEditorConfiguration configuration,
                           @Nonnull final NotificationManager notificationManager); @Override TextEditorConfiguration getConfiguration(); @Override ImageResource getTitleImage(); @Override SVGResource getTitleSVGImage(); @Nonnull @Override String getTitle(); @Override void doSave(); @Override void doSave(final AsyncCallback<EditorInput> callback); @Override void doSaveAs(); @Override HandlesUndoRedo getUndoRedo(); @Override EditorState getErrorState(); @Override void setErrorState(final EditorState errorState); @Override BreakpointRenderer getBreakpointRenderer(); @Override EmbeddedDocument getDocument(); @Override String getContentType(); @Override TextRange getSelectedTextRange(); @Override LinearRange getSelectedLinearRange(); @Override void showMessage(final String message); @Override TextPosition getCursorPosition(); @Override int getCursorOffset(); @Override void refreshEditor(); @Override void addEditorUpdateAction(final EditorUpdateAction action); @Override void addKeybinding(final Keybinding keybinding); HasTextMarkers getHasTextMarkers(); HasKeybindings getHasKeybindings(); @Override CursorModelWithHandler getCursorModel(); @Override PositionConverter getPositionConverter(); void showCompletionProposals(final CompletionsSource source); void showCompletionProposals(); EditorHandle getEditorHandle(); @Override void onResize(); @Override void editorLostFocus(); @Override void editorGotFocus(); @Override void editorCursorPositionChanged(); @Override boolean canDoOperation(final int operation); @Override void doOperation(final int operation); @Override void setReadOnly(final boolean readOnly); @Override boolean isReadOnly(); }
EmbeddedTextEditorPresenter extends AbstractEditorPresenter implements EmbeddedTextEditor,
                                                                                    FileEventHandler,
                                                                                    UndoableEditor,
                                                                                    HasBreakpointRenderer,
                                                                                    HasReadOnlyProperty,
                                                                                    HandlesTextOperations,
                                                                                    EditorWithErrors,
                                                                                    Delegate { @Override public void doOperation(final int operation) { switch (operation) { case TextEditorOperations.CODEASSIST_PROPOSALS: if (this.document != null) { this.document.getDocumentHandle().getDocEventBus().fireEvent(new CompletionRequestEvent()); } break; case TextEditorOperations.FORMAT: ContentFormatter formatter = getConfiguration().getContentFormatter(); if (this.document != null && formatter != null) { formatter.format(getDocument()); } break; default: throw new UnsupportedOperationException("Operation code: " + operation + " is not supported!"); } } @AssistedInject  EmbeddedTextEditorPresenter(final CodeAssistantFactory codeAssistantFactory,
                                       final BreakpointManager breakpointManager,
                                       final BreakpointRendererFactory breakpointRendererFactory,
                                       final DialogFactory dialogFactory,
                                       final DocumentStorage documentStorage,
                                       final JsEditorConstants constant,
                                       @Assisted final EditorWidgetFactory<T> editorWidgetFactory,
                                       final EditorModule<T> editorModule,
                                       final EmbeddedTextEditorPartView editorView,
                                       final EventBus eventBus,
                                       final FileTypeIdentifier fileTypeIdentifier,
                                       final QuickAssistantFactory quickAssistantFactory,
                                       final Resources resources,
                                       final WorkspaceAgent workspaceAgent); @Override void close(final boolean save); @Inject void injectAsyncLoader(final AsyncRequestLoader loader); @Override boolean isEditable(); @Override void doRevertToSaved(); @Override OutlineImpl getOutline(); @Override void go(final AcceptsOneWidget container); @Override String getTitleToolTip(); @Override void onClose(@Nonnull final AsyncCallback<Void> callback); @Override EmbeddedTextEditorPartView getView(); @Override void activate(); @Override void onFileOperation(final FileEvent event); @Override void initialize(@Nonnull final TextEditorConfiguration configuration,
                           @Nonnull final NotificationManager notificationManager); @Override TextEditorConfiguration getConfiguration(); @Override ImageResource getTitleImage(); @Override SVGResource getTitleSVGImage(); @Nonnull @Override String getTitle(); @Override void doSave(); @Override void doSave(final AsyncCallback<EditorInput> callback); @Override void doSaveAs(); @Override HandlesUndoRedo getUndoRedo(); @Override EditorState getErrorState(); @Override void setErrorState(final EditorState errorState); @Override BreakpointRenderer getBreakpointRenderer(); @Override EmbeddedDocument getDocument(); @Override String getContentType(); @Override TextRange getSelectedTextRange(); @Override LinearRange getSelectedLinearRange(); @Override void showMessage(final String message); @Override TextPosition getCursorPosition(); @Override int getCursorOffset(); @Override void refreshEditor(); @Override void addEditorUpdateAction(final EditorUpdateAction action); @Override void addKeybinding(final Keybinding keybinding); HasTextMarkers getHasTextMarkers(); HasKeybindings getHasKeybindings(); @Override CursorModelWithHandler getCursorModel(); @Override PositionConverter getPositionConverter(); void showCompletionProposals(final CompletionsSource source); void showCompletionProposals(); EditorHandle getEditorHandle(); @Override void onResize(); @Override void editorLostFocus(); @Override void editorGotFocus(); @Override void editorCursorPositionChanged(); @Override boolean canDoOperation(final int operation); @Override void doOperation(final int operation); @Override void setReadOnly(final boolean readOnly); @Override boolean isReadOnly(); final static String DEFAULT_CONTENT_TYPE; }