2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.view
.datasource
.handler
;
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
;
18 import eu
.etaxonomy
.cdm
.database
.CdmPersistentDataSource
;
19 import eu
.etaxonomy
.taxeditor
.datasource
.CdmDataSourceRepository
;
20 import eu
.etaxonomy
.taxeditor
.view
.datasource
.CdmMetaDataAwareDataSourceContainer
;
27 public class DeleteDataSourceHandler
extends AbstractDataSourceHandler
{
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();
36 if(! MessageDialog
.openConfirm(HandlerUtil
.getActiveShell(event
), "Confirm Deletion", "Do you want to delete the selected datasources?")){
39 // Delete from persistent data sources
40 for(Object object
: selectedObjects
){
41 CdmPersistentDataSource dataSource
= (CdmPersistentDataSource
) ((CdmMetaDataAwareDataSourceContainer
) object
).getCdmSource();
42 CdmDataSourceRepository
.delete(dataSource
);