// Path: src/main/java/ca/sqlpower/architect/swingui/PlayPen.java
// public enum MouseModeType {IDLE,
// 					CREATING_TABLE,
// 					CREATING_RELATIONSHIP,
// 					SELECT_TABLE,
// 					SELECT_RELATIONSHIP,
// 					SELECT_ITEM,
// 					SELECT_SECTION,
// 					MULTI_SELECT,
// 					RUBBERBAND_MOVE}


import java.awt.Color;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.swing.JComponent;
import org.apache.log4j.Logger;
import ca.sqlpower.architect.layout.LayoutNode;
import ca.sqlpower.architect.swingui.PlayPen.MouseModeType;
import ca.sqlpower.architect.swingui.event.ItemSelectionEvent;
import ca.sqlpower.architect.swingui.event.ItemSelectionListener;
import ca.sqlpower.architect.swingui.event.SelectionEvent;
import ca.sqlpower.object.annotation.Accessor;
import ca.sqlpower.object.annotation.Mutator;
import ca.sqlpower.object.annotation.NonBound;
import ca.sqlpower.object.annotation.Transient;
import ca.sqlpower.swingui.SPSUtils;

        Point p = evt.getPoint();
        pp.unzoomPoint(p);
        p.translate(-getX(), -getY());

        if (evt.getID() == MouseEvent.MOUSE_CLICKED) {
            if (evt.getClickCount() == 1 && evt.getButton() == MouseEvent.BUTTON1){ 
                int selectedItemIndex = pointToItemIndex(p);
                if(selectedItemIndex >= 0 && selectedItemIndex < getItems().size()) {
                    previousSelectedItem = getItems().get(selectedItemIndex);
                }
                if (selectedItemIndex > ITEM_INDEX_TITLE && componentPreviouslySelected){
                    if(evt.isControlDown()) {
                        deselectItem(selectedItemIndex);
                        fireSelectionEvent(new SelectionEvent(this, SelectionEvent.DESELECTION_EVENT, SelectionEvent.SINGLE_SELECT));
                    } else {
                        selectNone();
                        selectItem(selectedItemIndex);
                        fireSelectionEvent(new SelectionEvent(this, SelectionEvent.SELECTION_EVENT, SelectionEvent.SINGLE_SELECT));
                    }
                } else if (isSelected() && componentPreviouslySelected) {
                    setSelected(false, SelectionEvent.SINGLE_SELECT);
                }
            }
        } else if (evt.getID() == MouseEvent.MOUSE_PRESSED) {
            componentPreviouslySelected = false;
            int clickItem = pointToItemIndex(p);

            if (pp.getMouseMode() != MouseModeType.CREATING_TABLE) {
                if ((evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | SPSUtils.MULTISELECT_MASK)) == 0) {
// Path: src/main/java/ca/sqlpower/architect/swingui/PlayPen.java
// public enum MouseModeType {IDLE,
// 					CREATING_TABLE,
// 					CREATING_RELATIONSHIP,
// 					SELECT_TABLE,
// 					SELECT_RELATIONSHIP,
// 					SELECT_ITEM,
// 					SELECT_SECTION,
// 					MULTI_SELECT,
// 					RUBBERBAND_MOVE}


// Path: src/main/java/ca/sqlpower/architect/swingui/ContainerPane.java
import java.awt.Color;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.swing.JComponent;
import org.apache.log4j.Logger;
import ca.sqlpower.architect.layout.LayoutNode;
import ca.sqlpower.architect.swingui.PlayPen.MouseModeType;
import ca.sqlpower.architect.swingui.event.ItemSelectionEvent;
import ca.sqlpower.architect.swingui.event.ItemSelectionListener;
import ca.sqlpower.architect.swingui.event.SelectionEvent;
import ca.sqlpower.object.annotation.Accessor;
import ca.sqlpower.object.annotation.Mutator;
import ca.sqlpower.object.annotation.NonBound;
import ca.sqlpower.object.annotation.Transient;
import ca.sqlpower.swingui.SPSUtils;


        Point p = evt.getPoint();
        pp.unzoomPoint(p);
        p.translate(-getX(), -getY());

        if (evt.getID() == MouseEvent.MOUSE_CLICKED) {
            if (evt.getClickCount() == 1 && evt.getButton() == MouseEvent.BUTTON1){ 
                int selectedItemIndex = pointToItemIndex(p);
                if(selectedItemIndex >= 0 && selectedItemIndex < getItems().size()) {
                    previousSelectedItem = getItems().get(selectedItemIndex);
                }
                if (selectedItemIndex > ITEM_INDEX_TITLE && componentPreviouslySelected){
                    if(evt.isControlDown()) {
                        deselectItem(selectedItemIndex);
                        fireSelectionEvent(new SelectionEvent(this, SelectionEvent.DESELECTION_EVENT, SelectionEvent.SINGLE_SELECT));
                    } else {
                        selectNone();
                        selectItem(selectedItemIndex);
                        fireSelectionEvent(new SelectionEvent(this, SelectionEvent.SELECTION_EVENT, SelectionEvent.SINGLE_SELECT));
                    }
                } else if (isSelected() && componentPreviouslySelected) {
                    setSelected(false, SelectionEvent.SINGLE_SELECT);
                }
            }
        } else if (evt.getID() == MouseEvent.MOUSE_PRESSED) {
            componentPreviouslySelected = false;
            int clickItem = pointToItemIndex(p);

            if (pp.getMouseMode() != MouseModeType.CREATING_TABLE) {
                if ((evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | SPSUtils.MULTISELECT_MASK)) == 0) {
                    if (!isSelected() || pp.getMouseMode() == MouseModeType.IDLE) {