1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.view.datasource.handler;
|
11
|
|
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;
|
18
|
|
19
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
20
|
import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
|
21
|
import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer;
|
22
|
|
23
|
/**
|
24
|
* @author n.hoffmann
|
25
|
* @created 19.05.2009
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
abstract class AbstractDataSourceHandler extends AbstractHandler {
|
29
|
|
30
|
/* (non-Javadoc)
|
31
|
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
32
|
*/
|
33
|
/** {@inheritDoc} */
|
34
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
35
|
|
36
|
boolean refresh = specificExecute(event);
|
37
|
|
38
|
CdmDataSourceViewPart view = (CdmDataSourceViewPart) StoreUtil.showView(CdmDataSourceViewPart.ID);
|
39
|
if(refresh) view.refresh();
|
40
|
|
41
|
return null;
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* <p>getSelectedDataSourceContainer</p>
|
46
|
*
|
47
|
* @param event a {@link org.eclipse.core.commands.ExecutionEvent} object.
|
48
|
* @return a {@link eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer} object.
|
49
|
*/
|
50
|
protected CdmMetaDataAwareDataSourceContainer getSelectedDataSourceContainer(ExecutionEvent event){
|
51
|
ISelection menuSelection = HandlerUtil.getCurrentSelection(event);
|
52
|
CdmMetaDataAwareDataSourceContainer container = (CdmMetaDataAwareDataSourceContainer) ((StructuredSelection) menuSelection).getFirstElement();
|
53
|
return container;
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* <p>specificExecute</p>
|
58
|
*
|
59
|
* @param event a {@link org.eclipse.core.commands.ExecutionEvent} object.
|
60
|
* @return a boolean.
|
61
|
*/
|
62
|
public abstract boolean specificExecute(ExecutionEvent event);
|
63
|
}
|