1 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.eclipse.ui.internal.intro.impl.util.Log; 16 import org.osgi.framework.Bundle; 17 import org.w3c.dom.Element ; 18 import org.w3c.dom.NodeList ; 19 20 27 public class IntroHTML extends AbstractTextElement { 28 29 protected static final String TAG_HTML = "html"; 31 private static final String ATT_SRC = "src"; 35 private static final String ATT_TYPE = "type"; private static final String ATT_ENCODING = "encoding"; 39 private String src; 40 private String html_type; 41 private String encoding; 42 private IntroImage introImage; 43 44 IntroHTML(Element element, Bundle bundle, String base) { 45 super(element, bundle); 46 src = getAttribute(element, ATT_SRC); 47 html_type = getAttribute(element, ATT_TYPE); 48 encoding = getAttribute(element, ATT_ENCODING); 49 if (encoding == null) 50 encoding = "UTF-8"; if (html_type != null && !html_type.equalsIgnoreCase("inline") && !html_type.equalsIgnoreCase("embed")) html_type = null; 55 56 introImage = getIntroImage(element, base); 58 59 src = BundleUtil.getResolvedResourceLocation(base, src, bundle); 61 } 62 63 66 private IntroImage getIntroImage(Element element, String base) { 67 try { 68 NodeList imageElements = element 71 .getElementsByTagName(IntroImage.TAG_IMAGE); 72 if (imageElements.getLength() == 0) 73 return null; 75 IntroImage image = new IntroImage((Element ) imageElements.item(0), 76 getBundle(), base); 77 image.setParent(this); 78 return image; 79 } catch (Exception e) { 80 Log.error(e.getMessage(), e); 81 return null; 82 } 83 } 84 85 91 public boolean isInlined() { 92 return (html_type != null && html_type.equalsIgnoreCase("inline")) ? true : false; 94 } 95 96 99 public String getSrc() { 100 return src; 101 } 102 103 107 public String getInlineEncoding() { 108 return encoding; 109 } 110 111 117 public IntroImage getIntroImage() { 118 return introImage; 119 } 120 121 126 public int getType() { 127 return AbstractIntroElement.HTML; 128 } 129 130 133 public Object clone() throws CloneNotSupportedException { 134 IntroHTML clone = (IntroHTML) super.clone(); 135 if (introImage != null) { 136 IntroImage cloneIntroImage = (IntroImage) introImage.clone(); 137 cloneIntroImage.setParent(clone); 138 clone.introImage = cloneIntroImage; 139 } 140 return clone; 141 } 142 143 } 144 | Popular Tags |