1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.datasource.handler;
|
12
|
|
13
|
import org.eclipse.core.commands.ExecutionEvent;
|
14
|
import org.eclipse.jface.viewers.ISelection;
|
15
|
import org.eclipse.jface.viewers.StructuredSelection;
|
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.datasource.view.CdmMetaDataAwareDataSourceContainer;
|
21
|
|
22
|
/**
|
23
|
* <p>DeleteDataSourceHandler class.</p>
|
24
|
*
|
25
|
* @author n.hoffmann
|
26
|
* @created 15.04.2009
|
27
|
* @version 1.0
|
28
|
*/
|
29
|
public class DeleteDataSourceHandler extends AbstractDataSourceHandler {
|
30
|
|
31
|
/* (non-Javadoc)
|
32
|
* @see eu.etaxonomy.taxeditor.store.datasource.handler.AbstractDataSourceHandler#specificExecute(org.eclipse.core.commands.ExecutionEvent)
|
33
|
*/
|
34
|
/** {@inheritDoc} */
|
35
|
@Override
|
36
|
public boolean specificExecute(ExecutionEvent event) {
|
37
|
ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event);
|
38
|
Object[] selectedObjects = ((StructuredSelection) menuSelection).toArray();
|
39
|
|
40
|
// Delete from persistent data sources
|
41
|
for(Object object : selectedObjects){
|
42
|
CdmPersistentDataSource dataSource = (CdmPersistentDataSource) ((CdmMetaDataAwareDataSourceContainer) object).getDataSource();
|
43
|
CdmDataSourceRepository.delete(dataSource);
|
44
|
}
|
45
|
|
46
|
return true;
|
47
|
}
|
48
|
}
|