boolean (T s) { PyRunConfigurationEditorFactory newEditorFactory = PyRunConfigurationEditorExtension.EP_NAME.getExtensionList().stream() .map(extension -> extension.accepts(s)) .filter(Objects::nonNull) .findFirst() .orElse(null); if (!Objects.equals(myCurrentEditorFactory, newEditorFactory)) { // discard previous if (myCurrentSettingsEditorComponent != null) { mySettingsPlaceholder.remove(myCurrentSettingsEditorComponent); } if (myCurrentSettingsEditor != null) { Disposer.dispose(myCurrentSettingsEditor); } // set current editor myCurrentEditorFactory = newEditorFactory; myCurrentSettingsEditor = null; // add new if (newEditorFactory != null) { myCurrentSettingsEditor = newEditorFactory.createEditor(s); myCurrentSettingsEditorComponent = myCurrentSettingsEditor.getComponent(); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridy = 1; constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1.0; constraints.insets.top = 10; mySettingsPlaceholder.add(myCurrentSettingsEditorComponent, constraints); Disposer.register(this, myCurrentSettingsEditor); } return true; } return false; }