1
|
package eu.etaxonomy.taxeditor.editor.handler;
|
2
|
|
3
|
import org.eclipse.core.commands.AbstractHandler;
|
4
|
import org.eclipse.core.commands.ExecutionEvent;
|
5
|
import org.eclipse.core.commands.ExecutionException;
|
6
|
import org.eclipse.jface.viewers.ISelection;
|
7
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
8
|
import org.eclipse.ui.PartInitException;
|
9
|
import org.eclipse.ui.handlers.HandlerUtil;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.common.ICdmBase;
|
12
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
13
|
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
|
14
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
15
|
|
16
|
public class OpenDerivateViewHandler extends AbstractHandler {
|
17
|
|
18
|
/* (non-Javadoc)
|
19
|
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
20
|
*/
|
21
|
@Override
|
22
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
23
|
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
|
24
|
if(currentSelection instanceof IStructuredSelection){
|
25
|
Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
|
26
|
if(selectedElement instanceof ICdmBase){
|
27
|
DerivateViewEditorInput input = new DerivateViewEditorInput(((ICdmBase) selectedElement).getUuid());
|
28
|
try {
|
29
|
EditorUtil.open(input);
|
30
|
} catch (PartInitException e) {
|
31
|
AbstractUtility.error(OpenDerivateViewHandler.class, "Could not open DerivateView", e);
|
32
|
}
|
33
|
}
|
34
|
}
|
35
|
return null;
|
36
|
|
37
|
}
|
38
|
|
39
|
}
|