01: /*
02: * This file is not part of the ItsNat framework.
03: *
04: * Original source code use and closed source derivatives are authorized
05: * to third parties with no restriction or fee.
06: * The original source code is owned by the author.
07: *
08: * This program is distributed AS IS in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * Author: Jose Maria Arranz Santamaria
13: * (C) Innowhere Software Services S.L., Spanish company, year 2007
14: */
15:
16: package org.itsnat.feashow.features.components.trees;
17:
18: import java.util.EventObject;
19: import javax.swing.event.CellEditorListener;
20: import javax.swing.tree.DefaultMutableTreeNode;
21: import org.itsnat.comp.ItsNatComponent;
22: import org.itsnat.comp.ItsNatTree;
23: import org.itsnat.comp.ItsNatTreeCellEditor;
24: import org.w3c.dom.Element;
25:
26: public class TreeTableItemEditor implements ItsNatTreeCellEditor {
27: protected ItsNatTreeCellEditor defaultEditor;
28: protected TreeTableItem currentItem;
29:
30: public TreeTableItemEditor(ItsNatTreeCellEditor defaultEditor) {
31: this .defaultEditor = defaultEditor;
32: }
33:
34: public ItsNatComponent getTreeCellEditorComponent(ItsNatTree tree,
35: int row, Object value, boolean isSelected,
36: boolean expanded, boolean leaf, Element labelElem) {
37: DefaultMutableTreeNode dataNode = (DefaultMutableTreeNode) value;
38: this .currentItem = (TreeTableItem) dataNode.getUserObject();
39: return defaultEditor.getTreeCellEditorComponent(tree, row,
40: currentItem.getPrincipal(), isSelected, expanded, leaf,
41: labelElem);
42: }
43:
44: public Object getCellEditorValue() {
45: currentItem.setPrincipal((String) defaultEditor
46: .getCellEditorValue());
47: return currentItem;
48: }
49:
50: public boolean isCellEditable(EventObject anEvent) {
51: return defaultEditor.isCellEditable(anEvent);
52: }
53:
54: public boolean shouldSelectCell(EventObject anEvent) {
55: return defaultEditor.shouldSelectCell(anEvent);
56: }
57:
58: public boolean stopCellEditing() {
59: return defaultEditor.stopCellEditing();
60: }
61:
62: public void cancelCellEditing() {
63: defaultEditor.cancelCellEditing();
64: }
65:
66: public void addCellEditorListener(CellEditorListener l) {
67: defaultEditor.addCellEditorListener(l);
68: }
69:
70: public void removeCellEditorListener(CellEditorListener l) {
71: defaultEditor.removeCellEditorListener(l);
72: }
73:
74: }
|