Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.ui.intro/schema/IntroContent.exsd8
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroContainer.java2
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java45
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroHomePage.java77
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java2
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java19
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java5
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageStyleManager.java16
8 files changed, 116 insertions, 58 deletions
diff --git a/org.eclipse.ui.intro/schema/IntroContent.exsd b/org.eclipse.ui.intro/schema/IntroContent.exsd
index eef32c6ed..3ad6607e3 100644
--- a/org.eclipse.ui.intro/schema/IntroContent.exsd
+++ b/org.eclipse.ui.intro/schema/IntroContent.exsd
@@ -87,6 +87,14 @@ A <b>group</b> subelement is used to group of content and apply styl
</restriction>
</simpleType>
</attribute>
+ <attribute name="content" type="string">
+ <annotation>
+ <documentation>
+ an optional attribute which can define the location of an introContent.xml file that represents the content of this page. When defined all attributes in this page element are honored, but all children are ignored. This is because the content of this page is now assumed to reside in the xml files pointed to by the content file. It is also assumed that this new file has only one page deifned, and so when resolving to content of this file, the first page is loaded.
+This seperation out of pages can be used when performance is an issue, as the content of a page is now only loaded when really needed.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroContainer.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroContainer.java
index 401c5212d..964fb33a0 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroContainer.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroContainer.java
@@ -28,7 +28,7 @@ public abstract class AbstractIntroContainer extends AbstractBaseIntroElement {
protected boolean loaded = false;
protected boolean resolved = false;
- private Element element;
+ protected Element element;
/**
* @param element
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 081419d3e..0206b14d4 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
@@ -12,6 +12,8 @@ package org.eclipse.ui.internal.intro.impl.model;
import java.util.*;
+import org.eclipse.ui.internal.intro.impl.model.loader.*;
+import org.eclipse.ui.internal.intro.impl.util.*;
import org.osgi.framework.*;
import org.w3c.dom.*;
@@ -23,10 +25,12 @@ public abstract class AbstractIntroPage extends AbstractIntroContainer {
protected static final String TAG_PAGE = "page"; //$NON-NLS-1$
private static final String ATT_STYLE = "style"; //$NON-NLS-1$
private static final String ATT_ALT_STYLE = "alt-style"; //$NON-NLS-1$
+ private static final String ATT_CONTENT = "content"; //$NON-NLS-1$
private String style;
private String altStyle;
private IntroPageTitle title;
+ private String content;
/**
* The vectors to hold all inhertied styles and alt styles from included
@@ -61,9 +65,11 @@ public abstract class AbstractIntroPage extends AbstractIntroContainer {
super(element, bundle);
style = getAttribute(element, ATT_STYLE);
altStyle = getAttribute(element, ATT_ALT_STYLE);
+ content = getAttribute(element, ATT_CONTENT);
// Resolve.
style = IntroModelRoot.getPluginLocation(style, bundle);
altStyle = IntroModelRoot.getPluginLocation(altStyle, bundle);
+ content = IntroModelRoot.getPluginLocation(content, bundle);
}
/**
@@ -225,4 +231,41 @@ public abstract class AbstractIntroPage extends AbstractIntroContainer {
}
-} \ No newline at end of file
+ /**
+ * load the children of this container. Override parent behavior because we
+ * want to support laoding content from other xml files.
+ *
+ * @return Returns all the children of this container.
+ */
+ protected void loadChildren() {
+ if (content == null) {
+ // no content. do regular loading.
+ super.loadChildren();
+ return;
+ }
+
+ // load the first page from content xml file.
+ Document dom = new IntroContentParser(content).getDocument();
+ if (dom == null)
+ // return empty array. Parser would have logged fact.
+ return;
+
+ Element[] pages = ModelLoaderUtil.getElementsByTagName(dom,
+ IntroPage.TAG_PAGE);
+ if (pages.length != 1) {
+ String message = StringUtil.concat("Content file for page: ",
+ getId(), " has ", String.valueOf(pages.length), " pages")
+ .toString();
+ Log.warning(message);
+ // return empty array.
+ return;
+ }
+ // point the element of this page to the new element.
+ this.element = pages[0];
+ // now do children loading as usual.
+ super.loadChildren();
+ }
+}
+
+
+
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroHomePage.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroHomePage.java
index d7a1dbacc..dfe653954 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroHomePage.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroHomePage.java
@@ -70,45 +70,6 @@ public class IntroHomePage extends AbstractIntroPage {
return AbstractIntroElement.HOME_PAGE;
}
- // THESE METHODS WILL BE REMOVED. ADDED HERE FOR BACKWARD COMPATIBILITY.
- /**
- * This method is a customized method for root page to return the root page
- * links. Try to get the real links in the page. If there are non, return
- * the links in the first no-empty div.
- */
- public IntroLink[] getLinks() {
- // DONOW:
- IntroLink[] links = (IntroLink[]) getChildrenOfType(AbstractIntroElement.LINK);
- if (links.length != 0)
- return links;
-
- // root page does not have any links, append all links off non-filtered
- // divs.
- IntroGroup[] rootPageDivs = (IntroGroup[]) getChildrenOfType(AbstractIntroElement.GROUP);
- Vector linkVector = new Vector();
-
- for (int i = 0; i < rootPageDivs.length; i++)
- addLinks(rootPageDivs[i], linkVector);
-
- links = new IntroLink[linkVector.size()];
- linkVector.copyInto(links);
-
- return links;
- }
-
- private void addLinks(IntroGroup div, Vector linksVector) {
- linksVector.addAll(Arrays.asList(getLinks(div)));
- IntroGroup[] divs = (IntroGroup[]) div
- .getChildrenOfType(AbstractIntroElement.GROUP);
- for (int i = 0; i < divs.length; i++)
- addLinks(divs[i], linksVector);
- }
-
-
- public IntroLink[] getLinks(IntroGroup div) {
- return (IntroLink[]) div.getChildrenOfType(AbstractIntroElement.LINK);
- }
-
/**
* @return Returns the isStandbyPage.
@@ -124,5 +85,43 @@ public class IntroHomePage extends AbstractIntroPage {
public void setStandbyPage(boolean isStandbyPage) {
this.isStandbyPage = isStandbyPage;
}
+
+
+ // THESE METHODS WILL BE REMOVED!
+ /**
+ * This method is a customized method for root page to return the root page
+ * links. Try to get the real links in the page, and all links in all divs.
+ */
+ public IntroLink[] getLinks() {
+ Vector linkVector = new Vector();
+
+ AbstractIntroElement[] children = getChildren();
+ for (int i = 0; i < children.length; i++) {
+ AbstractIntroElement child = children[i];
+ if (child.isOfType(AbstractIntroElement.LINK))
+ linkVector.add(child);
+ else if (child.isOfType(AbstractIntroElement.GROUP)) {
+ addLinks((IntroGroup) child, linkVector);
+ }
+ }
+
+ IntroLink[] links = new IntroLink[linkVector.size()];
+ linkVector.copyInto(links);
+ return links;
+ }
+
+ private void addLinks(IntroGroup group, Vector linkVector) {
+ AbstractIntroElement[] children = group.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ AbstractIntroElement child = children[i];
+ if (child.isOfType(AbstractIntroElement.LINK))
+ linkVector.add(child);
+ else if (child.isOfType(AbstractIntroElement.GROUP)) {
+ addLinks((IntroGroup) child, linkVector);
+ }
+ }
+ }
+
+
}
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 f1bbf1325..a77d6e4af 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
@@ -76,9 +76,7 @@ public class IntroModelRoot extends AbstractIntroContainer {
// org.eclipse.ui.into.config extension point. Start off with true, and set
// to false whenever something bad happens.
private boolean hasValidConfig = true;
-
private boolean isdynamicIntro;
-
private IntroPartPresentation introPartPresentation;
private IntroHomePage homePage;
private String currentPageId;
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java
index 642557585..66445b9ac 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java
@@ -216,18 +216,23 @@ public class BrowserIntroPartImplementation extends
// presentation is shown here. toggle standby page. No need to update
// history here.
+ IntroHomePage homePage = getModel().getHomePage();
+ IntroHomePage standbyPage = getModel().getStandbyPage();
+ if (standbyPage == null)
+ standbyPage = homePage;
+ // TODO: revisit. do we really need to set current page?
if (standby)
- getModel().setCurrentPageId(getModel().getStandbyPage().getId());
- else
- getModel().setCurrentPageId(getModel().getCurrentPageId());
-
-
+ getModel().setCurrentPageId(standbyPage.getId());
+ else {
+ // trick model into firing event, outside thread.
+ String currentPageId = getModel().getCurrentPageId();
+ getModel().setCurrentPageId("", false);
+ getModel().setCurrentPageId(currentPageId);
+ }
}
-
-
/**
* Handle model property changes. Property listeners are only added in the
* dynamic case.
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java
index e24555e02..4ab2108b5 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java
@@ -253,7 +253,10 @@ public class FormIntroPartImplementation extends
if (standby) {
// we are in standby. Show standby page, in PageForm.
- String standbyPageId = getModel().getStandbyPage().getId();
+ String standbyPageId = getModel().getCurrentPageId();
+ AbstractIntroPage standbyPage = getModel().getStandbyPage();
+ if (standbyPage != null)
+ standbyPageId = standbyPage.getId();
pageForm.showPage(standbyPageId);
mainPageBook.showPage(PageForm.PAGE_FORM_ID);
} else {
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageStyleManager.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageStyleManager.java
index 45dacb695..c0bd38193 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageStyleManager.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageStyleManager.java
@@ -43,13 +43,15 @@ public class PageStyleManager extends SharedStyleManager {
// AltStyles Hashtable has alt-styles as keys, the bundles as
// values.
Hashtable altStyles = page.getAltStyles();
- Enumeration styles = altStyles.keys();
- while (styles.hasMoreElements()) {
- String style = (String) styles.nextElement();
- Properties inheritedProperties = new Properties();
- Bundle bundle = (Bundle) altStyles.get(style);
- load(inheritedProperties, style);
- altStyleProperties.put(inheritedProperties, bundle);
+ if (altStyles != null) {
+ Enumeration styles = altStyles.keys();
+ while (styles.hasMoreElements()) {
+ String style = (String) styles.nextElement();
+ Properties inheritedProperties = new Properties();
+ Bundle bundle = (Bundle) altStyles.get(style);
+ load(inheritedProperties, style);
+ altStyleProperties.put(inheritedProperties, bundle);
+ }
}
// cache root

Back to the top