4d92e047d995a46409f4df9ea2c85a64db9dbd29
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / EditorCdmViewer.java
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.core.commands.ExecutionEvent;
17 import org.eclipse.ui.PartInitException;
18
19 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
20 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
21 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
22 import eu.etaxonomy.taxeditor.model.MessagingUtils;
23 import eu.etaxonomy.taxeditor.view.ICdmViewer;
24
25 /**
26 * @author pplitzner
27 * @date Feb 23, 2015
28 *
29 */
30 public class EditorCdmViewer implements ICdmViewer {
31
32 private final Logger logger = Logger.getLogger(EditorCdmViewer.class);
33
34 /* (non-Javadoc)
35 * @see eu.etaxonomy.taxeditor.view.ICdmViewer#show(java.lang.Object)
36 */
37 @Override
38 public void show(Object input, Class<?> viewerClass, ExecutionEvent event) {
39 try {
40 if(viewerClass.equals(MultiPageTaxonEditor.class)){
41 if(input instanceof TaxonBase){
42 TaxonEditorInput editorInput = TaxonEditorInput.NewInstanceFromTaxonBase(((TaxonBase<?>) input).getUuid());
43 EditorUtil.open(editorInput);
44 }
45 }
46 else if(viewerClass.equals(DerivateView.class)){
47 if(input instanceof SpecimenOrObservationBase){
48 }
49 }
50 } catch (PartInitException e) {
51 String errorMessage = "Could not open editor";
52 logger.error(errorMessage, e);
53 MessagingUtils.error(EditorCdmViewer.class, errorMessage, e);
54 }
55 }
56
57 /* (non-Javadoc)
58 * @see eu.etaxonomy.taxeditor.view.ICdmViewer#getViewerClasses(java.lang.Object)
59 */
60 @Override
61 public Map<Class<?>, String> getViewerClasses(Object input) {
62 Map<Class<?>, String> viewerNameMap = new HashMap<Class<?>, String>();
63 if(input instanceof TaxonBase){
64 viewerNameMap.put(MultiPageTaxonEditor.class, "Taxon Editor");
65 }
66 return viewerNameMap;
67 }
68
69 }