我想在執行操作時打開包含表格的視圖。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