Reuse Project Explorer' view for your custom plugin project

蓝咒 提交于 2020-01-03 03:48:08

问题


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:

  1. 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 ?

  2. 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.

  3. 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);
        }
    }


回答1:


If you want to customize your own ProjectExplorer view, you need to study the Common Navigator Framework docs and tutorials like this one



来源:https://stackoverflow.com/questions/29432507/reuse-project-explorer-view-for-your-custom-plugin-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!