// 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 )
{
ConnectionFolder folder = ( ConnectionFolder ) object;
if ( event.detail == DND.DROP_MOVE )
{
ConnectionFolder parentConnectionFolder = connectionFolderManager
.getParentConnectionFolder( folder );
parentConnectionFolder.removeSubFolderId( folder.getId() );
targetFolder.addSubFolderId( folder.getId() );
// TODO: expand target folder
}
else if ( event.detail == DND.DROP_COPY )
{
ConnectionFolder newFolder = ( ConnectionFolder ) folder.clone();
connectionFolderManager.addConnectionFolder( newFolder );
targetFolder.addSubFolderId( newFolder.getId() );
// TODO: expand target folder
}
}
}
}