package template;

/*
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

import java.awt.AWTEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.ListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.DocumentEvent;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

import de.cbse.jeasy.JECallBack;

public class DefaultJECallBack implements JECallBack, PropertyChangeListener {
	/**
	 * All events from the swing components like menus, buttons, checkboxes,
	 * datafields are send to this callBack.
	 * 
	 * @param e
	 *            the event send by the component
	 * @param id
	 *            the id of the JEObject
	 */
	public void callBack(AWTEvent e, String id) {}

	/**
	 * All Mouse events from the JETable are send to this callBack.
	 * 
	 * @param e
	 *            the event send by the Table
	 * @param id
	 *            the id of the JEObject
	 * @param row
	 *            the row of the tableModel
	 * @param column
	 *            the column of the tableModel
	 */
	public void callBack(AWTEvent e, String id, int row, int column) {
	//		System.out.println("JEDefaultJECallBack.callBack() AWTEvent: " + id + "at row: " + row + " column: " + column + "\n" + e);
	}

	/**
	 * The events from a tabbedpane are send to this callBack.
	 * 
	 * @param e
	 *            the event send when a tabbedpane element is activated
	 * @param id
	 *            the id of the JEObject
	 */
	public void callBack(ChangeEvent e, String id) {
	//		System.out.println("JEDefaultJECallBack.callBack() ChangeEvent: " + id + "\n" + e);
	}

	/**
	 * All events from the text components like datafields are
	 * send to this callBack.
	 * 
	 * @param e
	 *            the event send by the component
	 * @param id
	 *            the id of the JEObject
	 */
	public void callBack(DocumentEvent e, String id) {
	//		System.out.println("JEDefaultJECallBack.callBack() DocumentEvent: "+id+"\n"+e);
	}

	/**
	 * All returns from JEEditorPane HyperlinkListener will call this method
	 */
	public void callBack(HyperlinkEvent e, String id) {
	//		System.out.println("JEDefaultJECallBack.callBack() HyperlinkEvent: " + id + "\n" + e);
	}

	/**
	 * All ItemEvents from the swing components like comboboxes, radiobuttons, checkboxes
	 * are send to this callBack.
	 * 
	 * @param e
	 *            the event send by the component
	 * @param id
	 *            the id of the JEObject
	 */
	public void callBack(ItemEvent e, String id) {}

	/**
	 * All Selection events from the JETable are send to this callBack.
	 * 
	 * @param e
	 *            the event send by the Table
	 * @param id
	 *            the id of the JEObject
	 * @param lsm
	 *            the id of the JEObject where the component was added
	 */
	public void callBack(ListSelectionEvent e, String id, ListSelectionModel lsm) {
	//		System.out.println("JEDefaultJECallBack.callBack() ListSelectionEvent: "+id+"\n"+e);
	}

	/**
	 * All mouse events from treenodes or lists are send to this callBack.
	 * 
	 * @param e
	 *            the event send by the swing component
	 * @param id
	 *            the id of the JEObject
	 * @param dmt
	 *            the DefaultMutableTreeNode clicked on
	 */
	public void callBack(MouseEvent e, String id, DefaultMutableTreeNode dmt) {
	//		System.out.println("JEDefaultJECallBack.callBack() MouseEvent: " + id + "\n" + e);

	}

	/**
	 * All events from the TableModel of the JETable are send to this callBack.
	 * 
	 * @param e
	 *            the event send by the TableModel
	 * @param id
	 *            the id of the JEObject
	 */
	public void callBack(TableModelEvent e, String id) {
	//		System.out.println("JEDefaultJECallBack.callBack() TableModelEvent: "+id+"\n"+e);
	}

	/**
	 * All Expansion events from a JETreeNode are send to this callBack
	 * 
	 * @param e
	 * @param id
	 *            of the sending JEObject
	 */
	public void callBack(TreeExpansionEvent e, String id) {
	//		System.out.println("JEDefaultJECallBack.callBack() TreeExpansionEvent: "+id+"\n"+e);
	}

	/**
	 * All TreeModel events from a JETreeNode are send to this callBack
	 * 
	 * @param e
	 * @param id
	 *            of the sending JEObject
	 */
	public void callBack(TreeModelEvent e, String id) {
	//		System.out.println("JEDefaultJECallBack.callBack() TreeModelEvent: "+id+"\n"+e);
	}

	/**
	 * All Selection events from a JETreeNode are send to this callBack
	 * 
	 * @param e
	 *            TreeSelectionEvent
	 * @param id
	 *            of the sending JEObject
	 * @param tp
	 *            TreePath
	 */
	public void callBack(TreeSelectionEvent e, String id, TreePath tp) {
	//		System.out.println("JEDefaultJECallBack.callBack() TreeSelectionEvent: "+id+"\n"+e);
	// Object object=e.getSource();
	// String s = object.toString();
	// System.out.println("TreeSelectionEvent id="+id+" souece"+e.getSource()+"
	// s="+s);
	// DefaultMutableTreeNode
	// tn=(DefaultMutableTreeNode)tp.getLastPathComponent();
	// Object o =tn.getUserObject();
	// String x=o.toString();
	// System.out.println("x="+x);
	// JETreeNode z;
	// z.
	}

	/**
	 * Input Verifiers will send to this callback
	 * 
	 * @param id
	 *            the id of the JEObject
	 * @param text
	 *            of the input component
	 * @param error
	 */
	public boolean callBackInputVerifier(String id, String text, int error) {
		//		System.out.println("JEDefaultJECallBack.callBack() InputVerifier: " + id + "\n" + text+" Error: "+error);
		return true;
	}

	/**
	 * All returns from JEMethodinvocation will call this method
	 * 
	 * @param xmi
	 *            xmi String that will be invoked or null if nothing is to do
	 */
	public void callBackInvoke(String xmi) {}

	/**
	 * If a TimerTask for this object was created, this method will be called time by time.
	 * You must return false to destroy the timer.
	 * @param id
	 * @return
	 */
	public boolean callBackTimerTask(String id) {
		return false;
	}

	/**
	 * Should be called before first user action and after initializing all
	 * JEObjects
	 */
	public void initJECallBack() {}

	/**
	 * A "PropertyChange" event gets delivered whenever a bean changes a "bound"
	 * or "constrained" property.  
	 */
	public void propertyChange(PropertyChangeEvent evt) {}

	
	/**
	 * A low-level event which indicates that a component moved, changed
	 * size, or changed visibility (also, the root class for the other 
	 * component-level events).
	 */
	public void callBackComponentEvent(ComponentEvent e, String id) {
	//		System.out.println("JEDefaultJECallBack.callBack() ComponentEvent: " + id + "\n" + e);
	}

	/**
	 * If a jeasy id will get the focus or a mouse will enter a component its id and mode is send to this callback.
	 * It may be used to show a context sensitiv help.
	 * modes:
	 * 	JEObject.CONTEXT_HELP_FOCUS_GAINED
	 *  JEObject.CONTEXT_HELP_FOCUS_LOST
	 *  JEObject.CONTEXT_HELP_MOUSE_ENTERED
	 *  JEObject.CONTEXT_HELP_MOUSE_EXITED
	 * @param mode
	 * @param id jeasy id
	 * @return
	 */
	public void callBackContextHelp(int mode, String id) {
	}

}