Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.vex.xhtml')
-rw-r--r--org.eclipse.vex.xhtml/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java50
2 files changed, 26 insertions, 29 deletions
diff --git a/org.eclipse.vex.xhtml/META-INF/MANIFEST.MF b/org.eclipse.vex.xhtml/META-INF/MANIFEST.MF
index 6b3b8656..1d2dca37 100644
--- a/org.eclipse.vex.xhtml/META-INF/MANIFEST.MF
+++ b/org.eclipse.vex.xhtml/META-INF/MANIFEST.MF
@@ -6,9 +6,8 @@ Bundle-Version: 1.1.0.qualifier
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.vex.ui;bundle-version="[1.0.0,2.0.0)",
org.eclipse.vex.core;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.jface;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.emf.common;bundle-version="[2.4.1,3.0.0)",
- org.eclipse.emf.ecore;bundle-version="[2.4.1,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.4.0,5.0.0)",
+ org.eclipse.jface;bundle-version="[3.4.0,5.0.0)",
org.eclipse.wst.standard.schemas;bundle-version="[1.0.0,2.0.0)"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
diff --git a/org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java b/org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java
index 5a16d26c..7b5aad1e 100644
--- a/org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java
+++ b/org.eclipse.vex.xhtml/src/org/eclipse/vex/xhtml/XhtmlOutlineProvider.java
@@ -18,8 +18,9 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.vex.core.internal.dom.Document;
-import org.eclipse.vex.core.internal.dom.Element;
+import org.eclipse.vex.core.dom.Filters;
+import org.eclipse.vex.core.dom.IDocument;
+import org.eclipse.vex.core.dom.IElement;
import org.eclipse.vex.ui.internal.editor.VexEditor;
import org.eclipse.vex.ui.internal.outline.IOutlineProvider;
@@ -39,8 +40,8 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
return labelProvider;
}
- public Element getOutlineElement(final Element child) {
- Element element = child;
+ public IElement getOutlineElement(final IElement child) {
+ IElement element = child;
while (element.getParentElement() != null) {
// TODO: compare to all structural element names
@@ -66,11 +67,11 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
}
public Object[] getChildren(final Object parentElement) {
- return getOutlineChildren((Element) parentElement);
+ return getOutlineChildren((IElement) parentElement);
}
public Object getParent(final Object element) {
- final Element parent = ((Element) element).getParentElement();
+ final IElement parent = ((IElement) element).getParentElement();
if (parent == null) {
return element;
} else {
@@ -79,11 +80,11 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
}
public boolean hasChildren(final Object element) {
- return getOutlineChildren((Element) element).length > 0;
+ return getOutlineChildren((IElement) element).length > 0;
}
public Object[] getElements(final Object inputElement) {
- final Document document = (Document) inputElement;
+ final IDocument document = (IDocument) inputElement;
return new Object[] { document.getRootElement() };
}
@@ -96,23 +97,23 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
* @param element
* @return
*/
- private Element[] getOutlineChildren(final Element element) {
- final List children = new ArrayList();
+ private IElement[] getOutlineChildren(final IElement element) {
+ final List<IElement> children = new ArrayList<IElement>();
if (element.getParent() == null) {
- final Element body = findChild(element, "body");
+ final IElement body = findChild(element, "body");
if (body != null) {
- final List<Element> childElements = body.getChildElements();
+ final List<? extends IElement> childElements = body.childElements().asList();
// First, find the lowest numbered h tag available
String lowH = "h6";
- for (final Element child : childElements) {
+ for (final IElement child : childElements) {
if (isHTag(child) && child.getLocalName().compareTo(lowH) < 0) {
lowH = child.getLocalName();
}
}
// Now, get all body children at that level
- for (final Element child : childElements) {
+ for (final IElement child : childElements) {
if (child.getLocalName().equals(lowH)) {
children.add(child);
}
@@ -123,9 +124,8 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
// between this element and the next element at the same level
final int level = Integer.parseInt(element.getLocalName().substring(1));
final String childName = "h" + (level + 1);
- final List<Element> childElements = element.getParentElement().getChildElements();
boolean foundSelf = false;
- for (final Element child : childElements) {
+ for (final IElement child : element.getParentElement().childElements()) {
if (child == element) {
foundSelf = true;
} else if (!foundSelf) {
@@ -138,19 +138,19 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
}
}
}
- return (Element[]) children.toArray(new Element[children.size()]);
+ return children.toArray(new IElement[children.size()]);
}
private final ILabelProvider labelProvider = new LabelProvider() {
@Override
public String getText(final Object o) {
String text;
- final Element element = (Element) o;
+ final IElement element = (IElement) o;
if (element.getParent() == null) {
text = "html";
- final Element head = findChild(element, "head");
+ final IElement head = findChild(element, "head");
if (head != null) {
- final Element title = findChild(head, "title");
+ final IElement title = findChild(head, "title");
if (title != null) {
text = title.getText();
}
@@ -162,16 +162,14 @@ public class XhtmlOutlineProvider implements IOutlineProvider {
}
};
- private Element findChild(final Element parent, final String childName) {
- for (final Element child : parent.getChildElements()) {
- if (child.getLocalName().equals(childName)) {
- return child;
- }
+ private IElement findChild(final IElement parent, final String childName) {
+ for (final IElement child : parent.childElements().matching(Filters.elementsNamed(childName))) {
+ return child;
}
return null;
}
- private boolean isHTag(final Element element) {
+ private boolean isHTag(final IElement element) {
final String name = element.getLocalName();
return name.equals("h1") || name.equals("h2") || name.equals("h3") || name.equals("h4") || name.equals("h5") || name.equals("h6");
}

Back to the top