Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to correctly use ButtonCellPainter?
How to correctly use ButtonCellPainter? [message #1137469] Mon, 14 October 2013 14:15 Go to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
I followed the Rendereing_a_cell_as_a_button example and did the following:


  1. Added a button cell painter to each cell with a specific label
  2. Added a ButtonClickConfiguration similar to the one in the example
  3. Added a click listener to the painter


But the button is neither shown as pressed nor is the click listener even called when clicking the button. What am I missing? When adding a LayerListener to my table which simply logs all received events, it only receives cell selection events.

EDIT: I did some more research:
When adding the configuration to the selection or the data layer of the table body, it is called, but the layer stack only contains the layer BODY, even if I attach the label accumulator right there. The label accumulator works correctly as the labels are used as a base for rendering, and the buttons are rendered correctly. Plus, the button does not appear pressed when I click it.

[Updated on: Mon, 14 October 2013 14:46]

Report message to a moderator

Re: How to correctly use ButtonCellPainter? [message #1137519 is a reply to message #1137469] Mon, 14 October 2013 14:54 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
How did you create the ButtonCellPainter? Did you specify two different painter or one interiour painter?
Did you ensure to add your ButtonClickConfiguration BEFORE calling natTable.configure()?

I haven't implemented the ButtonCellPainter nor have I ever used it before. Looking at the implementation scares me as it uses background threads to update the visualization. But I really don't know what happens.
Re: How to correctly use ButtonCellPainter? [message #1137532 is a reply to message #1137519] Mon, 14 October 2013 15:05 Go to previous messageGo to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
I did it this way:
final TextPainter flatCellPainter = new TextPainter();
final ButtonCellPainter bcp = new ButtonCellPainter(new BeveledBorderDecorator(flatCellPainter), new BeveledBorderDecorator(flatCellPainter, false));
config.registerConfigAttribute(CELL_PAINTER, bcp, NORMAL, MY_BUTTON_LABEL);
bcp.addClickListener(new IMouseAction() {

    @Override
    public void run(final NatTable natTable, final MouseEvent event) {
        // do stuff
    }
});


config is a ConfigRegistry.
Re: How to correctly use ButtonCellPainter? [message #1137667 is a reply to message #1137532] Mon, 14 October 2013 16:59 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2903
Registered: July 2012
Senior Member
Are you doing this in a configuration? And when are you adding the configuration?
Re: How to correctly use ButtonCellPainter? [message #1176372 is a reply to message #1137667] Fri, 08 November 2013 09:40 Go to previous message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
Sorry for not answering this thread for a long time, but it turned out that I did not need buttons in that table. I came up with a combo box solution which just works fine. I wanted the button to be a "Delete" button in the last column of every row, which now opens a combo box where I can select "Yes" or "no". So I got a nice user confirmation without having to open a dialog box.
Previous Topic:Row numbers are also changed , when rows are reordered using row reorder layer
Next Topic:Select all column cells by clicking on column header
Goto Forum:
  


Current Time: Thu Sep 19 01:50:55 GMT 2024

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

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

Back to the top