|
Lines 10-23
Link Here
|
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.e4.ui.css.swt.properties.custom; |
11 |
package org.eclipse.e4.ui.css.swt.properties.custom; |
| 12 |
|
12 |
|
| 13 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
13 |
import org.eclipse.swt.custom.CTabFolderRenderer; |
| 14 |
import org.eclipse.e4.core.services.contributions.IContributionFactory; |
14 |
|
|
|
15 |
import java.lang.reflect.Constructor; |
| 16 |
|
| 15 |
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler; |
17 |
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler; |
| 16 |
import org.eclipse.e4.ui.css.core.engine.CSSEngine; |
18 |
import org.eclipse.e4.ui.css.core.engine.CSSEngine; |
| 17 |
import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; |
19 |
import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; |
|
|
20 |
import org.eclipse.e4.ui.internal.css.swt.CSSActivator; |
| 21 |
import org.eclipse.emf.common.util.URI; |
| 18 |
import org.eclipse.swt.custom.CTabFolder; |
22 |
import org.eclipse.swt.custom.CTabFolder; |
| 19 |
import org.eclipse.swt.custom.CTabFolderRenderer; |
|
|
| 20 |
import org.eclipse.swt.widgets.Control; |
23 |
import org.eclipse.swt.widgets.Control; |
|
|
24 |
import org.osgi.framework.Bundle; |
| 21 |
import org.w3c.dom.css.CSSPrimitiveValue; |
25 |
import org.w3c.dom.css.CSSPrimitiveValue; |
| 22 |
import org.w3c.dom.css.CSSValue; |
26 |
import org.w3c.dom.css.CSSValue; |
| 23 |
|
27 |
|
|
Lines 32-46
Link Here
|
| 32 |
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { |
36 |
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { |
| 33 |
if (((CSSPrimitiveValue) value).getPrimitiveType() == CSSPrimitiveValue.CSS_URI) { |
37 |
if (((CSSPrimitiveValue) value).getPrimitiveType() == CSSPrimitiveValue.CSS_URI) { |
| 34 |
String rendURL = ((CSSPrimitiveValue) value).getStringValue(); |
38 |
String rendURL = ((CSSPrimitiveValue) value).getStringValue(); |
| 35 |
|
39 |
URI uri = URI.createURI(rendURL); |
| 36 |
Object cssContext = control.getDisplay().getData("org.eclipse.e4.ui.css.context"); |
40 |
Bundle bundle = CSSActivator.getDefault().getBundleForName(uri.segment(1)); |
| 37 |
if (cssContext != null && cssContext instanceof IEclipseContext) { |
41 |
if (bundle != null) { |
| 38 |
IEclipseContext context = (IEclipseContext) cssContext; |
42 |
if (uri.segmentCount() > 3) { |
| 39 |
context.set(CTabFolder.class.getName(), control); |
43 |
//TODO: handle this case? |
| 40 |
IContributionFactory factory = (IContributionFactory) context.get(IContributionFactory.class.getName()); |
44 |
} else { |
| 41 |
Object rend = factory.create(rendURL, context); |
45 |
String clazz = uri.segment(2); |
| 42 |
if (rend != null && rend instanceof CTabFolderRenderer){ |
46 |
try { |
| 43 |
((CTabFolder) control).setRenderer((CTabFolderRenderer)rend); |
47 |
Class<?> targetClass = bundle.loadClass(clazz); |
|
|
48 |
Constructor constructor = targetClass.getConstructor(CTabFolder.class); |
| 49 |
if (constructor != null) { |
| 50 |
Object rend = constructor.newInstance(control); |
| 51 |
if (rend != null && rend instanceof CTabFolderRenderer) { |
| 52 |
((CTabFolder) control).setRenderer((CTabFolderRenderer)rend); |
| 53 |
} |
| 54 |
} |
| 55 |
} catch (ClassNotFoundException e) { |
| 56 |
String message = "Unable to load class '" + clazz + "' from bundle '" //$NON-NLS-1$ //$NON-NLS-2$ |
| 57 |
+ bundle.getBundleId() + "'"; //$NON-NLS-1$ |
| 58 |
System.err.println(message); |
| 59 |
if (e != null) { |
| 60 |
e.printStackTrace(System.err); |
| 61 |
} |
| 62 |
} |
| 44 |
} |
63 |
} |
| 45 |
} |
64 |
} |
| 46 |
} else { |
65 |
} else { |