项目资源管理器未在 Eclipse RCP 应用程序中显示项目

问题描述 投票:0回答:2

在 stackoverflow 的许多成员的帮助下,我终于完成了我的第一个 RCP 申请。

我的项目资源管理器遇到一些问题

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

图:

我的 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 添加到依赖项列表中

java eclipse eclipse-rcp rcp perspective
2个回答
1
投票

对于初始空视图,您需要重写 RCP 定义插件的 WorkbenchAdvisor 类中的

getDefaultPageInput
,如下所示:

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

0
投票

我遇到了类似的问题:项目资源管理器没有显示任何项目,即使在我创建了一些项目之后也是如此。

“新建项目”向导中的“项目引用”页面为每个项目都有一个未标记的复选框,因此它们以某种形式存在,但项目资源管理器似乎没有选择它们。根据 memery 的答案添加

getDefaultPageInput
方法后,我能够创建一个项目,它会出现在资源管理器中,但它的名称是空白的,就像在“项目引用”页面中一样。如果我关闭并重新打开应用程序,资源管理器将返回“无项目”。

IDE.registerAdapters
中调用
ApplicationWorkbenchAdvisor.java
后,它对我来说完全有效:

@Override
public void preStartup() {
    super.preStartup();
    IDE.registerAdapters();
}
© www.soinside.com 2019 - 2024. All rights reserved.