Bug 333685: NPE thrown when selecting 'Edit Namespace Prefixes' from the 'XPath' view's view menu with no editors open
diff --git a/bundles/org.eclipse.wst.xml.xpath.ui/plugin.xml b/bundles/org.eclipse.wst.xml.xpath.ui/plugin.xml index f8052f5..d95897e 100644 --- a/bundles/org.eclipse.wst.xml.xpath.ui/plugin.xml +++ b/bundles/org.eclipse.wst.xml.xpath.ui/plugin.xml
@@ -103,6 +103,15 @@ <equals value="org.eclipse.wst.xml.views.XPathView"/> </with> </activeWhen> + <enabledWhen> + <with variable="activeEditorId"> + <or> + <equals value="org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart"/> + <equals value="org.eclipse.wst.xsl.ui.XSLEditor"/> + <equals value="org.eclipse.wst.xsd.ui.internal.editor.InternalXSDMultiPageEditor"/> + </or> + </with> + </enabledWhen> </handler> </extension>
diff --git a/bundles/org.eclipse.wst.xml.xpath.ui/src/org/eclipse/wst/xml/xpath/ui/internal/handler/PrefixHandler.java b/bundles/org.eclipse.wst.xml.xpath.ui/src/org/eclipse/wst/xml/xpath/ui/internal/handler/PrefixHandler.java index 4aa9e9f..8bc1d6b 100644 --- a/bundles/org.eclipse.wst.xml.xpath.ui/src/org/eclipse/wst/xml/xpath/ui/internal/handler/PrefixHandler.java +++ b/bundles/org.eclipse.wst.xml.xpath.ui/src/org/eclipse/wst/xml/xpath/ui/internal/handler/PrefixHandler.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Standards for Technology in Automotive Retail and others. + * Copyright (c) 2009-11 Standards for Technology in Automotive Retail and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * David Carver - initial API + * Jesper Steen Møller - Bug 333685 - NPE thrown when no XML editor selected *******************************************************************************/ package org.eclipse.wst.xml.xpath.ui.internal.handler; @@ -48,6 +49,9 @@ XPathUIPlugin plugin = XPathUIPlugin.getDefault(); IEditorPart activeEditor = HandlerUtil.getActiveEditor(event); + + // suppress an NPE in the log (shouldn't happen with the enabledWhen rule) + if (activeEditor == null) return null; IFile file = (IFile) activeEditor.getEditorInput().getAdapter( IFile.class); IModelManager modelManager = StructuredModelManager.getModelManager();