/**
* {@inheritDoc}
*/
public void run()
{
ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
.getConnectionFolderManager();
ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
ConnectionFolder[] selectedFolders = getSelectedConnectionFolders();
Connection[] selectedConnections = getSelectedConnections();
ConnectionFolder targetFolder = null;
if ( selectedFolders.length > 0 )
{
targetFolder = selectedFolders[0];
}
else if ( selectedConnections.length > 0 )
{
targetFolder = connectionFolderManager.getParentConnectionFolder( selectedConnections[0] );
}
if ( targetFolder == null )
{
targetFolder = connectionFolderManager.getRootConnectionFolder();
}
// connections
List<Connection> connections = getConnectionsToPaste();
for ( Connection connection : connections )
{
Connection newConnection = ( Connection ) connection.clone();
connectionManager.addConnection( newConnection );
targetFolder.addConnectionId( newConnection.getId() );
}
// connection folders
List<ConnectionFolder> connectionFolders = getConnectionFoldersToPaste();
for ( ConnectionFolder connectionFolder : connectionFolders )
{
ConnectionFolder newConnectionFolder = ( ConnectionFolder ) connectionFolder.clone();
connectionFolderManager.addConnectionFolder( newConnectionFolder );
targetFolder.addSubFolderId( newConnectionFolder.getId() );
}
}