package gov.nih.nci.cbiit.cmps.ui.tree;

import gov.nih.nci.cbiit.cmps.ui.mapping.ElementMetaLoader;
import gov.nih.nci.cbiit.cmps.ui.properties.PropertiesSwitchController;

import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

public class TreeSelectionHandler implements TreeSelectionListener {

	private PropertiesSwitchController propertyController;
	public TreeSelectionHandler(PropertiesSwitchController controller)
	{
		propertyController=controller;
	}
	// TODO Auto-generated method stub
	/**
	 * Called whenever the value of the selection changes.
	 *
	 * @param e the event that characterizes the change.
	 */
	public void valueChanged(TreeSelectionEvent e)
	{
		TreePath newPath = e.getNewLeadSelectionPath();
		if(newPath==null)
		{
			propertyController.setSelectedItem(null);
		}
		else
		{
			DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) newPath.getLastPathComponent();
			Object newSelection = treeNode.getUserObject();
			if(newSelection instanceof ElementMetaLoader.MyTreeObject)
				newSelection = ((ElementMetaLoader.MyTreeObject)newSelection).getObj();
			
			propertyController.setSelectedItem(newSelection);
		}
		propertyController.getPropertiesPage().updateProptiesDisplay(null);
	}

}

@@ -71,31 +71,40 @@
 .ui.
-mapping.ElementMetaLoad
+jgraph.MiddlePanelJGraphControll
 er;%0A
@@ -140,43 +140,31 @@
 .ui.
-properties.PropertiesSwitchControll
+mapping.ElementMetaLoad
 er;%0A
@@ -419,31 +419,32 @@
 private 
-PropertiesSwitc
+MiddlePanelJGrap
 hControl
@@ -447,24 +447,21 @@
 troller 
-property
+graph
 Controll
@@ -497,23 +497,24 @@
 ler(
-PropertiesSwitc
+MiddlePanelJGrap
 hCon
@@ -538,24 +538,21 @@
 r)%0A%09%7B%0A%09%09
-property
+graph
 Controll
@@ -780,16 +780,71 @@
 t e)%0A%09%7B%0A
+%09%09if (graphController.isGraphSelected())%0A%09%09%09return;%0A%09%09%0A
 %09%09TreePa
@@ -908,32 +908,59 @@
 ull)%0A%09%09%7B%0A%09%09%09
-property
+graphController.getPropertiesSwitch
 Controller.s
@@ -949,32 +949,34 @@
 SwitchController
+()
 .setSelectedItem
@@ -1005,98 +1005,484 @@
 %0A%09%09%09
-DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) newPath.getLastPathComponent();
+//clear graph selection%0A%09%09%09graphController.getMiddlePanel().getGraph().clearSelection();%0A%09%09%09DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) newPath.getLastPathComponent();%0A%09%09%09//clear selection of %22the other tree%22%0A%09%09%09if (treeNode instanceof DefaultSourceTreeNode)%0A%09%09%09%09graphController.getMappingPanel().getTargetTree().clearSelection();%0A%09%09%09else if (treeNode instanceof DefaultTargetTreeNode)%0A%09%09%09%09graphController.getMappingPanel().getSourceTree().clearSelection();%0A%09%09%09
 %0A%09%09%09
@@ -1674,24 +1674,51 @@
 %0A%09%09%09%0A%09%09%09
-property
+graphController.getPropertiesSwitch
 Controll
@@ -1719,16 +1719,18 @@
 ntroller
+()
 .setSele
@@ -1763,16 +1763,43 @@
 %7D%0A%09%09
-property
+graphController.getPropertiesSwitch
 Cont
@@ -1796,32 +1796,34 @@
 SwitchController
+()
 .getPropertiesPa

clear gaph and other tree selection