From 23a531ea63909c1b455316e4152be49978ba2b36 Mon Sep 17 00:00:00 2001 From: Patrick Plitzner Date: Tue, 21 Jul 2015 08:55:52 +0200 Subject: [PATCH] Add missing null check --- .../taxeditor/view/CdmViewerUtil.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java index 8fc2e73e3..88552f12f 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java @@ -59,22 +59,23 @@ public class CdmViewerUtil { public static Map getAvailableViewers(Object input){ Map commandViewerNameMap = new HashMap(); - 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 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 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); } } } -- 2.34.1