FileDocCategorySizeDatePackage
CategoryImmediateEditor.javaAPI DocApache log4j 1.2.154657Sat Aug 25 00:09:38 BST 2007org.apache.log4j.lf5.viewer.categoryexplorer

CategoryImmediateEditor

public class CategoryImmediateEditor extends DefaultTreeCellEditor
CategoryImmediateEditor
author
Michael J. Sikorsky
author
Robert Shaw

Fields Summary
private CategoryNodeRenderer
renderer
protected Icon
editingIcon
Constructors Summary
public CategoryImmediateEditor(JTree tree, CategoryNodeRenderer renderer, CategoryNodeEditor editor)


  //--------------------------------------------------------------------------
  //   Private Variables:
  //--------------------------------------------------------------------------

  //--------------------------------------------------------------------------
  //   Constructors:
  //--------------------------------------------------------------------------
    
       
        
    super(tree, renderer, editor);
    this.renderer = renderer;
    renderer.setIcon(null);
    renderer.setLeafIcon(null);
    renderer.setOpenIcon(null);
    renderer.setClosedIcon(null);

    super.editingIcon = null;
  
Methods Summary
protected booleancanEditImmediately(java.util.EventObject e)

    boolean rv = false;

    if (e instanceof MouseEvent) {
      MouseEvent me = (MouseEvent) e;
      rv = inCheckBoxHitRegion(me);
    }

    return rv;
  
protected voiddetermineOffset(javax.swing.JTree tree, java.lang.Object value, boolean isSelected, boolean expanded, boolean leaf, int row)

    // Very important: means that the tree won't jump around.
    offset = 0;
  
public booleaninCheckBoxHitRegion(java.awt.event.MouseEvent e)

    TreePath path = tree.getPathForLocation(e.getX(),
        e.getY());
    if (path == null) {
      return false;
    }
    CategoryNode node = (CategoryNode) path.getLastPathComponent();
    boolean rv = false;

    if (true) {
      // offset and lastRow DefaultTreeCellEditor
      // protected members

      Rectangle bounds = tree.getRowBounds(lastRow);
      Dimension checkBoxOffset =
          renderer.getCheckBoxOffset();

      bounds.translate(offset + checkBoxOffset.width,
          checkBoxOffset.height);

      rv = bounds.contains(e.getPoint());
    }
    return true;
  
public booleanshouldSelectCell(java.util.EventObject e)

    boolean rv = false;  // only mouse events

    if (e instanceof MouseEvent) {
      MouseEvent me = (MouseEvent) e;
      TreePath path = tree.getPathForLocation(me.getX(),
          me.getY());
      CategoryNode node = (CategoryNode)
          path.getLastPathComponent();

      rv = node.isLeaf() /*|| !inCheckBoxHitRegion(me)*/;
    }
    return rv;