我目前正在学习“创建Eclipse插件”教程,但我被困在下面的阶段:
enter image description here
我做的最后一件事是为“Hello World!“扩展org. eclipse. ui. views的视图。但是,我得到错误“类型SampleView的层次结构不一致”。
据我所知,这个错误通常是由继承类(在本例中是ViewPart)的.jar文件不在项目的构建路径上引起的。
但是,目标平台确实包含org.eclipse.ui.views插件(其中应该包含org. eclipse. ui. views. jar文件):
enter image description here
任何帮助与此将不胜感激!
更新:以下是内容…
plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<category
id="com.example.helloworld.commands.category"
name="Sample Category">
</category>
<command
categoryId="com.example.helloworld.commands.category"
name="Display Hello World"
id="com.example.helloworld.commands.sampleCommand">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.example.helloworld.handlers.SampleHandler"
commandId="com.example.helloworld.commands.sampleCommand">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="com.example.helloworld.commands.sampleCommand"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="com.example.helloworld.menus.sampleMenu"
label="Sample Menu"
mnemonic="M">
<command
commandId="com.example.helloworld.commands.sampleCommand"
id="com.example.helloworld.menus.sampleCommand"
mnemonic="S">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="com.example.helloworld.toolbars.sampleToolbar">
<command
id="com.example.helloworld.toolbars.sampleCommand"
commandId="com.example.helloworld.commands.sampleCommand"
icon="icons/sample.png"
tooltip="Say hello world">
</command>
</toolbar>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.views">
<category
id="com.example.helloworld.view.helloworldcategory"
name="Hello World!">
</category>
<view
category="com.example.helloworld.view.helloworldcategory"
class="com.example.helloworld.view.SampleView"
id="com.example.helloworld.view.helloworldview"
name="Hello World!"
restorable="true">
</view>
</extension>
</plugin>
MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Helloworld
Bundle-SymbolicName: com.example.helloworld;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EXAMPLE
Require-Bundle: org.eclipse.ui
Automatic-Module-Name: com.example.helloworld
Bundle-RequiredExecutionEnvironment: JavaSE-17
1条答案
按热度按时间z9ju0rcb1#
看起来您还需要MANIFEST.MF中的
org.eclipse.core.runtime
插件所以清单的
Require-Bundle
部分应该是:在这样做之后,你可能仍然会有一个错误显示为视图部分,但现在它将是关于不实现
createPartControl
和setFocus
方法。Quick Fix将处理添加以下内容的问题: