//# 0 errors, 232 messages
//#
/*
    //#ReorderableJList.java:1:1: class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#ReorderableJList.java:1:1: method: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.addons.ui_swing.components.reorderablelist;


import com.dmdirc.addons.ui_swing.components.renderers.ReorderableJListCellRenderer;
import com.dmdirc.logger.ErrorLevel;
import com.dmdirc.logger.Logger;

import java.awt.Cursor;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
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 java.io.IOException;
import java.util.ArrayList;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.ListSelectionModel;

/**
 * Reorderable JList.
 */
public final class ReorderableJList extends JList implements DragSourceListener,
    //#ReorderableJList.java:59: method: ListModel com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.getModel()
    //#input(ListModel getModel()): this
    //#output(ListModel getModel()): return_value
    //#post(ListModel getModel()): init'ed(return_value)
    //#unanalyzed(ListModel getModel()): Effects-of-calling:javax.swing.JList:getModel
    //#ReorderableJList.java:59: end of method: ListModel com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.getModel()
        DropTargetListener, DragGestureListener {
    
    /**
     * A version number for this class. It should be changed whenever the class
     * structure is changed (or anything else that would prevent serialized
     * objects being unserialized with the new class).
     */
    private static final long serialVersionUID = 1;
    
    /** Drag source. */
    private final DragSource dragSource;
    /** Drag target. */
    private final DropTarget dropTarget;
    /** Drop target. */
    private Object dropTargetCell;
    /** Dragged index. */
    private int draggedIndex = -1;
    /** Data flavor. */
    private DataFlavor dataFlavor;
    /** Below drop target. */
    private boolean belowTarget;
    
    /** Instantiate new ReorderableJList. */
    public ReorderableJList() {
        this(new DefaultListModel());
    //#ReorderableJList.java:84: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): "unable to create data flavor: "._tainted
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): com.dmdirc.logger.ErrorLevel.LOW
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferHandler.com.dmdirc.logger.ErrorLevel.LOW
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): this
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): new DataFlavor(ReorderableJList#4) num objects
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): new DropTarget(ReorderableJList#3) num objects
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): this.dataFlavor
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): this.dragSource
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): this.draggedIndex
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): this.dropTarget
    //#new obj(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): new DataFlavor(ReorderableJList#4)
    //#new obj(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): new DropTarget(ReorderableJList#3)
    //#presumption(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): java.awt.dnd.DragSource:getDefaultDragSource(...)@99 != null
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): this.dataFlavor == One-of{&new DataFlavor(ReorderableJList#4), null}
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): this.dataFlavor in Addr_Set{null,&new DataFlavor(ReorderableJList#4)}
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): this.dragSource != null
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): init'ed(this.draggedIndex)
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): this.dropTarget == &new DropTarget(ReorderableJList#3)
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): new DataFlavor(ReorderableJList#4) num objects <= 1
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): new DropTarget(ReorderableJList#3) num objects == 1
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:javax.swing.JList
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:com.dmdirc.addons.ui_swing.components.renderers.ReorderableJListCellRenderer
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:setCellRenderer
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:setSelectionMode
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:javax.swing.TransferHandler
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:java.awt.datatransfer.DataFlavor
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:java.lang.ClassNotFoundException:getMessage
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:com.dmdirc.logger.Logger:userError
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:setTransferHandler
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:java.awt.dnd.DragSource:getDefaultDragSource
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:java.awt.dnd.DropTarget
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()): Effects-of-calling:java.awt.dnd.DragSource:createDefaultDragGestureRecognizer
    }
    //#ReorderableJList.java:85: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList()

    /**
     * Instantiate new ReorderableJList.
     *
     * @param model Model
     */
    public ReorderableJList(final DefaultListModel model) {
        super(model);
    //#ReorderableJList.java:93: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): "unable to create data flavor: "._tainted
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): com.dmdirc.logger.ErrorLevel.LOW
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferHandler.com.dmdirc.logger.ErrorLevel.LOW
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): model
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): this
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): new DataFlavor(ReorderableJList#4) num objects
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): new DropTarget(ReorderableJList#3) num objects
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): this.dataFlavor
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): this.dragSource
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): this.draggedIndex
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): this.dropTarget
    //#new obj(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): new DataFlavor(ReorderableJList#4)
    //#new obj(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): new DropTarget(ReorderableJList#3)
    //#presumption(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): init'ed(com.dmdirc.logger.ErrorLevel.LOW)
    //#presumption(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): java.awt.dnd.DragSource:getDefaultDragSource(...)@99 != null
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): this.dataFlavor in Addr_Set{null,&new DataFlavor(ReorderableJList#4)}
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): this.dragSource != null
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): init'ed(this.draggedIndex)
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): this.dropTarget == &new DropTarget(ReorderableJList#3)
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): new DataFlavor(ReorderableJList#4) num objects <= 1
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): new DropTarget(ReorderableJList#3) num objects == 1
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): Effects-of-calling:javax.swing.TransferHandler
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): Effects-of-calling:java.awt.datatransfer.DataFlavor
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): Effects-of-calling:java.lang.ClassNotFoundException:getMessage
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)): Effects-of-calling:com.dmdirc.logger.Logger:userError
        
        setCellRenderer(new ReorderableJListCellRenderer(this));
    //#ReorderableJList.java:95: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:setCellRenderer(ListCellRenderer)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:setCellRenderer(ListCellRenderer)
        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    //#ReorderableJList.java:96: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:setSelectionMode(int)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:setSelectionMode(int)
        setTransferHandler(new ArrayListTransferHandler());
    //#ReorderableJList.java:97: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:setTransferHandler(TransferHandler)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:setTransferHandler(TransferHandler)
        
        dragSource = DragSource.getDefaultDragSource();
        dropTarget = new DropTarget(this, this);
        
        dragSource.createDefaultDragGestureRecognizer(this,
                DnDConstants.ACTION_MOVE, this);
        try {
            
            dataFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType
                    + ";class=java.util.ArrayList");
        } catch (ClassNotFoundException e) {
            Logger.userError(ErrorLevel.LOW, "unable to create data flavor: "
    //#ReorderableJList.java:109: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)
    //#    unanalyzed callee: void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
                    + e.getMessage());
            dataFlavor = null;
        }
    }
    //#ReorderableJList.java:113: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList(DefaultListModel)
    
    /** {@inheritDoc} */
    @Override
    public DefaultListModel getModel() {
        return (DefaultListModel) super.getModel();
    //#ReorderableJList.java:118: method: DefaultListModel com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.getModel()
    //#input(DefaultListModel getModel()): this
    //#output(DefaultListModel getModel()): return_value
    //#post(DefaultListModel getModel()): init'ed(return_value)
    //#ReorderableJList.java:118: end of method: DefaultListModel com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.getModel()
    }
    
    /** 
     * Sets the model for the list.
     *
     * @param model Model for the list
     */
    public void setModel(final DefaultListModel model) { //NOPMD stupid
        super.setModel(model);
    //#ReorderableJList.java:127: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.setModel(DefaultListModel)
    //#input(void setModel(DefaultListModel)): model
    //#input(void setModel(DefaultListModel)): this
    }
    //#ReorderableJList.java:128: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.setModel(DefaultListModel)
    
    /**
     * Returns the target drop item.
     *
     * @return Drop target cell
     */
    public Object getTargetCell() {
        return dropTargetCell;
    //#ReorderableJList.java:136: method: Object com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.getTargetCell()
    //#input(Object getTargetCell()): this
    //#input(Object getTargetCell()): this.dropTargetCell
    //#output(Object getTargetCell()): return_value
    //#pre[2] (Object getTargetCell()): init'ed(this.dropTargetCell)
    //#post(Object getTargetCell()): return_value == this.dropTargetCell
    //#post(Object getTargetCell()): init'ed(return_value)
    //#ReorderableJList.java:136: end of method: Object com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.getTargetCell()
    }
    
    /**
     * Returns whether the target is below the drop cell.
     *
     * @return if the target is above or below the point
     */
    public boolean getBelowTarget() {
        return belowTarget;
    //#ReorderableJList.java:145: method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.getBelowTarget()
    //#input(bool getBelowTarget()): this
    //#input(bool getBelowTarget()): this.belowTarget
    //#output(bool getBelowTarget()): return_value
    //#pre[2] (bool getBelowTarget()): init'ed(this.belowTarget)
    //#post(bool getBelowTarget()): return_value == this.belowTarget
    //#post(bool getBelowTarget()): init'ed(return_value)
    //#ReorderableJList.java:145: end of method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.getBelowTarget()
    }
    
    /** {@inheritDoc} */
    @Override
    public void dragEnter(final DragSourceDragEvent dsde) {
        //Ignore
    }
    //#ReorderableJList.java:152: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragEnter(DragSourceDragEvent)
    //#ReorderableJList.java:152: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragEnter(DragSourceDragEvent)
    
    /** {@inheritDoc} */
    @Override
    public void dragOver(final DragSourceDragEvent dsde) {
        //Ignore
    }
    //#ReorderableJList.java:158: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragOver(DragSourceDragEvent)
    //#ReorderableJList.java:158: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragOver(DragSourceDragEvent)
    
    /** {@inheritDoc} */
    @Override
    public void dropActionChanged(final DragSourceDragEvent dsde) {
        //Ignore
    }
    //#ReorderableJList.java:164: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dropActionChanged(DragSourceDragEvent)
    //#ReorderableJList.java:164: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dropActionChanged(DragSourceDragEvent)
    
    /** {@inheritDoc} */
    @Override
    public void dragExit(final DragSourceEvent dse) {
        //Ignore
    }
    //#ReorderableJList.java:170: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragExit(DragSourceEvent)
    //#ReorderableJList.java:170: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragExit(DragSourceEvent)
    
    /** {@inheritDoc} */
    @Override
    public void dragDropEnd(final DragSourceDropEvent dsde) {
        //clear drop variables and repaint
        dropTargetCell = null;
    //#ReorderableJList.java:176: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragDropEnd(DragSourceDropEvent)
    //#input(void dragDropEnd(DragSourceDropEvent)): this
    //#output(void dragDropEnd(DragSourceDropEvent)): this.draggedIndex
    //#output(void dragDropEnd(DragSourceDropEvent)): this.dropTargetCell
    //#post(void dragDropEnd(DragSourceDropEvent)): this.draggedIndex == -1
    //#post(void dragDropEnd(DragSourceDropEvent)): this.dropTargetCell == null
        draggedIndex = -1;
        repaint();
    //#ReorderableJList.java:178: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:repaint()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void dragDropEnd(DragSourceDropEvent)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:repaint()
    }
    //#ReorderableJList.java:179: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragDropEnd(DragSourceDropEvent)
    
    /** {@inheritDoc} */
    @Override
    public void dragEnter(final DropTargetDragEvent dtde) {
        //check whether to accept drag
        if (dtde.getSource() == dropTarget) {
    //#ReorderableJList.java:185: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragEnter(DropTargetDragEvent)
    //#input(void dragEnter(DropTargetDragEvent)): dtde
    //#input(void dragEnter(DropTargetDragEvent)): this
    //#input(void dragEnter(DropTargetDragEvent)): this.dropTarget
    //#pre[1] (void dragEnter(DropTargetDragEvent)): dtde != null
            dtde.acceptDrag(DnDConstants.ACTION_MOVE);
        } else {
            dtde.rejectDrag();
        }
    }
    //#ReorderableJList.java:190: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragEnter(DropTargetDragEvent)
    
    /** {@inheritDoc} */
    @Override
    public void dragOver(final DropTargetDragEvent dtde) {
        //Reject drops on self
        if (dtde.getSource() != dropTarget) {
    //#ReorderableJList.java:196: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragOver(DropTargetDragEvent)
    //#input(void dragOver(DropTargetDragEvent)): dtde
    //#input(void dragOver(DropTargetDragEvent)): this
    //#input(void dragOver(DropTargetDragEvent)): this.dropTarget
    //#output(void dragOver(DropTargetDragEvent)): this.belowTarget
    //#output(void dragOver(DropTargetDragEvent)): this.dropTargetCell
    //#pre[1] (void dragOver(DropTargetDragEvent)): dtde != null
    //#presumption(void dragOver(DropTargetDragEvent)): com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:getCellBounds(...)@210 != null
    //#presumption(void dragOver(DropTargetDragEvent)): java.awt.dnd.DropTargetDragEvent:getLocation(...)@201 != null
    //#presumption(void dragOver(DropTargetDragEvent)): javax.swing.JList:getModel(...)@118 != null
    //#presumption(void dragOver(DropTargetDragEvent)): javax.swing.JList:getModel(...)@118 != null
    //#post(void dragOver(DropTargetDragEvent)): possibly_updated(this.belowTarget)
    //#post(void dragOver(DropTargetDragEvent)): init'ed(this.dropTargetCell)
    //#unanalyzed(void dragOver(DropTargetDragEvent)): Effects-of-calling:javax.swing.JList:getModel
    //#test_vector(void dragOver(DropTargetDragEvent)): com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:locationToIndex(...)@202: {-2_147_483_648..-2, 0..4_294_967_294}, {-1}
            dtde.rejectDrag();
        }
        
        //get location and index
        final Point dragPoint = dtde.getLocation();
        final int index = locationToIndex(dragPoint);
    //#ReorderableJList.java:202: Warning: method not available - call not analyzed
    //#    call on int com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:locationToIndex(Point)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void dragOver(DropTargetDragEvent)
    //#    unanalyzed callee: int com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:locationToIndex(Point)
        
        //set drag variables and repaint
        if (index == -1) {
            dropTargetCell = null;
        } else {
            dropTargetCell = getModel().getElementAt(index);
            //check whether the drop point is after the last index
            final Rectangle bounds = getCellBounds(index, index);
    //#ReorderableJList.java:210: Warning: method not available - call not analyzed
    //#    call on Rectangle com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:getCellBounds(int, int)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void dragOver(DropTargetDragEvent)
    //#    unanalyzed callee: Rectangle com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:getCellBounds(int, int)
            if (index == getModel().getSize() - 1 
                    && dragPoint.y > bounds.y + bounds.height) {
                belowTarget = true;
            } else {
                belowTarget = false;
            }
        }
        
        repaint();
    //#ReorderableJList.java:219: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:repaint()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void dragOver(DropTargetDragEvent)
    //#    unanalyzed callee: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:repaint()
    }
    //#ReorderableJList.java:220: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragOver(DropTargetDragEvent)
    
    /** {@inheritDoc} */
    @Override
    public void dropActionChanged(final DropTargetDragEvent dtde) {
        //Ignore
    }
    //#ReorderableJList.java:226: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dropActionChanged(DropTargetDragEvent)
    //#ReorderableJList.java:226: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dropActionChanged(DropTargetDragEvent)
    
    /** {@inheritDoc} */
    @Override
    public void dragExit(final DropTargetEvent dte) {
        //Ignore
    }
    //#ReorderableJList.java:232: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragExit(DropTargetEvent)
    //#ReorderableJList.java:232: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragExit(DropTargetEvent)
    
    /** {@inheritDoc} */
    @Override
    public void drop(final DropTargetDropEvent dtde) {
        //check source and reject
        if (dtde.getSource() != dropTarget) {
    //#ReorderableJList.java:238: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.drop(DropTargetDropEvent)
    //#input(void drop(DropTargetDropEvent)): dtde
    //#input(void drop(DropTargetDropEvent)): this
    //#input(void drop(DropTargetDropEvent)): this.belowTarget
    //#input(void drop(DropTargetDropEvent)): this.dataFlavor
    //#input(void drop(DropTargetDropEvent)): this.draggedIndex
    //#input(void drop(DropTargetDropEvent)): this.dropTarget
    //#pre[1] (void drop(DropTargetDropEvent)): dtde != null
    //#pre[3] (void drop(DropTargetDropEvent)): (soft) init'ed(this.belowTarget)
    //#pre[4] (void drop(DropTargetDropEvent)): (soft) init'ed(this.dataFlavor)
    //#pre[5] (void drop(DropTargetDropEvent)): (soft) init'ed(this.draggedIndex)
    //#presumption(void drop(DropTargetDropEvent)): com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:getSelectionModel(...)@277 != null
    //#presumption(void drop(DropTargetDropEvent)): com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:locationToIndex(...)@244 <= 4_294_967_294
    //#presumption(void drop(DropTargetDropEvent)): java.awt.datatransfer.Transferable:getTransferData(...)@261 != null
    //#presumption(void drop(DropTargetDropEvent)): java.awt.dnd.DropTargetDropEvent:getTransferable(...)@261 != null
    //#presumption(void drop(DropTargetDropEvent)): java.util.ArrayList:iterator(...)@273 != null
    //#presumption(void drop(DropTargetDropEvent)): javax.swing.JList:getModel(...)@118 != null
    //#unanalyzed(void drop(DropTargetDropEvent)): Effects-of-calling:javax.swing.JList:getModel
    //#test_vector(void drop(DropTargetDropEvent)): this.belowTarget: {0}, {1}
    //#test_vector(void drop(DropTargetDropEvent)): java.util.Iterator:hasNext(...)@273: {0}, {1}
            dtde.rejectDrop();
            return;
        }
        //get object location and index
        final Point dropPoint = dtde.getLocation();
        int index = locationToIndex(dropPoint);
    //#ReorderableJList.java:244: Warning: method not available - call not analyzed
    //#    call on int com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:locationToIndex(Point)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void drop(DropTargetDropEvent)
    //#    unanalyzed callee: int com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:locationToIndex(Point)
        if (belowTarget) {
            index++;
        }
        
        //reject invalid drops
        if ((index == -1) || (index == draggedIndex)) {
            dtde.rejectDrop();
            return;
        }
        
        //accept drop as a move
        dtde.acceptDrop(DnDConstants.ACTION_MOVE);
        
        //get dropped item
        Object dragged;
        try {
            dragged = dtde.getTransferable().getTransferData(dataFlavor);
        } catch (UnsupportedFlavorException e) {
            return;
        } catch (IOException e) {
            return;
        }
        
        //move items
        final boolean sourceBeforeTarget = draggedIndex < index;
        final DefaultListModel mod = getModel();
        final int newIndex = sourceBeforeTarget ? index - 1 : index;
        mod.remove(draggedIndex);
        for (Object item : (ArrayList) dragged) {
            mod.add(newIndex, item);
        }
        
        getSelectionModel().setSelectionInterval(newIndex, newIndex);
    //#ReorderableJList.java:277: Warning: method not available - call not analyzed
    //#    call on ListSelectionModel com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:getSelectionModel()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void drop(DropTargetDropEvent)
    //#    unanalyzed callee: ListSelectionModel com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:getSelectionModel()
        
        //drop complete
        dtde.dropComplete(true);
    }
    //#ReorderableJList.java:281: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.drop(DropTargetDropEvent)
    
    /** {@inheritDoc} */
    @Override
    public void dragGestureRecognized(final DragGestureEvent dge) {
        //find the objects location and index
        final Point clickPoint = dge.getDragOrigin();
    //#ReorderableJList.java:287: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragGestureRecognized(DragGestureEvent)
    //#input(void dragGestureRecognized(DragGestureEvent)): "unable to create data flavor: "._tainted
    //#input(void dragGestureRecognized(DragGestureEvent)): com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferable.com.dmdirc.logger.ErrorLevel.LOW
    //#input(void dragGestureRecognized(DragGestureEvent)): dge
    //#input(void dragGestureRecognized(DragGestureEvent)): this
    //#input(void dragGestureRecognized(DragGestureEvent)): this.dragSource
    //#output(void dragGestureRecognized(DragGestureEvent)): this.draggedIndex
    //#pre[1] (void dragGestureRecognized(DragGestureEvent)): dge != null
    //#pre[4] (void dragGestureRecognized(DragGestureEvent)): (soft) this.dragSource != null
    //#presumption(void dragGestureRecognized(DragGestureEvent)): javax.swing.JList:getModel(...)@118 != null
    //#post(void dragGestureRecognized(DragGestureEvent)): possibly_updated(this.draggedIndex)
    //#unanalyzed(void dragGestureRecognized(DragGestureEvent)): Effects-of-calling:javax.swing.JList:getModel
    //#unanalyzed(void dragGestureRecognized(DragGestureEvent)): Effects-of-calling:java.awt.datatransfer.DataFlavor
    //#unanalyzed(void dragGestureRecognized(DragGestureEvent)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void dragGestureRecognized(DragGestureEvent)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void dragGestureRecognized(DragGestureEvent)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void dragGestureRecognized(DragGestureEvent)): Effects-of-calling:java.lang.ClassNotFoundException:getMessage
    //#unanalyzed(void dragGestureRecognized(DragGestureEvent)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void dragGestureRecognized(DragGestureEvent)): Effects-of-calling:com.dmdirc.logger.Logger:userError
    //#test_vector(void dragGestureRecognized(DragGestureEvent)): com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:locationToIndex(...)@288: {-2_147_483_648..-2, 0..4_294_967_295}, {-1}
        final int index = locationToIndex(clickPoint);
    //#ReorderableJList.java:288: Warning: method not available - call not analyzed
    //#    call on int com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:locationToIndex(Point)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
    //#    method: void dragGestureRecognized(DragGestureEvent)
    //#    unanalyzed callee: int com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList:locationToIndex(Point)
        
        if (index == -1) {
            return;
        }
        
        //get the list object
        final Object target = getModel().getElementAt(index);
        //create the trasnferable object
        final ArrayList<Object> transferObject = new ArrayList<Object>();
        transferObject.add(target);
        final Transferable trans = new ArrayListTransferable(transferObject);
        //start drag
        draggedIndex = index;
        dragSource.startDrag(dge, Cursor.getDefaultCursor(), trans, this);
    }
    //#ReorderableJList.java:303: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.dragGestureRecognized(DragGestureEvent)
}


    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/reorderablelist/ReorderableJList]
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragDropEnd(Ljava/awt/dnd/DragSourceDropEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragEnter(Ljava/awt/dnd/DragSourceDragEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragEnter(Ljava/awt/dnd/DropTargetDragEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragExit(Ljava/awt/dnd/DragSourceEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragExit(Ljava/awt/dnd/DropTargetEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragGestureRecognized(Ljava/awt/dnd/DragGestureEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragOver(Ljava/awt/dnd/DragSourceDragEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragOver(Ljava/awt/dnd/DropTargetDragEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.drop(Ljava/awt/dnd/DropTargetDropEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dropActionChanged(Ljava/awt/dnd/DragSourceDragEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dropActionChanged(Ljava/awt/dnd/DropTargetDragEvent;)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.getBelowTarget()Z
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.getModel()Ljavax/swing/DefaultListModel;
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.getModel()Ljavax/swing/ListModel;
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.getTargetCell()Ljava/lang/Object;
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.setModel(Ljavax/swing/DefaultListModel;)V
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/reorderablelist/ReorderableJList] == &__Dispatch_Table
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragDropEnd(Ljava/awt/dnd/DragSourceDropEvent;)V == &dragDropEnd
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragEnter(Ljava/awt/dnd/DragSourceDragEvent;)V == &dragEnter
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragEnter(Ljava/awt/dnd/DropTargetDragEvent;)V == &dragEnter
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragExit(Ljava/awt/dnd/DragSourceEvent;)V == &dragExit
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragExit(Ljava/awt/dnd/DropTargetEvent;)V == &dragExit
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragGestureRecognized(Ljava/awt/dnd/DragGestureEvent;)V == &dragGestureRecognized
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragOver(Ljava/awt/dnd/DragSourceDragEvent;)V == &dragOver
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dragOver(Ljava/awt/dnd/DropTargetDragEvent;)V == &dragOver
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.drop(Ljava/awt/dnd/DropTargetDropEvent;)V == &drop
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dropActionChanged(Ljava/awt/dnd/DragSourceDragEvent;)V == &dropActionChanged
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.dropActionChanged(Ljava/awt/dnd/DropTargetDragEvent;)V == &dropActionChanged
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.getBelowTarget()Z == &getBelowTarget
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.getModel()Ljavax/swing/DefaultListModel; == &getModel
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.getModel()Ljavax/swing/ListModel; == &getModel
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.getTargetCell()Ljava/lang/Object; == &getTargetCell
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init): __Dispatch_Table.setModel(Ljavax/swing/DefaultListModel;)V == &setModel
    //#ReorderableJList.java:: end of method: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList.com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList__static_init
    //#ReorderableJList.java:: end of class: com.dmdirc.addons.ui_swing.components.reorderablelist.ReorderableJList
