我想在执行操作时打开包含表格的视图。Eclipse RCP - 如何以编程方式创建和打开View?
我可以viewId通过代码开放的观点:在plugin.xml中定义
display.asyncExec(new Runnable(){
public void run() {
ApplicationGIS.getView(true, viewId);
}});
这种观点的ID,但我要传递一些参数表上的这一观点。我可以以编程方式创建自定义视图,但是这次我无法打开它,因为我没有它的ID。这里是我的视图类:
public class MyCustomView extends ViewPart {
private Text text;
private Table table;
private TableViewer tableViewer;
@Override
public void createPartControl(Composite parent) {
// TODO Auto-generated method stub
parent.setLayout(new GridLayout(4, false));
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
composite.setLayout(new GridLayout(2, false));
text = new Text(composite, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Composite composite_1 = new Composite(composite, SWT.NONE);
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
GridLayout gl_composite_1 = new GridLayout(1, false);
gl_composite_1.horizontalSpacing = 0;
gl_composite_1.marginHeight = 0;
gl_composite_1.marginWidth = 0;
gl_composite_1.verticalSpacing = 0;
composite_1.setLayout(gl_composite_1);
tableViewer = new TableViewer(composite_1, SWT.BORDER | SWT.FULL_SELECTION);
table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
}
那么如何访问这个编程创建的视图并打开它?
什么Eclipse版本你使用3.x或4.x的? – Chriss 2013-03-14 10:50:12
我正在使用3.x.顺便说一句,我会尝试你的答案,谢谢。 – cgrgcn 2013-03-14 11:28:19