pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anton dos santos <adsan...@free.fr>
Subject Re: TableHeader
Date Thu, 06 Jan 2011 17:10:47 GMT
Hi Greg

I tried the easy way and added a MenuHandler to a custom header like this:

public class TableViewFilterHeader extends TableViewHeader {

       private MenuHandler menuHandler = new MenuHandler.Adapter() {
         public boolean configureContextMenu(Component component, Menu menu, int x, int y)

             Menu.Section menuSection = new Menu.Section();
             int index = TableViewFilterHeader.this.getHeaderAt(x);
             String name = TableViewFilterHeader.this.getTableView().getColumns().get(index).getName();
             Menu.Item whatIsThisMenuItem = new Menu.Item("filter for "+name);
             whatIsThisMenuItem.setAction(new Action() {
                 public void perform( Component component) {
                     System.out.println("FilterAction performed");


             return false;

   public TableViewFilterHeader() {

It works, when I right mouse click in the header, the menu is displayed and then when I click
in the 
menu, menu becomes invisible and header is redisplayed.
When I right mouse click in the header, the menu is displayed and then when I left click outside
the table header, menu becomes also invisible and header is redisplayed.
But when right mouse click in the header, the menu is displayed and then when I left click
inside of 
the table header, menu becomes also invisible but header is not correctly redisplayed (see
I am doing this with 1.5.2 and the demo with the Olympic Medals

On 05/01/2011 21:34, Greg Brown wrote:
> Yes, that is exactly what I was thinking. You can register a mouse button listener on
the header and call getHeaderAt() to determine which header was pressed. Then you can call
getHeaderBounds() to get that header's bounding area. Finally, you can call mapPointToAncestor()
on the TableViewHeader to convert the header bounds to display coordinates for displaying
the context menu (you can call getDisplay() on the header to get the display).
> Let me know how it goes.
> On Jan 5, 2011, at 3:26 PM, anton dos santos wrote:
>> Yes you are right :)
>> To do this I think I need a context menu as described here: http://pivot.apache.org/tutorials/context-menus.html
>> Regards
>> Anton
>> On 05/01/2011 21:06, Greg Brown wrote:
>>> Well, a ListButton displays a popup, so I think we are probably describing the
same thing.  :-)  I have written a similar UI where right-clicking on the table header makes
a menu popup appear immediately below the header. The user can then select one of the values
from the menu to filter the table contents.
>>> G
>>> On Jan 5, 2011, at 3:00 PM, anton dos santos wrote:
>>>> not exactly
>>>> I want to implement a filter feature: when in a column there are multiple
distinct values then a ListButton with these distinct values is displayed in the header and
when user select one of the values, only the corresponding rows will be displayed in the table.
>>>> I am not sure a popup is user friendly in this case
>>>> Regards
>>>> Anton
>>>> On 05/01/2011 20:34, Greg Brown wrote:
>>>>> You are correct - renderers do not support user interaction because they
aren't really there - they are just painted by the skin.
>>>>> Are you trying to display a popup when the user clicks on the table header?
If so, there are other ways to do this. I can try to put together a quick example if it would
>>>>> G
>>>>> On Jan 5, 2011, at 2:30 PM, anton dos santos wrote:
>>>>>> Hi
>>>>>> I  have a  TableViewHeader that displays a ListButton, but the ListButon
is not usable.
>>>>>> I assume it is because the header is drawn by a "renderer" and not
an "editor". Right?
>>>>>> Is it possible to have a working button or checkbox in a column's
header ?
>>>>>> Regards
>>>>>> Anton

View raw message