@Test public void testUninstall() { final EventList<String> source = new BasicEventList<>(); final TreeList<String> treeList = new TreeList<>(source, TreeListTest.COMPRESSED_CHARACTER_TREE_FORMAT, TreeList.<String>nodesStartExpanded()); final EventList<String> proxyList = GlazedListsSwing.swingThreadProxyList(treeList); final String[] propertyNames = {""}; final String[] columnLabels = {"Column 1"}; final TableFormat<String> itemTableFormat = GlazedLists.tableFormat(propertyNames, columnLabels); final DefaultEventTableModel<String> model = new DefaultEventTableModel<>(proxyList, itemTableFormat); final JTable table = new JTable(model); final TableColumn hierarchyColumn = table.getColumnModel().getColumn(0); final TableCellRenderer originalRenderer = new DefaultTableCellRenderer(); final TableCellEditor originalEditor = new DefaultCellEditor(new JComboBox<>()); hierarchyColumn.setCellRenderer(originalRenderer); hierarchyColumn.setCellEditor(originalEditor); final int originalKeyListenerCount = table.getKeyListeners().length; final Set<MouseListener> originalMouseListenerSet = new HashSet<>(Arrays.asList(table.getMouseListeners())); final TreeTableSupport support = TreeTableSupport.install(table, treeList, 0); final TreeTableCellRenderer newRenderer = (TreeTableCellRenderer) hierarchyColumn.getCellRenderer(); final TreeTableCellEditor newEditor = (TreeTableCellEditor) hierarchyColumn.getCellEditor(); final Set<MouseListener> newMouseListeners = new HashSet<>(Arrays.asList(table.getMouseListeners())); newMouseListeners.removeAll(originalMouseListenerSet); assertSame(originalRenderer, newRenderer.getDelegate()); assertSame(originalEditor, newEditor.getDelegate()); assertEquals(originalKeyListenerCount + 2, table.getKeyListeners().length); assertEquals(1, newMouseListeners.size()); support.uninstall(); assertSame(originalRenderer, hierarchyColumn.getCellRenderer()); assertSame(originalEditor, hierarchyColumn.getCellEditor()); assertEquals(originalKeyListenerCount, table.getKeyListeners().length); assertEquals(originalMouseListenerSet, new HashSet<>(Arrays.asList(table.getMouseListeners()))); }
public void uninstall() { checkAccessThread(); treeList.removeListEventListener(SWING_THREAD_CHECKER); setArrowKeyExpansionEnabled(false); table.removeKeyListener(arrowKeyListener); table.removeKeyListener(expandAndCollapseKeyListener); undecorateUIDelegateMouseListener(table); final int viewColumnIndex = table.convertColumnIndexToView(hierarchyColumnModelIndex); final TableColumn viewColumn = table.getColumnModel().getColumn(viewColumnIndex); final TableCellRenderer renderer = viewColumn.getCellRenderer(); final TableCellEditor editor = viewColumn.getCellEditor(); if (renderer == treeTableCellRenderer) { viewColumn.setCellRenderer(originalRenderer); } if (editor == treeTableCellEditor) { viewColumn.setCellEditor(originalEditor); } treeTableCellRenderer.dispose(); treeTableCellEditor.dispose(); }
TreeTableSupport { public void uninstall() { checkAccessThread(); treeList.removeListEventListener(SWING_THREAD_CHECKER); setArrowKeyExpansionEnabled(false); table.removeKeyListener(arrowKeyListener); table.removeKeyListener(expandAndCollapseKeyListener); undecorateUIDelegateMouseListener(table); final int viewColumnIndex = table.convertColumnIndexToView(hierarchyColumnModelIndex); final TableColumn viewColumn = table.getColumnModel().getColumn(viewColumnIndex); final TableCellRenderer renderer = viewColumn.getCellRenderer(); final TableCellEditor editor = viewColumn.getCellEditor(); if (renderer == treeTableCellRenderer) { viewColumn.setCellRenderer(originalRenderer); } if (editor == treeTableCellEditor) { viewColumn.setCellEditor(originalEditor); } treeTableCellRenderer.dispose(); treeTableCellEditor.dispose(); } }
TreeTableSupport { public void uninstall() { checkAccessThread(); treeList.removeListEventListener(SWING_THREAD_CHECKER); setArrowKeyExpansionEnabled(false); table.removeKeyListener(arrowKeyListener); table.removeKeyListener(expandAndCollapseKeyListener); undecorateUIDelegateMouseListener(table); final int viewColumnIndex = table.convertColumnIndexToView(hierarchyColumnModelIndex); final TableColumn viewColumn = table.getColumnModel().getColumn(viewColumnIndex); final TableCellRenderer renderer = viewColumn.getCellRenderer(); final TableCellEditor editor = viewColumn.getCellEditor(); if (renderer == treeTableCellRenderer) { viewColumn.setCellRenderer(originalRenderer); } if (editor == treeTableCellEditor) { viewColumn.setCellEditor(originalEditor); } treeTableCellRenderer.dispose(); treeTableCellEditor.dispose(); } private  TreeTableSupport(JTable table, TreeList treeList, int modelColumnIndex); }
TreeTableSupport { public void uninstall() { checkAccessThread(); treeList.removeListEventListener(SWING_THREAD_CHECKER); setArrowKeyExpansionEnabled(false); table.removeKeyListener(arrowKeyListener); table.removeKeyListener(expandAndCollapseKeyListener); undecorateUIDelegateMouseListener(table); final int viewColumnIndex = table.convertColumnIndexToView(hierarchyColumnModelIndex); final TableColumn viewColumn = table.getColumnModel().getColumn(viewColumnIndex); final TableCellRenderer renderer = viewColumn.getCellRenderer(); final TableCellEditor editor = viewColumn.getCellEditor(); if (renderer == treeTableCellRenderer) { viewColumn.setCellRenderer(originalRenderer); } if (editor == treeTableCellEditor) { viewColumn.setCellEditor(originalEditor); } treeTableCellRenderer.dispose(); treeTableCellEditor.dispose(); } private  TreeTableSupport(JTable table, TreeList treeList, int modelColumnIndex); static TreeTableSupport install(JTable table, TreeList treeList, int modelColumnIndex); void uninstall(); void setShowExpanderForEmptyParent(boolean showExpanderForEmptyParent); boolean getShowExpanderForEmptyParent(); void setArrowKeyExpansionEnabled(boolean arrowKeyExpansionEnabled); boolean getArrowKeyExpansionEnabled(); boolean getSpaceKeyExpansionEnabled(); void setSpaceKeyExpansionEnabled(boolean spaceKeyExpansionEnabled); void setRenderer(TreeTableCellRenderer treeTableCellRenderer); TreeTableCellRenderer getRenderer(); void setDelegateRenderer(TableCellRenderer renderer); TableCellRenderer getDelegateRenderer(); void setEditor(TreeTableCellEditor treeTableCellEditor); TreeTableCellEditor getEditor(); void setDelegateEditor(TableCellEditor editor); TableCellEditor getDelegateEditor(); }
TreeTableSupport { public void uninstall() { checkAccessThread(); treeList.removeListEventListener(SWING_THREAD_CHECKER); setArrowKeyExpansionEnabled(false); table.removeKeyListener(arrowKeyListener); table.removeKeyListener(expandAndCollapseKeyListener); undecorateUIDelegateMouseListener(table); final int viewColumnIndex = table.convertColumnIndexToView(hierarchyColumnModelIndex); final TableColumn viewColumn = table.getColumnModel().getColumn(viewColumnIndex); final TableCellRenderer renderer = viewColumn.getCellRenderer(); final TableCellEditor editor = viewColumn.getCellEditor(); if (renderer == treeTableCellRenderer) { viewColumn.setCellRenderer(originalRenderer); } if (editor == treeTableCellEditor) { viewColumn.setCellEditor(originalEditor); } treeTableCellRenderer.dispose(); treeTableCellEditor.dispose(); } private  TreeTableSupport(JTable table, TreeList treeList, int modelColumnIndex); static TreeTableSupport install(JTable table, TreeList treeList, int modelColumnIndex); void uninstall(); void setShowExpanderForEmptyParent(boolean showExpanderForEmptyParent); boolean getShowExpanderForEmptyParent(); void setArrowKeyExpansionEnabled(boolean arrowKeyExpansionEnabled); boolean getArrowKeyExpansionEnabled(); boolean getSpaceKeyExpansionEnabled(); void setSpaceKeyExpansionEnabled(boolean spaceKeyExpansionEnabled); void setRenderer(TreeTableCellRenderer treeTableCellRenderer); TreeTableCellRenderer getRenderer(); void setDelegateRenderer(TableCellRenderer renderer); TableCellRenderer getDelegateRenderer(); void setEditor(TreeTableCellEditor treeTableCellEditor); TreeTableCellEditor getEditor(); void setDelegateEditor(TableCellEditor editor); TableCellEditor getDelegateEditor();  }