2013-09-24 56 views
2

我想在Eclipse RCP应用程序添加工具栏,我试着写在fillCoolBar函数的代码在ActionBarAdvisor.java,也使用扩展。但其他插件提供的扩展没有正确对齐。我的猜测是工具栏内的各种toolbarManager名称不正确。 任何人都可以告诉我如何添加所有图标,以便通过其他插件添加并由我添加的额外图标正确对齐? 每次我重新启动或打开一个新的工作空间时,图标间距都会改变! 我附上了问题的图片。添加工具栏在Eclipse RCP应用程序

Coolbar problem in eclipse application

在fillCoolBar的代码如下:

@Override 
protected void fillCoolBar(ICoolBarManager coolBar){ 
     IToolBarManager fileToolbar1 = new ToolBarManager(SWT.WRAP); 
     fileToolbar1.add(new Separator(IWorkbenchActionConstants.NEW_GROUP)); 
     fileToolbar1.add(newDropDownAction); 
     fileToolbar1.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT)); 
     fileToolbar1.add(new GroupMarker(IWorkbenchActionConstants.SAVE_GROUP)); 
     fileToolbar1.add(saveFileAction); 
     fileToolbar1.add(saveAllFilesAction); 
     fileToolbar1.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT)); 
     fileToolbar1.add(printAction); 
     fileToolbar1.add(new GroupMarker(IWorkbenchActionConstants.PRINT_EXT)); 
     coolBar.add(fileToolbar1); 
} 

回答

1

了它。 需要向其添加CSS样式。 采取以下步骤:

1. Open plugin.xml 
2. Add extension org.eclipse.e4.ui.css.swt.theme 
    2.1 Add Theme to above extension. 
     2.1.2 Basestyleurl is relative path to css file, like css/theme.css 
     2.1.2 Give a id like plugin.theme [id can be anything] 
     2.1.3 Fill rest of the fields 
3. In extension org.eclipse.core.runtime.products , the one that has your product 
    3.1 Add a property 
     3.1.1 name: cssTheme [do not change] 
     3.1.2 value: id given in step 2.1.2 
    3.2 Add a property 
     3.2.1 name: applicationCSSResources 
     3.2.2 value: platform:/plugin/plugin.name/images/ 
[inside plugin i have images folder which has all essential images for my css, you can see images used by eclipse css theme in eclipse\plugins\org.eclipse.platform_4.3.0.v20130605-2000\images and the css used is inside css folder ] 

而那就是它! 完成:)

+0

对于非e4应用程序呢?另外,你可以请客气,张贴CSS文件?我需要看看你修改过的标签。谢谢。 – GGrec

+0

那么我不确定那个文件现在在哪里!如果我找到它,我会附上它。 – Destructor

+0

当你有时间,请在这里发布答案:http://stackoverflow.com/questions/20385974/eclipse-kepler-rcp-coolbar-actions-css – GGrec

相关问题