为您的自定义插件项目重用项目资源管理器视图 [英] Reuse Project Explorer' view for your custom plugin project
问题描述
我正在处理一个eclipse插件,并重用项目浏览器视图来显示树的内容。
-
如何禁用排序 - 目前的项目浏览器查看我不想要的排序树节点。是一个单一的地方,我可以改变标志或什么吗?或者我将不得不实施查看分拣机?
-
如何以一种java项目的方式保存扩展状态的项目,我想要相同实现自定义插件项目。
-
如何标记某些节点不显示。我想要几个文件夹被隐藏,不显示在项目浏览器视图中。
插件正在使用向导(INewWizard )创建IProject并添加一些IFolder。
代码片段:
private static IProject createBaseProject(String projectName,URI location){
//可以使用ResourcesPlugin类
IProject newProject = ResourcesPlugin.getWorkspace()。getRoot()。 getProject(PROJECTNAME);
if(!newProject.exists()){
URI projectLocation = location;
IProjectDescription desc = newProject.getWorkspace()。newProjectDescription(newProject.getName());
if(location!= null&& ResourcesPlugin.getWorkspace()。getRoot()。getLocationURI()。equals(location)){
projectLocation = null;
}
desc.setLocationURI(projectLocation);
try {
newProject.create(desc,null);
if(!newProject.isOpen()){
newProject.open(null);
}
} catch(CoreException e){
e.printStackTrace();
}
}
return newProject;
}
private static void createFolder(IFolder folder)throws CoreException {
IContainer parent = folder.getParent();
if(parent instanceof IFolder){
createFolder((IFolder)parent);
}
if(!folder.exists()){
folder.create(false,true,null);
}
}
自己的ProjectExplorer视图,您需要学习常见的导航框架文档和教程,如这一个
I am working on a eclipse plugin and reusing the 'Project Explorer' view to display the tree content.
I have few questions to make it best possible reuse:
How can I disable the sort - currently 'Project Explorer' view sort tree nodes which I dont want. Is thr a single place where i can change the flags or something? Or I will have to implement a View Sorter ?
How can I save the expanded state of projects the way it does for a java project , i want the same to implemented for custom plugin project.
How can I mark some nodes not to be displayed. I want few folders to be hidden and not displayed in 'Project Explorer' view.
Plugin is using Wizards (INewWizard) to create a IProject and add some IFolder(s) to it.
Code snippet:
private static IProject createBaseProject(String projectName, URI location) {
// it is acceptable to use the ResourcesPlugin class
IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (!newProject.exists()) {
URI projectLocation = location;
IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName());
if (location != null && ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location)) {
projectLocation = null;
}
desc.setLocationURI(projectLocation);
try {
newProject.create(desc, null);
if (!newProject.isOpen()) {
newProject.open(null);
}
} catch (CoreException e) {
e.printStackTrace();
}
}
return newProject;
}
private static void createFolder(IFolder folder) throws CoreException {
IContainer parent = folder.getParent();
if (parent instanceof IFolder) {
createFolder((IFolder) parent);
}
if (!folder.exists()) {
folder.create(false, true, null);
}
}
If you want to customize your own ProjectExplorer view, you need to study the Common Navigator Framework docs and tutorials like this one
这篇关于为您的自定义插件项目重用项目资源管理器视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!