KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > intro > impl > model > IntroHomePage


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.intro.impl.model;
13
14 import java.util.Vector JavaDoc;
15
16 import org.eclipse.ui.internal.intro.impl.model.util.ModelUtil;
17 import org.osgi.framework.Bundle;
18 import org.w3c.dom.Element JavaDoc;
19
20 /**
21  * An Intro Home page. A home page is special because it is the page that
22  * decides whether the OOBE pages are dynamic or static. This model class models
23  * the home and the standby page (since there is no difference between the two).
24  */

25 public class IntroHomePage extends AbstractIntroPage {
26
27     private static final String JavaDoc ATT_URL = "url"; //$NON-NLS-1$
28

29     private String JavaDoc url;
30     private boolean isDynamic = false;
31     private boolean isStandbyPage;
32
33
34     IntroHomePage(Element JavaDoc element, Bundle bundle, String JavaDoc base) {
35         super(element, bundle, base);
36         url = getAttribute(element, ATT_URL);
37         if (url == null)
38             // if we do not have a URL attribute, then we have dynamic content.
39
isDynamic = true;
40         else
41             // check the url/standby-url attributes and update accordingly.
42
url = ModelUtil.resolveURL(base, url, bundle);
43     }
44
45
46     /**
47      * @return Returns the url.
48      */

49     public String JavaDoc getUrl() {
50         return url;
51     }
52
53
54     /**
55      * Returns true if this is a dynamic model or not. This is based on whether
56      * this root page has a URL attribute or not.
57      *
58      * @return Returns the isDynamic.
59      */

60     public boolean isDynamic() {
61         return isDynamic;
62     }
63
64
65     /*
66      * (non-Javadoc)
67      *
68      * @see org.eclipse.ui.internal.intro.impl.model.IntroElement#getType()
69      */

70     public int getType() {
71         return AbstractIntroElement.HOME_PAGE;
72     }
73
74
75     /**
76      * @return Returns the isStandbyPage.
77      */

78     public boolean isStandbyPage() {
79         return isStandbyPage;
80     }
81
82     /**
83      * @param isStandbyPage
84      * The isStandbyPage to set.
85      */

86     public void setStandbyPage(boolean isStandbyPage) {
87         this.isStandbyPage = isStandbyPage;
88     }
89
90
91     // THESE METHODS WILL BE REMOVED!
92
/**
93      * This method is a customized method for root page to return the root page
94      * links. Try to get the real links in the page, and all links in all divs.
95      */

96     public IntroLink[] getLinks() {
97         Vector JavaDoc linkVector = new Vector JavaDoc();
98
99         AbstractIntroElement[] children = getChildren();
100         for (int i = 0; i < children.length; i++) {
101             AbstractIntroElement child = children[i];
102             if (child.isOfType(AbstractIntroElement.LINK))
103                 linkVector.add(child);
104             else if (child.isOfType(AbstractIntroElement.GROUP)) {
105                 addLinks((IntroGroup) child, linkVector);
106             }
107         }
108
109         IntroLink[] links = new IntroLink[linkVector.size()];
110         linkVector.copyInto(links);
111         return links;
112     }
113
114     private void addLinks(IntroGroup group, Vector JavaDoc linkVector) {
115         AbstractIntroElement[] children = group.getChildren();
116         for (int i = 0; i < children.length; i++) {
117             AbstractIntroElement child = children[i];
118             if (child.isOfType(AbstractIntroElement.LINK))
119                 linkVector.add(child);
120             else if (child.isOfType(AbstractIntroElement.GROUP)) {
121                 addLinks((IntroGroup) child, linkVector);
122             }
123         }
124     }
125
126
127 }
128
Popular Tags