Sorting in TableCombohttps://www.eclipse.org/forums/index.php/mv/msg/171298/544712/#msg_544712
In my application I m using tablecombo with 2 columns. I have added sorter
to both the columns. This works fine when no combo item is selected.
Clicking the column header in combo sorts the list and the combo remains
open after sorting is done.
But if a item is selected in the combo, clicking the combo header sorts the
list but the combo is closed and combo text is set to the selected item.
What I need is the the combo remains expanded after sorting.
I have added a selection listner to the colums in table combo for sorting
and another selection listner to TableComboViewer.
Is there a way to do so ?
Please do let me know

Thanks in Advance!
Regards,
Neha]]>Neha2010-07-05T05:02:04-00:00Re: Sorting in TableCombohttps://www.eclipse.org/forums/index.php/mv/msg/171298/544755/#msg_544755
Do you have a snippet that shows the issue that you are seeing? If so, attach it and I will look into the issue.

Thanks,

Marty]]>Marty Jones2010-07-05T12:36:22-00:00Re: Sorting in TableCombohttps://www.eclipse.org/forums/index.php/mv/msg/171298/599844/#msg_599844
Do you have a snippet that shows the issue that you are seeing? If so, attach it and I will look into the issue.

Thanks,

Marty]]>Marty Jones2010-07-05T12:36:23-00:00Re: Sorting in TableCombohttps://www.eclipse.org/forums/index.php/mv/msg/171298/599861/#msg_599861
Below is the code snippet. Please do have a look and let me know if anything
can be done

comboRecordViewer.getTableCombo().defineColumns(

new String[] { "ID", "Name" });

combo= comboViewer.getTableCombo();

for (iCounter = 0; iCounter < 2; iCounter++) {

ColumnSelectionListener colListener = new ColumnSelectionListener(

iCounter);

combo.getTable().getColumn(iCounter)

..addSelectionListener(colListener);

}

// ColumnSelectionLlistner code is below

private class ColumnSelectionListener extends SelectionAdapter {

private int colNumber;

private ColumnSelectionListener(int colNumber) {

this.colNumber = colNumber;

}

@Override

public void widgetSelected(SelectionEvent e) {

TableColumn sortColumn = combogetTable()

..getSortColumn();

TableColumn currentColumn = (TableColumn) e.widget;

int dir = combo.getTable().getSortDirection();

if (sortColumn == currentColumn) {

dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;

} else {

combo.getTable().setSortColumn(currentColumn);

// sorting direction is descending as its already sorted in

// ascending order.

if (currentColumn == combo.getTable().getColumn(

colNumber)) {

dir = SWT.DOWN;

} else {

dir = SWT.UP;

}

}

combo.getTable().setSortDirection(dir);

comboViewer.setSorter(new TableSorter(

colNumber, dir));

}

}

"TableSorter" is a class that extends ViewerSorter class and has sorting
logic.

Thanks & Regards

Neha.

"Marty Jones" <martybjones@gmail.com> wrote in message
news:i0sjk8$lgo$1@build.eclipse.org...
> Neha,
>
> Do you have a snippet that shows the issue that you are seeing? If so,
> attach it and I will look into the issue.
>
> Thanks,
>
> Marty]]>Neha2010-07-06T07:05:22-00:00Re: Sorting in TableCombohttps://www.eclipse.org/forums/index.php/mv/msg/171298/544934/#msg_544934
Below is the code snippet. Please do have a look and let me know if anything
can be done

comboRecordViewer.getTableCombo().defineColumns(

new String[] { "ID", "Name" });

combo= comboViewer.getTableCombo();

for (iCounter = 0; iCounter < 2; iCounter++) {

ColumnSelectionListener colListener = new ColumnSelectionListener(

iCounter);

combo.getTable().getColumn(iCounter)

..addSelectionListener(colListener);

}

// ColumnSelectionLlistner code is below

private class ColumnSelectionListener extends SelectionAdapter {

private int colNumber;

private ColumnSelectionListener(int colNumber) {

this.colNumber = colNumber;

}

@Override

public void widgetSelected(SelectionEvent e) {

TableColumn sortColumn = combogetTable()

..getSortColumn();

TableColumn currentColumn = (TableColumn) e.widget;

int dir = combo.getTable().getSortDirection();

if (sortColumn == currentColumn) {

dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;

} else {

combo.getTable().setSortColumn(currentColumn);

// sorting direction is descending as its already sorted in

// ascending order.

if (currentColumn == combo.getTable().getColumn(

colNumber)) {

dir = SWT.DOWN;

} else {

dir = SWT.UP;

}

}

combo.getTable().setSortDirection(dir);

comboViewer.setSorter(new TableSorter(

colNumber, dir));

}

}

"TableSorter" is a class that extends ViewerSorter class and has sorting
logic.

Thanks & Regards

Neha.

"Marty Jones" <martybjones@gmail.com> wrote in message
news:i0sjk8$lgo$1@build.eclipse.org...
> Neha,
>
> Do you have a snippet that shows the issue that you are seeing? If so,
> attach it and I will look into the issue.
>
> Thanks,
>
> Marty]]>Neha2010-07-06T07:05:22-00:00Re: Sorting in TableCombohttps://www.eclipse.org/forums/index.php/mv/msg/171298/599868/#msg_599868
Though I can't speak for Marty. It would help Marty if he gets a fully
runnable snippet without having to code something his own.

I'd use one of the snippets available and modify it so that we can
reproduce it without any time overhead on ourside.

Marty]]>Marty Jones2010-07-06T11:43:31-00:00Re: Sorting in TableCombohttps://www.eclipse.org/forums/index.php/mv/msg/171298/599872/#msg_599872
Tom is correct. It is always helpful to have a full snippet showing the issue that you are seeing. That way I will see exactly what you are seeing instead of me coding a full snippet and may not be able to reproduce the bug.