【发布时间】:2023-03-20 01:44:01
【问题描述】:
我创建了一个以视图为模板的 RCP 应用程序 最初创建项目后,我的透视类看起来像这样
import org.eclipse.ui.IPageLayout;
public class Perspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
layout.setEditorAreaVisible(false);
layout.setFixed(true);
}
}
我创建了一个新视图并添加到名为 ErrorView 的 org.eclipse.ui.views 扩展中,并生成了该视图的相应类。 我对透视类做了一个小改动
public class Perspective implements IPerspectiveFactory {
private URL u;
private HttpURLConnection huc;
public void createInitialLayout(IPageLayout layout) {
try{
u= new URL("https://google.com/");
huc = ( HttpURLConnection )u.openConnection ();
huc.setRequestMethod("GET");
huc.connect();
if(huc.getResponseCode()==200){
layout.setEditorAreaVisible(false);
layout.setFixed(true);
}
else{
layout.addStandaloneView(View1.ID, true, IPageLayout.LEFT, 1.0f, layout.getEditorArea());
layout.getViewLayout(View1.ID).setCloseable(false);
layout.setEditorAreaVisible(false);
}
}
catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
layout.addStandaloneView(View1.ID, true, IPageLayout.LEFT, 1.0f, layout.getEditorArea());
layout.getViewLayout(View1.ID).setCloseable(false);
layout.setEditorAreaVisible(false);
}
}
}
肯定是 else/catch 块被执行
如何使 ErrorView 占据整个视角而不显示基本视图或完全隐藏基本视图(默认视图)。
【问题讨论】:
-
IPerspectiveFactory类只执行一次,用于在第一次打开透视图时定义布局。之后它不会运行,因为布局是已知的。你想要什么行为?它是一种启动行为吗(例如您重新启动并且打开了一个编辑器但 google 不会给您信息)? -
@Paul Webster 更准确地说,我想单独显示完全适合透视图的 erroview,而不是加载默认视图(上图中的右侧部分)。是的,这是显示视图之前的一种启动行为问题
标签: plugins eclipse-plugin swt eclipse-rcp jface