diff options
author | Mazen Faraj | 2005-05-26 12:03:57 +0000 |
---|---|---|
committer | Mazen Faraj | 2005-05-26 12:03:57 +0000 |
commit | 1d2458ea9f1c11553ab3c7d30b646a5d037d5d1b (patch) | |
tree | 221700d071653d27b33320cdb8c6e655ff1fc383 /org.eclipse.ui.intro | |
parent | 44d272892b88d3c435205028cf6ef4d4bd44120a (diff) | |
download | eclipse.platform.ua-1d2458ea9f1c11553ab3c7d30b646a5d037d5d1b.tar.gz eclipse.platform.ua-1d2458ea9f1c11553ab3c7d30b646a5d037d5d1b.tar.xz eclipse.platform.ua-1d2458ea9f1c11553ab3c7d30b646a5d037d5d1b.zip |
Diffstat (limited to 'org.eclipse.ui.intro')
3 files changed, 75 insertions, 5 deletions
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java index a384cbcca..85c24a100 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java @@ -597,10 +597,21 @@ public abstract class AbstractIntroPage extends AbstractIntroContainer { protected void resolvePage() { // insert base meta-tag, ModelUtil.insertBase(dom, ModelUtil.getParentFolderOSString(content)); - // resolve all relative resources relative to content file. + + // resolve all relative resources relative to content file. Do it before + // inserting shared style to enable comparing fully qualified styles. ModelUtil.updateResourceAttributes(dom.getDocumentElement(), this); + + // now add shared style. + String style = IntroPlugin.getDefault().getIntroModelRoot() + .getPresentation().getImplementationStyle(); + if (style != null) { + ModelUtil.insertStyle(dom, style); + } + // and resolve includes. resolveIncludes(); + // now remove all anchors from this page. ModelUtil.removeAllElements(dom, IntroAnchor.TAG_ANCHOR); resolved = true; 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 10e04240a..aa42a55aa 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 @@ -480,6 +480,15 @@ public class IntroModelRoot extends AbstractIntroContainer { extensionContent); targetAnchor.getParentNode().insertBefore(targetNode, targetAnchor); } + + // now handle style inheritance. + // Update the parent page styles. skip style if it is null; + String[] styles = extensionContent.getStyles(); + if (styles != null) { + for(int i =0; i< styles.length; i++) + ModelUtil.insertStyle(pageDom, styles[i]); + } + return true; } @@ -525,10 +534,10 @@ public class IntroModelRoot extends AbstractIntroContainer { /** - * Updates the inherited styles based on the merge-style attribute. If we - * are extending a shared group do nothing. For inherited alt-styles, we - * have to cache the bundle from which we inherited the styles to be able to - * access resources in that plugin. + * Updates the inherited styles based on the style attribtes defined in the + * confgiExtension. If we are extending a shared group do nothing. For + * inherited alt-styles, we have to cache the bundle from which we inherited + * the styles to be able to access resources in that plugin. * * @param include * @param target diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/util/ModelUtil.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/util/ModelUtil.java index aebd9fdb1..695337245 100644 --- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/util/ModelUtil.java +++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/util/ModelUtil.java @@ -43,6 +43,7 @@ public class ModelUtil { private static String TAG_HEAD = "head"; //$NON-NLS-1$ private static String TAG_BASE = "base"; //$NON-NLS-1$ public static String TAG_DIV = "div"; //$NON-NLS-1$ + public static String TAG_HEAD_LINK = "link"; private static String TAG_PARAM = "param"; //$NON-NLS-1$ private static String ATT_SRC = "src"; //$NON-NLS-1$ private static String ATT_HREF = "href"; //$NON-NLS-1$ @@ -52,6 +53,9 @@ public class ModelUtil { private static String ATT_CODEBASE = "codebase"; //$NON-NLS-1$ private static String ATT_VALUE = "value"; //$NON-NLS-1$ private static String ATT_VALUE_TYPE = "valuetype"; //$NON-NLS-1$ + private static String ATT_REL = "rel"; //$NON-NLS-1$ + private static String ATT_TYPE = "type"; //$NON-NLS-1$ + /* @@ -199,6 +203,52 @@ public class ModelUtil { } + public static Element getBase(Document dom) { + // there should only be one head and one base element dom. + NodeList headList = dom.getElementsByTagName(TAG_HEAD); + Element head = (Element) headList.item(0); + NodeList baseList = head.getElementsByTagName(TAG_BASE); + if (baseList.getLength() == 0) + // no base defined, signal failure. + return null; + + return (Element) baseList.item(baseList.getLength() - 1); + + } + + + // <link rel="stylesheet" href="shared.css" type="text/css" /> + public static void insertStyle(Document dom, String cssUrl) { + // there should only be one head and one base element dom. + NodeList headList = dom.getElementsByTagName(TAG_HEAD); + Element head = null; + // Element base = getBase(dom); + NodeList styleList = null; + // there can be more than one style. DO not add style if it exists. + if (headList.getLength() >= 1) { + head = (Element) headList.item(0); + styleList = head.getElementsByTagName(TAG_HEAD_LINK); + for (int i = 0; i < styleList.getLength(); i++) { + Element style = (Element) styleList.item(0); + String styleString = style.getAttribute(ATT_HREF); + if (styleString.equals(cssUrl)) + return; + } + } + + // insert the style, since it is not defined. + Element styleToAdd = dom.createElement(TAG_HEAD_LINK); + styleToAdd.setAttribute(ATT_HREF, cssUrl); + styleToAdd.setAttribute(ATT_REL, "stylesheet"); + styleToAdd.setAttribute(ATT_TYPE, "text/css"); + if (styleList != null && styleList.getLength() >= 1) + styleList.item(0).getParentNode().insertBefore(styleToAdd, + styleList.item(0)); + else + head.appendChild(styleToAdd); + + } + /** * Returns a reference to the body of the DOM. * |