package org.jcon.test;

import java.awt.Component;
import java.util.EventObject;

import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.event.CellEditorListener;
import javax.swing.tree.TreeCellEditor;

/**
 * First iteration.
 *
 * @author Jack Harich
 */
public class TreeCellField implements TreeCellEditor {

//---------- Private Fields ------------------------------
private JTextField field = new JTextField();

//---------- Initialization ------------------------------

//---------- TreeCellEditor Implementation ---------------
public Component getTreeCellEditorComponent(JTree tree,
        Object value, boolean isSelected,
        boolean expanded, boolean leaf,int row) {

    field.setText(value.toString());
    return (Component)field;
}
//----- CellEditor interface, the superclass of TreeCellEditor
public void cancelCellEditing() {
    // *** Later
}
public Object getCellEditorValue() {
    return field.getText();
}
public boolean isCellEditable(EventObject evt) {
    /**if (evt instanceof MouseEvent) {
        if (((MouseEvent)evt).getClickCount() < clickCountToStart) {
    	    return false;
    	}
    }
    return delegate.isCellEditable(anEvent); */
    return true;
}
public boolean shouldSelectCell(EventObject anEvent) {
    return true;
}
public boolean stopCellEditing() {
    return true;
}
public void addCellEditorListener(CellEditorListener l) {
    // ***
}

public void removeCellEditorListener(CellEditorListener l) {
    // ***
}
//---------- Properties ----------------------------------

//---------- Events --------------------------------------

//---------- Public Methods ------------------------------

//---------- Private Methods -----------------------------
//--- Std
private static void print(String text) {
    System.out.println("TreeCellField" + text);
}

} // End class
