[英]CSS not used by Eclipse e4
I want to use CSS styling for some widgets in only one plugin of my application.我只想在我的应用程序的一个插件中对某些小部件使用 CSS 样式。
The Plugin's plugin.xml contains:插件的 plugin.xml 包含:
<extension
point="org.eclipse.e4.ui.css.swt.theme">
<theme
basestylesheeturi="css/default.css"
id="my.app.id.css"
label="Planning Theme">
</theme>
</extension>
The Plugin.xml's extension tab didn't suggest the extension point, but after I entered it in the file, I could see the properties. Plugin.xml的扩展选项卡没有提示扩展点,但我在文件中输入后,我可以看到属性。 One of which is "basestylesheeturi" and it allows me to browse for the file.
其中之一是“basestylesheeturi”,它允许我浏览文件。 So the file definitely exists.
所以这个文件肯定存在。
@charset "ISO-8859-1";
#MYTESTLABEL{
color: blue;
}
Text {
color: COLOR-CYAN;
background-color: COLOR-WIDGET-BACKGROUND;
}
Button {
font: Verdana 24px;
border-color: #EEEE00;
border-width: 2;
}
But it isn't used by Eclipse. When I start my Application, I cannot see any styles from the css file.但它未被 Eclipse 使用。当我启动我的应用程序时,我无法从 css 文件中看到任何 styles。 Setting colors to black or fonts to huge sizes... nothing has an effect.
将 colors 设置为黑色或将 fonts 设置为大尺寸......没有任何效果。 Even Syntax Errors in the css file won't result in an error message.
即使 css 文件中的语法错误也不会导致错误消息。
What can I do to ensure my plugin uses this css file for Texts, Buttons, etc.?我该怎么做才能确保我的插件将这个 css 文件用于文本、按钮等? Is my old Eclipse version maybe not supporting the extension point?
我的旧 Eclipse 版本可能不支持扩展点吗?
Version: Oxygen.3 Release (4.7.3)
EDIT编辑
If I understand greg's answer correctly, I have to use both extension points ( org.eclipse.core.runtime.product
and org.eclipse.e4.ui.css.swt.theme
).如果我正确理解了格雷格的回答,我必须同时使用两个扩展点(
org.eclipse.core.runtime.product
和org.eclipse.e4.ui.css.swt.theme
)。 Additionally I added the css/default.css to the bin.includes section of the build.properties.此外,我将 css/default.css 添加到 build.properties 的 bin.includes 部分。 The style is still not used.
该样式仍未使用。
There is a cssTheme already defined in another plugin.xml for the product by using those two extension points.通过使用这两个扩展点,已经在产品的另一个 plugin.xml 中定义了一个 cssTheme。 From my understanding it should be possible to define a second theme only for a certain plugin.
根据我的理解,应该可以只为某个插件定义第二个主题。
It may be that I need to implement a ThemeSwitchHandler
as vogella describes here but it's unclear how to make use of it (how and when to call it).可能我需要实现一个
ThemeSwitchHandler
,正如vogella 在这里描述的那样,但不清楚如何使用它(如何以及何时调用它)。
That extension point just defines a theme, it doesn't tell e4 to use it.该扩展点只是定义了一个主题,并没有告诉 e4 使用它。
For a pure e4 RCP you specify the theme to be used in the cssTheme
property of the org.eclipse.core.runtime.products
extension point which defines your product:对于纯 e4 RCP,您指定要在定义产品的
org.eclipse.core.runtime.products
扩展点的cssTheme
属性中使用的主题:
<extension
id="product"
point="org.eclipse.core.runtime.products">
<product
name="%product.name"
application="org.eclipse.e4.ui.workbench.swt.E4Application">
<property
name="cssTheme"
value="my.app.id.css">
</property>
... other properties
If there is already a theme defined in the RCP you can contribute an extra stylesheet file to the theme.如果 RCP 中已经定义了一个主题,您可以为该主题提供一个额外的样式表文件。 For example:
例如:
<extension
point="org.eclipse.e4.ui.css.swt.theme">
<stylesheet
uri="css/e4-dark_pde_prefstyle.css">
<themeid
refid="org.eclipse.e4.ui.css.theme.e4_dark">
</themeid>
</stylesheet>
</extension>
Which adds an extra file to the standard Eclipse org.eclipse.e4.ui.css.theme.e4_dark
dark theme.它向标准 Eclipse
org.eclipse.e4.ui.css.theme.e4_dark
黑暗主题添加了一个额外的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.