1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.view.datasource.handler;
|
11
|
|
12
|
import org.eclipse.core.commands.ExecutionEvent;
|
13
|
import org.eclipse.jface.dialogs.MessageDialog;
|
14
|
import org.eclipse.jface.viewers.ISelection;
|
15
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
16
|
import org.eclipse.ui.handlers.HandlerUtil;
|
17
|
|
18
|
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
|
19
|
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
|
20
|
import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer;
|
21
|
|
22
|
/**
|
23
|
* @author n.hoffmann
|
24
|
* @created 15.04.2009
|
25
|
* @version 1.0
|
26
|
*/
|
27
|
public class DeleteDataSourceHandler extends AbstractDataSourceHandler {
|
28
|
|
29
|
/** {@inheritDoc} */
|
30
|
@Override
|
31
|
public boolean specificExecute(ExecutionEvent event) {
|
32
|
ISelection selection = HandlerUtil.getActivePart(event).getSite().getSelectionProvider().getSelection();
|
33
|
if(selection instanceof IStructuredSelection){
|
34
|
Object[] selectedObjects = ((IStructuredSelection) selection).toArray();
|
35
|
|
36
|
if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you want to delete the selected datasources?")){
|
37
|
return false;
|
38
|
}
|
39
|
// Delete from persistent data sources
|
40
|
for(Object object : selectedObjects){
|
41
|
CdmPersistentDataSource dataSource = (CdmPersistentDataSource) ((CdmMetaDataAwareDataSourceContainer) object).getCdmSource();
|
42
|
CdmDataSourceRepository.delete(dataSource);
|
43
|
}
|
44
|
|
45
|
return true;
|
46
|
}
|
47
|
return false;
|
48
|
}
|
49
|
}
|