ToolbarDecorator (@NotNull JComponent component, @Nullable ElementProducer<?> producer) { if (component instanceof JTree) { return createDecorator((JTree)component, producer); } if (component instanceof JTable) { if (producer == null) return createDecorator((JTable)component); throw new IllegalArgumentException("unexpected producer " + producer.getClass()); } if (component instanceof JList) { if (producer == null) return createDecorator((JList<?>)component); throw new IllegalArgumentException("unexpected producer " + producer.getClass()); } try { Class<?> type = Class.forName("com.intellij.ui.components.JBTreeTable", false, ToolbarDecorator.class.getClassLoader()); JTree tree = (JTree)type.getDeclaredMethod("getTree").invoke(component); return new TreeToolbarDecorator(component, tree, producer).initPosition(); } catch (LinkageError | Exception exception) { throw new IllegalArgumentException("unsupported component " + component.getClass(), exception); } }