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.eclipse.ui.internal.intro.impl.model.util.BundleUtil;
13: import org.osgi.framework.Bundle;
14: import org.w3c.dom.Element;
15:
16: /**
17: * An intro image element.
18: */
19: public class IntroImage extends AbstractBaseIntroElement {
20:
21: protected static final String TAG_IMAGE = "img"; //$NON-NLS-1$
22:
23: private static final String ATT_SRC = "src"; //$NON-NLS-1$
24: private static final String ATT_ALT = "alt"; //$NON-NLS-1$
25:
26: private Element element;
27: private String src;
28: private String base;
29:
30: IntroImage(Element element, Bundle bundle, String base) {
31: super (element, bundle);
32: this .element = element;
33: this .base = base;
34: }
35:
36: /**
37: * @return Returns the alt.
38: */
39: public String getAlt() {
40: return getAttribute(element, ATT_ALT);
41: }
42:
43: /*
44: * (non-Javadoc)
45: *
46: * @see org.eclipse.ui.internal.intro.impl.model.IntroElement#getType()
47: */
48: public int getType() {
49: return AbstractIntroElement.IMAGE;
50: }
51:
52: /**
53: * @return Returns the src value, already resolved as a local url.
54: */
55: public String getSrc() {
56: if (src == null)// Resolve src.
57: src = BundleUtil.getResolvedResourceLocation(base,
58: getSrcAsIs(), getBundle());
59: return src;
60: }
61:
62: /**
63: * @return Returns the src value, as is, without resolving it as a local
64: * url. The src value is relative to the parent plugin.
65: */
66: public String getSrcAsIs() {
67: return getAttribute(element, ATT_SRC);
68: }
69: }
|