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
.AbstractHandler
;
13 import org
.eclipse
.core
.commands
.ExecutionEvent
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.jface
.viewers
.ISelection
;
16 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
17 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
19 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
20 import eu
.etaxonomy
.taxeditor
.view
.datasource
.CdmDataSourceViewPart
;
21 import eu
.etaxonomy
.taxeditor
.view
.datasource
.CdmMetaDataAwareDataSourceContainer
;
28 abstract class AbstractDataSourceHandler
extends AbstractHandler
{
31 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
34 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
36 boolean refresh
= specificExecute(event
);
38 CdmDataSourceViewPart view
= (CdmDataSourceViewPart
) StoreUtil
.showView(CdmDataSourceViewPart
.ID
);
39 if(refresh
) view
.refresh();
45 * <p>getSelectedDataSourceContainer</p>
47 * @param event a {@link org.eclipse.core.commands.ExecutionEvent} object.
48 * @return a {@link eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer} object.
50 protected CdmMetaDataAwareDataSourceContainer
getSelectedDataSourceContainer(ExecutionEvent event
){
51 ISelection menuSelection
= HandlerUtil
.getCurrentSelection(event
);
52 CdmMetaDataAwareDataSourceContainer container
= (CdmMetaDataAwareDataSourceContainer
) ((StructuredSelection
) menuSelection
).getFirstElement();
57 * <p>specificExecute</p>
59 * @param event a {@link org.eclipse.core.commands.ExecutionEvent} object.
62 public abstract boolean specificExecute(ExecutionEvent event
);