![](/img/trans.png)
[英]How to implement IWindowCloseHandler in Eclipse (e4) RCP?
[英]How To Implement Custom Tree Columns and Cells In Eclipse RCP
我需要在Eclipse RCP中為樹組件實現定制列。 諸如“組合”或選擇按鈕之類的列可以顯示另一個選擇對話框。 默認情況下,Eclipse樹列僅支持原始文本字符串。 我想用另一個控件替換簡單的TextBox(或標簽)。 我該如何實現? 下面的示例實現一個簡單的文本單元格。
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Table table = new Table(shell, SWT.BORDER);
table.setHeaderVisible(true);
table.setLinesVisible(true);
for (int i = 0; i < 2; i++) {
new TableColumn(table, SWT.NONE);
}
table.getColumn(0).setText ("Task");
table.getColumn(1).setText ("Progress");
for (int i = 0; i < 40; i++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText("Task " + i);
}
table.getColumn(0).pack();
table.getColumn(1).setWidth(128);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
如果要在此處放置控件,可能不是因為只能顯示文本(其本身並不完全正確),而是因為您希望內容是可編輯的。 因此,請使用單元格編輯器1 。 您可以在https://eclipse.org/articles/Article-Table-viewer/table_viewer.html和http://www.java2s.com/Tutorial/Java/0280__SWT/TableCellEditorComboTextandButton.htm上編寫教程。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.