* This implementation drops the dragged connection to
* the selected position.
*/
public void drop( DropTargetEvent event )
{
ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
.getConnectionFolderManager();
try
{
if ( ConnectionTransfer.getInstance().isSupportedType( event.currentDataType ) )
{
// get connection and folders to handle
Object[] objects = ( Object[] ) event.data;
Object target = event.item != null ? event.item.getData() : connectionFolderManager
.getRootConnectionFolder();
ConnectionFolder targetFolder = null;
if ( target instanceof ConnectionFolder )
{
targetFolder = ( ConnectionFolder ) target;
}
else if ( target instanceof Connection )
{
Connection connection = ( Connection ) target;
targetFolder = connectionFolderManager.getParentConnectionFolder( connection );
}
for ( Object object : objects )
{
if ( object instanceof Connection )
{
Connection connection = ( Connection ) object;
if ( event.detail == DND.DROP_MOVE )
{
ConnectionFolder parentConnectionFolder = connectionFolderManager
.getParentConnectionFolder( connection );
parentConnectionFolder.removeConnectionId( connection.getId() );
targetFolder.addConnectionId( connection.getId() );
}
else if ( event.detail == DND.DROP_COPY )
{
Connection newConnection = ( Connection ) connection.clone();
connectionManager.addConnection( newConnection );
targetFolder.addConnectionId( newConnection.getId() );
}
}
else if ( object instanceof ConnectionFolder )
{