/** Creates a new instance of DefaultOutlineModel. <strong><b>Note</b> * Do not fire table structure changes from the wrapped TableModel (value * changes are okay). Changes that affect the number of rows must come * from the TreeModel. * @param treeModel The tree model * @param tableModel The table model * @param largeModel <code>true</code> if it's a large model tree, <code>false</code> otherwise. * @param nodesColumnLabel Label of the node's column */ protected DefaultOutlineModel(TreeModel treeModel, TableModel tableModel, boolean largeModel, String nodesColumnLabel) { this.treeModel = treeModel; this.tableModel = tableModel; if (nodesColumnLabel != null) { this.nodesColumnLabel = nodesColumnLabel; } layout = largeModel ? (AbstractLayoutCache) new FixedHeightLayoutCache() : (AbstractLayoutCache) new VariableHeightLayoutCache(); broadcaster = new EventBroadcaster (this); layout.setRootVisible(true); layout.setModel(this); treePathSupport = new TreePathSupport(this, layout); treePathSupport.addTreeExpansionListener(broadcaster); treePathSupport.addTreeWillExpandListener(broadcaster); treeModel.addTreeModelListener(broadcaster); tableModel.addTableModelListener(broadcaster); if (tableModel instanceof ProxyTableModel) { ((ProxyTableModel) tableModel).setOutlineModel(this); } }
public void testCreateLayoutCache() { tree.setRowHeight(0); assertNotNull(ui.createLayoutCache()); assertNotSame(ui.createLayoutCache(), ui.createLayoutCache()); assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache); assertTrue(ui.treeState instanceof VariableHeightLayoutCache); tree.setRowHeight(10); assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache); assertTrue(ui.treeState instanceof VariableHeightLayoutCache); tree.setRowHeight(0); tree.setLargeModel(true); assertTrue(ui.createLayoutCache() instanceof VariableHeightLayoutCache); assertTrue(ui.treeState instanceof VariableHeightLayoutCache); tree.setRowHeight(10); assertTrue(ui.createLayoutCache() instanceof FixedHeightLayoutCache); assertTrue(ui.treeState instanceof FixedHeightLayoutCache); }
private static void clearSelectionCache(RowMapper rm) { if (rm instanceof FixedHeightLayoutCache) { try { Field infoField = rm.getClass().getDeclaredField("info"); infoField.setAccessible(true); Object searchInfo = infoField.get(rm); if (searchInfo != null) { Field nodeField = searchInfo.getClass().getDeclaredField("node"); nodeField.setAccessible(true); nodeField.set(searchInfo, null); } } catch (Exception ex) {} } }
@Override public boolean isLargeModel() { return layout instanceof FixedHeightLayoutCache; }
protected AbstractLayoutCache createLayoutCache() { return rowHeight > 0 && largeModel ? (AbstractLayoutCache)new FixedHeightLayoutCache() : (AbstractLayoutCache)new VariableHeightLayoutCache(); }