KickJava   Java API By Example, From Geeks To Geeks.

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


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.eclipse.ui.internal.intro.impl.model.util.BundleUtil;
15 import org.osgi.framework.Bundle;
16 import org.w3c.dom.Element JavaDoc;
17
18 /**
19  * An intro image element.
20  */

21 public class IntroImage extends AbstractBaseIntroElement {
22
23     protected static final String JavaDoc TAG_IMAGE = "img"; //$NON-NLS-1$
24

25     private static final String JavaDoc ATT_SRC = "src"; //$NON-NLS-1$
26
private static final String JavaDoc ATT_ALT = "alt"; //$NON-NLS-1$
27

28     private Element JavaDoc element;
29     private String JavaDoc src;
30     private String JavaDoc base;
31
32     IntroImage(Element JavaDoc element, Bundle bundle, String JavaDoc base) {
33         super(element, bundle);
34         this.element = element;
35         this.base = base;
36     }
37  
38     /**
39      * @return Returns the alt.
40      */

41     public String JavaDoc getAlt() {
42         return getAttribute(element, ATT_ALT);
43     }
44
45
46     /*
47      * (non-Javadoc)
48      *
49      * @see org.eclipse.ui.internal.intro.impl.model.IntroElement#getType()
50      */

51     public int getType() {
52         return AbstractIntroElement.IMAGE;
53     }
54
55     /**
56      * @return Returns the src value, already resolved as a local url.
57      */

58     public String JavaDoc getSrc() {
59         if (src==null)// Resolve src.
60
src = BundleUtil.getResolvedResourceLocation(base, getSrcAsIs(), getBundle());
61         return src;
62     }
63
64     /**
65      * @return Returns the src value, as is, without resolving it as a local
66      * url. The src value is relative to the parent plugin.
67      */

68     public String JavaDoc getSrcAsIs() {
69         return getAttribute(element, ATT_SRC);
70     }
71 }
72
Popular Tags