-2
我正在寫一個調用程序的Eclipse插件,並將結果數據顯示在視圖中的表中。Eclipse插件顯示數據如表
我已成功從調用中獲取數據,但無法顯示它。
這裏是我的代碼(編輯爲簡潔起見)
static Vector results ;
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
try{
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
IWorkbenchPage pg = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
ObjectWhereUsedInputDialog gtid = new ObjectWhereUsedInputDialog(window.getShell());
ArrayList<Object> input = gtid.openDialog();
CallProgram callPrg = new CallProgram();
String callPCML = "callPcml";
int idx = (input.size()-1);
AS400 as400 = (AS400) input.get(idx);
input.remove(idx);
results = callPrg.callProgram(as400, input);
ObjectWhereUsedResultTableView dlg = new ObjectWhereUsedResultTableView(results);
public void createPartControl(Composite parent) {
Table myTable = new Table (parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
myTable.setHeaderVisible (true);
myTable.setLinesVisible (true);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.heightHint = 200;
myTable.setLayoutData(data);
String[] titles = getColumns(myTable);
for (int i=0; i<titles.length; i++) {
TableColumn column = new TableColumn (myTable, SWT.NONE);
column.setText (titles [i]);
}
if(data!=null){System.out.println("datag "+data.size());};
createTable(myTable, data);
for (int i=0; i<titles.length; i++) {
myTable.getColumn (i).pack();
}
parent.layout(true);
parent.pack();
}
TableRow[] createTable(Table myTable, Vector<String> dataLines){
String[] columns = this.getColumns(myTable);
for (int i=0; i<columns.length; i++) {
TableColumn column = new TableColumn (myTable, SWT.NONE);
column.setText (columns[i]);
}
int dSize = dataLines==null||dataLines.isEmpty()?0:dataLines.size();
for(int i = 0;i<dSize;i++){
String[] elements = dataLines.get(i).split(",");
TableItem item = new TableItem (myTable, SWT.NONE);
for(int j = 0;j<elements.length;j++){
String itemStr = elements[j].isEmpty()?" ":elements[j];
item.setText(j,itemStr);
}
}
對不起,我是新來張貼在這個論壇上,還沒有弄清楚細微差別。 – Gretchen
是'ObjectWhereUsedResultTableView'是一個'ViewPart'並且你將它聲明爲Eclipse的視圖嗎? –
@ greg-449是的。我可以看到視圖和列標題,但不能看到數據 – Gretchen