cgr*_*gcn 0 swt eclipse-plugin view eclipse-rcp
我想在执行操作时打开包含表的View.
我可以通过viewId打开该代码的视图:
display.asyncExec(new Runnable(){
public void run() {
ApplicationGIS.getView(true, viewId);
}});
Run Code Online (Sandbox Code Playgroud)
此视图的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
}
}
Run Code Online (Sandbox Code Playgroud)
那么如何访问这个以编程方式创建的视图并打开它呢?
在Eclipse 3.x中,您可以打开如下所示的View:
MyView view = (MyView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(viewer_ID);
Run Code Online (Sandbox Code Playgroud)
或者,如果要实现命令处理程序,则可以调用:
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(viewId);
Run Code Online (Sandbox Code Playgroud)
要设置一些内容,您只需添加一个类似于void setInput(MyContent input)ViewPart的方法,并在打开它之后将所需的参数传递给此方法.
| 归档时间: |
|
| 查看次数: |
10404 次 |
| 最近记录: |