3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.view
;
12 import java
.util
.HashMap
;
14 import java
.util
.Map
.Entry
;
16 import org
.eclipse
.core
.runtime
.CoreException
;
17 import org
.eclipse
.core
.runtime
.IConfigurationElement
;
18 import org
.eclipse
.core
.runtime
.IExtensionRegistry
;
19 import org
.eclipse
.core
.runtime
.IStatus
;
20 import org
.eclipse
.core
.runtime
.Platform
;
21 import org
.eclipse
.core
.runtime
.Status
;
23 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
24 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
31 public class CdmViewerUtil
{
33 public static Map
<Entry
<Class
<?
>, String
>, ICdmViewer
> getNameViewerMap(Object input
){
34 Map
<Entry
<Class
<?
>, String
>, ICdmViewer
> nameViewerMap
= new HashMap
<Entry
<Class
<?
>, String
>, ICdmViewer
>();
36 IExtensionRegistry reg
= Platform
.getExtensionRegistry();
37 IConfigurationElement
[] extensions
= reg
38 .getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer");
39 for (IConfigurationElement configElement
: extensions
) {
41 Object object
= configElement
.createExecutableExtension("class");
42 if(object
instanceof ICdmViewer
){
43 ICdmViewer cdmViewer
= (ICdmViewer
)object
;
44 Map
<Class
<?
>, String
> viewerClasses
= cdmViewer
.getViewerClasses(input
);
45 for (Entry
<Class
<?
>, String
> entry
: viewerClasses
.entrySet()) {
46 nameViewerMap
.put(entry
, cdmViewer
);
50 MessagingUtils
.error(CdmViewerChooser
.class, new Status(IStatus
.ERROR
, TaxeditorStorePlugin
.PLUGIN_ID
, "Could not load cdmViewer extension"));
52 } catch (CoreException e
) {
53 MessagingUtils
.error(CdmViewerChooser
.class, "Could not load cdmViewer extension", e
);