【问题标题】:Project Explorer not showing projects in eclipse rcp application项目资源管理器未在 Eclipse rcp 应用程序中显示项目
【发布时间】:2014-02-22 23:42:40
【问题描述】:

在 stackoverflow 的许多成员的帮助下,我终于完成了我的第一个 RCP 应用程序。

我的 Project Explorer 遇到了一些问题

  1. 当我打开我的 RCP 应用程序时,项目资源管理器似乎没有处于活动状态(当我右键单击我的空项目资源管理器窗口时会唤醒)
  2. 即使它打开,它也不会显示项目探索选项。我的意思是它只显示了项目的名称,没有其他内容(没有显示其中的文件)

Pic:

我的 Perspective.java 文件如下所示

 package kr;

import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class Perspective implements IPerspectiveFactory {

    public void createInitialLayout(IPageLayout layout) {
        String editorArea = layout.getEditorArea();

         // Top left: Project Explorer view and Bookmarks view placeholder
         IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f,
            editorArea);
         topLeft.addView(IPageLayout.ID_PROJECT_EXPLORER);
         topLeft.addPlaceholder(IPageLayout.ID_BOOKMARKS);

         // Bottom left: Outline view and Property Sheet view
         IFolderLayout bottomLeft = layout.createFolder("bottomLeft", IPageLayout.BOTTOM, 0.50f,
                   "topLeft");
         bottomLeft.addView(IPageLayout.ID_OUTLINE);
         bottomLeft.addView(IPageLayout.ID_PROP_SHEET);

         // Bottom right: Task List view
        // layout.addView(IPageLayout.ID_TASK_LIST, IPageLayout.BOTTOM, 0.66f, editorArea);
    }
}

我已将 o.e.ui.navigatoro.e.ui.navigator.resources 添加到依赖列表中

【问题讨论】:

  • Eclipse 工作区是否知道这些文件?如果您的 RCP 中有 File > Refresh,请尝试 IProject.refreshLocal 以编程方式更新项目。

标签: java eclipse eclipse-rcp rcp perspective


【解决方案1】:

对于初始的空视图,您需要覆盖 RCP 定义插件的 WorkbenchAdvisor 类中的 getDefaultPageInput,如下所示:

@Override
public IAdaptable getDefaultPageInput() {
    return ResourcesPlugin.getWorkspace().getRoot();
}

【讨论】:

  • 谢谢,这有帮助:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-20
相关资源
最近更新 更多