Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 173721 Details for
Bug 313950
CSS Engine creates unnecessary contexts and injections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Back to Reflection!
Patch_313950.txt (text/plain), 17.41 KB, created by
Bogdan Gheorghe
on 2010-07-07 18:14:25 EDT
(
hide
)
Description:
Back to Reflection!
Filename:
MIME Type:
Creator:
Bogdan Gheorghe
Created:
2010-07-07 18:14:25 EDT
Size:
17.41 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.ui.css.swt >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.swt/META-INF/MANIFEST.MF,v >retrieving revision 1.19 >diff -u -r1.19 MANIFEST.MF >--- META-INF/MANIFEST.MF 30 Jun 2010 13:51:17 -0000 1.19 >+++ META-INF/MANIFEST.MF 7 Jul 2010 22:13:21 -0000 >@@ -20,6 +20,9 @@ > org.eclipse.e4.core.contexts, > org.eclipse.e4.core.di, > org.eclipse.e4.core.services;bundle-version="0.9.1", >- org.eclipse.core.runtime;bundle-version="3.6.0" >+ org.eclipse.core.runtime;bundle-version="3.6.0", >+ org.eclipse.emf.common;bundle-version="2.6.0" > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > Bundle-Vendor: Eclipse.org >+Bundle-Activator: org.eclipse.e4.ui.internal.css.swt.CSSActivator >+Bundle-ActivationPolicy: lazy >Index: src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCornerRadiusSWTHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCornerRadiusSWTHandler.java,v >retrieving revision 1.6 >diff -u -r1.6 CSSPropertyCornerRadiusSWTHandler.java >--- src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCornerRadiusSWTHandler.java 30 Jun 2010 17:05:46 -0000 1.6 >+++ src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyCornerRadiusSWTHandler.java 7 Jul 2010 22:13:21 -0000 >@@ -10,6 +10,9 @@ > *******************************************************************************/ > package org.eclipse.e4.ui.css.swt.properties.custom; > >+import java.lang.reflect.Method; >+import org.eclipse.swt.graphics.Color; >+ > import org.eclipse.e4.core.contexts.ContextInjectionFactory; > import org.eclipse.e4.core.contexts.IEclipseContext; > import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler; >@@ -31,15 +34,9 @@ > if (!(control instanceof CTabFolder)) return; > if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { > int radiusValue = (int) ((CSSPrimitiveValue) value).getFloatValue(CSSPrimitiveValue.CSS_NUMBER); >- > CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer(); >- >- Object cssContext = control.getDisplay().getData("org.eclipse.e4.ui.css.context"); >- if (cssContext != null && cssContext instanceof IEclipseContext) { >- IEclipseContext context = (IEclipseContext) cssContext; >- context.set("radius", new Integer(radiusValue)); >- ContextInjectionFactory.inject(renderer, context); >- } >+ Method m = renderer.getClass().getMethod("setCornerRadius", new Class[]{Integer.class}); >+ m.invoke(renderer, Integer.valueOf(radiusValue)); > } > } > >Index: src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyInnerKeylineSWTHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyInnerKeylineSWTHandler.java,v >retrieving revision 1.5 >diff -u -r1.5 CSSPropertyInnerKeylineSWTHandler.java >--- src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyInnerKeylineSWTHandler.java 30 Jun 2010 17:05:46 -0000 1.5 >+++ src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyInnerKeylineSWTHandler.java 7 Jul 2010 22:13:21 -0000 >@@ -33,22 +33,9 @@ > if (!(control instanceof CTabFolder)) return; > if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { > Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay()); >- > CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer(); >- Object cssContext = control.getDisplay().getData("org.eclipse.e4.ui.css.context"); >- if (cssContext != null && cssContext instanceof IEclipseContext) { >- IEclipseContext context = (IEclipseContext) cssContext; >- context.set("innerKeyline", newColor); >- ContextInjectionFactory.inject(renderer, context); >- } else { >- Method[] methods = renderer.getClass().getMethods(); >- for (int i = 0; i < methods.length; i++) { >- Method m = methods[i]; >- if (m.getName().toLowerCase().contains("setinnerkeyline")) { >- m.invoke(renderer, newColor); >- } >- } >- } >+ Method m = renderer.getClass().getMethod("setInnerKeyline", new Class[]{Color.class}); >+ m.invoke(renderer, newColor); > } > } > >Index: src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyOuterKeylineSWTHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyOuterKeylineSWTHandler.java,v >retrieving revision 1.5 >diff -u -r1.5 CSSPropertyOuterKeylineSWTHandler.java >--- src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyOuterKeylineSWTHandler.java 30 Jun 2010 17:05:46 -0000 1.5 >+++ src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyOuterKeylineSWTHandler.java 7 Jul 2010 22:13:21 -0000 >@@ -10,11 +10,7 @@ > *******************************************************************************/ > package org.eclipse.e4.ui.css.swt.properties.custom; > >-import java.util.HashMap; >- > import java.lang.reflect.Method; >-import org.eclipse.e4.core.contexts.ContextInjectionFactory; >-import org.eclipse.e4.core.contexts.IEclipseContext; > import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler; > import org.eclipse.e4.ui.css.core.engine.CSSEngine; > import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; >@@ -26,8 +22,6 @@ > > public class CSSPropertyOuterKeylineSWTHandler extends AbstractCSSPropertySWTHandler { > >- HashMap contexts = new HashMap(); >- > public static final ICSSPropertyHandler INSTANCE = new CSSPropertyOuterKeylineSWTHandler(); > > @Override >@@ -36,27 +30,9 @@ > if (!(control instanceof CTabFolder)) return; > if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { > Color newColor = (Color) engine.convert(value, Color.class, control.getDisplay()); >- > CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer(); >- Object cssContext = control.getDisplay().getData("org.eclipse.e4.ui.css.context"); >- if (cssContext != null && cssContext instanceof IEclipseContext) { >- IEclipseContext context = (IEclipseContext) cssContext; >- IEclipseContext childContext = (IEclipseContext) contexts.get(control); >- if (childContext == null) { >- childContext = context.createChild(); >- contexts.put(control, childContext); >- } >- childContext.set("outerKeyline", newColor); >- ContextInjectionFactory.inject(renderer, childContext); >- } else { >- Method[] methods = renderer.getClass().getMethods(); >- for (int i = 0; i < methods.length; i++) { >- Method m = methods[i]; >- if (m.getName().toLowerCase().contains("setouterkeyline")) { >- m.invoke(renderer, newColor); >- } >- } >- } >+ Method m = renderer.getClass().getMethod("setOuterKeyline", new Class[]{Color.class}); >+ m.invoke(renderer, newColor); > } > } > >Index: src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyShadowVisibleSWTHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyShadowVisibleSWTHandler.java,v >retrieving revision 1.5 >diff -u -r1.5 CSSPropertyShadowVisibleSWTHandler.java >--- src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyShadowVisibleSWTHandler.java 28 May 2010 20:17:13 -0000 1.5 >+++ src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyShadowVisibleSWTHandler.java 7 Jul 2010 22:13:21 -0000 >@@ -10,6 +10,9 @@ > *******************************************************************************/ > package org.eclipse.e4.ui.css.swt.properties.custom; > >+import java.lang.reflect.Method; >+import org.eclipse.swt.graphics.Color; >+ > import org.eclipse.e4.core.contexts.ContextInjectionFactory; > import org.eclipse.e4.core.contexts.IEclipseContext; > import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler; >@@ -29,16 +32,9 @@ > CSSValue value, String pseudo, CSSEngine engine) throws Exception { > if (!(control instanceof CTabFolder)) return; > boolean shadowVisible = (Boolean) engine.convert(value, Boolean.class, null); >- > CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer(); >- >- Object appContext = control.getDisplay().getData("org.eclipse.e4.ui.css.context"); >- if (appContext != null && appContext instanceof IEclipseContext) { >- IEclipseContext context = (IEclipseContext) appContext; >- IEclipseContext childContext = context.createChild(); >- childContext.set("shadowVisible", new Boolean(shadowVisible)); >- ContextInjectionFactory.inject(renderer, childContext); >- } >+ Method m = renderer.getClass().getMethod("setShadowVisible", new Class[]{Boolean.class}); >+ m.invoke(renderer, Boolean.valueOf(shadowVisible)); > } > > protected String retrieveCSSProperty(Control control, String property, >Index: src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabRendererSWTHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabRendererSWTHandler.java,v >retrieving revision 1.7 >diff -u -r1.7 CSSPropertyTabRendererSWTHandler.java >--- src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabRendererSWTHandler.java 30 Jun 2010 17:05:46 -0000 1.7 >+++ src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyTabRendererSWTHandler.java 7 Jul 2010 22:13:21 -0000 >@@ -10,14 +10,18 @@ > *******************************************************************************/ > package org.eclipse.e4.ui.css.swt.properties.custom; > >-import org.eclipse.e4.core.contexts.IEclipseContext; >-import org.eclipse.e4.core.services.contributions.IContributionFactory; >+import org.eclipse.swt.custom.CTabFolderRenderer; >+ >+import java.lang.reflect.Constructor; >+ > import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler; > import org.eclipse.e4.ui.css.core.engine.CSSEngine; > import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; >+import org.eclipse.e4.ui.internal.css.swt.CSSActivator; >+import org.eclipse.emf.common.util.URI; > import org.eclipse.swt.custom.CTabFolder; >-import org.eclipse.swt.custom.CTabFolderRenderer; > import org.eclipse.swt.widgets.Control; >+import org.osgi.framework.Bundle; > import org.w3c.dom.css.CSSPrimitiveValue; > import org.w3c.dom.css.CSSValue; > >@@ -32,15 +36,30 @@ > if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { > if (((CSSPrimitiveValue) value).getPrimitiveType() == CSSPrimitiveValue.CSS_URI) { > String rendURL = ((CSSPrimitiveValue) value).getStringValue(); >- >- Object cssContext = control.getDisplay().getData("org.eclipse.e4.ui.css.context"); >- if (cssContext != null && cssContext instanceof IEclipseContext) { >- IEclipseContext context = (IEclipseContext) cssContext; >- context.set(CTabFolder.class.getName(), control); >- IContributionFactory factory = (IContributionFactory) context.get(IContributionFactory.class.getName()); >- Object rend = factory.create(rendURL, context); >- if (rend != null && rend instanceof CTabFolderRenderer){ >- ((CTabFolder) control).setRenderer((CTabFolderRenderer)rend); >+ URI uri = URI.createURI(rendURL); >+ Bundle bundle = CSSActivator.getDefault().getBundleForName(uri.segment(1)); >+ if (bundle != null) { >+ if (uri.segmentCount() > 3) { >+ //TODO: handle this case? >+ } else { >+ String clazz = uri.segment(2); >+ try { >+ Class<?> targetClass = bundle.loadClass(clazz); >+ Constructor constructor = targetClass.getConstructor(CTabFolder.class); >+ if (constructor != null) { >+ Object rend = constructor.newInstance(control); >+ if (rend != null && rend instanceof CTabFolderRenderer) { >+ ((CTabFolder) control).setRenderer((CTabFolderRenderer)rend); >+ } >+ } >+ } catch (ClassNotFoundException e) { >+ String message = "Unable to load class '" + clazz + "' from bundle '" //$NON-NLS-1$ //$NON-NLS-2$ >+ + bundle.getBundleId() + "'"; //$NON-NLS-1$ >+ System.err.println(message); >+ if (e != null) { >+ e.printStackTrace(System.err); >+ } >+ } > } > } > } else { >Index: src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedTabsSWTHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedTabsSWTHandler.java,v >retrieving revision 1.5 >diff -u -r1.5 CSSPropertyUnselectedTabsSWTHandler.java >--- src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedTabsSWTHandler.java 30 Jun 2010 17:05:46 -0000 1.5 >+++ src/org/eclipse/e4/ui/css/swt/properties/custom/CSSPropertyUnselectedTabsSWTHandler.java 7 Jul 2010 22:13:21 -0000 >@@ -8,6 +8,8 @@ > *******************************************************************************/ > package org.eclipse.e4.ui.css.swt.properties.custom; > >+import java.lang.reflect.Method; >+ > import org.eclipse.e4.core.contexts.ContextInjectionFactory; > import org.eclipse.e4.core.contexts.IEclipseContext; > import org.eclipse.e4.ui.css.core.dom.properties.Gradient; >@@ -38,17 +40,13 @@ > folder.setBackground(colors, percents, true); > > CTabFolderRenderer renderer = ((CTabFolder) control).getRenderer(); >- Object cssContext = control.getDisplay().getData("org.eclipse.e4.ui.css.context"); >- if (cssContext != null && cssContext instanceof IEclipseContext) { >- IEclipseContext context = (IEclipseContext) cssContext; >- if (pseudo != null && pseudo.equals("selected")) { >- context.set("activeToolbarColors", colors); >- context.set("activeToolbarPercents", percents); >- } else { >- context.set("inactiveToolbarColors", colors); >- context.set("inactiveToolbarPercents", percents); >- } >- ContextInjectionFactory.inject(renderer, context); >+ >+ if (pseudo != null && pseudo.equals("selected")) { >+ Method m = renderer.getClass().getMethod("setActiveToolbarGradient", new Class[]{Color[].class, int[].class}); >+ m.invoke(renderer, colors, percents); >+ } else { >+ Method m = renderer.getClass().getMethod("setInactiveToolbarGradient", new Class[]{Color[].class, int[].class}); >+ m.invoke(renderer, colors, percents); > } > } > } >Index: src/org/eclipse/e4/ui/internal/css/swt/CSSActivator.java >=================================================================== >RCS file: src/org/eclipse/e4/ui/internal/css/swt/CSSActivator.java >diff -N src/org/eclipse/e4/ui/internal/css/swt/CSSActivator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/internal/css/swt/CSSActivator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.e4.ui.internal.css.swt; >+ >+import org.osgi.framework.Bundle; >+import org.osgi.framework.BundleActivator; >+import org.osgi.framework.BundleContext; >+import org.osgi.service.packageadmin.PackageAdmin; >+import org.osgi.util.tracker.ServiceTracker; >+ >+public class CSSActivator implements BundleActivator { >+ >+ private static CSSActivator activator; >+ >+ private BundleContext context; >+ private ServiceTracker pkgAdminTracker; >+ >+ public static CSSActivator getDefault() { >+ return activator; >+ } >+ >+ public Bundle getBundle() { >+ return context.getBundle(); >+ } >+ >+ public PackageAdmin getBundleAdmin() { >+ if (pkgAdminTracker == null) { >+ if (context == null) >+ return null; >+ pkgAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null); >+ pkgAdminTracker.open(); >+ } >+ return (PackageAdmin) pkgAdminTracker.getService(); >+ } >+ >+ /** >+ * @param bundleName >+ * the bundle id >+ * @return A bundle if found, or <code>null</code> >+ */ >+ public Bundle getBundleForName(String bundleName) { >+ Bundle[] bundles = getBundleAdmin().getBundles(bundleName, null); >+ if (bundles == null) >+ return null; >+ // Return the first bundle that is not installed or uninstalled >+ for (int i = 0; i < bundles.length; i++) { >+ if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) { >+ return bundles[i]; >+ } >+ } >+ return null; >+ } >+ >+ public BundleContext getContext() { >+ return context; >+ } >+ >+ public void start(BundleContext context) throws Exception { >+ activator = this; >+ this.context = context; >+ } >+ >+ public void stop(BundleContext context) throws Exception { >+ if (pkgAdminTracker != null) { >+ pkgAdminTracker.close(); >+ pkgAdminTracker = null; >+ } >+ context = null; >+ } >+ >+ >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 313950
:
169530
|
173128
|
173573
| 173721