* This implementation drops the dragged connection to
* the selected position.
*/
public void drop( DropTargetEvent event )
{
ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
try
{
if ( ConnectionTransfer.getInstance().isSupportedType( event.currentDataType ) )
{
// get connection to handle
Connection[] connections = ( Connection[] ) event.data;
Connection targetConnection = ( Connection ) event.item.getData();
if ( event.detail == DND.DROP_MOVE )
{
boolean fromTop = connectionManager.indexOf( connections[0] ) < connectionManager
.indexOf( targetConnection );
for ( int i = 0; i < connections.length; i++ )
{
connectionManager.removeConnection( connections[i] );
}
for ( int i = 0; i < connections.length; i++ )
{
int index = connectionManager.indexOf( targetConnection );
if ( fromTop )
{
index++;
connectionManager.addConnection( index + i, connections[i] );
}
else
{
connectionManager.addConnection( index, connections[i] );
}
}
}
else if ( event.detail == DND.DROP_COPY )
{
for ( int i = 0; i < connections.length; i++ )
{
Connection newConnection = ( Connection ) connections[i].clone();
int index = connectionManager.indexOf( targetConnection );
connectionManager.addConnection( index + i + 1, newConnection );
}
}
}
else
{