diff options
author | Brian de Alwis | 2016-04-20 02:32:43 +0000 |
---|---|---|
committer | Brian de Alwis | 2016-04-21 13:37:53 +0000 |
commit | 31bcbfb0012425aa1b5b9b9b974cf7ae878f0b79 (patch) | |
tree | 38ef8f4495ddbd753f3d7e6df01db7f7bba12c82 /org.eclipse.ui.intro.universal | |
parent | 18cb084eeee21bab27389aeefe7e6d1e597721f0 (diff) | |
download | eclipse.platform.ua-31bcbfb0012425aa1b5b9b9b974cf7ae878f0b79.tar.gz eclipse.platform.ua-31bcbfb0012425aa1b5b9b9b974cf7ae878f0b79.tar.xz eclipse.platform.ua-31bcbfb0012425aa1b5b9b9b974cf7ae878f0b79.zip |
Bug 491556 - [Welcome] Provide theme-specific mechanism to influence path resolutionY20160428-1430Y20160428-1000I20160504-2000I20160504-0035I20160503-2000I20160502-2000I20160501-2000I20160430-2000I20160429-2300I20160429-2000I20160428-0800I20160427-2000I20160427-1200I20160427-0800I20160427-0400I20160426-2330I20160426-2000I20160426-1615I20160426-1430I20160426-1245I20160426-1105I20160426-1045I20160426-1000I20160426-0800I20160426-0130I20160426-0030I20160425-2230I20160425-2000I20160425-1300I20160425-0800I20160424-2245I20160424-2000
Add support for resolving theme-specific files. When resolving a
file path, the Intro first checks for a file under a path with the
theme-id. For example, resolving 'intro-eclipse.png' ->
'org.eclipse.ui.intro.universal.solstice/intro-eclipse.png'.
Change-Id: I8f558a4c264fb459efe0dbaeed7f92aaa980fb09
Diffstat (limited to 'org.eclipse.ui.intro.universal')
-rw-r--r-- | org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/UniversalIntroConfigurer.java | 68 |
1 files changed, 49 insertions, 19 deletions
diff --git a/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/UniversalIntroConfigurer.java b/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/UniversalIntroConfigurer.java index 941eaa2fc..06bfddc28 100644 --- a/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/UniversalIntroConfigurer.java +++ b/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/UniversalIntroConfigurer.java @@ -29,6 +29,7 @@ import org.eclipse.help.internal.util.ProductPreferences; import org.eclipse.help.internal.util.SequenceResolver; import org.eclipse.jface.action.Action; import org.eclipse.ui.internal.intro.impl.model.ExtensionMap; +import org.eclipse.ui.internal.intro.impl.model.IntroTheme; import org.eclipse.ui.internal.intro.universal.contentdetect.ContentDetector; import org.eclipse.ui.internal.intro.universal.util.ImageUtil; import org.eclipse.ui.internal.intro.universal.util.PreferenceArbiter; @@ -177,27 +178,56 @@ public class UniversalIntroConfigurer extends IntroConfigurer implements } private String resolveVariable(Bundle bundle, String value) { - if (value != null) { - String path = null; - if (value.startsWith("intro:")) { //$NON-NLS-1$ - bundle = UniversalIntroPlugin.getDefault().getBundle(); - path = value.substring(6); - } else if (value.startsWith("product:")) { //$NON-NLS-1$ - path = value.substring(8); - } else - return value; - try { - URL url = bundle.getEntry(path); - if (url != null) { - URL localURL = FileLocator.toFileURL(url); - return localURL.toString(); - } - } catch (IOException e) { - // just use the value as-is - return value; + if (value == null) { + return null; + } + if (value.startsWith("intro:")) { //$NON-NLS-1$ + bundle = UniversalIntroPlugin.getDefault().getBundle(); + return resolveFile(bundle, value.substring(6)); + } else if (value.startsWith("product:")) { //$NON-NLS-1$ + return resolveFile(bundle, value.substring(8)); + } + return value; + } + + private String resolveFile(Bundle bundle, String path) { + String prefixedPath = getThemePrefixedPath(path); + try { + URL url = null; + if (prefixedPath != null) { + url = bundle.getEntry(prefixedPath); } + if (url == null) { + url = bundle.getEntry(path); + } + if (url != null) { + URL localURL = FileLocator.toFileURL(url); + return localURL.toString(); + } + } catch (IOException e) { } - return null; + // just use the value as-is + return path; + } + + /** + * Prefix the file component of the given path with the theme's id. For + * example, with theme <code>org.eclipse.ui.intro.universal.solstice</code>: + * <ul> + * <li>foo → org.eclipse.ui.intro.universal.solstice/foo + * </ul> + * + * @param path + * the path + * @return same path with a prefixed theme directory component + */ + private String getThemePrefixedPath(String path) { + String prefix = themeProperties != null ? themeProperties.get(IntroTheme.ATT_ID) : null; + prefix = prefix == null ? "" : prefix.trim(); //$NON-NLS-1$ + if (prefix.length() == 0) { + return null; + } + return prefix + Path.SEPARATOR + path; } private String getProductProperty(IProduct product, String variableName) { |