summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Trimble2013-04-19 20:29:04 (EDT)
committerIan Trimble2013-04-19 20:29:04 (EDT)
commit3338e3bd78368de2f08363a2534e108742927dc8 (patch)
tree3f56ae938fcd66b0bfe03b2ffa5a44a3d1eb358f
parent445b6f4c3f59e5e0ea64c50b8dd87f617a693b3f (diff)
downloadwebtools.jsf-3338e3bd78368de2f08363a2534e108742927dc8.zip
webtools.jsf-3338e3bd78368de2f08363a2534e108742927dc8.tar.gz
webtools.jsf-3338e3bd78368de2f08363a2534e108742927dc8.tar.bz2
Bug 392021
Web Page Editor is throwing java.lang.NullPointerException
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/figurehandler/ObjectFigureHandler.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/figurehandler/ObjectFigureHandler.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/figurehandler/ObjectFigureHandler.java
index f3d8a95..5f51f6f 100644
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/figurehandler/ObjectFigureHandler.java
+++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/figurehandler/ObjectFigureHandler.java
@@ -12,7 +12,12 @@
package org.eclipse.jst.pagedesigner.figurehandler;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jst.pagedesigner.editors.palette.TagImageManager;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.w3c.dom.Element;
/**
@@ -28,8 +33,22 @@ import org.w3c.dom.Element;
*/
protected void initializeImage(Element node) {
if (_image == null) {
- //FIXME - file/project should NOT be null!
- _image = TagImageManager.getInstance().getSmallIconImage((IFile)null, "HTML", node.getTagName()); //$NON-NLS-1$
+ if (node instanceof IDOMNode) {
+ final IDOMModel model = ((IDOMNode)node).getModel();
+ if (model != null) {
+ final String location = model.getBaseLocation();
+ if (location != null) {
+ final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ if (workspace != null) {
+ final IResource resource = workspace.getRoot().findMember(location);
+ if (resource.getType() == IResource.FILE) {
+ _image = TagImageManager.getInstance().getSmallIconImage(
+ (IFile)resource, "HTML", node.getTagName()); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
}
}
}