я новичок в SWT, кто-нибудь, пожалуйста, помогите, моя проблема: у меня есть таблица, которая имеет 10 столбцов, первый столбец имеет флажок, а остальная часть столбца заполняется из базы данных, когда я устанавливаю флажок, я хочу, чтобы эта конкретная строка быть выбранным,
я вставляю свой код таблицы ниже,
public static void main(String arg[])
{
// shell and display declared here
mainTable = new TableViewer(content, SWT.H_SCROLL| SWT.V_SCROLL | SWT.BORDER |SWT.DM_FILL_BACKGROUND|SWT.FULL_SELECTION);
mainTable .getTable().setHeaderVisible(true);
mainTable .getTable().setLinesVisible(true);
mainTable .setContentProvider(new ArrayContentProvider());
// COLUM FOR PLACING THE CHECK BOXES
TableColumn columncOL=new TableColumn(mainTable .getTable(),SWT.NONE);
columncOL.setText("");
columncOL.setWidth(40);
TableViewerColumn columnaC=new TableViewerColumn(mainTable ,columncOL);
columnaC.setLabelProvider(new ColumnLabelProvider(){
Map<Object, Button> buttons = new HashMap<Object, Button>();
@Override
public void update(ViewerCell cell) {
TableItem item = (TableItem) cell.getItem();
Button button;
if(buttons.containsKey(cell.getElement()))
{
button = buttons.get(cell.getElement());
}
else
{
button = new Button((Composite) cell.getViewerRow().getControl(),SWT.CHECK);
String s = "Item 1";
button.setData(s, "Some other info or object here");
s = "Item 2";
button.setData(s, "This is item two");
//buttons.put(cell.getElement(), button);
}
TableEditor editor = new TableEditor(item.getParent());
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setEditor(button , item, cell.getColumnIndex());
editor.layout();
}
});
// CREATING 1st COLUMNS
TableColumn column1Head=new TableColumn(mainTable.getTable(),SWT.NONE);
column1Head.setText("col1");
column1Head.setWidth(200);
// setting column input
TableViewerColumn column1=new TableViewerColumn(mainTable,column1Head);
column1.setLabelProvider(new ColumnLabelProvider()
{
public String getText(Object Element)
{
Student ap=(Student )Element;
return ap.col1();
}
});
}
как это, я создаю оставшиеся 8 столбцов, я хочу выбрать всю строку, когда установлен флажок perticluar. кто-нибудь, пожалуйста, помогите мне как можно раньше ....
CheckboxTableViewer
? - person greg-449   schedule 12.03.2014