1 11 package org.eclipse.ui.internal.intro.impl.model; 12 13 import java.net.MalformedURLException ; 14 import java.net.URL ; 15 16 import org.eclipse.core.runtime.IConfigurationElement; 17 import org.eclipse.jface.resource.ImageDescriptor; 18 import org.eclipse.ui.internal.intro.impl.util.ImageUtil; 19 import org.eclipse.ui.intro.config.IntroElement; 20 21 26 public class IntroLaunchBarShortcut extends AbstractIntroElement { 27 28 protected static final String TAG_SHORTCUT = "shortcut"; 30 private static final String ATT_TOOLTIP = "tooltip"; private static final String ATT_ICON = "icon"; private static final String ATT_URL = "url"; 34 private IntroElement ielement; 35 36 IntroLaunchBarShortcut(IConfigurationElement element, IntroElement ielement) { 37 super(element); 38 this.ielement = ielement; 39 } 40 41 IntroLaunchBarShortcut(IConfigurationElement element) { 42 super(element); 43 } 44 45 46 public int getType() { 47 return AbstractIntroElement.LAUNCH_BAR_SHORTCUT; 48 } 49 50 private String getAttribute(String name) { 51 if (ielement!=null) 52 return ielement.getAttribute(name); 53 return getCfgElement().getAttribute(name); 54 } 55 56 61 public String getURL() { 62 return getAttribute(ATT_URL); 63 } 64 65 70 public String getToolTip() { 71 return getAttribute(ATT_TOOLTIP); 72 } 73 74 79 private String getIcon() { 80 return getAttribute(ATT_ICON); 81 } 82 83 89 public ImageDescriptor getImageDescriptor() { 90 String icon = getIcon(); 91 if (icon!=null) { 92 try { 93 URL imageUrl = new URL (icon); 94 ImageDescriptor desc = ImageDescriptor.createFromURL(imageUrl); 95 return desc; 96 } 97 catch (MalformedURLException e) { 98 } 100 } 101 return ImageUtil.createImageDescriptor(getBundle(), getIcon()); 102 } 103 } 104 | Popular Tags |