Add missing null check
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 21 Jul 2015 06:55:52 +0000 (08:55 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 21 Jul 2015 10:38:51 +0000 (12:38 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java

index 8fc2e73e35c41d041efdfb9188fee6101ab32a89..88552f12f0310ef70e47948aa38a5608012bb516 100644 (file)
@@ -59,22 +59,23 @@ public class CdmViewerUtil {
     public static  Map<String, String> getAvailableViewers(Object input){
         Map<String, String> commandViewerNameMap = new HashMap<String, String>();
 
-        IExtensionRegistry reg = Platform.getExtensionRegistry();
-        IConfigurationElement[] extensions = reg
-                .getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer");
-        for (IConfigurationElement configElement : extensions) {
-            if(configElement.getName().equals("viewCommandMapping")){
-                String commandId = configElement.getAttribute("commandId");
-                String viewerName = configElement.getAttribute("viewerName");
-                try {
-                    Object selectionObject = configElement.createExecutableExtension("selection");
-                    System.out.println(selectionObject);
-                    Class<? extends Object> selectionClass = selectionObject.getClass();
-                    if(input.getClass().isAssignableFrom(selectionClass)){
-                        commandViewerNameMap.put(commandId, viewerName);
+        if(input!=null){
+            IExtensionRegistry reg = Platform.getExtensionRegistry();
+            IConfigurationElement[] extensions = reg
+                    .getConfigurationElementsFor("eu.etaxonomy.taxeditor.store.cdmViewer");
+            for (IConfigurationElement configElement : extensions) {
+                if(configElement.getName().equals("viewCommandMapping")){
+                    String commandId = configElement.getAttribute("commandId");
+                    String viewerName = configElement.getAttribute("viewerName");
+                    try {
+                        Object selectionObject = configElement.createExecutableExtension("selection");
+                        Class<? extends Object> selectionClass = selectionObject.getClass();
+                        if(input.getClass().isAssignableFrom(selectionClass)){
+                            commandViewerNameMap.put(commandId, viewerName);
+                        }
+                    } catch (CoreException e) {
+                        MessagingUtils.error(CdmViewerChooser.class, "Could not initalize selection class element of cdmViewer extension", e);
                     }
-                } catch (CoreException e) {
-                    MessagingUtils.error(CdmViewerChooser.class, "Could not initalize selection class element of cdmViewer extension", e);
                 }
             }
         }