import java.net.URL;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.eclipse.ui.internal.ide.model.WorkbenchAdapterBuilder;
import org.eclipse.ui.internal.intro.impl.util.ImageUtil;
import org.eclipse.ui.views.navigator.ResourceNavigator;
import org.osgi.framework.Bundle;
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
@Override
public void postStartup() {
// TODO Auto-generated method stub
try {
IWorkbenchPage activePage = this.getWorkbenchConfigurer().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = activePage.showView("org.eclipse.jdt.ui.PackageExplorer");
PackageExplorerPart packageExplorer = ((PackageExplorerPart)view);
packageExplorer.getTreeViewer().setLabelProvider(new PackageExplorerLabelProvider());
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
super.postStartup();
}
class PackageExplorerLabelProvider extends LabelProvider{
@Override
public Image getImage(Object element) {
// TODO Auto-generated method stub
Image image = null;
String text = element.toString();
System.out.println(text);
final Bundle bundle = Platform.getBundle("pluginid");
final URL url = bundle.getEntry("icons/full/eview16/projects.gif");
final URL wfUrl = bundle.getEntry("icons/wfeditor.gif");
// image = ImageDescriptor.createFromURL(url).createImage();
if(text.startsWith("P/",0)){
image = ImageDescriptor.createFromURL(url).createImage();
}
if(text.startsWith("L/",0)){
image = ImageDescriptor.createFromURL(wfUrl).createImage();
}
return image;
}
@Override
public String getText(Object element) {
// TODO Auto-generated method stub
String text = element.toString();
text = text.substring(2,text.length());
int pos = text.indexOf("/");
if(pos == -1){
return text;
}else{
if(text.endsWith(".project")){
return "Your name";
}else{
text = text.substring(pos+1,text.length());
}
}
return text;
}
}
}
注意要在rcp插件的dependencies里加入org.eclipse.jdt.ui依赖才行,否则PackageExplorerPart packageExplorer = ((PackageExplorerPart)view);不能引用到。
分享到:
相关推荐
ECLIPSE+SWTJFACE核心应用 附有案例的源代码光盘Eclipse+SWT+JFace核心应用光盘,其中工程SuperCRM是一个比较完整的介绍RCP应用的项目,但是在真正运行该工程时,却存在许多bug问题,本人通过调试解决了上述问题,...
这是rcp中重要的代码 你们可以了解到rcp技术
eclipse RCP的mp3工程,非常棒的一个rcp应用程序,学习学习,快来下
RCP 产品介绍图片
用视图显示在GEF编辑器编辑好的图形 在视图里加入GraphicalViewer viewer = new ScrollingGraphicalViewer(); viewer.createControl(parent);
RCP&OSGI;
RCP在线升级RCP在线升级RCP在线升级RCP在线升级RCP在线升级
一个在RCP 的View中显示JFreeChart报表的小例子,所需要用到的Jar包都已经包含在里面 没有分的也可以去我的博客看看,也有相关的代码。
RCP系统使用的弹出式日期控件,可切换上月下月,前一年后一年,可选择年、月
RCP导出EXE 老大难问题。 RCp 程序导出步骤,保证能够导出~
将RCP工程转成RAP工程,在浏览器中运行。
1.2.Eclipse RCP 建设风格——插件,扩展和扩展点 1 2.创建你的第一个RCP程序 1 2.1.创建一个RCP程序 2 2.2.启动你的RCP程序 5 2.3.应用程序VS 产品 6 3.应用程序里的插件ID 7 4.Actions的用法(菜单和...
在RCP工程中需要的应用jar,转换成插件,然后依赖到RCP工程中去,这样减小了插件包的大小。
eclipseRCP的数独工程,非常不错的一个实例,大家快点下载吧
activemq rcp测试的依赖资源,不包含rcp的例子
RCP程序设计主要组件的文档,可以适用于初学RCP程序设计的同学。
Eclipse RCP允许开发者使用eclipse结构风格设计弹性的可扩展的应用程序,可重用Eclipse中已存在的方法和编码模式。俗话说,万事开头难。Eclipse RCP入手可能会比较困难、费时。接下来我们将主要讲述如何让RCP工作. ...
clipse RCP允许开发者使用eclipse结构风格设计弹性的可扩展的应用程序,可重用Eclipse中已存在的方法和编码模式。俗话说,万事开头难。Eclipse RCP入手可能会比较困难、费时。接下来我们将主要讲述如何让RCP工作 ...
有关rcp的内容 是rcp入门的好帮手,rcp自学的好帮手
Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT