【问题标题】:Why is this Eclipse RCP plugin missing a view?为什么这个 Eclipse RCP 插件缺少视图?
【发布时间】:2019-06-02 23:43:06
【问题描述】:

我正在试验 Eclipse RCP 应用程序处理其插件的方式。在 Eclipse IDE 中,我创建了一个 Eclipse RCP 3.x 项目,其视图生成了所有必要的文件并且工作正常。

假设我可以通过删除 plugin.xml 文件的各个部分将这个应用程序转换为只保留一个空透视图的应用程序,我将所有处理视图的行注释掉,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
     id="application"
     point="org.eclipse.core.runtime.applications">
       <application>
         <run
           class="pluginwithview.Application">
         </run>
       </application>
    </extension>
    <extension
     point="org.eclipse.ui.perspectives">
       <perspective
        name="Perspective"
        class="pluginwithview.Perspective"
        id="PluginWithView.perspective">
       </perspective>
    </extension>
    <!-- 
       even without these lines 
       there's an Exception thrown saying:
       "Could not create the view: PluginWithView.view
    -->  
    <!-- <extension
          point="org.eclipse.ui.views">
          <view
            name="View"
            inject="true"
            class="pluginwithview.View"
            id="PluginWithView.view">
          </view>
         </extension>
         <extension
           point="org.eclipse.ui.perspectiveExtensions">
           <perspectiveExtension
              targetID="*">
           <view
              standalone="true"
              minimized="false"
              relative="org.eclipse.ui.editorss"
              relationship="left"
              id="PluginWithView.view">
           </view>
         </perspectiveExtension>
      </extension> -->
   <extension
     point="org.eclipse.ui.menus">
     <menuContribution
        locationURI="menu:org.eclipse.ui.main.menu">
     <menu
           label="File">
           <command
              commandId="org.eclipse.ui.file.exit"
              label="Exit">
           </command>
     </menu>
     </menuContribution>
   </extension>
</plugin>

但应用程序现在看起来像这样,而不是显示一个空的透视图:

我必须怎么做才能让应用程序不搜索视图?是否有我缺少的配置文件? (我知道没有视图有几个原因,但现在我主要对 Eclipse RCP 应用程序的内部工作感兴趣)

【问题讨论】:

    标签: eclipse-plugin eclipse-rcp


    【解决方案1】:

    观点会记住它们所包含的观点。如果您更改透视定义,则必须进行透视重置(“Window > Perspective > Reset Perspective”)以使其读取更新后的定义。

    对于测试,您还可以在 RCP 运行配置的“程序参数”部分中指定 -clean-clearPersistedState 选项以丢弃所有保存的信息。

    【讨论】:

    • 只使用-clearPersistedState 选项就可以了。谢谢。您是否可能确切地知道 Perspectives 存储状态的位置和方式?
    • 我认为对于 Eclipse 4,它位于 .metadata/plugins/org.eclipse.e4.workbench 目录中的 workbench.xmi - 这是 -clearPersistedState 删除的文件。
    • 没错,我刚刚进行了几次试运行。使用-clearPersistedState 时,旧的workbench.xmi 文件将被删除并创建一个新文件。非常有价值的提示。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-14
    • 1970-01-01
    • 2015-01-31
    • 2010-11-04
    • 1970-01-01
    相关资源
    最近更新 更多