Changeset 6249


Ignore:
Timestamp:
2003-12-12T17:49:32+13:00 (20 years ago)
Author:
jmt12
Message:

In order to fix 203B240 it was necessary to force DragTree's UI not to use the buggy VariableHeightLayoutCache

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java

    r6157 r6249  
    1010import javax.swing.*;
    1111import javax.swing.event.*;
     12import javax.swing.plaf.basic.BasicTreeUI;
    1213import javax.swing.tree.*;
    1314import org.greenstone.gatherer.Dictionary;
     
    9798    this.setOpaque(true);
    9899    this.setSelectionModel(new DragTreeSelectionModel(this, mixed_selection));
     100    this.setShowsRootHandles(true);
     101    this.setUI(new BasicTreeUI());
    99102    // Connection
    100103    addTreeSelectionListener(this);
     
    104107    //renderer.setBackgroundNonSelectionColor(new Color(0,0,0,0));
    105108    setCellRenderer(renderer);
    106 
    107           // Drag'n'drop Setup
    108           // Drag source setup.
     109    // It turns out VariableHeightLayoutCache is buggy under MacOS, so I'll force it to use FixedHeightLayoutCache. To do that I have to set a cell height, ala below, and set the large model property to true, ala above. And buggy VariableHeightLayoutCache goes away. Plus this actually provides a minor performance boost as the layout manager doesn't have to calculate new bounds each time (well... I suppose any gain is actually pretty much eclipsed by the time taken for file access while we determine what a certain nodes children are).
     110    // And once we have the cell renderer, use it to determine a fixed height for the rows
     111    Component prototype_row = renderer.getTreeCellRendererComponent(this, "Prototype", true, true, false, 0, true);
     112    this.setRowHeight(prototype_row.getSize().height);
     113    prototype_row = null;
     114
     115
     116    // Drag'n'drop Setup
     117    // Drag source setup.
    109118    DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(this, drag_action, this);
    110119    // Drop destination setup.
Note: See TracChangeset for help on using the changeset viewer.