CategoryImmediateEditorpublic class CategoryImmediateEditor extends DefaultTreeCellEditor
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 boolean | canEditImmediately(java.util.EventObject e)
boolean rv = false;
if (e instanceof MouseEvent) {
MouseEvent me = (MouseEvent) e;
rv = inCheckBoxHitRegion(me);
}
return rv;
| protected void | determineOffset(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 boolean | inCheckBoxHitRegion(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 boolean | shouldSelectCell(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;
|
|