Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian de Alwis2016-04-20 02:32:43 +0000
committerBrian de Alwis2016-04-21 13:37:53 +0000
commit31bcbfb0012425aa1b5b9b9b974cf7ae878f0b79 (patch)
tree38ef8f4495ddbd753f3d7e6df01db7f7bba12c82 /org.eclipse.ui.intro.universal
parent18cb084eeee21bab27389aeefe7e6d1e597721f0 (diff)
downloadeclipse.platform.ua-31bcbfb0012425aa1b5b9b9b974cf7ae878f0b79.tar.gz
eclipse.platform.ua-31bcbfb0012425aa1b5b9b9b974cf7ae878f0b79.tar.xz
eclipse.platform.ua-31bcbfb0012425aa1b5b9b9b974cf7ae878f0b79.zip
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.java68
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 &rarr; 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) {

Back to the top