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 138735 Details for
Bug 277471
[CSS] css background image does not work in rcp apps
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]
Patch with initial implementation of OSGi based resource lookup
277471 add osgi resource locating to css (text/plain), 11.09 KB, created by
Kevin McGuire
on 2009-06-09 19:41:00 EDT
(
hide
)
Description:
Patch with initial implementation of OSGi based resource lookup
Filename:
MIME Type:
Creator:
Kevin McGuire
Created:
2009-06-09 19:41:00 EDT
Size:
11.09 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.ui.workbench.swt >Index: src/org/eclipse/e4/ui/workbench/swt/internal/WorkbenchApplication.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/WorkbenchApplication.java,v >retrieving revision 1.5 >diff -u -r1.5 WorkbenchApplication.java >--- src/org/eclipse/e4/ui/workbench/swt/internal/WorkbenchApplication.java 25 May 2009 16:54:10 -0000 1.5 >+++ src/org/eclipse/e4/ui/workbench/swt/internal/WorkbenchApplication.java 9 Jun 2009 23:31:25 -0000 >@@ -54,6 +54,9 @@ > } > final String cssURI = product == null ? null : product > .getProperty("applicationCSS"); //$NON-NLS-1$; >+ final String cssResourcesURI = product == null ? null : product >+ .getProperty("applicationCSSResources"); //$NON-NLS-1$; >+ > Assert.isNotNull(appURI, "-applicationXMI argument missing"); //$NON-NLS-1$ > final URI initialWorkbenchDefinitionInstance = URI > .createPlatformPluginURI(appURI, true); >@@ -75,7 +78,7 @@ > .getBundleAdmin())); > if (cssURI != null) { > WorkbenchStylingSupport.initializeStyling(display, >- cssURI, appContext); >+ cssURI, cssResourcesURI, appContext); > } else { > WorkbenchStylingSupport > .initializeNullStyling(appContext); >Index: src/org/eclipse/e4/ui/workbench/swt/internal/WorkbenchStylingSupport.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/WorkbenchStylingSupport.java,v >retrieving revision 1.2 >diff -u -r1.2 WorkbenchStylingSupport.java >--- src/org/eclipse/e4/ui/workbench/swt/internal/WorkbenchStylingSupport.java 26 May 2009 13:40:16 -0000 1.2 >+++ src/org/eclipse/e4/ui/workbench/swt/internal/WorkbenchStylingSupport.java 9 Jun 2009 23:31:25 -0000 >@@ -29,7 +29,7 @@ > public class WorkbenchStylingSupport { > > public static void initializeStyling(Display display, String cssURI, >- IEclipseContext appContext) { >+ String resourceURI, IEclipseContext appContext) { > // Instantiate SWT CSS Engine > try { > Class engineClass = Class >@@ -49,6 +49,37 @@ > setErrorHandler.invoke(engine, new Object[] { errorHandlerImplClass > .newInstance() }); > >+ // Create the OSGi resource locator >+ >+ if (resourceURI != null) { >+ Class resourceLocatorClass = Class >+ .forName("org.eclipse.e4.ui.css.core.util.impl.resources.OSGiResourceLocator"); //$NON-NLS-1$ >+ Constructor resourceLocatorConst = resourceLocatorClass >+ .getConstructor(new Class[] { String.class }); >+ final Object resourceLocator = resourceLocatorConst >+ .newInstance(new Object[] { resourceURI.toString() }); >+ display.setData( >+ "org.eclipse.e4.ui.css.core.resourceURL", resourceURI); //$NON-NLS-1$ >+ >+ // engine.getResourcesLocatorManager().registerResourceLocator(IResourceLocator); >+ Method getResourcesLocatorManagerMethod = engineClass >+ .getMethod("getResourcesLocatorManager", new Class[] {}); //$NON-NLS-1$ >+ Object resourceRegistryManager = getResourcesLocatorManagerMethod >+ .invoke(engine, new Object[] {}); >+ >+ Class iResourceLocatorClass = Class >+ .forName("org.eclipse.e4.ui.css.core.util.resources.IResourceLocator"); //$NON-NLS-1$ >+ >+ Method registerResourceLocatorMethod = resourceRegistryManager >+ .getClass() >+ .getMethod( >+ "registerResourceLocator", new Class[] { iResourceLocatorClass }); //$NON-NLS-1$ >+ registerResourceLocatorMethod.invoke(resourceRegistryManager, >+ new Object[] { resourceLocator }); >+ } >+ >+ // Lookup the style sheet >+ > URL url = FileLocator.resolve(new URL(cssURI.toString())); > display.setData("org.eclipse.e4.ui.css.core.cssURL", url); //$NON-NLS-1$ > >#P org.eclipse.e4.ui.workbench.fragment >Index: src/org/eclipse/ui/internal/Workbench.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.workbench.fragment/src/org/eclipse/ui/internal/Workbench.java,v >retrieving revision 1.4 >diff -u -r1.4 Workbench.java >--- src/org/eclipse/ui/internal/Workbench.java 8 Jun 2009 14:36:41 -0000 1.4 >+++ src/org/eclipse/ui/internal/Workbench.java 9 Jun 2009 23:31:25 -0000 >@@ -1379,9 +1379,11 @@ > IProduct product = Platform.getProduct(); > final String cssURI = product == null ? null : product > .getProperty("applicationCSS"); //$NON-NLS-1$; >+ final String cssResourcesURI = product == null ? null : product >+ .getProperty("applicationCSSResources"); //$NON-NLS-1$; > if (cssURI != null) { > WorkbenchStylingSupport.initializeStyling(display, cssURI, >- e4Context); >+ cssResourcesURI, e4Context); > } else { > WorkbenchStylingSupport.initializeNullStyling(e4Context); > } >#P org.eclipse.e4.demo.e4photo >Index: css/e4photo.css >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/examples/org.eclipse.e4.demo.e4photo/css/e4photo.css,v >retrieving revision 1.5 >diff -u -r1.5 e4photo.css >--- css/e4photo.css 24 Feb 2009 04:07:30 -0000 1.5 >+++ css/e4photo.css 9 Jun 2009 23:31:26 -0000 >@@ -70,6 +70,7 @@ > Tree { > font: Verdana 8px; > color: #666666; >+ background: url(bluefade-full.gif); > } > > Composite Shell { >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/examples/org.eclipse.e4.demo.e4photo/plugin.xml,v >retrieving revision 1.7 >diff -u -r1.7 plugin.xml >--- plugin.xml 2 Apr 2009 15:50:08 -0000 1.7 >+++ plugin.xml 9 Jun 2009 23:31:26 -0000 >@@ -66,6 +66,10 @@ > name="applicationCSS" > value="platform:/plugin/org.eclipse.e4.demo.e4photo/css/e4photo.css"> > </property> >+ <property >+ name="applicationCSSResources" >+ value="platform:/plugin/org.eclipse.e4.demo.e4photo/images/"> >+ </property> > </product> > </extension> > >#P org.eclipse.e4.ui.examples.css >Index: src/org/eclipse/e4/ui/examples/css/editor/AbstractCSSSWTEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/examples/org.eclipse.e4.ui.examples.css/src/org/eclipse/e4/ui/examples/css/editor/AbstractCSSSWTEditor.java,v >retrieving revision 1.3 >diff -u -r1.3 AbstractCSSSWTEditor.java >--- src/org/eclipse/e4/ui/examples/css/editor/AbstractCSSSWTEditor.java 28 Jan 2009 23:55:05 -0000 1.3 >+++ src/org/eclipse/e4/ui/examples/css/editor/AbstractCSSSWTEditor.java 9 Jun 2009 23:31:26 -0000 >@@ -17,8 +17,11 @@ > import org.eclipse.e4.ui.css.core.dom.IElementProvider; > import org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties; > import org.eclipse.e4.ui.css.core.engine.CSSEngine; >+import org.eclipse.e4.ui.examples.css.Activator; > import org.eclipse.e4.ui.examples.css.editor.AbstractCSSEditor; > import org.eclipse.e4.ui.css.core.serializers.CSSSerializerConfiguration; >+import org.eclipse.e4.ui.css.core.util.impl.resources.FileResourcesLocatorImpl; >+import org.eclipse.e4.ui.css.core.util.impl.resources.OSGiResourceLocator; > import org.eclipse.e4.ui.css.swt.dom.SWTElementProvider; > import org.eclipse.e4.ui.css.swt.dom.html.SWTHTMLElementProvider; > import org.eclipse.e4.ui.css.swt.engine.CSSSWTEngineImpl; >@@ -527,7 +530,10 @@ > * @see org.eclipse.e4.ui.core.css.examples.csseditors.AbstractCSSEditor#createCSSEngine() > */ > protected CSSEngine createCSSEngine() { >- return new CSSSWTEngineImpl(shell.getDisplay()); >+ CSSEngine engine = new CSSSWTEngineImpl(shell.getDisplay()); >+ engine.getResourcesLocatorManager().registerResourceLocator( >+ new FileResourcesLocatorImpl()); >+ return engine; > } > > /* >#P org.eclipse.e4.ui.css.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF,v >retrieving revision 1.8 >diff -u -r1.8 MANIFEST.MF >--- META-INF/MANIFEST.MF 7 May 2009 15:07:08 -0000 1.8 >+++ META-INF/MANIFEST.MF 9 Jun 2009 23:31:27 -0000 >@@ -28,5 +28,6 @@ > org.eclipse.e4.ui.css.xml.engine, > org.eclipse.e4.ui.css.xml.properties.css2 > Require-Bundle: org.w3c.css.sac;bundle-version="1.3.0", >- org.apache.batik.css;bundle-version="[1.6.0,1.7.0)" >+ org.apache.batik.css;bundle-version="[1.6.0,1.7.0)", >+ org.eclipse.core.runtime;bundle-version="3.5.0" > Bundle-RequiredExecutionEnvironment: J2SE-1.5 >Index: src/org/eclipse/e4/ui/css/core/util/impl/resources/ResourcesLocatorManager.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/util/impl/resources/ResourcesLocatorManager.java,v >retrieving revision 1.3 >diff -u -r1.3 ResourcesLocatorManager.java >--- src/org/eclipse/e4/ui/css/core/util/impl/resources/ResourcesLocatorManager.java 27 Nov 2008 22:56:56 -0000 1.3 >+++ src/org/eclipse/e4/ui/css/core/util/impl/resources/ResourcesLocatorManager.java 9 Jun 2009 23:31:27 -0000 >@@ -37,7 +37,6 @@ > > public ResourcesLocatorManager() { > registerResourceLocator(new HttpResourcesLocatorImpl()); >- registerResourceLocator(new FileResourcesLocatorImpl()); > } > > /* >Index: src/org/eclipse/e4/ui/css/core/util/impl/resources/OSGiResourceLocator.java >=================================================================== >RCS file: src/org/eclipse/e4/ui/css/core/util/impl/resources/OSGiResourceLocator.java >diff -N src/org/eclipse/e4/ui/css/core/util/impl/resources/OSGiResourceLocator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/css/core/util/impl/resources/OSGiResourceLocator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+package org.eclipse.e4.ui.css.core.util.impl.resources; >+ >+import java.io.InputStream; >+import java.io.InputStreamReader; >+import java.io.Reader; >+import java.net.URL; >+ >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.e4.ui.css.core.util.resources.IResourceLocator; >+ >+public class OSGiResourceLocator implements IResourceLocator { >+ >+ private String startLocation; >+ >+ public OSGiResourceLocator(String start) { >+ startLocation = start; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.e4.ui.css.core.util.resources.IURIResolver#resolve(java.lang.String) >+ */ >+ public String resolve(String uri) { >+ return uri; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.e4.ui.css.core.util.resources.IResourceLocator#getInputStream(java.lang.String) >+ */ >+ public InputStream getInputStream(String uri) throws Exception { >+ return FileLocator.resolve( >+ new URL(startLocation + uri) >+ ).openStream(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.e4.ui.css.core.util.resources.IResourceLocator#getReader(java.lang.String) >+ */ >+ public Reader getReader(String uri) throws Exception { >+ return new InputStreamReader(getInputStream(uri)); >+ } >+ >+ >+}
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 277471
: 138735