1 11 12 package org.eclipse.ui.internal.intro.impl.model; 13 14 import org.eclipse.ui.internal.intro.impl.model.url.IntroURL; 15 import org.eclipse.ui.internal.intro.impl.model.url.IntroURLParser; 16 import org.eclipse.ui.internal.intro.impl.model.util.ModelUtil; 17 import org.osgi.framework.Bundle; 18 import org.w3c.dom.Element ; 19 import org.w3c.dom.NodeList ; 20 21 25 public class IntroLink extends AbstractTextElement { 26 27 protected static final String TAG_LINK = "link"; 29 private static final String ATT_LABEL = "label"; private static final String ATT_URL = "url"; private static final String TAG_IMG = "img"; 33 private String label; 34 private String url; 35 private IntroImage img; 36 private IntroURL introURL; 37 38 41 IntroLink(Element element, Bundle bundle, String base) { 42 super(element, bundle); 43 url = getAttribute(element, ATT_URL); 44 label = getAttribute(element, ATT_LABEL); 45 46 url = ModelUtil.resolveURL(base, url, bundle); 47 if (url != null) { 48 IntroURLParser parser = new IntroURLParser(url); 50 if (parser.hasIntroUrl()) 51 introURL = parser.getIntroURL(); 52 } 53 54 NodeList imgElements = element.getElementsByTagName(TAG_IMG); 56 if (imgElements.getLength() > 0) { 57 img = new IntroImage((Element ) imgElements.item(0), getBundle(), 58 base); 59 img.setParent(this); 60 } 61 } 62 63 66 public String getLabel() { 67 return label; 68 } 69 70 73 public String getUrl() { 74 return url; 75 } 76 77 83 public IntroURL getIntroURL() { 84 return introURL; 85 } 86 87 92 public int getType() { 93 return AbstractIntroElement.LINK; 94 } 95 96 99 public IntroImage getImg() { 100 return img; 101 } 102 103 106 public Object clone() throws CloneNotSupportedException { 107 IntroLink clone = (IntroLink) super.clone(); 108 if (img != null) { 109 IntroImage cloneIntroImage = (IntroImage) img.clone(); 110 cloneIntroImage.setParent(clone); 111 clone.img = cloneIntroImage; 112 } 113 return clone; 115 } 116 } 117 | Popular Tags |