Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDejan Gloszic2006-02-09 16:12:14 -0500
committerDejan Gloszic2006-02-09 16:12:14 -0500
commit834e3d487a039eabb087a1e601194b6a4c0f2ed4 (patch)
tree0b1982327205f215dc83f6e22a10b5b928d8e424
parentd6e3d9d22d4cedb6b53ce705f46d41ea5576d466 (diff)
downloadeclipse.platform.ua-834e3d487a039eabb087a1e601194b6a4c0f2ed4.tar.gz
eclipse.platform.ua-834e3d487a039eabb087a1e601194b6a4c0f2ed4.tar.xz
eclipse.platform.ua-834e3d487a039eabb087a1e601194b6a4c0f2ed4.zip
Bug 126267 Insert-at-anchor should insert elements, not just files.
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentMergeProcessor.java20
-rw-r--r--org.eclipse.help/src/org/eclipse/help/internal/xhtml/UATopicExtension.java77
-rw-r--r--org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor.xhtml34
-rw-r--r--org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2.xhtml26
-rw-r--r--org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2_serialized.txt22
-rw-r--r--org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor_serialized.txt39
-rw-r--r--org.eclipse.ua.tests/data/intro/dynamicXHTML/ext.xml2
-rw-r--r--org.eclipse.ua.tests/data/intro/dynamicXHTML/ext2.xml8
-rw-r--r--org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent.xml1
-rw-r--r--org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent_serialized.txt24
-rw-r--r--org.eclipse.ua.tests/plugin.xml8
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroExtensionContent.java84
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java15
13 files changed, 253 insertions, 107 deletions
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentMergeProcessor.java b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentMergeProcessor.java
index d3aff6120..786531559 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentMergeProcessor.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UAContentMergeProcessor.java
@@ -199,13 +199,9 @@ public class UAContentMergeProcessor {
else
return false;
}
- Document topicExtensionDom = topicExtension.getDocument();
- if (topicExtensionDom == null)
- return false;
- Element extensionBody = DOMUtil.getBodyElement(topicExtensionDom);
- Element[] children = DOMUtil.getElementsByTagName(extensionBody, "*"); //$NON-NLS-1$
- for (int i = 0; i < children.length; i++) {
- Node targetNode = document.importNode(children[i], true);
+ Element[] elements = topicExtension.getElements();
+ for (int i = 0; i < elements.length; i++) {
+ Node targetNode = document.importNode(elements[i], true);
anchorElement.getParentNode().insertBefore(targetNode, anchorElement);
}
return true;
@@ -265,13 +261,9 @@ public class UAContentMergeProcessor {
else
return false;
}
- Document topicExtensionDom = topicReplace.getDocument();
- if (topicExtensionDom == null)
- return false;
- Element extensionBody = DOMUtil.getBodyElement(topicExtensionDom);
- Element[] children = DOMUtil.getElementsByTagName(extensionBody, "*"); //$NON-NLS-1$
- for (int i = 0; i < children.length; i++) {
- Node targetNode = document.importNode(children[i], true);
+ Element[] elements = topicReplace.getElements();
+ for (int i = 0; i < elements.length; i++) {
+ Node targetNode = document.importNode(elements[i], true);
replaceElement.getParentNode().insertBefore(targetNode, replaceElement);
}
replaceElement.getParentNode().removeChild(replaceElement);
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UATopicExtension.java b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UATopicExtension.java
index b92b8816b..32e6b9b60 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UATopicExtension.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/xhtml/UATopicExtension.java
@@ -9,6 +9,9 @@
package org.eclipse.help.internal.xhtml;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.osgi.framework.Bundle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -20,45 +23,85 @@ public class UATopicExtension extends AbstractUAElement {
protected static final String ATT_PATH = "path"; //$NON-NLS-1$
private static final String ATT_CONTENT = "content"; //$NON-NLS-1$
+
+ private static final Element[] EMPTY_ELEMENT_ARRAY = new Element[0];
private String path;
- private String content;
+ private String contentFile;
+ private String contentId;
private Element element;
UATopicExtension(Element element, Bundle bundle) {
super(element, bundle);
path = getAttribute(element, ATT_PATH);
- content = getAttribute(element, ATT_CONTENT);
- content = BundleUtil.getResolvedResourceLocation(content, bundle, false);
+ extractFileAndId(getAttribute(element, ATT_CONTENT), bundle);
+ contentFile = BundleUtil.getResolvedResourceLocation(contentFile, bundle, false);
this.element = element;
}
/**
- * @return Returns the content.
- */
- public String getContent() {
- return content;
- }
-
- /**
* @return Returns the path.
*/
public String getPath() {
return path;
}
-
- public Document getDocument() {
-
- UAContentParser parser = new UAContentParser(content);
+ /**
+ * Returns the elements loaded from the content attribute. This is the content
+ * that should be inserted for the extension. If it is a file, all child elements
+ * of body are returned. If it is a file with an id, only the element with the id
+ * is returned.
+ *
+ * @return the elements to be inserted
+ */
+ public Element[] getElements() {
+ UAContentParser parser = new UAContentParser(contentFile);
Document dom = parser.getDocument();
- return dom;
+ if (dom != null) {
+ if (contentId != null) {
+ // id specified, only get that element
+ return new Element[] { dom.getElementById(contentId) };
+ }
+ else {
+ // no id specified, use the whole body
+ Element extensionBody = DOMUtil.getBodyElement(dom);
+ return DOMUtil.getElementsByTagName(extensionBody, "*"); //$NON-NLS-1$
+ }
+ }
+ return EMPTY_ELEMENT_ARRAY;
}
-
public Element getElement() {
return element;
}
-
+ /**
+ * Extracts the file and id parts of the content attribute. This attribute has two modes -
+ * if you specify a file, it will include the body of that file (minus the body element itself).
+ * If you append an id after the file, only the element with that id will be included. However
+ * we need to know which mode we're in.
+ *
+ * @param content the content attribute value
+ * @param bundle the bundle that contributed this extension
+ */
+ private void extractFileAndId(String content, Bundle bundle) {
+ // look for the file first
+ IPath resourcePath = new Path(content);
+ if (Platform.find(bundle, resourcePath) != null) {
+ // found it, it's a file with no id
+ contentFile = content;
+ }
+ else {
+ // didn't find the file, assume the last segment is an id
+ int lastSlashIndex = content.lastIndexOf('/');
+ if (lastSlashIndex != -1) {
+ contentFile = content.substring(0, lastSlashIndex);
+ contentId = content.substring(lastSlashIndex + 1);
+ }
+ else {
+ // there was no slash, it must be a file
+ contentFile = content;
+ }
+ }
+ }
}
diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor.xhtml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor.xhtml
index a8e3aaf20..036e06b1f 100644
--- a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor.xhtml
+++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor.xhtml
@@ -1,22 +1,32 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<!--
- The anchor test page. This page contains an anchor, and content is contributed into the anchor
- from an intro extension. See ext.xml in the same folder.
--->
-
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>anchor.xhtml</title>
</head>
-
<body>
-<h2>anchor.xhtml</h2>
+
<p>
-This page contains an anchor, where other pages can contribute content to it. In this case there should
-be one contribution from anchor2.xhtml below:
+<strong>The section below should have the entire contents of anchor2.xhtml.</strong>
</p>
-<anchor id="my.anchor.id"/>
+
+<small>[begin anchor 1]</small>
+<hr/>
+<anchor id="anchor.1" />
+<hr/>
+<small>[end anchor 1]</small>
+
+<p>
+<strong>The section below should only have the second paragraph from anchor2.xhtml.</strong>
+</p>
+
+<small>[begin anchor 2]</small>
+<hr/>
+<anchor id="anchor.2" />
+<hr/>
+<small>[end anchor 2]</small>
+
</body>
</html>
+
diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2.xhtml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2.xhtml
index eef8c5e70..6f1a8fd9b 100644
--- a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2.xhtml
+++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2.xhtml
@@ -1,19 +1,21 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<!--
- This page contains content that is contributed into an anchor in anchor.xhtml. This file is
- referenced by ext.xhtml. When viewed you don't see this page, only the line that is contributed.
--->
-
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>anchor.xhtml</title>
+<title>anchor2.xhtml</title>
</head>
-
<body>
-<ul>
-<li>This text comes from anchor2.xhtml and is contributed into an anchor in anchor.xhtml.</li>
-</ul>
+
+<p id="paragraph.1">
+This is the first paragraph in anchor2.xhtml.
+</p>
+<p id="paragraph.2">
+This is the second paragraph in anchor2.xhtml.
+</p>
+<p id="paragraph.3">
+This is the third paragraph in anchor2.xhtml.
+</p>
+
</body>
</html>
diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2_serialized.txt
index 251808bed..5349ea707 100644
--- a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2_serialized.txt
+++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor2_serialized.txt
@@ -1,16 +1,20 @@
-<!--
- This page contains content that is contributed into an anchor in anchor.xhtml. This file is
- referenced by ext.xhtml. When viewed you don't see this page, only the line that is contributed.
---><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
-<title>anchor.xhtml</title>
+<title>anchor2.xhtml</title>
</head>
-
<body>
-<ul>
-<li>This text comes from anchor2.xhtml and is contributed into an anchor in anchor.xhtml.</li>
-</ul>
+
+<p id="paragraph.1">
+This is the first paragraph in anchor2.xhtml.
+</p>
+<p id="paragraph.2">
+This is the second paragraph in anchor2.xhtml.
+</p>
+<p id="paragraph.3">
+This is the third paragraph in anchor2.xhtml.
+</p>
+
</body>
</html>
diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor_serialized.txt
index 9540a2f68..71ce94d9e 100644
--- a/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor_serialized.txt
+++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/content/anchor_serialized.txt
@@ -1,21 +1,38 @@
-<!--
- The anchor test page. This page contains an anchor, and content is contributed into the anchor
- from an intro extension. See ext.xml in the same folder.
---><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>anchor.xhtml</title>
</head>
-
<body>
-<h2>anchor.xhtml</h2>
+
+<p>
+<strong>The section below should have the entire contents of anchor2.xhtml.</strong>
+</p>
+
+<small>[begin anchor 1]</small>
+<hr />
+<p id="paragraph.1">
+This is the first paragraph in anchor2.xhtml.
+</p><p id="paragraph.2">
+This is the second paragraph in anchor2.xhtml.
+</p><p id="paragraph.3">
+This is the third paragraph in anchor2.xhtml.
+</p>
+<hr />
+<small>[end anchor 1]</small>
+
<p>
-This page contains an anchor, where other pages can contribute content to it. In this case there should
-be one contribution from anchor2.xhtml below:
+<strong>The section below should only have the second paragraph from anchor2.xhtml.</strong>
</p>
-<ul>
-<li>This text comes from anchor2.xhtml and is contributed into an anchor in anchor.xhtml.</li>
-</ul>
+
+<small>[begin anchor 2]</small>
+<hr />
+<p id="paragraph.2">
+This is the second paragraph in anchor2.xhtml.
+</p>
+<hr />
+<small>[end anchor 2]</small>
+
</body>
</html>
diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext.xml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext.xml
index 8d6215016..d78f088d6 100644
--- a/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext.xml
+++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext.xml
@@ -3,6 +3,6 @@
An extension to introContent.xml with an additional page and a contribution to an anchor.
-->
<introContent>
- <extensionContent content="content/anchor2.xhtml" path="anchor/my.anchor.id" />
+ <extensionContent content="content/anchor2.xhtml" path="anchor/anchor.1" />
<page id="anchor2" content="content/anchor2.xhtml"/>
</introContent>
diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext2.xml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext2.xml
new file mode 100644
index 000000000..e3503a017
--- /dev/null
+++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/ext2.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ An extension to introContent.xml with an additional page and a contribution to an anchor.
+-->
+<introContent>
+ <extensionContent content="content/anchor2.xhtml/paragraph.2" path="anchor/anchor.2" />
+ <page id="anchor2" content="content/anchor2.xhtml"/>
+</introContent>
diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent.xml b/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent.xml
index 7f9845dc1..2173492cb 100644
--- a/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent.xml
+++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent.xml
@@ -10,4 +10,5 @@
<page id="include" content="content/include.xhtml"/>
<page id="include2" content="content/include2.xhtml"/>
<page id="anchor" content="content/anchor.xhtml"/>
+ <page id="anchor2" content="content/anchor2.xhtml"/>
</introContent>
diff --git a/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent_serialized.txt b/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent_serialized.txt
index 3d4d8af5b..11cac79bf 100644
--- a/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent_serialized.txt
+++ b/org.eclipse.ua.tests/data/intro/dynamicXHTML/introContent_serialized.txt
@@ -5,7 +5,7 @@ Intro Model Content:
Model has valid config = true
Presentation type = 2
Home page id = root
-Number of pages (not including Root Page) = 6
+Number of pages (not including Root Page) = 8
Number of shared groups = 0
Number of unresolved extensions = 0
@@ -89,6 +89,28 @@ PAGE id = anchor2
page children = 0
+PAGE id = anchor2
+----------
+ title = null
+ style = null
+ alt-style = null
+ style-id = null
+ page styles are =
+ page alt-styles are =
+ page children = 0
+
+
+PAGE id = anchor2
+----------
+ title = null
+ style = null
+ alt-style = null
+ style-id = null
+ page styles are =
+ page alt-styles are =
+ page children = 0
+
+
Model Flag Tests:
----------------
First page children are:
diff --git a/org.eclipse.ua.tests/plugin.xml b/org.eclipse.ua.tests/plugin.xml
index af0ac2ab7..7245e8b16 100644
--- a/org.eclipse.ua.tests/plugin.xml
+++ b/org.eclipse.ua.tests/plugin.xml
@@ -169,10 +169,6 @@
class="org.eclipse.ui.intro.config.CustomizableIntroPart"
id="org.eclipse.ua.tests.intro.dynamicXML">
</intro>
- <introProductBinding
- introId="org.eclipse.ua.tests.intro.dynamicXML"
- productId="org.eclipse.sdk.ide">
- </introProductBinding>
</extension>
<extension
point="org.eclipse.ui.intro.config">
@@ -212,6 +208,10 @@
configId="org.eclipse.ua.tests.intro.config.dynamicXHTML">
</configExtension>
<configExtension
+ content="data/intro/dynamicXHTML/ext2.xml"
+ configId="org.eclipse.ua.tests.intro.config.dynamicXHTML">
+ </configExtension>
+ <configExtension
content="data/intro/dynamicXML/ext.xml"
configId="org.eclipse.ua.tests.intro.config.dynamicXML">
</configExtension>
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroExtensionContent.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroExtensionContent.java
index 727ecce09..e3eec7387 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroExtensionContent.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroExtensionContent.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 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
@@ -16,6 +16,8 @@ import java.util.Vector;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.help.internal.xhtml.DOMUtil;
import org.eclipse.ui.internal.intro.impl.model.loader.IntroContentParser;
import org.eclipse.ui.internal.intro.impl.model.util.BundleUtil;
import org.eclipse.ui.internal.intro.impl.model.util.ModelUtil;
@@ -43,9 +45,13 @@ public class IntroExtensionContent extends AbstractIntroElement {
private static final String ATT_ALT_STYLE = "alt-style"; //$NON-NLS-1$
private static final String ATT_CONTENT = "content"; //$NON-NLS-1$
+ private static final Element[] EMPTY_ELEMENT_ARRAY = new Element[0];
+
private String path;
private String content;
- private String id;
+ private String contentFile;
+ private String contentId;
+ private String anchorId;
private Element element;
private String base;
@@ -57,7 +63,7 @@ public class IntroExtensionContent extends AbstractIntroElement {
super(element, bundle);
path = getAttribute(element, ATT_PATH);
content = getAttribute(element, ATT_CONTENT);
- id = getAttribute(element, ATT_ID);
+ anchorId = getAttribute(element, ATT_ID);
this.element = element;
this.base = base;
@@ -71,7 +77,8 @@ public class IntroExtensionContent extends AbstractIntroElement {
// the new xml file location.
IPath subBase = ModelUtil.getParentFolderPath(content);
String newBase = new Path(base).append(subBase).toString();
- content = BundleUtil.getResolvedResourceLocation(base, content,
+ extractFileAndId(bundle);
+ contentFile = BundleUtil.getResolvedResourceLocation(base, contentFile,
bundle);
this.base = newBase;
}
@@ -79,7 +86,7 @@ public class IntroExtensionContent extends AbstractIntroElement {
}
public String getId() {
- return id;
+ return anchorId;
}
@@ -175,20 +182,36 @@ public class IntroExtensionContent extends AbstractIntroElement {
return content != null ? true : false;
}
- public Document getDocument() {
+ /**
+ * Returns the elements loaded from the content attribute. This is the content
+ * that should be inserted for the extension. If it is a file, all child elements
+ * of body are returned. If it is a file with an id, only the element with the id
+ * is returned.
+ *
+ * @return the elements to be inserted
+ */
+ public Element[] getElements() {
+ // only applicable when content attribute is specified
if (isXHTMLContent()) {
- IntroContentParser parser = new IntroContentParser(content);
+ IntroContentParser parser = new IntroContentParser(contentFile);
Document dom = parser.getDocument();
- if (dom == null)
- // bad xml. Parser would have logged fact.
- return null;
- // parser content should be XHTML because defining content here
- // means that we want XHTML extension.
- if (parser.hasXHTMLContent())
- return dom;
-
+ if (dom != null) {
+ // parser content should be XHTML because defining content here
+ // means that we want XHTML extension.
+ if (parser.hasXHTMLContent()) {
+ if (contentId != null) {
+ // id specified, only get that element
+ return new Element[] { dom.getElementById(contentId) };
+ }
+ else {
+ // no id specified, use the whole body
+ Element extensionBody = DOMUtil.getBodyElement(dom);
+ return DOMUtil.getElementsByTagName(extensionBody, "*"); //$NON-NLS-1$
+ }
+ }
+ }
}
- return null;
+ return EMPTY_ELEMENT_ARRAY;
}
/**
@@ -217,4 +240,33 @@ public class IntroExtensionContent extends AbstractIntroElement {
public String getBase() {
return base;
}
+
+ /**
+ * Extracts the file and id parts of the content attribute. This attribute has two modes -
+ * if you specify a file, it will include the body of that file (minus the body element itself).
+ * If you append an id after the file, only the element with that id will be included. However
+ * we need to know which mode we're in.
+ *
+ * @param bundle the bundle that contributed this extension
+ */
+ private void extractFileAndId(Bundle bundle) {
+ // look for the file
+ IPath resourcePath = new Path(base + content);
+ if (Platform.find(bundle, resourcePath) != null) {
+ // found it, assume it's a file
+ contentFile = content;
+ }
+ else {
+ // didn't find the file, assume the last segment is an id
+ int lastSlashIndex = content.lastIndexOf('/');
+ if (lastSlashIndex != -1) {
+ contentFile = content.substring(0, lastSlashIndex);
+ contentId = content.substring(lastSlashIndex + 1);
+ }
+ else {
+ // there was no slash, it must be a file
+ contentFile = content;
+ }
+ }
+ }
}
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
index 7ba34ff6c..2794d48a0 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2006 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
@@ -480,16 +480,11 @@ public class IntroModelRoot extends AbstractIntroContainer {
if (targetAnchor == null)
return false;
- // get extension content node.
- Document extensionDom = extensionContent.getDocument();
- if (extensionDom == null)
- return false;
-
- Element extensionBody = ModelUtil.getBodyElement(extensionDom);
- Element[] children = ModelUtil.getElementsByTagName(extensionBody, "*"); //$NON-NLS-1$
+ // get extension content
+ Element[] elements = extensionContent.getElements();
// insert all children before anchor in page body.
- for (int i = 0; i < children.length; i++) {
- Node targetNode = pageDom.importNode(children[i], true);
+ for (int i = 0; i < elements.length; i++) {
+ Node targetNode = pageDom.importNode(elements[i], true);
// update the src attribute of this node, if defined by w3
// specs.

Back to the top