1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 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
|
package eu.etaxonomy.taxeditor.editor;
|
11
|
|
12
|
import java.util.HashMap;
|
13
|
import java.util.Map;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.eclipse.ui.PartInitException;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
19
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
20
|
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
|
21
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
22
|
import eu.etaxonomy.taxeditor.view.ICdmViewer;
|
23
|
|
24
|
/**
|
25
|
* @author pplitzner
|
26
|
* @date Feb 23, 2015
|
27
|
*
|
28
|
*/
|
29
|
public class EditorCdmViewer implements ICdmViewer {
|
30
|
|
31
|
private final Logger logger = Logger.getLogger(EditorCdmViewer.class);
|
32
|
|
33
|
@Override
|
34
|
public void show(Object input, Class<?> viewerClass) {
|
35
|
try {
|
36
|
if(viewerClass.equals(MultiPageTaxonEditor.class)){
|
37
|
if(input instanceof TaxonBase){
|
38
|
TaxonEditorInput editorInput = TaxonEditorInput.NewInstanceFromTaxonBase(((TaxonBase<?>) input).getUuid());
|
39
|
EditorUtil.open(editorInput);
|
40
|
}
|
41
|
}
|
42
|
else if(viewerClass.equals(DerivateView.class)){
|
43
|
if(input instanceof SpecimenOrObservationBase){
|
44
|
}
|
45
|
}
|
46
|
} catch (PartInitException e) {
|
47
|
String errorMessage = "Could not open editor";
|
48
|
logger.error(errorMessage, e);
|
49
|
MessagingUtils.error(EditorCdmViewer.class, errorMessage, e);
|
50
|
}
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
public Map<Class<?>, String> getViewerClasses(Object input) {
|
55
|
Map<Class<?>, String> viewerNameMap = new HashMap<Class<?>, String>();
|
56
|
if(input instanceof TaxonBase){
|
57
|
viewerNameMap.put(MultiPageTaxonEditor.class, "Taxon Editor");
|
58
|
}
|
59
|
return viewerNameMap;
|
60
|
}
|
61
|
|
62
|
}
|