diff options
author | Nick Sandonato | 2013-01-09 21:24:47 +0000 |
---|---|---|
committer | Nick Sandonato | 2013-01-09 21:24:47 +0000 |
commit | 9b0b713f4b6743492af90e6ce4cd6a540b91d379 (patch) | |
tree | 2eabbff5fd9c7c10aa4fce3f51aafd6a98a8b07b | |
parent | d8775a8cec40f030740608b96be1e876a91b3c12 (diff) | |
download | webtools.sourceediting-9b0b713f4b6743492af90e6ce4cd6a540b91d379.tar.gz webtools.sourceediting-9b0b713f4b6743492af90e6ce4cd6a540b91d379.tar.xz webtools.sourceediting-9b0b713f4b6743492af90e6ce4cd6a540b91d379.zip |
[365620] Content Model View gets NPE's if an element doesn't exist in the schemav201301092124
3 files changed, 20 insertions, 9 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java index a9e6b5fb7d..2f93c7254c 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2005, 2012 IBM Corporation and others. All rights reserved. This + * Copyright (c) 2005, 2013 IBM Corporation 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 http://www.eclipse.org/legal/epl-v10.html @@ -252,6 +252,7 @@ public class XMLUIMessages extends NLS { public static String Suggestion_Strategy_Strict; public static String Element____1; public static String Content_Model____2; + public static String ContentModel_ElementNotDescribed; public static String Attribute____3; public static String Data_Type____4; public static String Enumerated_Values____5; diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties index dc8c8ed0cc..b14da0c496 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2001, 2012 IBM Corporation and others. +# Copyright (c) 2001, 2013 IBM Corporation 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 @@ -284,6 +284,7 @@ Suggestion_Strategy_Strict=Strict ## tag info Element____1=Element : Content_Model____2=Content Model : +ContentModel_ElementNotDescribed=The content model does not describe the selected element. Attribute____3=Attribute : Data_Type____4=Data Type : Enumerated_Values____5=Enumerated Values : diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/CMListWorkbenchAdapter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/CMListWorkbenchAdapter.java index 08d4fd27b0..ac76d8769d 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/CMListWorkbenchAdapter.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/CMListWorkbenchAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 IBM Corporation and others. + * Copyright (c) 2010, 2013 IBM Corporation 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 @@ -24,6 +24,7 @@ import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup; import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap; import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; import org.eclipse.wst.xml.core.internal.contentmodel.util.CMVisitor; +import org.eclipse.wst.xml.ui.internal.XMLUIMessages; import org.eclipse.wst.xml.ui.internal.XMLUIPlugin; import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages; @@ -35,18 +36,26 @@ public class CMListWorkbenchAdapter extends CMVisitor implements IWorkbenchAdapt private GroupStack fGroupStack; private CMDescriber fRoot; + private static final Object[] EMPTY = new Object[0]; + public CMListWorkbenchAdapter(CMElementDeclaration decl) { - text = getFormattedLabel(decl.getNodeName(), decl.getMinOccur(), decl.getMaxOccur(), decl.getDataType()); - fDeclaration = decl; - image = AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, XMLEditorPluginImages.IMG_OBJ_ELEMENT); + if (decl != null) { + text = getFormattedLabel(decl.getNodeName(), decl.getMinOccur(), decl.getMaxOccur(), decl.getDataType()); + fDeclaration = decl; + image = AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, XMLEditorPluginImages.IMG_OBJ_ELEMENT); - fGroupStack = new GroupStack(); - fRoot = new CMDescriber(decl); + fGroupStack = new GroupStack(); + fRoot = new CMDescriber(decl); + } + else { + text = XMLUIMessages.ContentModel_ElementNotDescribed; + image = AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, XMLEditorPluginImages.IMG_OBJ_WARNING_OBJ); + } } public Object[] getChildren(Object o) { /* TODO Use the CMElementDeclaration and ModelQuery to get the available children of the root element */ - return fRoot.getChildren(o); + return fRoot != null ? fRoot.getChildren(o) : EMPTY; } public ImageDescriptor getImageDescriptor(Object object) { |