PropertiesPanelPresenter implements PropertiesPanelView.ActionDelegate, PropertiesPanel { protected void initializeEditor(@NotNull final VirtualFile file, @NotNull EditorProvider provider, @NotNull FileTypeRegistry fileTypeRegistry) { FileType fileType = fileTypeRegistry.getFileTypeByFile(file); editor = provider.getEditor(); editor.addPropertyListener(new PropertyListener() { @Override public void propertyChanged(PartPresenter source, int propId) { switch (propId) { case PROP_INPUT: setReadOnlyProperty(file); view.showEditor(editor); break; case PROP_DIRTY: if (validateUndoOperation()) { enableSaveAndCancelButtons(); } break; default: } } }); try { editor.init(new DockerFileEditorInput(fileType, file)); } catch (EditorInitException e) { Log.error(getClass(), e); } } PropertiesPanelPresenter(@NotNull PropertiesPanelView view, @NotNull AppContext appContext); @Override void onConfigurationChanged(); @Override void go(AcceptsOneWidget container); @Override void update(@NotNull Runner runner); @Override void update(@NotNull Environment environment); @Override void addListener(@NotNull RemovePanelListener listener); @Override void hideButtonsPanel(); @Override void onCopyButtonClicked(); @Override void onSaveButtonClicked(); @Override void onDeleteButtonClicked(); @Override void onCancelButtonClicked(); @Override void onConfigLinkClicked(); void onSwitcherChanged(boolean isOn);  }
@Test public void propertiesShouldBeChangedWithPropIdPropInputAndEditorIsNotInstanceOfHasReadOnlyProperty() { PartPresenter partPresenter = mock(PartPresenter.class); presenter.initializeEditor(file, editorProvider, fileTypeRegistry); verify(fileTypeRegistry).getFileTypeByFile(file); verify(editorProvider).getEditor(); verify(editor).addPropertyListener(propertyListenerArgCaptor.capture()); propertyListenerArgCaptor.getValue().propertyChanged(partPresenter, PROP_INPUT); verify(view).showEditor(editor); }
@Test public void propertiesShouldBeChangedWithPropIdPropInputAndEditorIsInstanceOfHasReadOnlyProperty() { PartPresenter partPresenter = mock(PartPresenter.class); EditorPartPresenter editor2 = mock(TestEditor.class); when(editorProvider.getEditor()).thenReturn(editor2); when(file.isReadOnly()).thenReturn(true); presenter.initializeEditor(file, editorProvider, fileTypeRegistry); verify(fileTypeRegistry).getFileTypeByFile(file); verify(editorProvider).getEditor(); verify(editor2).addPropertyListener(propertyListenerArgCaptor.capture()); propertyListenerArgCaptor.getValue().propertyChanged(partPresenter, PROP_INPUT); verify(file).isReadOnly(); verify((HasReadOnlyProperty)editor2).setReadOnly(true); verify(view).showEditor(editor2); }
@Test public void propertiesShouldBeChangedWithPropIdDropDirtyWhenValidateUndoOperationIsTrue() { PartPresenter partPresenter = mock(PartPresenter.class); EditorPartPresenter editor2 = mock(TestEditor.class); when(editorProvider.getEditor()).thenReturn(editor2); when(file.isReadOnly()).thenReturn(true); presenter.initializeEditor(file, editorProvider, fileTypeRegistry); verify(fileTypeRegistry).getFileTypeByFile(file); verify(editorProvider).getEditor(); verify(editor2).addPropertyListener(propertyListenerArgCaptor.capture()); propertyListenerArgCaptor.getValue().propertyChanged(partPresenter, PROP_DIRTY); verify(view).setEnableSaveButton(true); verify(view).setEnableCancelButton(true); }
@Test public void propertiesShouldBeChangedWithPropIdDropDirtyWhenValidateUndoOperationIsFalse() { PartPresenter partPresenter = mock(PartPresenter.class); EditorPartPresenter editor2 = mock(TestEditor.class); when(editorProvider.getEditor()).thenReturn(editor2); when(file.isReadOnly()).thenReturn(true); presenter.initializeEditor(file, editorProvider, fileTypeRegistry); verify(editor2).addPropertyListener(propertyListenerArgCaptor.capture()); propertyListenerArgCaptor.getValue().propertyChanged(partPresenter, PROP_DIRTY); verify(view).setEnableSaveButton(true); verify(view).setEnableCancelButton(true); }