SWT Column Sorting Icons

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SWT Column Sorting Icons

Bruce Alspaugh-2
It would be nice if the SWT table columns had sorting icons the same way
the Swing tables do.

I was looking through the SWT TableComparatorChooser and all the related
code it calls and kept getting lost in it.  Where is the best place to
call setImage() to update the column icons depending on their sorting
state?  Are there any technical reasons the SWT version doesn't do this now?

Bruce

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: SWT Column Sorting Icons

Jesse Wilson
Hey Bruce ---

When we first built the SWT TableComparatorChooser,
there was no way to set the icon on an SWT table header.
I imagine this limitation has since lifted and we can work
on solving the problem.

If you'd like to add methods to install the appropriate icons,
the methods you'll want to work with are
  TableComparatorChooser.rebuildComparator() and
  TableComparatorChooser.redetectComparator() and
You can look at the Swing TableComparatorChooser
for an example - it calls repaint() on the table's header
to force re-rendering, but in SWT we'll actually want to
just install the icons there.

This is a much desired feature, I'd love to see it!

Cheers,
Jesse

On 8/22/06, Bruce Alspaugh <[hidden email]> wrote:

> It would be nice if the SWT table columns had sorting icons the same way
> the Swing tables do.
>
> I was looking through the SWT TableComparatorChooser and all the related
> code it calls and kept getting lost in it.  Where is the best place to
> call setImage() to update the column icons depending on their sorting
> state?  Are there any technical reasons the SWT version doesn't do this now?
>
> Bruce
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: SWT Column Sorting Icons

Maidul
In reply to this post by Bruce Alspaugh-2
Bruce,

To do a very simple set image you could do the following -

NOTE: You dont really need to clear out the old images, but could do that if you have functionality to undo sorts.

                tableComparatorChooser.addSortListener(new Listener()
                {
                        private Image BACK_IMG = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_BACK).createImage();
                        private Image FORWARD_IMG = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD).createImage();
                       
                        public void handleEvent(Event event)
                        {
                                Image img = null;
                                List<Integer> cols = tableComparatorChooser.getSortingColumns();
                               
                                // Reset all the column images
                                for(TableColumn col : table.getColumns())
                                {
                                        col.setImage(null);
                                }
                               
                                // Get the selected column
                               
                                for(int i : cols)
                                {
                                        if(tableComparatorChooser.isColumnReverse(i))
                                        {
                                                img = BACK_IMG;
                                        }
                                        else
                                        {
                                                img = FORWARD_IMG;
                                        }
                                       
                                        table.getColumn(i).setImage(img);
                                }
                        }
                });


Bruce Alspaugh wrote
It would be nice if the SWT table columns had sorting icons the same way
the Swing tables do.

I was looking through the SWT TableComparatorChooser and all the related
code it calls and kept getting lost in it.  Where is the best place to
call setImage() to update the column icons depending on their sorting
state?  Are there any technical reasons the SWT version doesn't do this now?

Bruce

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@glazedlists.dev.java.net
For additional commands, e-mail: dev-help@glazedlists.dev.java.net
Reply | Threaded
Open this post in threaded view
|

Re: SWT Column Sorting Icons

Bruce Alspaugh-2
In reply to this post by Jesse Wilson
I was looking at SortIconFactory where you initialize iconFileNames:

    private static String[] iconFileNames = new String[] {
        "unsorted.png", "primary_sorted.png", "primary_sorted_reverse.png",
        "primary_sorted_alternate.png",
"primary_sorted_alternate_reverse.png",
        "secondary_sorted.png", "secondary_sorted_reverse.png",
        "secondary_sorted_alternate.png",
"secondary_sorted_alternate_reverse.png"
    };

I see all the .png files listed in the .jar except for unsorted.png.  Is
it missing or no longer used?  It would be useful to have it for SWT as
a placeholder in the column header.

Bruce

Jesse Wilson wrote:

> Hey Bruce ---
>
> When we first built the SWT TableComparatorChooser,
> there was no way to set the icon on an SWT table header.
> I imagine this limitation has since lifted and we can work
> on solving the problem.
>
> If you'd like to add methods to install the appropriate icons,
> the methods you'll want to work with are
>  TableComparatorChooser.rebuildComparator() and
>  TableComparatorChooser.redetectComparator() and
> You can look at the Swing TableComparatorChooser
> for an example - it calls repaint() on the table's header
> to force re-rendering, but in SWT we'll actually want to
> just install the icons there.
>
> This is a much desired feature, I'd love to see it!
>
> Cheers,
> Jesse
>
> On 8/22/06, Bruce Alspaugh <[hidden email]> wrote:
>> It would be nice if the SWT table columns had sorting icons the same way
>> the Swing tables do.
>>
>> I was looking through the SWT TableComparatorChooser and all the related
>> code it calls and kept getting lost in it.  Where is the best place to
>> call setImage() to update the column icons depending on their sorting
>> state?  Are there any technical reasons the SWT version doesn't do
>> this now?
>>
>> Bruce
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]