KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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 org.osgi.framework.Bundle;
15 import org.w3c.dom.Element JavaDoc;
16
17 /**
18  * An intro config component that can have a single Text element as a child. In
19  * case there is more than one text child, the text is retrieved from the first
20  * text child element.
21  */

22 public abstract class AbstractTextElement extends AbstractIntroContainer {
23
24     AbstractTextElement(Element JavaDoc element, Bundle bundle) {
25         super(element, bundle);
26     }
27
28     /**
29      * Retruns the intro text element embedded in this element.
30      */

31     public IntroText getIntroText() {
32         AbstractIntroElement[] children = getChildren();
33         for (int i=0;i<children.length;++i) {
34             if (children[i] instanceof IntroText) {
35                 return (IntroText)children[i];
36             }
37         }
38         return null;
39     }
40
41     /**
42      * @return Returns the text of the child text of this element.
43      */

44     public String JavaDoc getText() {
45         // intro text may be null if there is no child Text element.
46
IntroText text = getIntroText();
47         if (text != null) {
48             return text.getText();
49         }
50         return null;
51     }
52
53     /*
54      * (non-Javadoc)
55      *
56      * @see org.eclipse.ui.internal.intro.impl.model.IntroElement#getType()
57      */

58     public int getType() {
59         return AbstractIntroElement.ABSTRACT_TEXT;
60     }
61 }
62
Popular Tags