[align=left]我们在rcp的项目开发中,view和editor的字体都是eclipse默认的。但是,很多时候,由于其字体太小或者想改变其样式,需要能够设置tilte的字体。eclipse里可以非常方便的设置其字体和颜色:按照如下路径:
Preferences/General/Appearance/Colors and Fonts/Part title font
即可以更改view和editor的外观。
但是,在rcp中,该怎样重新设置其值呢。找了很久发现,当在eclipse中作如上修改后,在eclipse的工作空间workspace下有一个配置文件保存了其修改后的值,只要找到这个值,我们就有办法了。具体的路径如下,${workspace}代表当前你正在使用的workspace路径。
${workspace}\.metadata\.plugins\org.eclipse.core.runtime\.settings
\org.eclipse.ui.workbench.prefs
在org.eclipse.ui.workbench.prefs文件中多了一行记录,类似于:
org.eclipse.ui.workbench.TAB_TEXT_FONT
=1|\u5B8B\u4F53|11.0|1|WINDOWS|1|-16|0|0|0|700|0|0|0|-122|3|2|1|2|\u5B8B\u4F53
就是这个TAB_TEXT_FONT属性,想死我了。
其中红色的11代表字体大小,700代表粗体。如果是normal则为400.\u5B8B\u4F53代表的是unicode编码的
"宋体"
好了,知道了这个参数,该怎么用呢??
在rcp中,我们有一个
plugin_customization.ini的全局配置文件。很多配置可以写在代码里也可以写在这个配置项中。比如设置view和editor的tab样式为非传统的样式,可以这么写:
org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false
该配置文件的书写格式一般为:
<pluginId>/<preferenceName>=<preferenceValue>
这里,我们要想改变view和editor的title字体,则可以写成:
org.eclipse.ui.workbench/org.eclipse.ui.workbench.TAB_TEXT_FONT
=1|\u5B8B\u4F53|11.0|0|WINDOWS|1|-16|0|0|0|700|0|0|0|-122|3|2|1|2|\u5B8B\u4F53
当然了,还有很多的配置都可以写在plugin_customization.ini文件中。
从org.eclipse.ui.internal.IWorkbenchThemeConstants接口中我们能够看见eclipse系统定义的一些可配属性。该接口完整代码如下
/*******************************************************************************
* Copyright (c) 2004, 2007 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.ui.internal;
/**
* A source of color/font/theme data constants used throughout the workbench.
*
* @since 3.0
*/
public interface IWorkbenchThemeConstants {
public static final String TAB_TEXT_FONT = "org.eclipse.ui.workbench.TAB_TEXT_FONT"; //$NON-NLS-1$
public static final String VIEW_MESSAGE_TEXT_FONT = "org.eclipse.ui.workbench.VIEW_MESSAGE_TEXT_FONT"; //$NON-NLS-1$
public static final String ACTIVE_TAB_TEXT_COLOR = "org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR"; //$NON-NLS-1$
public static final String ACTIVE_NOFOCUS_TAB_TEXT_COLOR = "org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_TEXT_COLOR"; //$NON-NLS-1$
public static final String INACTIVE_TAB_TEXT_COLOR = "org.eclipse.ui.workbench.INACTIVE_TAB_TEXT_COLOR"; //$NON-NLS-1$
public static final String ACTIVE_TAB_BG_START = "org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"; //$NON-NLS-1$
public static final String ACTIVE_TAB_BG_END = "org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"; //$NON-NLS-1$
public static final String ACTIVE_TAB_HIGHLIGHT = "org.eclipse.ui.workbench.ACTIVE_TAB_HIGHLIGHT"; //$NON-NLS-1$
public static final String ACTIVE_TAB_HIGHLIGHT_START = "org.eclipse.ui.workbench.ACTIVE_TAB_HIGHLIGHT_START"; //$NON-NLS-1$
public static final String ACTIVE_NOFOCUS_TAB_BG_START = "org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START"; //$NON-NLS-1$
public static final String ACTIVE_NOFOCUS_TAB_BG_END = "org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END"; //$NON-NLS-1$
public static final String INACTIVE_TAB_BG_START = "org.eclipse.ui.workbench.INACTIVE_TAB_BG_START"; //$NON-NLS-1$
public static final String INACTIVE_TAB_BG_END = "org.eclipse.ui.workbench.INACTIVE_TAB_BG_END"; //$NON-NLS-1$
public static final String ACTIVE_TAB_PERCENT = "org.eclipse.ui.workbench.ACTIVE_TAB_PERCENT"; //$NON-NLS-1$
public static final String ACTIVE_NOFOCUS_TAB_PERCENT = "org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_PERCENT"; //$NON-NLS-1$
public static final String INACTIVE_TAB_PERCENT = "org.eclipse.ui.workbench.INACTIVE_TAB_PERCENT"; //$NON-NLS-1$
public static final String ACTIVE_TAB_VERTICAL = "org.eclipse.ui.workbench.ACTIVE_TAB_VERTICAL"; //$NON-NLS-1$
public static final String ACTIVE_NOFOCUS_TAB_VERTICAL = "org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_VERTICAL"; //$NON-NLS-1$
public static final String INACTIVE_TAB_VERTICAL = "org.eclipse.ui.workbench.INACTIVE_TAB_VERTICAL"; //$NON-NLS-1$
}
借助于这个接口,我们可以了解到很多的配置项信息。
从上面可以看见进行view和editor外观颜色的设置,颜色的设置可以用扩展点来实现,会在后续的文章中介绍这种设置颜色的方法。
先写到这里吧
[/align]
分享到:
相关推荐
RCP入门: 1.View 2.Editor
RCP的VIEWER和EDITOR做成的压缩包,可以下载了看看,是转载了别人的,不过忘了哪弄的了
NULL 博文链接:https://mojianpo.iteye.com/blog/1000437
rcp editor实例的项目代码,eclipse插件开发,可以下载来学习一下
RCP中文入门教程,RCP中文入门教程,RCP中文入门教程,RCP中文入门教程
rcp editor实例的项目代码,eclipse插件开发2,观察观察,学习学习
java中RCP中使用JNI
索尼 sony rcp 1500 中文操作手册,非常好,是中文的,希望大家多多下载 谢谢谢谢,让我多赚些积分
一个在RCP 的View中显示JFreeChart报表的小例子,所需要用到的Jar包都已经包含在里面 没有分的也可以去我的博客看看,也有相关的代码。
RCP中文入门教程.pdf
难得的Eclipse插件RCP中文入门教程
RCP中使用adapter扩展模型为IPropertySource,达到显示属性视图的目的;详细介绍了各种适配器方式。
RCP&OSGI;
Eclipse RCP中使用第三方包,图文并茂很不错。
RCP中文入门教程RCP中文入门教程RCP中文入门教程RCP中文入门教程
RCP程序中集成其他插件的配置方法RCP程序中集成其他插件的配置方法RCP程序中集成其他插件的配置方法
rcp中英文双版 建议读英文版 这样更有助于提高