我想在执行操作时打开一个包含表格的视图。
我可以通过该代码通过 viewId 打开视图:
display.asyncExec(new Runnable(){
public void run() {
ApplicationGIS.getView(true, viewId);
}});
此视图的 id 在 plugin.xml 上定义,但我必须将一些参数传递给此视图上的表。我可以以编程方式创建我的自定义视图,但这次我无法打开它,因为我没有它的 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
}
}
那么如何访问这个以编程方式创建的视图并打开它呢?