01: /*******************************************************************************
02: * Copyright (c) 2004, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.intro.impl.model;
11:
12: import org.osgi.framework.Bundle;
13: import org.w3c.dom.Element;
14:
15: /**
16: * An intro config component that can have a single Text element as a child. In
17: * case there is more than one text child, the text is retrieved from the first
18: * text child element.
19: */
20: public abstract class AbstractTextElement extends
21: AbstractIntroContainer {
22:
23: AbstractTextElement(Element element, Bundle bundle) {
24: super (element, bundle);
25: }
26:
27: /**
28: * Retruns the intro text element embedded in this element.
29: */
30: public IntroText getIntroText() {
31: AbstractIntroElement[] children = getChildren();
32: for (int i = 0; i < children.length; ++i) {
33: if (children[i] instanceof IntroText) {
34: return (IntroText) children[i];
35: }
36: }
37: return null;
38: }
39:
40: /**
41: * @return Returns the text of the child text of this element.
42: */
43: public String getText() {
44: // intro text may be null if there is no child Text element.
45: IntroText text = getIntroText();
46: if (text != null) {
47: return text.getText();
48: }
49: return null;
50: }
51:
52: /*
53: * (non-Javadoc)
54: *
55: * @see org.eclipse.ui.internal.intro.impl.model.IntroElement#getType()
56: */
57: public int getType() {
58: return AbstractIntroElement.ABSTRACT_TEXT;
59: }
60: }
|