3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.view
.datasource
.handler
;
13 import org
.eclipse
.core
.commands
.ExecutionEvent
;
14 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
15 import org
.eclipse
.jface
.viewers
.ISelection
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
19 import eu
.etaxonomy
.cdm
.database
.CdmPersistentDataSource
;
20 import eu
.etaxonomy
.taxeditor
.datasource
.CdmDataSourceRepository
;
21 import eu
.etaxonomy
.taxeditor
.view
.datasource
.CdmMetaDataAwareDataSourceContainer
;
24 * <p>DeleteDataSourceHandler class.</p>
30 public class DeleteDataSourceHandler
extends AbstractDataSourceHandler
{
33 * @see eu.etaxonomy.taxeditor.store.datasource.handler.AbstractDataSourceHandler#specificExecute(org.eclipse.core.commands.ExecutionEvent)
37 public boolean specificExecute(ExecutionEvent event
) {
38 ISelection selection
= HandlerUtil
.getActivePart(event
).getSite().getSelectionProvider().getSelection();
39 if(selection
instanceof IStructuredSelection
){
40 Object
[] selectedObjects
= ((IStructuredSelection
) selection
).toArray();
42 if(! MessageDialog
.openConfirm(HandlerUtil
.getActiveShell(event
), "Confirm Deletion", "Do you want to delete the selected datasources?")){
45 // Delete from persistent data sources
46 for(Object object
: selectedObjects
){
47 CdmPersistentDataSource dataSource
= (CdmPersistentDataSource
) ((CdmMetaDataAwareDataSourceContainer
) object
).getCdmSource();
48 CdmDataSourceRepository
.delete(dataSource
);