我创建了一个带有最小模板的新插件项目并定义了两个视图。 这是我的第一个观点:
public class MyView extends ViewPart {
public MyView() {
// TODO Auto-generated constructor stub
}
@Override
public void createPartControl(Composite parent) {
Text text = new Text(parent, SWT.BORDER);
text.setText("First view");
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
}
这是我的第二个观点:
public class SecondView extends ViewPart {
public SecondView() {
// TODO Auto-generated constructor stub
}
@Override
public void createPartControl(Composite parent) {
Text text = new Text(parent, SWT.BORDER);
text.setText("Second view");
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
}
这是我的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="com.rcptest.testez.Application">
</run>
</application>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
name="RCP Perspective"
class="com.rcptest.testez.Perspective"
id="com.rcptest.testez.perspective">
</perspective>
</extension>
<extension
point="org.eclipse.ui.views">
<view
class="com.rcptest.testez.view.MyView"
id="com.rcptest.testez.view.MyView"
name="FirstView"
restorable="true">
</view>
<view
class="com.rcptest.testez.view.SecondView"
id="com.rcptest.testez.view.SecondView"
name="SecondView"
restorable="true">
</view>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="*">
<view
id="com.rcptest.testez.view.MyView"
minimized="false"
ratio="0.3f"
relationship="top"
relative="org.eclipse.ui.editorss">
</view>
<view
id="com.rcptest.testez.view.SecondView"
minimized="false"
ratio="0.5f"
relationship="bottom"
relative="org.eclipse.ui.editorss">
</view>
</perspectiveExtension>
</extension>
</plugin>
当我运行应用程序时,我只能看到我的第一个视图。我真的不知道我哪里出错了。我怎样才能显示第二个视图?
修改 透视课程:
public void createInitialLayout(IPageLayout layout) {
layout.addView("com.rcptest.testez.view.MyView", IPageLayout.TOP,
IPageLayout.RATIO_MAX, IPageLayout.ID_EDITOR_AREA);
layout.addView("com.rcptest.testez.view.SecondView", IPageLayout.BOTTOM,
IPageLayout.RATIO_MAX, IPageLayout.ID_EDITOR_AREA);
}
答案 0 :(得分:1)
您的Perspective
课程表示每个视图应占据95%的空间(IPageLayout.RATIO.MAX
),这是不可能的。
如果您还需要编辑区域,则必须指定加起来不超过100%(1.0)或更少的比率。例如:
layout.addView("com.rcptest.testez.view.MyView", IPageLayout.TOP,
0.3f, IPageLayout.ID_EDITOR_AREA);
layout.addView("com.rcptest.testez.view.SecondView", IPageLayout.BOTTOM,
0.3f, IPageLayout.ID_EDITOR_AREA);
注意:当您使用修改过的透视图重新运行测试时,可能需要执行“重置透视”。