Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Sorting in TableCombo
Sorting in TableCombo [message #544712] Mon, 05 July 2010 05:02 Go to next message
Neha is currently offline Neha
Messages: 52
Registered: July 2009
Member
Hi
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
Re: Sorting in TableCombo [message #544755 is a reply to message #544712] Mon, 05 July 2010 12:36 Go to previous messageGo to next message
Marty Jones is currently offline Marty Jones
Messages: 54
Registered: July 2009
Member
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
Re: Sorting in TableCombo [message #544934 is a reply to message #544755] Tue, 06 July 2010 07:05 Go to previous messageGo to next message
Neha is currently offline Neha
Messages: 52
Registered: July 2009
Member
Hi Marty,
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
Re: Sorting in TableCombo [message #544937 is a reply to message #544934] Tue, 06 July 2010 07:11 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5351
Registered: July 2009
Senior Member
Hi Neha,

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.

Tom

Am 06.07.10 09:05, schrieb Neha:
> Hi Marty,
> 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
>
>
Re: Sorting in TableCombo [message #545014 is a reply to message #544937] Tue, 06 July 2010 11:43 Go to previous messageGo to next message
Marty Jones is currently offline Marty Jones
Messages: 54
Registered: July 2009
Member
Neha,

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.

Marty
Re: Sorting in TableCombo [message #599844 is a reply to message #544712] Mon, 05 July 2010 12:36 Go to previous messageGo to next message
Marty Jones is currently offline Marty Jones
Messages: 54
Registered: July 2009
Member
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
Re: Sorting in TableCombo [message #599861 is a reply to message #599844] Tue, 06 July 2010 07:05 Go to previous messageGo to next message
Neha is currently offline Neha
Messages: 52
Registered: July 2009
Member
Hi Marty,
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
Re: Sorting in TableCombo [message #599868 is a reply to message #544934] Tue, 06 July 2010 07:11 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5351
Registered: July 2009
Senior Member
Hi Neha,

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.

Tom

Am 06.07.10 09:05, schrieb Neha:
> Hi Marty,
> 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
>
>
Re: Sorting in TableCombo [message #599872 is a reply to message #544937] Tue, 06 July 2010 11:43 Go to previous message
Marty Jones is currently offline Marty Jones
Messages: 54
Registered: July 2009
Member
Neha,

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.

Marty
Previous Topic:[paperclips] Printing error when there are some kind of images
Next Topic:One Framework to bind them All ?!
Goto Forum:
  


Current Time: Thu Oct 02 04:40:16 GMT 2014

Powered by FUDForum. Page generated in 0.01863 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software