/*
 * @(#)CDView.java
 *
 * This file is part of webCDwriter - Network CD Writing.
 *
 * Copyright (C) 2001 Jörg P. M. Haeger
 *
 * webCDwriter is free software. See CDcreator.java for details.
 */

/*
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
*/
import javax.swing.JTree;
import javax.swing.DefaultListSelectionModel;
import javax.swing.tree.DefaultTreeSelectionModel;

class CDView extends JTreeTable {
	public CDView(TreeTableModel treeTableModel) {
		super(treeTableModel);
		tree.setSelectionModel(new DefaultTreeSelectionModel());
		setSelectionModel(new MyListSelectionModel());

/*		DropTarget target = new DropTarget(this,
			new DropTargetListener() {
				public void dragEnter(DropTargetDragEvent dtde) {
					System.out.println("dragEnter");
				}
				public void dragOver(DropTargetDragEvent dtde) {
					System.out.println("dragOver");
				}
				public void dropActionChanged(DropTargetDragEvent dtde) {
					System.out.println("dropActionChanged");
				}
				public void dragExit(DropTargetEvent dte) {
					System.out.println("dragExit");
				}
				public void drop(DropTargetDropEvent dtde) {
					System.out.println("drop");
				}
			});
*/
	}

	class MyListSelectionModel extends DefaultListSelectionModel {
		public MyListSelectionModel() {
			super();
		}

		public void addSelectionInterval(int index0, int index1) {
//			System.out.println("addSelectionInterval("
//				+ index0 + ", " + index1 + ")");
			tree.addSelectionInterval(index0, index1);
			super.addSelectionInterval(index0, index1);
		}

		public boolean isSelectedIndex(int index) {
//			System.out.println("isSelectedIndex(" + index + ")");
			return tree.isRowSelected(index);
		}

		public void removeIndexInterval(int index0, int index1) {
			System.out.println("removeIndexInterval("
				+ index0 + ", " + index1 + ")");
			tree.removeSelectionInterval(index0, index1);
			super.removeIndexInterval(index0, index1);
		}

		public void removeSelectionInterval(int index0, int index1) {
//			System.out.println("removeSelectionInterval("
//				+ index0 + ", " + index1 + ")");
			super.removeSelectionInterval(index0, index1);
		}

		public void setLeadSelectionIndex(int index) {
//			System.out.println("setLeadSelectionIndex(" + index + ")");
			super.setLeadSelectionIndex(index);
		}

		public void setSelectionInterval(int index0, int index1) {
//			System.out.println("setSelectionInterval("
//				+ index0 + ", " + index1 + ")");
			tree.setSelectionInterval(index0, index1);
			super.setSelectionInterval(index0, index1);
		}
	}
}
