<tfoot id='QQy31'></tfoot>

      <bdo id='QQy31'></bdo><ul id='QQy31'></ul>
    <i id='QQy31'><tr id='QQy31'><dt id='QQy31'><q id='QQy31'><span id='QQy31'><b id='QQy31'><form id='QQy31'><ins id='QQy31'></ins><ul id='QQy31'></ul><sub id='QQy31'></sub></form><legend id='QQy31'></legend><bdo id='QQy31'><pre id='QQy31'><center id='QQy31'></center></pre></bdo></b><th id='QQy31'></th></span></q></dt></tr></i><div id='QQy31'><tfoot id='QQy31'></tfoot><dl id='QQy31'><fieldset id='QQy31'></fieldset></dl></div>
  1. <small id='QQy31'></small><noframes id='QQy31'>

    1. <legend id='QQy31'><style id='QQy31'><dir id='QQy31'><q id='QQy31'></q></dir></style></legend>
    2. 在 Project Explorer (Eclipse) 中查找项目位置

      时间:2023-08-20
      <i id='GtXQi'><tr id='GtXQi'><dt id='GtXQi'><q id='GtXQi'><span id='GtXQi'><b id='GtXQi'><form id='GtXQi'><ins id='GtXQi'></ins><ul id='GtXQi'></ul><sub id='GtXQi'></sub></form><legend id='GtXQi'></legend><bdo id='GtXQi'><pre id='GtXQi'><center id='GtXQi'></center></pre></bdo></b><th id='GtXQi'></th></span></q></dt></tr></i><div id='GtXQi'><tfoot id='GtXQi'></tfoot><dl id='GtXQi'><fieldset id='GtXQi'></fieldset></dl></div>
      <tfoot id='GtXQi'></tfoot>

        <bdo id='GtXQi'></bdo><ul id='GtXQi'></ul>
                  <tbody id='GtXQi'></tbody>

                <small id='GtXQi'></small><noframes id='GtXQi'>

                <legend id='GtXQi'><style id='GtXQi'><dir id='GtXQi'><q id='GtXQi'></q></dir></style></legend>
                本文介绍了在 Project Explorer (Eclipse) 中查找项目位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在上下文菜单中添加了一个按钮,仅当您在项目资源管理器窗口中单击鼠标右键时才会执行.我希望能够在 Project Explorer 窗口中抓取每个项目并抓取 ProjectName 和 ProjectLocation 并将其单独放入一个对象中并返回新的对象数组.

                I've added a button in the context menu to execute only when you right click in the Project Explorer window. I want to be able to grab each project in the Project Explorer window and grab the ProjectName and ProjectLocation and put that into an object by itself and return the new array of objects.

                我找不到访问所需信息的方法.

                I can't find a way to access the information that I need.

                插件.xml

                <extension point="org.eclipse.ui.menus">
                    <menuContribution locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu">
                      <command commandId="helloworld.sample"
                        label="Hello World" style="push">
                      </command>
                    </menuContribution>
                  </extension>
                  <extension point="org.eclipse.ui.commands">
                    <command defaultHandler="helloworld.handler.samplehandler"
                      id="helloworld.sample" name="Sample">
                    </command>
                  </extension>
                

                samplehandler.java

                samplehandler.java

                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                
                IWorkbenchPart viewpart  = page.findView("org.eclipse.ui.navigator.ProjectExplorer");
                
                Tree tree = (Tree) ((TreeViewer) viewpart.getSite().getSelectionProvider()).getControl(); 
                TreeItem[] selTree = tree.getSelection();
                

                我觉得好像 tree 或 selTree 会有我想要的信息,但我找不到.有什么帮助吗?

                I feel as though tree or selTree would have the information I want but I can't find it. Any help?

                推荐答案

                使用来自选择提供者的选择数据:

                Use the selection data from the selection provider:

                IStructuredSelection sel =   
                     (IStructuredSelection)viewpart.getSite().getSelectionProvider().getSelection(); 
                
                Object selObj = sel.getFirstElement();
                
                IProject project =
                   (IProject)Platform.getAdapterManager().getAdapter(selObj, IProject.class);
                
                ... might return null if selection is not the project
                
                String name = project.getName();
                
                IPath location = project.getLocation();
                

                要让所有项目使用:

                IWorkspace workspace = ResourcesPlugin.getPlugin().getWorkspace();
                
                IProject [] projects = workspace.getRoot().getProjects();
                

                这篇关于在 Project Explorer (Eclipse) 中查找项目位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在 Eclipse 4 (RCP/SWT/OSGi) 应用程序中包含 log4j 的正确方法 下一篇:Eclipse IDL 编译

                相关文章

              1. <i id='N9L35'><tr id='N9L35'><dt id='N9L35'><q id='N9L35'><span id='N9L35'><b id='N9L35'><form id='N9L35'><ins id='N9L35'></ins><ul id='N9L35'></ul><sub id='N9L35'></sub></form><legend id='N9L35'></legend><bdo id='N9L35'><pre id='N9L35'><center id='N9L35'></center></pre></bdo></b><th id='N9L35'></th></span></q></dt></tr></i><div id='N9L35'><tfoot id='N9L35'></tfoot><dl id='N9L35'><fieldset id='N9L35'></fieldset></dl></div>

                    <bdo id='N9L35'></bdo><ul id='N9L35'></ul>
                  <legend id='N9L35'><style id='N9L35'><dir id='N9L35'><q id='N9L35'></q></dir></style></legend>

                  <small id='N9L35'></small><noframes id='N9L35'>

                  <tfoot id='N9L35'></tfoot>