Removed all calls to active menu selection (fixes #1106)
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / datasource / handler / AbstractDataSourceHandler.java
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.view.datasource.handler;
12
13 import org.eclipse.core.commands.AbstractHandler;
14 import org.eclipse.core.commands.ExecutionEvent;
15 import org.eclipse.core.commands.ExecutionException;
16 import org.eclipse.jface.viewers.ISelection;
17 import org.eclipse.jface.viewers.StructuredSelection;
18 import org.eclipse.ui.handlers.HandlerUtil;
19
20 import eu.etaxonomy.taxeditor.store.StoreUtil;
21 import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
22 import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer;
23
24 /**
25 * @author n.hoffmann
26 * @created 19.05.2009
27 * @version 1.0
28 */
29 abstract class AbstractDataSourceHandler extends AbstractHandler {
30
31 /* (non-Javadoc)
32 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
33 */
34 /** {@inheritDoc} */
35 public Object execute(ExecutionEvent event) throws ExecutionException {
36
37 boolean refresh = specificExecute(event);
38
39 CdmDataSourceViewPart view = (CdmDataSourceViewPart) StoreUtil.showView(CdmDataSourceViewPart.ID);
40 if(refresh) view.refresh();
41
42 return null;
43 }
44
45 /**
46 * <p>getSelectedDataSourceContainer</p>
47 *
48 * @param event a {@link org.eclipse.core.commands.ExecutionEvent} object.
49 * @return a {@link eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer} object.
50 */
51 protected CdmMetaDataAwareDataSourceContainer getSelectedDataSourceContainer(ExecutionEvent event){
52 ISelection menuSelection = HandlerUtil.getCurrentSelection(event);
53 CdmMetaDataAwareDataSourceContainer container = (CdmMetaDataAwareDataSourceContainer) ((StructuredSelection) menuSelection).getFirstElement();
54 return container;
55 }
56
57 /**
58 * <p>specificExecute</p>
59 *
60 * @param event a {@link org.eclipse.core.commands.ExecutionEvent} object.
61 * @return a boolean.
62 */
63 public abstract boolean specificExecute(ExecutionEvent event);
64 }