@Test public void disposeShouldReleaseEditor() throws Exception { application.invokeAndWait(() -> underTest.dispose()); final Editor[] actual = EditorFactory.getInstance().getAllEditors(); assertThat(actual) .isEmpty(); }
@Override public void dispose() { Collections.list(styleGroup.getElements()).forEach(button -> button.removeActionListener(this)); classNamePrefixField.getDocument().removeDocumentListener(this); classNameSuffixField.getDocument().removeDocumentListener(this); generatedAnnotationCheckBox.removeActionListener(this); suppressWarningsAnnotationCheckBox.removeActionListener(this); if (previewEditor == null || previewEditor.isDisposed()) { return; } EditorFactory.getInstance().releaseEditor(previewEditor); }
SettingsPanel implements Disposable, ActionListener, DocumentListener { @Override public void dispose() { Collections.list(styleGroup.getElements()).forEach(button -> button.removeActionListener(this)); classNamePrefixField.getDocument().removeDocumentListener(this); classNameSuffixField.getDocument().removeDocumentListener(this); generatedAnnotationCheckBox.removeActionListener(this); suppressWarningsAnnotationCheckBox.removeActionListener(this); if (previewEditor == null || previewEditor.isDisposed()) { return; } EditorFactory.getInstance().releaseEditor(previewEditor); } }
SettingsPanel implements Disposable, ActionListener, DocumentListener { @Override public void dispose() { Collections.list(styleGroup.getElements()).forEach(button -> button.removeActionListener(this)); classNamePrefixField.getDocument().removeDocumentListener(this); classNameSuffixField.getDocument().removeDocumentListener(this); generatedAnnotationCheckBox.removeActionListener(this); suppressWarningsAnnotationCheckBox.removeActionListener(this); if (previewEditor == null || previewEditor.isDisposed()) { return; } EditorFactory.getInstance().releaseEditor(previewEditor); } SettingsPanel(); }
SettingsPanel implements Disposable, ActionListener, DocumentListener { @Override public void dispose() { Collections.list(styleGroup.getElements()).forEach(button -> button.removeActionListener(this)); classNamePrefixField.getDocument().removeDocumentListener(this); classNameSuffixField.getDocument().removeDocumentListener(this); generatedAnnotationCheckBox.removeActionListener(this); suppressWarningsAnnotationCheckBox.removeActionListener(this); if (previewEditor == null || previewEditor.isDisposed()) { return; } EditorFactory.getInstance().releaseEditor(previewEditor); } SettingsPanel(); @Override void dispose(); @Override void actionPerformed(@Nonnull ActionEvent event); @Override void insertUpdate(@Nonnull DocumentEvent event); @Override void removeUpdate(@Nonnull DocumentEvent event); @Override void changedUpdate(@Nonnull DocumentEvent event); @Nonnull @CheckReturnValue JComponent getComponent(); @Nonnull @CheckReturnValue Style getStyle(); void setStyle(@Nonnull Style style); @Nonnull @CheckReturnValue String getClassNamePrefix(); void setClassNamePrefix(@Nonnull String prefix); @Nonnull @CheckReturnValue String getClassNameSuffix(); void setClassNameSuffix(@Nonnull String suffix); @CheckReturnValue boolean isGeneratedAnnotationEnabled(); void setGeneratedAnnotationEnabled(boolean enabled); @CheckReturnValue boolean isSuppressWarningsAnnotationEnabled(); void setSuppressWarningsAnnotationEnabled(boolean enabled); void setPreviewText(@Nonnull String text); }
SettingsPanel implements Disposable, ActionListener, DocumentListener { @Override public void dispose() { Collections.list(styleGroup.getElements()).forEach(button -> button.removeActionListener(this)); classNamePrefixField.getDocument().removeDocumentListener(this); classNameSuffixField.getDocument().removeDocumentListener(this); generatedAnnotationCheckBox.removeActionListener(this); suppressWarningsAnnotationCheckBox.removeActionListener(this); if (previewEditor == null || previewEditor.isDisposed()) { return; } EditorFactory.getInstance().releaseEditor(previewEditor); } SettingsPanel(); @Override void dispose(); @Override void actionPerformed(@Nonnull ActionEvent event); @Override void insertUpdate(@Nonnull DocumentEvent event); @Override void removeUpdate(@Nonnull DocumentEvent event); @Override void changedUpdate(@Nonnull DocumentEvent event); @Nonnull @CheckReturnValue JComponent getComponent(); @Nonnull @CheckReturnValue Style getStyle(); void setStyle(@Nonnull Style style); @Nonnull @CheckReturnValue String getClassNamePrefix(); void setClassNamePrefix(@Nonnull String prefix); @Nonnull @CheckReturnValue String getClassNameSuffix(); void setClassNameSuffix(@Nonnull String suffix); @CheckReturnValue boolean isGeneratedAnnotationEnabled(); void setGeneratedAnnotationEnabled(boolean enabled); @CheckReturnValue boolean isSuppressWarningsAnnotationEnabled(); void setSuppressWarningsAnnotationEnabled(boolean enabled); void setPreviewText(@Nonnull String text);  }